Ejemplo n.º 1
0
        /// <summary>
        /// Left mouse button is pressed
        /// </summary>
        /// <param name="DrawRegion"></param>
        /// <param name="e"></param>
        public override void OnMouseDown(DrawRegion drawRegion, MouseEventArgs e)
        {
            selectMode = SelectionMode.None;
            Point point = new Point(e.X, e.Y);


            // Test for move (cursor is on the object)
            if (selectMode == SelectionMode.None)
            {
                int        n1 = drawRegion.GraphicsList.Count;
                DrawObject o  = null;

                for (int i = 0; i < n1; i++)
                {
                    if (drawRegion.GraphicsList[i].HitTest(point) == 0)
                    {
                        o = drawRegion.GraphicsList[i];
                        break;
                    }
                }

                if (o != null)
                {
                    selectMode = SelectionMode.Move;
                    o.Selected = true;
                }
            }

            // Net selection
            if (selectMode == SelectionMode.None)
            {
                selectMode = SelectionMode.NetSelection;
                drawRegion.DrawNetRectangle = true;
            }

            lastPoint.X  = e.X;
            lastPoint.Y  = e.Y;
            startPoint.X = e.X;
            startPoint.Y = e.Y;

            drawRegion.Capture = true;


            drawRegion.NetRectangle = DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint);

            drawRegion.Refresh();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Right mouse button is released
        /// </summary>
        /// <param name="DrawRegion"></param>
        /// <param name="e"></param>
        public override void OnMouseUp(DrawRegion drawRegion, MouseEventArgs e)
        {
            if (selectMode == SelectionMode.NetSelection)
            {
                // Group selection
                drawRegion.GraphicsList.SelectInRectangle(drawRegion.NetRectangle);

                selectMode = SelectionMode.None;
                drawRegion.DrawNetRectangle = false;
            }

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

            drawRegion.Capture = false;
            drawRegion.Refresh();
        }
Ejemplo n.º 3
0
 public void Add(DrawObject obj)
 {
     // insert to the top of z-order
     graphicsList.Insert(0, obj);
 }