private void openFile() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Circles doc file (*.plc)|*.plc"; 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(); circleDoc = (CircleDoc)formater.Deserialize(fileStream); } } catch (Exception) { MessageBox.Show("Could not read file: " + FileName); FileName = null; return; } Invalidate(true); } }
public Form1() { InitializeComponent(); circleDoc = new CircleDoc(); color = Color.Red; DoubleBuffered = true; timer = new Timer(); timer.Interval = 500; timer.Tick += new EventHandler(timer1_Tick); isStarted = false; }
private void Form1_Paint(object sender, PaintEventArgs e) { e.Graphics.Clear(Color.White); CircleDoc.DrawCircles(e.Graphics); if (Filename != string.Empty) { this.Text = $"Half Circles | {Filename.Substring(Filename.LastIndexOf(@"\") + 1)}"; } else { this.Text = "Half Circles"; } }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { timer1.Stop(); if (MessageBox.Show("Are you sure you want to start a new game?", "Start a new game", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { CircleDoc = new CircleDoc(); Filename = string.Empty; if (btnStart.Text != "Старт") { btnStart_Click(sender, e); } Invalidate(true); } if (btnStart.Text != "Старт") { timer1.Start(); } }
private void timer1_Tick(object sender, EventArgs e) { CircleDoc.SwapCirclesColors(); Invalidate(); }
private void Form1_MouseDoubleClick(object sender, MouseEventArgs e) { CircleDoc.AddCircle(e.Location, Color); Invalidate(true); }
public Form1() { InitializeComponent(); CircleDoc = new CircleDoc(); this.DoubleBuffered = true; }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { circleDoc = new CircleDoc(); }
private void newToolStripButton_Click(object sender, EventArgs e) { circleDoc = new CircleDoc(); }