Exemplo n.º 1
0
        public void Delete()
        {
            int i = objects.IndexOf(SelectedObject);

            objects.Remove(SelectedObject);
            if (i >= objects.Count)
            {
                i = objects.Count - 1;
            }
            if (i >= 0)
            {
                SelectedObject = objects[i];
            }
            else
            {
                SelectedObject = null;
            }
            Designer.Invalidate();
            if (AfterSelect != null)
            {
                AfterSelect(this, SelectedObject);
            }
        }
Exemplo n.º 2
0
 private void DrawMemBmp(Bitmap BackImage, Region Clip)
 {
     CreateMemBmp();
     if (Designer != null)
     {
         Graphics g = Graphics.FromImage(MemBmp);
         g.SetClip(Clip, CombineMode.Replace);
         if (BackImage != null)
         {
             g.DrawImage(BackImage, 0, 0);
         }
         else
         {
             g.Clear(Designer.BackColor);
         }
         ObjectBase MovingObject = null;
         if (DragObject != null)
         {
             MovingObject = DragObject.Object;
         }
         Draw(g, SelectedObject, MovingObject);
     }
 }
Exemplo n.º 3
0
        private void DesignerControl_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (DragObject != null)
            {
                FormulaArea fa     = DragObject.Object.Area;
                float       DeltaX = e.X - DragObject.StartPoint.X;
                float       DeltaY = e.Y - DragObject.StartPoint.Y;
                InvalidateObject(DragObject.Object);
                if (DragObject.ControlPointIndex < 0)
                {
                    for (int i = 0; i < DragObject.Object.ControlPoints.Length; i++)
                    {
                        PointF pf = DragObject.Object.ToPointF(DragObject.ControlPoints[i]);
                        DragObject.Object.ControlPoints[i] = GetValueFromPos(pf.X + DeltaX, pf.Y + DeltaY, ref fa);
                    }
                }
                else
                {
                    DragObject.Object.ControlPoints[DragObject.ControlPointIndex] = GetValueFromPos(e.X, e.Y, ref fa);
                    if (DragObject.Object.InitPoints != null && DragObject.Object.InSetup)
                    {
                        if (DragObject.ControlPoints.Length > 1)
                        {
                            PointF pf1 = DragObject.Object.ToPointF(DragObject.Object.ControlPoints[1]);
                            PointF pf0 = DragObject.Object.ToPointF(DragObject.Object.ControlPoints[0]);

                            float FactorX = (pf1.X - pf0.X) / DragObject.Object.InitPoints[1].X;
                            float FactorY = (pf1.Y - pf0.Y) / DragObject.Object.InitPoints[1].Y;
                            for (int i = 2; i < DragObject.Object.ControlPoints.Length; i++)
                            {
                                DragObject.Object.ControlPoints[i] = GetValueFromPos(
                                    pf0.X + FactorX * DragObject.Object.InitPoints[i].X,
                                    pf0.Y + FactorY * DragObject.Object.InitPoints[i].Y, ref fa);
                            }
                        }
                    }
                }
                InvalidateObject(DragObject.Object);
            }
            else
            {
                Cursor OldCursor = Designer.Cursor;

                bool b = GetPointIndex(e.X, e.Y) >= 0;
                if (b)
                {
                    Designer.Cursor = Cursors.SizeAll;
                }
                else
                {
                    ObjectBase ob = GetObjectAt(e.X, e.Y);
                    if (ob != null)
                    {
                        Designer.Cursor = Cursors.Hand;
                    }
                    else if (ObjectType == null)
                    {
                        Designer.Cursor = OldCursor;
                    }
                    else
                    {
                        Designer.Cursor = Cursors.Cross;
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void DesignerControl_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            FormulaArea fa = null;

            StartPoint = GetValueFromPos(e.X, e.Y, ref fa);
            ObjectBase ob;

            if (Designer is ChartWinControl)
            {
                SavedShowCrossCursor = (Designer as ChartWinControl).ShowCrossCursor;
                SavedShowStatistic   = (Designer as ChartWinControl).ShowStatistic;
                (Designer as ChartWinControl).ShowCrossCursor = false;
                (Designer as ChartWinControl).ShowStatistic   = false;
            }

            if (ObjectType == null)
            {
                int PointIndex = GetPointIndex(e.X, e.Y, out ob);
                if (ob == null)
                {
                    ob = GetObjectAt(e.X, e.Y);
                }

                if (ob != null)
                {
                    SelectedObject = ob;
                    DragObject     = new DraggingObject(new PointF(e.X, e.Y), PointIndex, ob);
                    Designer.Invalidate(ob.GetRegion());
                    Canvas.Dragging = true;
                    ob.InMove       = true;
                }
            }
            else
            {
                if (e.Button == MouseButtons.Right)
                {
                    objects.Remove(DragObject.Object);
                    DragObjectFinished();
                }
                else
                {
                    if (ObjectSteps == 0)
                    {
                        ob          = ObjectType.Invoke();
                        ob.AreaName = fa.Name;
                        ob.Area     = fa;
                        ob.InSetup  = true;
                        ob.InMove   = true;
                        if (AfterCreate != null)
                        {
                            AfterCreate(this, ob);
                        }
                        ob.SetObjectManager(this);
                        for (int i = 0; i < ob.ControlPointNum; i++)
                        {
                            ob.ControlPoints[i] = StartPoint;
                        }
                        objects.Add(ob);
                        SelectedObject  = ob;
                        DragObject      = new DraggingObject(new PointF(e.X, e.Y), ObjectSteps + 1, ob);
                        Canvas.Dragging = true;
                    }
                    else
                    {
                        ob = DragObject.Object;
                        DragObject.ControlPointIndex = ObjectSteps + 1;
                    }
                    ObjectSteps++;
                    if (ObjectSteps == ob.InitNum)
                    {
                        DragObjectFinished();
                    }
                }
            }
            DragMemBmp = null;
        }
Exemplo n.º 5
0
 public void Remove(ObjectBase value)
 {
     List.Remove(value);
 }
Exemplo n.º 6
0
 public int IndexOf(ObjectBase ob)
 {
     return(List.IndexOf(ob));
 }
Exemplo n.º 7
0
 public virtual void Insert(int Index, ObjectBase ob)
 {
     this.List.Insert(Index, ob);
 }
Exemplo n.º 8
0
 public virtual void Add(ObjectBase ob)
 {
     this.List.Add(ob);
 }