示例#1
0
        public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e)
        {
            Point p;

            if (drawArea.SnapEnable)
            {
                p = drawArea.BackTrackMouse(new Point(drawArea.FittoSnap(e.X, drawArea.SnapX), drawArea.FittoSnap(e.Y, drawArea.SnapY)));
            }
            else
            {
                p = drawArea.BackTrackMouse(new Point(e.X, e.Y));
            }
            DrawRectangle o;

            //if (drawArea.CurrentPen == null)
            //    AddNewObject(drawArea,(o =  new DrawRectangle(p.X, p.Y, 1, 1, drawArea.LineColor, drawArea.FillColor, drawArea.DrawFilled, drawArea.LineWidth)));
            //else
            //AddNewObject(drawArea, (o = new DrawRectangle(drawArea.ParentTabGraphicPageControl.Pages(),p.X, p.Y, 1, 1, drawArea.PenType, drawArea.FillColor, drawArea.DrawFilled)));
            AddNewObject(drawArea, (o = new DrawRectangle(drawArea.ParentTabGraphicPageControl.Pages(), p.X, p.Y, 1, 1)));

            o.Dirty = true;
            drawArea.Pages.Dirty = true;
            o.oIndex             = drawArea.Pages.GetNewobjectoIndex();
            DCS.Forms.MainForm.Instance().m_propertyGrid.SelectedObject = o;
            DCS.Forms.MainForm.Instance().m_propertyGrid.Refresh();
        }
示例#2
0
        public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e)
        {
            Point p;

            Trace.WriteLine("Line OnMouseDown X=" + e.X.ToString() + " Y=", e.Y.ToString());
            if (drawArea.SnapEnable)
            {
                p = drawArea.BackTrackMouse(new Point(drawArea.FittoSnap(e.X, drawArea.SnapX), drawArea.FittoSnap(e.Y, drawArea.SnapY)));
            }
            else
            {
                p = drawArea.BackTrackMouse(new Point(e.X, e.Y));
            }
            Trace.WriteLine("Line OnMouseDown pX=" + p.X.ToString() + " pY=" + p.Y.ToString());
            DrawLine o;

            if (drawArea.PenType == DrawingPens.PenType.Generic)
            {
                //AddNewObject(drawArea, new DrawLine(p.X, p.Y, p.X + 1, p.Y + 1, drawArea.LineColor, drawArea.LineWidth));

                AddNewObject(drawArea, (o = new DrawLine(drawArea.Pages, p.X, p.Y, p.X + 1, p.Y + 1)));
            }
            else
            {
                //AddNewObject(drawArea, new DrawLine(p.X, p.Y, p.X + 1, p.Y + 1, drawArea.PenType));
                AddNewObject(drawArea, (o = new DrawLine(drawArea.Pages, p.X, p.Y, p.X + 1, p.Y + 1)));
            }
            o.Dirty = true;
            drawArea.Pages.Dirty = true;
            o.oIndex             = drawArea.Pages.GetNewobjectoIndex();
            DCS.Forms.MainForm.Instance().m_propertyGrid.SelectedObject = o;
            DCS.Forms.MainForm.Instance().m_propertyGrid.Refresh();
        }
示例#3
0
 public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e)
 {
     drawArea.Cursor = m_Cursor;
     if (e.Button == MouseButtons.Left)
     {
         Point point = drawArea.BackTrackMouse(new Point(e.X, e.Y));
         int   index = drawArea.ParentTabGraphicPageControl.NoOfObjectsinPage - 1;
         drawArea.ParentTabGraphicPageControl.Pages().GetObject(drawArea.ParentTabGraphicPageControl.Pages().ActivePageNo, index).MoveHandleTo(point, 5);
         Trace.WriteLine("OnMouseMove ");
         drawArea.Refresh();
     }
 }
示例#4
0
        public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e)
        {
            //drawArea.Cursor = m_Cursor;

            if (e.Button == MouseButtons.Left)
            {
                //Trace.WriteLine("Line OnMouseMove X=" + e.X.ToString() + " Y="+ e.Y.ToString());
                Point p;
                if (drawArea.SnapEnable)
                {
                    p = drawArea.BackTrackMouse(new Point(drawArea.FittoSnap(e.X, drawArea.SnapX), drawArea.FittoSnap(e.Y, drawArea.SnapY)));
                }
                else
                {
                    p = drawArea.BackTrackMouse(new Point(e.X, e.Y));
                }
                //Trace.WriteLine("Line OnMouseMove pX=" + p.X.ToString() + " pY="+ p.Y.ToString());
                int index = drawArea.ParentTabGraphicPageControl.NoOfObjectsinPage - 1;
                drawArea.Pages.GetObject(drawArea.Pages.ActivePageNo, index).MoveHandleTo(p, 2);
                drawArea.Refresh();
            }
        }
