Esempio n. 1
0
        private void openToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = "/files";
            openFileDialog.RestoreDirectory = true;
            openFileDialog.FileName         = "figures";
            openFileDialog.DefaultExt       = ".json";

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                StreamReader stream = new StreamReader(openFileDialog.OpenFile());
                string       data   = stream.ReadToEnd();
                {
                    string[] dataArray = data.Split('\n');
                    foreach (string dataBlock in dataArray)
                    {
                        try
                        {
                            InfoForJSON jSON = JsonConvert.DeserializeObject <InfoForJSON>(dataBlock);
                            foreach (Fabric fab in allFabrics)
                            {
                                if (jSON.figureName == fab.ToString())
                                {
                                    jsonList.Add(jSON);
                                    Fabric factory = fab;
                                    figure = factory.FactoryMethod(jSON.fatness, jSON.color, jSON.topLeft, jSON.bottomRight);
                                    figure.Draw(graphics);
                                    picture.Image = bmap;
                                    break;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(message, title_mess, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            continue;
                        }
                    }
                }
                stream.Close();
            }
        }
Esempio n. 2
0
 private void cb_figures_SelectionChangeCommitted(object sender, EventArgs e)
 {
     cmb_custom_figures.SelectedIndex = -1;
     maker = allFabrics[cb_figures.SelectedIndex];
 }