public void openFile() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Pie doc file (*.pie)|*.pie"; openFileDialog.Title = "Open pie doc"; if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { fileName = openFileDialog.FileName; try { using (FileStream fileStream = new FileStream(fileName, FileMode.Open)) { IFormatter formatter = new BinaryFormatter(); doc = (PieDocument)formatter.Deserialize(fileStream); } } catch (Exception ex) { MessageBox.Show("Could not read file: " + fileName); fileName = null; return; } Invalidate(true); } }
public Form1() { InitializeComponent(); doc = new PieDocument(); color = Color.Blue; timer = new Timer(); timer.Interval = 500; timer.Tick += new EventHandler(timer_Tick); }
private void newToolStripButton_Click(object sender, EventArgs e) { doc = new PieDocument(); Invalidate(true); }