Esempio n. 1
0
 private void SchematicButton_Click(object sender, EventArgs e)
 {
     startTime = DateTime.Now;
     convertTask?.Abort();
     if (saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         Schematic schem = new Schematic(blockMap.GetLength(0), maxHeight + 1, blockMap.GetLength(1));
         label4.Text = "Exporting";
         convertTask = new Thread(() =>
         {
             for (short i = 0; i < blockMap.GetLength(0); ++i)
             {
                 for (short j = 1; j < blockMap.GetLength(1); ++j)
                 {
                     ColorNote col = colorsNote[blockMap[i, j].ID - 1];
                     schem.SetBlock(i, (short)blockMap[i, j].Height, (short)(j - 1), col.SelectedBlock.ID, col.SelectedBlock.Data);
                 }
             }
             using (System.IO.FileStream fs = new System.IO.FileStream(saveFileDialog1.FileName.Contains(".schematic") ?
                                                                       saveFileDialog1.FileName : saveFileDialog1.FileName + ".schematic", System.IO.FileMode.Create))
                 schem.WriteToStream(fs);
             label4.BeginInvoke(new Action(() => { label4.Text = DateTime.Now.Subtract(startTime).ToString(); }));
             schem = null;
             GC.Collect();
             MessageBox.Show("Complete", "Complete", MessageBoxButtons.OK, MessageBoxIcon.Information); //-V3038
         });
         convertTask.Start();
     }
 }
Esempio n. 2
0
        void LoadData()
        {
            colorsNote = new List <ColorNote>();
            string[] colors = Properties.Resources.ColorsIDS.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            string[] blocks = Properties.Settings.Default.PossibleBlocks.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            if (colors.Length != blocks.Length)
            {
                throw new Exception("Length of the list of blocks and length of the list of colors did not match");
            }

            for (int i = 0; i < colors.Length; i++)
            {
                string[] curColor  = colors[i].Split('-');
                string   curBlocks = blocks[i];

                Color lCol = Color.FromArgb(Convert.ToInt32(curColor[1]), Convert.ToInt32(curColor[2]), Convert.ToInt32(curColor[3]));
                Color nCol = Color.FromArgb(lCol.R * 220 / 255, lCol.G * 220 / 255, lCol.B * 220 / 255);
                Color dCol = Color.FromArgb(lCol.R * 180 / 255, lCol.G * 180 / 255, lCol.B * 180 / 255);

                ColorNote note = new ColorNote(Convert.ToInt32(curColor[0]), dCol, nCol, lCol);
                note.Use = curBlocks.Split('~')[0] == "True";

                string[] block = curBlocks.Split('~')[2].Split('-');
                note.SelectedBlock = new BlockData(block[0], block[1], Convert.ToByte(block[2]), Convert.ToByte(block[3]), block[4] == "True");

                curBlocks = curBlocks.Split('~')[1];
                List <BlockData> blockDatas = new List <BlockData>();
                foreach (string str in curBlocks.Split(','))
                {
                    block = str.Split('-');
                    blockDatas.Add(new BlockData(block[0], block[1], Convert.ToByte(block[2]), Convert.ToByte(block[3]), block[4] == "True"));
                }
                note.PossibleBlocks = blockDatas;
                colorsNote.Add(note);
            }
        }