/// <summary> /// Show Properties dialog. Return true if list is changed /// </summary> /// <param name="parent"></param> /// <returns></returns> public bool ShowPropertiesDialog(DrawArea parent) { if (SelectionCount < 1) { return(false); } GraphicsProperties properties = GetProperties(); PropertiesDialog dlg = new PropertiesDialog(); dlg.Properties = properties; CommandChangeState c = new CommandChangeState(this); if (dlg.ShowDialog(parent) != DialogResult.OK) { return(false); } if (ApplyProperties(properties)) { c.NewState(this); parent.AddCommandToHistory(c); } return(true); }
/// <summary> /// Left mouse button is pressed /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { commandChangeState = null; wasMove = false; selectMode = SelectionMode.None; Point point = new Point(e.X, e.Y); // Test for resizing (only if control is selected, cursor is on the handle) foreach (DrawObject o in drawArea.Graphics.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 drawArea.Graphics.UnselectAll(); o.Selected = true; commandChangeState = new CommandChangeState(drawArea.Graphics); break; } } // Test for move (cursor is on the object) if (selectMode == SelectionMode.None) { int n1 = drawArea.Graphics.Count; DrawObject o = null; for (int i = 0; i < n1; i++) { if (drawArea.Graphics[i].HitTest(point) == 0) { o = drawArea.Graphics[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) { drawArea.Graphics.UnselectAll(); } // Select clicked object o.Selected = true; commandChangeState = new CommandChangeState(drawArea.Graphics); drawArea.Cursor = Cursors.SizeAll; } } // Net selection if (selectMode == SelectionMode.None) { // click on background if ((Control.ModifierKeys & Keys.Control) == 0) { drawArea.Graphics.UnselectAll(); } selectMode = SelectionMode.NetSelection; } lastPoint.X = e.X; lastPoint.Y = e.Y; startPoint.X = e.X; startPoint.Y = e.Y; drawArea.Capture = true; drawArea.Refresh(); if (selectMode == SelectionMode.NetSelection) { // Draw selection rectangle in initial position ControlPaint.DrawReversibleFrame( drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint)), Color.Black, FrameStyle.Dashed); } }