Ejemplo n.º 1
0
        private void DragObjectFinished()
        {
            if (Designer is ChartWinControl)
            {
                (Designer as ChartWinControl).ShowCrossCursor = SavedShowCrossCursor;
                (Designer as ChartWinControl).ShowStatistic   = SavedShowStatistic;
            }

            if (ObjectChanged != null && DragObject != null)
            {
                DragObject.Object.InSetup = false;
                DragObject.Object.InMove  = false;
                ObjectChanged(this, DragObject.Object);
            }
            DragObject      = null;
            ObjectType      = null;
            Canvas.Dragging = false;
            ObjectSteps     = 0;
            Designer.Invalidate();
        }
Ejemplo n.º 2
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;
        }