Esempio n. 1
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (pictureBox1.Image == null)
            {
                pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            }

            var filePath = string.Empty;

            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = "c:\\Downloads";
                openFileDialog.Filter           = "Vector shapes (*.cg2020)|*.cg2020";
                openFileDialog.FilterIndex      = 2;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    shapes.Clear();
                    foreach (var shape in ShapeSerializer.Load <Shape>(openFileDialog.FileName))
                    {
                        shapes.Add(shape);
                    }
                }
                else
                {
                    return;
                }
            }

            RefreshShapes();
        }
Esempio n. 2
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.InitialDirectory = "c:\\Downloads";
            saveFileDialog1.Filter           = "Vector shapes (*.cg2020)|*.cg2020";
            saveFileDialog1.DefaultExt       = "dat";
            saveFileDialog1.AddExtension     = true;
            saveFileDialog1.Title            = "Save the filtered image";
            saveFileDialog1.ShowDialog();

            if (saveFileDialog1.FileName != "")
            {
                ShapeSerializer.Save(saveFileDialog1.FileName, shapes);
            }
        }