コード例 #1
0
ファイル: Scene.cs プロジェクト: darinaKrasimirova/drawingApp
 private void FormScene_MouseUp(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         sh.Move(new Point(e.Location.X / CoordSystemUnit - distX, e.Location.Y / CoordSystemUnit - distY));
         Invalidate();
     }
 }
コード例 #2
0
        private void ButtonOK_Click(object sender, EventArgs e)
        {
            try
            {
                string[] chars = textBoxCharacteristics.Text.Split(',');
                if (chars.Length == 2)
                {
                    if (!int.TryParse(chars[0], out int w))
                    {
                        throw new Exception("Enter the shape characteristics as numbers\nseparated by a comma!");
                    }
                    if (!int.TryParse(chars[1], out int h))
                    {
                        throw new Exception("Enter the shape characteristics as numbers\nseparated by a comma!");
                    }
                    s.Resize(w, h);
                }
                else if (chars.Length == 1)
                {
                    if (!int.TryParse(chars[0], out int w))
                    {
                        throw new Exception("The shape characteristic must be a number!");
                    }
                    s.Resize(w);
                }
                string[] point = textBoxPoint.Text.Split(',');
                if (!int.TryParse(point[0], out int x))
                {
                    throw new Exception("Enter the coordinates as numbers\nseparated by a comma!");
                }
                if (!int.TryParse(point[1], out int y))
                {
                    throw new Exception("Enter the coordinates as numbers\nseparated by a comma!");
                }
                s.Move(new Point(x, y));
                if (!int.TryParse(textBoxPen.Text, out int pen))
                {
                    throw new Exception("The pen width must be an integer number!");
                }
                s.ShapeContourWidth = pen;
                if (ChooseColor(comboBoxPenColor) != Color.Empty)
                {
                    s.ShapeContourColor = ChooseColor(comboBoxPenColor);
                }
                if (ChooseColor(comboBoxFillColor) != Color.Empty)
                {
                    s.filled = true;
                }
                else
                {
                    s.filled = false;
                }
                s.FillingColor = ChooseColor(comboBoxFillColor);
            }

            catch (Exception ex)
            {
                DialogResult   = DialogResult.None;
                labelNote.Text = ex.Message;
            }
        }