예제 #1
0
파일: Form1.cs 프로젝트: habfer/MyPaint
 public void PictureBox_Paint(object sender, PaintEventArgs e)
 {
     if (shape != null)
     {
         shape.StartPoint  = X;
         shape.FinishPoint = Y;
         shape.Draw(e.Graphics, shape.Pen, shape.StartPoint, shape.FinishPoint);
         if (shapeList.myList.Count > 0)
         {
             foreach (var fig in shapeList.myList)
             {
                 fig.Draw(e.Graphics, fig.Pen, fig.StartPoint, fig.FinishPoint);
             }
         }
     }
 }
예제 #2
0
        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            press = false;
            if (curSelectFig != null)
            {
                startMove = false;
            }
            if (temp != null)
            {
                Bmp = temp.Draw(Bmp, one, two);
                pictureBox1.Image = Bmp;

                SaveData svd = new SaveData(one, two, temp, penWidth, Current.ToArgb(), Current.ToArgb());
                saveList.Add(svd);
            }
        }
예제 #3
0
        private void RedrawCanvas(SaveData svd)
        {
            try
            {
                temp = CountValue(svd);

                temp.getAtributs(Color.FromArgb(svd.clr), svd.pWidth);
                temp.Draw(Bmp, svd.one, svd.two);
                pictureBox1.Image = Bmp;
                temp = null;
                // pictureBox1.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #4
0
        private void ShapePictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            if (figure != null && !user)
            {
                Cursor.Current        = Cursors.Default;
                press                 = false;
                two                   = e.Location;
                Bmp                   = figure.Draw(Bmp, one, two);
                ShapePictureBox.Image = Bmp;
                figure.pos1           = one;
                figure.pos2           = two;

                /*
                 * figure.x = x;
                 * figure.y = y;
                 * figure.h = h;
                 * figure.w = w;
                 */
                figure.pWidth = penWidth;
                figure.clr    = Current;
                ListOfShapes.Add(this.figure);
                this.figure = FactoriesList[((Button)ShapeSender).Text].Create(Current, penWidth);
            }
            if (user && customShape != null)
            {
                Cursor.Current = Cursors.Default;
//                user = false;
                press = false;
                two   = e.Location;
                customShape.Draw(Bmp, one, two);


/*
 *              foreach (Shape figure in ListOfUserShapes)
 *              {
 *                  int newX1 = one.X + (two.X - one.X) * figure.pos1.X / ShapePictureBox.Width;//MaxP.X - MinP.X
 *                  int newY1 = one.Y + (two.Y - one.Y) * figure.pos1.Y / ShapePictureBox.Height;//MaxP.Y - MinP.Y
 *                  int newX2 = one.X + (two.X - one.X) * Math.Abs(figure.pos2.X - figure.pos1.X) / ShapePictureBox.Width;
 *                  int newY2 = one.Y + (two.Y - one.Y) * Math.Abs(figure.pos2.Y - figure.pos1.Y) / ShapePictureBox.Height;
 *                  /*
 *                  x = one.X + (figure.pos1.X - 0) * (two.X - one.X) / (ShapePictureBox.Width - 0);
 *                  y = one.Y + (figure.pos1.Y - 0) * (two.Y - one.Y) / (ShapePictureBox.Height - 0);
 *                  h = x + (figure.pos2.X - figure.pos1.X) * (two.X - one.X) / (ShapePictureBox.Width - 0);
 *                  w = y + (figure.pos2.Y - figure.pos1.Y) * (two.Y - one.Y) / (ShapePictureBox.Height - 0);
 */
//                    Bmp = figure.Draw(Bmp, one, two);
//                    ShapePictureBox.Image = Bmp;
//                }
                ShapePictureBox.Image = Bmp;
                int          i   = 0;
                List <Shape> tmp = new List <Shape>();
                foreach (Shape shp in customShape.components)
                {
                    tmp.Add(shp.Clone(customShape.newpoints[i][0], customShape.newpoints[i][1], shp.clr, shp.pWidth));
                    i++;
                }
                ListOfShapes.AddRange(tmp);

                /*
                 * List<Shape> tmp = new List<Shape>(customShape.components);
                 * foreach (Shape shp in tmp)
                 * {
                 *  shp.pos1 = customShape.newpoints[i][0];
                 *  shp.pos2 = customShape.newpoints[i][1];
                 *
                 *  ListOfShapes.Add(tmp);
                 *  i++;
                 * }
                 */
                /*
                 * foreach(Shape shp in customShape.components)
                 * {
                 *  shp.pos1 = customShape.newpoints[i][0];
                 *  shp.pos2 = customShape.newpoints[i][1];
                 *  i++;
                 *  ListOfShapes.Add(shp);
                 * }
                 */
                /*
                 * foreach(Shape shp in customShape.SerializeList)
                 * {
                 *  ListOfShapes.Add(shp);
                 * }
                 */
                /*
                 * foreach (Shape shp in customShape.SerializeList)
                 * {
                 *  ListOfShapes.Add(shp);
                 * }
                 */
                //                customShape = (CustomShape)ListOfCustomShapes.ElementAt<Shape>(comboBoxCustomShape.SelectedIndex);

                CustomShapeFactory csf = new CustomShapeFactory();
                customShape = (CustomShape)csf.Create(customShape.name, customShape.components, customShape.width, customShape.height);
            }
        }