示例#5
0
        public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e)
        {
            Point p;

            if (drawArea.SnapEnable)
            {
                p = drawArea.BackTrackMouse(new Point(drawArea.FittoSnap(e.X, drawArea.SnapX), drawArea.FittoSnap(e.Y, drawArea.SnapY)));
            }
            else
            {
                p = drawArea.BackTrackMouse(new Point(e.X, e.Y));
            }
            DrawImage o;

            AddNewObject(drawArea, (o = new DrawImage(drawArea.Pages, p.X, p.Y)));

            o.Dirty = true;
            drawArea.Pages.Dirty = true;
            o.oIndex             = drawArea.Pages.GetNewobjectoIndex();
            DCS.Forms.MainForm.Instance().m_propertyGrid.SelectedObject = o;
            DCS.Forms.MainForm.Instance().m_propertyGrid.Refresh();
        }
示例#6
0
        public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e)
        {
            Point      p  = drawArea.BackTrackMouse(new Point(e.X, e.Y));
            TextDialog td = new TextDialog();

            string   t = "Text";
            Color    c = Color.Black;
            Font     f = new Font("Arial", 10);
            DrawText o;

            AddNewObject(drawArea, (o = new DrawText(drawArea.Pages, p.X, p.Y, t, f, c)));
            o.Dirty  = true;
            o.oIndex = drawArea.Pages.GetNewobjectoIndex();
            DCS.Forms.MainForm.Instance().m_propertyGrid.SelectedObject = o;
            DCS.Forms.MainForm.Instance().m_propertyGrid.Refresh();
        }
示例#7
0
        public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e)
        {
            Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y));
            //if (drawArea.CurrentPen == null)
            //    AddNewObject(drawArea, new DrawEllipse(p.X, p.Y, 1, 1, drawArea.LineColor, drawArea.FillColor, drawArea.DrawFilled, drawArea.LineWidth));
            //else

            DrawEllipse o;

            AddNewObject(drawArea, (o = new DrawEllipse(drawArea.Pages, p.X, p.Y, 1, 1, drawArea.PenType, drawArea.FillColor, drawArea.DrawFilled)));

            o.Dirty = true;
            drawArea.Pages.Dirty = true;
            o.oIndex             = drawArea.Pages.GetNewobjectoIndex();
            DCS.Forms.MainForm.Instance().m_propertyGrid.SelectedObject = o;
            DCS.Forms.MainForm.Instance().m_propertyGrid.Refresh();
        }
示例#8
0
        /// <summary>
        /// Mouse move - resize new polygon
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="e"></param>
        public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e)
        {
            drawArea.Cursor = m_Cursor;

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            if (newPolyLine == null)
            {
                return; // precaution
            }
            Point point = drawArea.BackTrackMouse(new Point(e.X, e.Y));

            // move last point
            newPolyLine.MoveHandleTo(point, newPolyLine.HandleCount);
            drawArea.Refresh();
        }
示例#9
0
        public bool _drawingInProcess = false; // Set to true when drawing

        /// <summary>
        /// Left nouse button is pressed
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="e"></param>
        public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                _drawingInProcess = false;
                //newPolyLine = null;
            }
            else
            {
                Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y));
                if (_drawingInProcess == false)
                {
                    newPolyLine = new DrawPolyLine(drawArea.ParentTabGraphicPageControl.Pages(), p.X, p.Y, p.X + 1, p.Y + 1);
                    //newPolyLine.EndPoint = new Point(p.X + 1, p.Y + 1);
                    newPolyLine.oIndex = drawArea.Pages.GetNewobjectoIndex();
                    AddNewObject(drawArea, newPolyLine);
                    _drawingInProcess = true;
                    newPolyLine.MoveHandleTo(new Point(e.X, e.Y), newPolyLine.HandleCount);
                    drawArea.Refresh();
                    secondclick = true;
                }
                else
                {
                    if ((secondclick))
                    {
                        //newPolyLine.EndPoint = p;
                        newPolyLine.MoveHandleTo(p, newPolyLine.HandleCount);
                        drawArea.Refresh();
                        secondclick = false;
                    }
                    else
                    {
                        newPolyLine.AddPoint(p);
                        //newPolyLine.EndPoint = p;
                        newPolyLine.MoveHandleTo(new Point(e.X, e.Y), newPolyLine.HandleCount);
                        drawArea.Refresh();
                        secondclick = false;
                    }
                }
            }
        }
