Ejemplo n.º 1
0
 public Form1()
 {
     InitializeComponent();
     CircleDoc           = new CircleDoc();
     Color               = Color.DarkBlue;
     Filename            = string.Empty;
     this.DoubleBuffered = true;
 }
Ejemplo n.º 2
0
 private void newToolStripMenuItem_Click(object sender, EventArgs e)
 {
     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;
         Invalidate(true);
     }
 }
Ejemplo n.º 3
0
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape)
     {
         _drawingContour = false;
         _center         = Point.Empty;
         Invalidate();
     }
     else if (e.KeyCode == Keys.Delete)
     {
         CircleDoc.RemoveSelected();
         Invalidate(true);
     }
 }
Ejemplo n.º 4
0
        private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (selectAllToolStripMenuItem.Text == "Select &All")
            {
                CircleDoc.SelectAll(true);
                selectAllToolStripMenuItem.Text = "Unselect &All";
            }
            else
            {
                CircleDoc.SelectAll(false);
                selectAllToolStripMenuItem.Text = "Select &All";
            }

            Invalidate();
        }
Ejemplo n.º 5
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(Color.White);
            CircleDoc.Draw(e.Graphics);

            if (_drawingContour && _center != Point.Empty)
            {
                var pen = new Pen(Color.Gray, 3);
                pen.DashStyle = DashStyle.Dot;
                e.Graphics.DrawEllipse(pen, _center.X - _radius, _center.Y - _radius, _radius * 2, _radius * 2);
                pen.Dispose();
            }

            if (Filename != string.Empty)
            {
                this.Text = $"Color Circles | {Filename.Substring(Filename.LastIndexOf(@"\") + 1)}";
            }
            else
            {
                this.Text = "Color Circles";
            }
        }
Ejemplo n.º 6
0
        private void Form1_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (_center == Point.Empty)
                {
                    _center         = e.Location;
                    _drawingContour = true;
                }
                else
                {
                    _radius = (int)Math.Sqrt(Math.Pow(_center.X - e.X, 2) + Math.Pow(_center.Y - e.Y, 2));
                    CircleDoc.AddCircle(_center, Color, _radius);
                    _drawingContour = false;
                    _center         = Point.Empty;
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                CircleDoc.Select(e.Location);
            }

            Invalidate(true);
        }
Ejemplo n.º 7
0
 private void statusStrip1_Paint(object sender, PaintEventArgs e)
 {
     lblCircles.Text = $"Circles: {CircleDoc.CirclesCount()}";
 }