private void mnuLoad_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                ShapeCollection newShapes = null;
                try
                {
                    using (FileStream fs =
                               File.Open(openFileDialog.FileName, FileMode.Open))
                    {
                        BinaryFormatter f = new BinaryFormatter();
                        newShapes = (ShapeCollection)f.Deserialize(fs, null);
                    }
                }
                catch (Exception err)
                {
                    MessageBox.Show("Error while loading. " + err.Message);
                }

                // Trigger a refresh.
                shapes = newShapes;
                Invalidate();
            }
        }
예제 #2
0
        private void mnuLoad_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                ShapeCollection newShapes = null;
                try
                {
                    using (FileStream fs =
                        File.Open(openFileDialog.FileName, FileMode.Open))
                    {
                        BinaryFormatter f = new BinaryFormatter();
                        newShapes = (ShapeCollection)f.Deserialize(fs, null);
                    }
                }
                catch (Exception err)
                {
                    MessageBox.Show("Error while loading. " + err.Message);
                }

                // Trigger a refresh.
                shapes = newShapes;
                Invalidate();
            }
        }