示例#10
0
        /// <summary>
        /// Left mouse button is pressed
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="e"></param>
        public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e)
        {
            Point pointscroll = GetEventPointInArea(drawArea, e);

            commandChangeState = null;
            wasMove            = false;

            selectMode = SelectionMode.None;
            Trace.WriteLine("ToolPointer OnMouseDown ");
            if (e.Button == MouseButtons.Left)
            {
                Point point;
                //    if (drawArea.SnapEnable)
                {
                    //      point = drawArea.BackTrackMouse(new Point(drawArea.FittoSnap(e.X, drawArea.SnapX), drawArea.FittoSnap(e.Y, drawArea.SnapY)));
                }
                //else
                {
                    point = drawArea.BackTrackMouse(pointscroll);
                }
                startPoint = point;
                lastPoint  = point;
                FirstPoint = point;

                DrawObject o             = null;
                int        hittestresult = -1;
                for (int i = 0; i < drawArea.Pages.GraphicPagesList[drawArea.ActivePageNo].List.Count; i++)
                //foreach (DrawObject o in drawArea.Pages.GraphicPagesList[drawArea.ActivePageNo].List)
                {
                    o = drawArea.Pages.GraphicPagesList[drawArea.ActivePageNo].List[i];
                    if (drawArea.Pages.LayerIsNotLock((LAYERS)o.Layer))
                    {
                        hittestresult = o.HitTest(point);
                        if (hittestresult != -1)
                        {
#if EWSAPP
                            Trace.WriteLine("ToolPointer OnMouseDown Click over an object");
                            if (o.Selected)      // object was selected
                            {
                                Trace.WriteLine("ToolPointer OnMouseDown object was selected");
                                if (hittestresult > 0)  // over control points
                                {
                                    Console.WriteLine("ToolPointer OnMouseDown over control points e.x {0}  e.y {1}  First.x {2} First.y {3}", o.rectangle.X, o.rectangle.Y, FirstPoint.X, FirstPoint.Y);
                                    selectMode          = SelectionMode.Size;
                                    resizedObject       = o;
                                    resizedObjectHandle = hittestresult;
                                    // Since we want to resize only one object, unselect all other objects
                                    drawArea.UnselectAll();
                                    o.Selected           = true;
                                    commandChangeState   = new CommandChangeState(drawArea.Pages.GraphicPagesList[drawArea.ActivePageNo]);
                                    drawArea.Pages.Dirty = true;
                                }
                                else                  // clicked inside object
                                {
                                    Trace.WriteLine("ToolPointer OnMouseDown clicked inside object ");
                                    //drawArea.Graphics.UnselectAll();
                                    selectMode      = SelectionMode.Move;
                                    drawArea.Cursor = Cursors.SizeAll;
                                    startPoint      = point;
                                }
                            }
                            else  // object was not selected
                            {
                                Trace.WriteLine("ToolPointer OnMouseDown object was not selected ");
                                if ((Control.ModifierKeys & Keys.Control) == 0)
                                {
                                    drawArea.UnselectAll();
                                }
                                o.Selected = true;
                                DCS.Forms.MainForm.Instance().m_propertyGrid.SelectedObject = o;
                                DCS.Forms.MainForm.Instance().m_propertyGrid.Refresh();
                                commandChangeState = new CommandChangeState(drawArea.Pages.GraphicPagesList[drawArea.ActivePageNo]);
                                selectMode         = SelectionMode.Move;
                                drawArea.Cursor    = Cursors.SizeAll;
                                drawArea.Refresh();
                            }
                            break;
#endif
                        }
                    }
                }

                if (hittestresult == -1)   // not clicked over any objet
                {
                    Trace.WriteLine("ToolPointer OnMouseDown not clicked over an objet ");
                    selectMode = SelectionMode.NetSelection;
                    if ((Control.ModifierKeys & Keys.Control) == 0)
                    {
                        drawArea.UnselectAll();
                    }
                }
            }
            else
            {
            }
        }
