/* Evandro /// <summary> /// Left mouse is released. /// New object is created and resized. /// </summary> /// <param name="workarea"></param> /// <param name="e"></param> public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e) { drawArea.GraphicsList[0].Normalize(); drawArea.AddCommandToHistory(new CommandAdd(drawArea.GraphicsList[0])); drawArea.ActiveTool = DrawArea.DrawToolType.Pointer; drawArea.Capture = false; drawArea.Refresh(); } Fim Evandro */ /// <summary> /// Add new object to draw area. /// Function is called when user left-clicks draw area, /// and one of ToolObject-derived tools is active. /// </summary> /// <param name="drawArea"></param> /// <param name="o"></param> protected void AddNewObject(WorkArea workarea, DrawObject o) { workarea.GraphicsList.UnselectAll(); //workarea.Selected = true; workarea.GraphicsList.Add(o); workarea.Capture = true; workarea.Refresh(); //workarea.SetDirty(); }
/* Evandro * /// <summary> * /// Left mouse is released. * /// New object is created and resized. * /// </summary> * /// <param name="workarea"></param> * /// <param name="e"></param> * public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e) * { * drawArea.GraphicsList[0].Normalize(); * drawArea.AddCommandToHistory(new CommandAdd(drawArea.GraphicsList[0])); * drawArea.ActiveTool = DrawArea.DrawToolType.Pointer; * * drawArea.Capture = false; * drawArea.Refresh(); * } * Fim Evandro */ /// <summary> /// Add new object to draw area. /// Function is called when user left-clicks draw area, /// and one of ToolObject-derived tools is active. /// </summary> /// <param name="drawArea"></param> /// <param name="o"></param> protected void AddNewObject(WorkArea workarea, DrawObject o) { workarea.GraphicsList.UnselectAll(); //workarea.Selected = true; workarea.GraphicsList.Add(o); workarea.Capture = true; workarea.Refresh(); //workarea.SetDirty(); }
public void Add(DrawObject obj) { // insert to the top of z-order graphicsList.Insert(0, obj); }
/// <summary> /// Left mouse button is pressed /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseDown(WorkArea workArea, MouseEventArgs e) { selectMode = SelectionMode.None; Point point = new Point(e.X, e.Y); if (workArea.GraphicsList == null) { MessageBox.Show("Nenhum objeto"); return; } // Test for resizing (only if control is selected, cursor is on the handle) foreach (DrawObject o in workArea.GraphicsList.Selection) { int handleNumber = o.HitTest(point); if (handleNumber > 0) { selectMode = SelectionMode.Size; // keep resized object in class member resizedObject = o; resizedObjectHandle = handleNumber; // Since we want to resize only one object, unselect all other objects workArea.GraphicsList.UnselectAll(); o.Selected = true; break; } } // Test for move (cursor is on the object) if (selectMode == SelectionMode.None) { int n1 = workArea.GraphicsList.Count; DrawObject o = null; for (int i = 0; i < n1; i++) { if (workArea.GraphicsList[i].HitTest(point) == 0) { o = workArea.GraphicsList[i]; break; } } if (o != null) { selectMode = SelectionMode.Move; // Unselect all if Ctrl is not pressed and clicked object is not selected yet if ((Control.ModifierKeys & Keys.Control) == 0 && !o.Selected) workArea.GraphicsList.UnselectAll(); // Select clicked object o.Selected = true; workArea.Cursor = Cursors.SizeAll; } } // Net selection if (selectMode == SelectionMode.None) { // click on background if ((Control.ModifierKeys & Keys.Control) == 0) workArea.GraphicsList.UnselectAll(); selectMode = SelectionMode.NetSelection; } lastPoint.X = e.X; lastPoint.Y = e.Y; startPoint.X = e.X; startPoint.Y = e.Y; workArea.Capture = true; workArea.Refresh(); if (selectMode == SelectionMode.NetSelection) { // Draw selection rectangle in initial position ControlPaint.DrawReversibleFrame( workArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint)), Color.Black, FrameStyle.Dashed); } }
/// <summary> /// Right mouse button is released /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseUp(WorkArea drawArea, MouseEventArgs e) { if (selectMode == SelectionMode.NetSelection) { // Remove old selection rectangle ControlPaint.DrawReversibleFrame( drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint)), Color.Black, FrameStyle.Dashed); // Make group selection drawArea.GraphicsList.SelectInRectangle( DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint)); selectMode = SelectionMode.None; } if (resizedObject != null) { // after resizing resizedObject.Normalize(); resizedObject = null; } drawArea.Capture = false; drawArea.Refresh(); }
/// <summary> /// Left mouse button is pressed /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseDown(WorkArea workArea, MouseEventArgs e) { selectMode = SelectionMode.None; Point point = new Point(e.X, e.Y); if (workArea.GraphicsList == null) { MessageBox.Show("Nenhum objeto"); return; } // Test for resizing (only if control is selected, cursor is on the handle) foreach (DrawObject o in workArea.GraphicsList.Selection) { int handleNumber = o.HitTest(point); if (handleNumber > 0) { selectMode = SelectionMode.Size; // keep resized object in class member resizedObject = o; resizedObjectHandle = handleNumber; // Since we want to resize only one object, unselect all other objects workArea.GraphicsList.UnselectAll(); o.Selected = true; break; } } // Test for move (cursor is on the object) if (selectMode == SelectionMode.None) { int n1 = workArea.GraphicsList.Count; DrawObject o = null; for (int i = 0; i < n1; i++) { if (workArea.GraphicsList[i].HitTest(point) == 0) { o = workArea.GraphicsList[i]; break; } } if (o != null) { selectMode = SelectionMode.Move; // Unselect all if Ctrl is not pressed and clicked object is not selected yet if ((Control.ModifierKeys & Keys.Control) == 0 && !o.Selected) { workArea.GraphicsList.UnselectAll(); } // Select clicked object o.Selected = true; workArea.Cursor = Cursors.SizeAll; } } // Net selection if (selectMode == SelectionMode.None) { // click on background if ((Control.ModifierKeys & Keys.Control) == 0) { workArea.GraphicsList.UnselectAll(); } selectMode = SelectionMode.NetSelection; } lastPoint.X = e.X; lastPoint.Y = e.Y; startPoint.X = e.X; startPoint.Y = e.Y; workArea.Capture = true; workArea.Refresh(); if (selectMode == SelectionMode.NetSelection) { // Draw selection rectangle in initial position ControlPaint.DrawReversibleFrame( workArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint)), Color.Black, FrameStyle.Dashed); } }