コード例 #1
0
 private void DrawBox_MouseMove(object sender, MouseEventArgs e)
 {
     if (Drawing)
     {
         Line.SecondPoint = new Point(e.X, e.Y);
         DrawBox.Refresh();
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: nikitoss888/ISMArrays
      private void DrawButton_Click(object sender, EventArgs e)
      {
          if (shapes == null)
          {
              shapes = new List <Shape>();
          }
          Graphics draw = DrawBox.CreateGraphics();
          int      randomShape;

          if (checkBoxColorOfShapes.Checked)
          {
              color = colorDialog.Color;
          }
          else
          {
              color = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256));
          }
          for (int i = 0; i < trackBarDrawings.Value; i++)
          {
              switch (randomShape = rnd.Next(0, 5))
              {
              case 0:
                  shapes.Add(new Point(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                       pen = new Pen(color, 2)));
                  break;

              case 1:
                  shapes.Add(new Line(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                      rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                      pen = new Pen(color, 2)));
                  break;

              case 2:
                  shapes.Add(new Rectangle(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                           rnd.Next(0, DrawBox.Width), rnd.Next(DrawBox.Height),
                                           pen = new Pen(color, 2)));
                  break;

              case 3:
                  shapes.Add(new Circle(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                        rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                        pen = new Pen(color, 2)));
                  break;

              case 4:
                  shapes.Add(new Ellipse(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                         rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                         pen = new Pen(color, 2)));
                  break;
              }
          }
          DrawBox.Refresh();
      }
コード例 #3
0
ファイル: Form1.cs プロジェクト: nikitoss888/ISMArrays
      private void button1_Click(object sender, EventArgs e)
      {
          Pen pen;

          if (shapes == null)
          {
              shapes = new List <Shape>();
          }
          if (checkBoxColorOfShapes.Checked)
          {
              color = colorDialog.Color;
          }
          else
          {
              color = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256));
          }
          for (int i = 0; i < trackBarDrawings.Value; i++)
          {
              switch (comboBoxAdd.SelectedIndex)
              {
              case 0:
                  shapes.Add(new Point(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                       pen = new Pen(color, 2)));
                  break;

              case 1:
                  shapes.Add(new Line(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                      rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                      pen = new Pen(color, 2)));
                  break;

              case 2:
                  shapes.Add(new Rectangle(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                           rnd.Next(0, DrawBox.Width), rnd.Next(DrawBox.Height),
                                           pen = new Pen(color, 2)));
                  break;

              case 3:
                  shapes.Add(new Circle(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                        rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                        pen = new Pen(color, 2)));
                  break;

              case 4:
                  shapes.Add(new Ellipse(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                         rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height),
                                         pen = new Pen(color, 2)));
                  break;
              }
          }
          DrawBox.Refresh();
      }
コード例 #4
0
ファイル: Form1.cs プロジェクト: nikitoss888/ISMArrays
      private void buttonRemove_Click(object sender, EventArgs e)
      {
          int number = (int)numericUpDownNumOfShape.Value;

          if (shapes == null)
          {
              shapes = new List <Shape>();
          }
          if (number < shapes.Count)
          {
              shapes.RemoveAt(number);
              DrawBox.Refresh();
          }
      }
コード例 #5
0
ファイル: Form1.cs プロジェクト: nikitoss888/ISMArrays
 private void button2_Click(object sender, EventArgs e)
 {
     if (textBoxChangeX.Text == null)
     {
         textBoxChangeX.Text = "0";
     }
     if (textBoxChangeY.Text == null)
     {
         textBoxChangeY.Text = "0";
     }
     if (shapes != null && textBoxChangeX.Text != "0" && textBoxChangeY.Text != "0")
     {
         shapes[(int)numericUpDownNumOfShape.Value].CoordsChange(int.Parse(textBoxChangeX.Text), int.Parse(textBoxChangeY.Text));
         DrawBox.Refresh();
     }
 }
コード例 #6
0
ファイル: Form1.cs プロジェクト: nikitoss888/ISMArrays
 private void buttonMoveAll_Click(object sender, EventArgs e)
 {
     if (textBoxChangeX.Text == null)
     {
         textBoxChangeX.Text = "0";
     }
     if (textBoxChangeY.Text == null)
     {
         textBoxChangeY.Text = "0";
     }
     if (shapes != null && textBoxChangeX.Text != "0" && textBoxChangeY.Text != "0")
     {
         for (int i = 0; i < shapes.Count; i++)
         {
             shapes[i].CoordsChange(int.Parse(textBoxChangeX.Text), int.Parse(textBoxChangeY.Text));
         }
         DrawBox.Refresh();
     }
 }
コード例 #7
0
 private void ClearButton_Click(object sender, EventArgs e)
 {
     ShapePoints.Clear();
     DrawBox.Refresh();
 }
コード例 #8
0
 private void CreateDraw_Click(object sender, EventArgs e)
 {
     ShapePoints.Clear();
     DrawRandomShapes(Count.Value);
     DrawBox.Refresh();
 }