示例#11
0
        public override void MouseDoubleClick(DrawArea drawArea, MouseEventArgs e)
        {
            Point pointscroll = GetEventPointInArea(drawArea, e);

            commandChangeState = null;
            wasMove            = false;

            selectMode = SelectionMode.None;
            Trace.WriteLine("ToolPointer OnMouseDown ");
            if (e.Button == MouseButtons.Left)
            {
                Point point;
                //    if (drawArea.SnapEnable)
                {
                    //      point = drawArea.BackTrackMouse(new Point(drawArea.FittoSnap(e.X, drawArea.SnapX), drawArea.FittoSnap(e.Y, drawArea.SnapY)));
                }
                //else
                {
                    point = drawArea.BackTrackMouse(pointscroll);
                }
                startPoint = point;
                lastPoint  = point;
                FirstPoint = point;

                //DrawObject o = null;
                int hittestresult = -1;
                //for (int i = 0; i < drawArea.graphicsList.List.Count; i++)
                foreach (DrawObject drawobject in drawArea.Pages.GraphicPagesList[drawArea.ActivePageNo].List)
                {
                    //o = drawArea.graphicsList.List[i];
                    if (drawArea.Pages.LayerIsNotLock((LAYERS)drawobject.Layer))
                    {
                        hittestresult = drawobject.HitTest(point);
                        if (hittestresult != -1)
                        {
                            if (drawobject is DrawFunctionBlock)
                            {
                            }
                            else
                            {
                                if (drawobject is DrawFunction)
                                {
                                }
                                else
                                {
                                    if (drawobject is DrawFunctionEx)
                                    {
                                    }
                                    else
                                    {
                                        if (drawobject is DrawVariable)
                                        {
#if EWSAPP
                                            VariableForm varlistfrm = new VariableForm(/*drawArea.mainEWSForm,*/ ((TabFBDPageControl)drawArea.ParentTabGraphicPageControl).ID);
                                            if (DialogResult.OK == varlistfrm.ShowDialog())
                                            {
                                                ((DrawVariable)drawobject).tblvariable         = varlistfrm.tblvariable;
                                                ((DrawVariable)drawobject).tblformalparameter  = varlistfrm.tblformalparameter;
                                                ((DrawVariable)drawobject).ExtendedPropertyTXT = varlistfrm.SubPropertyTxt;
                                                drawArea.Capture = false;
                                            }
#endif
                                        }
                                    }
                                }
                            }

                            break;
                        }
                    }
                }
            }
        }
示例#12
0
        /// <summary>
        /// Right mouse button is released
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="e"></param>
        public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e)
        {
#if EWSAPP
            int newx;
            int newy;


            switch (selectMode)
            {
            case SelectionMode.NetSelection:
                Trace.WriteLine("ToolPointer OnMouseUp MouseButtons.Left SelectionMode.NetSelection");
                drawArea.Pages.SelectInRectangle(drawArea.NetRectangle);

                selectMode = SelectionMode.None;

                drawArea.DrawNetRectangle = false;
                if (resizedObject != null)
                {
                    // after resizing
                    resizedObject.Normalize();
                    resizedObject = null;
                }

                drawArea.Capture = false;
                drawArea.Refresh();

                if (commandChangeState != null && wasMove)
                {
                    // Keep state after moving/resizing and add command to history
                    commandChangeState.NewState(drawArea.Pages.GraphicPagesList[drawArea.ActivePageNo]);
                    drawArea.Pages.AddCommandToHistory(commandChangeState);
                    commandChangeState = null;
                }
                lastPoint = drawArea.BackTrackMouse(e.Location);
                break;

            case SelectionMode.Size:
                Trace.WriteLine("ToolPointer OnMouseUp MouseButtons.Left SelectionMode.Size");
                break;

            case SelectionMode.Move:
                newx = e.X - FirstPoint.X;
                newy = e.Y - FirstPoint.Y;
                //newx = drawArea.FittoSnap(e.X, drawArea.SnapX);
                //newy = drawArea.FittoSnap(e.Y, drawArea.SnapY);
                if ((newx != 0) || (newy != 0))
                {
                    if (drawArea.SnapEnable)
                    {
                        foreach (DrawObject o in drawArea.Pages.GraphicPagesList[drawArea.ActivePageNo].Selection)
                        {
                            //o.MoveTo(drawArea.FittoSnap(o._rectangle.X + newx, drawArea.SnapX), drawArea.FittoSnap(o._rectangle.Y + newy, drawArea.SnapY));
                            int _x = o.rectangle.X;
                            _x = o.rectangle.X + newx;
                            _x = drawArea.FittoSnap(o.rectangle.X, drawArea.SnapX);
                            int _y = o.rectangle.Y;
                            _y = o.rectangle.Y + newy;
                            _y = drawArea.FittoSnap(o.rectangle.Y, drawArea.SnapY);

                            o.MoveTo(_x, _y);
                            if ((o is DrawFBDBox))
                            {
                                ((DrawFBDBox)o).UpdateWireConnections();
                            }
                        }
                    }

                    drawArea.Cursor = Cursors.SizeAll;
                    drawArea.Refresh();
                    drawArea.Pages.Dirty = true;
                }
                break;

            default:

                break;
            }

            selectMode      = SelectionMode.None;
            drawArea.Cursor = Cursors.Default;
#endif
        }
