Esempio n. 1
0
        private void draw_Click(object sender, EventArgs e)
        {
            if (IsInt(tb_x1.Text, tb_y1.Text, tb_x2.Text, tb_y2.Text) && (cb_figures.SelectedIndex > -1) && ((Convert.ToInt32(tb_x1.Text, 10) < picture.Width) &&
                                                                                                             (Convert.ToInt32(tb_y1.Text, 10) < picture.Height) && (Convert.ToInt32(tb_x2.Text, 10) < picture.Width) &&
                                                                                                             (Convert.ToInt32(tb_y2.Text, 10) < picture.Height)))
            {
                Point topLeft     = new Point(Convert.ToInt32(tb_x1.Text, 10), Convert.ToInt32(tb_y1.Text));
                Point bottomRight = new Point(Convert.ToInt32(tb_x2.Text, 10), Convert.ToInt32(tb_y2.Text));
                figure = maker.FactoryMethod(fatness, color, topLeft, bottomRight);

                figureList.Add(figure);
                //figuresExs.Add(figure);

                figure.Draw(graphics);
                jsonList.Add(new InfoForJSON()
                {
                    fatness = fatness, color = color, topLeft = topLeft, bottomRight = bottomRight, figureName = maker.ToString()
                });

                currentFabrics.Add(maker);
                picture.Image = bmap;
            }
            else
            {
                //tb_x1.Text = tb_x2.Text = tb_y1.Text = tb_y2.Text = "";
                MessageBox.Show(message, title_mess, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
 private void picture_MouseUp(object sender, MouseEventArgs e)
 {
     if (isDrawing)
     {
         finish = new Point(e.X, e.Y);
         Graphics g = Graphics.FromImage(bmap);
         figure.MouseDraw(g, finish);
         isDrawing = false;
         picture.Invalidate();
         figureList.Add(figure);
         jsonList.Add(new JSON()
         {
             fatness = fatness, color = color, topLeft = start, bottomRight = finish, figureName = maker.ToString()
         });
     }
 }