public void Open() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Cicles doc file (*.bal) | *.bal"; openFileDialog.Title = "OpenFile"; if (openFileDialog.ShowDialog() == DialogResult.OK) { FileName = openFileDialog.FileName; try { using (FileStream filestream = new FileStream(FileName, FileMode.Open)) { IFormatter formatter = new BinaryFormatter(); doc = (BallsDoc)formatter.Deserialize(filestream); } } catch (Exception e) { MessageBox.Show("Could not read file: " + FileName); FileName = null; return; } Invalidate(true); } }
private void openFile() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Balls doc file (*.bll)|*.bll"; openFileDialog.Title = "Open balls doc file"; if (openFileDialog.ShowDialog() == DialogResult.OK) { FileName = openFileDialog.FileName; try { using (FileStream fileStream = new FileStream(FileName, FileMode.Open)) { IFormatter formater = new BinaryFormatter(); doc = (BallsDoc)formater.Deserialize(fileStream); } } catch (Exception ex) { MessageBox.Show("Could not read file: " + FileName); FileName = null; return; } Invalidate(true); } }
public Form1() { InitializeComponent(); DoubleBuffered = true; doc = new BallsDoc(this.Width, this.Height); timer = new Timer(); timer.Interval = 50; timer.Tick += new EventHandler(timer_Tick); }
public Form1() { InitializeComponent(); doc = new BallsDoc(); this.DoubleBuffered = true; timer = new Timer(); timer.Interval = 50; timer.Tick += new EventHandler(timer_Tick); timer.Start(); }
private void newToolStripButton_Click(object sender, EventArgs e) { doc = new BallsDoc(Width, Height); Invalidate(true); }
public void newFile() { clickedBall = null; random = new Random(); balls = new BallsDoc(); }