示例#13
0
        /// <summary>
        /// Mouse is moved.
        /// None button is pressed, ot left button is pressed.
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="e"></param>
        public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e)
        {
#if EWSAPP
            //Trace.WriteLine("OnMouseMove ");
            int hittestresult = -1;

            Point point;
            //Point OnSnappoint;
            //Point pt = new Point();
            point = drawArea.BackTrackMouse(new Point(e.X, e.Y));

            Point pointscroll = GetEventPointInArea(drawArea, e);
            Point oldPoint    = lastPoint;
            wasMove = true;
            //toolTip.InitialDelay = 1;

            int dx = e.X - lastPoint.X;
            int dy = e.Y - lastPoint.Y;

            lastPoint.X = e.X;
            lastPoint.Y = e.Y;
            switch (e.Button)
            {
            case MouseButtons.Left:
                switch (selectMode)
                {
                case SelectionMode.NetSelection:
                    Trace.WriteLine("ToolPointer OnMouseMove MouseButtons.Left SelectionMode.NetSelection");
                    // Remove old selection rectangle
                    ControlPaint.DrawReversibleFrame(
                        drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, oldPoint)),
                        Color.Black,
                        FrameStyle.Dashed);

                    // Draw new selection rectangle
                    ControlPaint.DrawReversibleFrame(
                        drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, new Point(e.X, e.Y))),
                        Color.Black,
                        FrameStyle.Dashed);
                    drawArea.NetRectangle = DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint);

                    break;

                case SelectionMode.Move:
                    Trace.WriteLine("ToolPointer OnMouseMove MouseButtons.Left SelectionMode.Move");

                    foreach (DrawObject o in drawArea.Pages.GraphicPagesList[drawArea.ActivePageNo].Selection)
                    {
                        o.Move(dx, dy);
                        if ((o is DrawFBDBox))
                        {
                            ((DrawFBDBox)o).UpdateWireConnections();
                        }
                    }

                    drawArea.Cursor      = Cursors.SizeAll;
                    drawArea.Pages.Dirty = true;
                    drawArea.Refresh();
                    drawArea.Pages.Dirty = true;
                    break;

                case SelectionMode.Size:
                    Trace.WriteLine("ToolPointer OnMouseMove MouseButtons.Left SelectionMode.Size");
                    if (resizedObject != null)
                    {
                        resizedObject.MoveHandleTo(pointscroll, resizedObjectHandle);

                        drawArea.Refresh();
                        drawArea.Pages.Dirty = true;
                    }
                    break;

                default:
                    break;
                }
                break;

            case MouseButtons.None:
                Cursor tempcursor = null;
                foreach (DrawObject o in drawArea.Pages.GraphicPagesList[drawArea.ActivePageNo].Selection)
                {
                    hittestresult = o.HitTest(point);
                    if (hittestresult > 0)
                    {
                        Trace.WriteLine("ToolPointer OnMouseDown over control points");
                        tempcursor = o.GetHandleCursor(hittestresult);
                        break;
                    }
                }
                if (tempcursor == null)
                {
                    tempcursor = Cursors.Default;
                }

                //drawArea.Cursor = tempcursor;
                break;

            default:
                break;
            }
#endif
        }