Exemplo n.º 1
0
            protected override void doExecute()
            {
                VisualCurve c = VisualCurve.CreateVisualCurve(new MoveTo((ICurve)owner.curves[index].Curve.Clone(), new_p));

                owner.curves.RemoveAt(index);
                owner.curves.Add(c);
            }
Exemplo n.º 2
0
 /// <summary>
 /// Перемещение кривой при нажатии на неё мышкой
 /// </summary>
 private void panel1_MouseMove(object sender, MouseEventArgs e)
 {
     if (moving)
     {
         IPoint new_p = new Geometry.Point(e.X + p_offset.X, e.Y + p_offset.Y);
         movingCurve.Curve = new MoveTo(movingCurve.Curve, new_p);
         panel1.Refresh();
         DrawMove(movingList, movingCurve);
     }
     else
     {
         foreach (VisualCurve c in curves)
         {
             if (hoverCurve = c.Path.IsOutlineVisible(e.Location, new Pen(Color.Black, 15)))
             {
                 VisualCurve cu = VisualCurve.CreateVisualCurve(c.Clone());
                 c.Draw(new DrawGraphics(g, 3));
                 hover = true;
                 break;
             }
         }
         if (!hoverCurve && hover)
         {
             panel1.Refresh();
             Draw(curves);
             hover = false;
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Генерация новой кривой при нажатии кнопки
        /// </summary>
        private void button1_Click(object sender, EventArgs e)
        {
            VisualCurve cu = GenerateCurve(rand.Next(1, 3));

            new Items_Add(cu.Clone(), this).Execute();
            cu.Draw(new DrawGraphics(g, 1));
        }
Exemplo n.º 4
0
 private void panel1_MouseUp(object sender, MouseEventArgs e)
 {
     if (moving)
     {
         IPoint new_p = new Geometry.Point(e.X + p_offset.X, e.Y + p_offset.Y);
         new Items_Move(movingList.IndexOf(movingCurve), new_p, this).Execute();
         movingCurve = null;
         moving      = false;
         panel1.Refresh();
         Draw(curves);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Генерация кривой
        /// </summary>
        private VisualCurve GenerateCurve(int type)
        {
            int w = panel1.Width / 2 - 10;
            int h = panel1.Height / 2 - 10;

            if (type == 1)
            {
                return(VisualCurve.CreateVisualLine(new Line(new Geometry.Point(correctX(rand.Next(-w, w)), correctY(rand.Next(-h, h))), new Geometry.Point(correctX(rand.Next(-w, w)), correctY(rand.Next(-h, h))))));
            }
            else
            {
                return(VisualCurve.CreateVisualBezier(new Bezier(new Geometry.Point(correctX(rand.Next(-w, w)), correctY(rand.Next(-h, h))), new Geometry.Point(correctX(rand.Next(-w, w)), correctY(rand.Next(-h, h))), new Geometry.Point(correctX(rand.Next(-w, w)), correctY(rand.Next(-h, h))), new Geometry.Point(correctX(rand.Next(-w, w)), correctY(rand.Next(-h, h))))));
            }
        }
Exemplo n.º 6
0
        private void DrawMove(List <VisualCurve> list, VisualCurve move)
        {
            IDrawer draw     = new DrawGraphics(g, 1);
            IDrawer drawMove = new DrawGraphics(g, 4);
            int     ind      = list.IndexOf(move);

            for (int i = 0; i < list.Count; i++)
            {
                if (i != ind)
                {
                    list[i].Draw(draw);
                }
                else
                {
                    list[i].Draw(drawMove);
                }
            }
        }
Exemplo n.º 7
0
 private void panel1_MouseDown(object sender, MouseEventArgs e)
 {
     CopyCurves(ref movingList);
     foreach (VisualCurve c in movingList)
     {
         if (c.Path.IsOutlineVisible(e.Location, new Pen(Color.Black, 15)))
         {
             c.GetPoint(0, out p_offset);
             p_offset.X -= e.X;
             p_offset.Y -= e.Y;
             movingCurve = c;
             break;
         }
     }
     if (movingCurve != null)
     {
         moving = true;
     }
 }
Exemplo n.º 8
0
 public Items_Add(VisualCurve curve, Form1 owner)
 {
     this.curve = curve;
     this.owner = owner;
 }