コード例 #1
0
 private void newDoc()
 {
     circlesDoc    = new CirclesDoc();
     previousPoint = Point.Empty;
     currentPoint  = Point.Empty;
     FileName      = "Untitled";
 }
コード例 #2
0
        private void openFile()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Circles doc file (*.cir)|*.cir";
            openFileDialog.Title  = "Open circles doc file";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                FileName = openFileDialog.FileName;
                try
                {
                    using (FileStream fileStream = new FileStream(FileName, FileMode.Open))
                    {
                        IFormatter formater = new BinaryFormatter();
                        circlesDoc = (CirclesDoc)formater.Deserialize(fileStream);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Could not read file: " + FileName);
                    FileName = null;
                    return;
                }
                Invalidate(true);
            }
        }