public void Add(DrawObject obj) { // insert to the top of z-order _graphicsList.Insert(0, obj); }
private void Point_MouseDown(object sender, MouseEventArgs e) { _selectMode = SelectionMode.None; var downPoint = new Point(e.X, e.Y); int selectObject = Now_Select_Object_Is(downPoint); if (selectObject > -1) { Now_Select_Grid_Row(selectObject); } // Test for resizing (only if control is selected, cursor is on the handle) foreach (DrawObject o in _graphicsList.Selection) { selectedListNo++; int handleNumber = o.HitTest(downPoint); Trace.WriteLine(handleNumber.ToString()); 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 _graphicsList.UnselectAll(); o.Selected = true; break; } } // Test for move (cursor is on the object) if (_selectMode == SelectionMode.None) { int n1 = _graphicsList.Count; DrawObject o = null; for (int i = 0; i < n1; i++) { if (_graphicsList[i].HitTest(downPoint) == 0) { o = _graphicsList[i]; break; } } if (o != null) { _selectMode = SelectionMode.Move; // Unselect all if Ctrl is not pressed and clicked object is not selected yet if ((ModifierKeys & Keys.Control) == 0 && !o.Selected) { _graphicsList.UnselectAll(); } // Select clicked object o.Selected = true; pictureBox1.Cursor = Cursors.SizeAll; } } // Net selection if (_selectMode == SelectionMode.None) { // click on background if ((ModifierKeys & Keys.Control) == 0) { _graphicsList.UnselectAll(); } _selectMode = SelectionMode.NetSelection; } _lastPoint.X = e.X; _lastPoint.Y = e.Y; _startPoint.X = e.X; _startPoint.Y = e.Y; pictureBox1.Capture = true; pictureBox1.Refresh(); if (_selectMode == SelectionMode.NetSelection) { // Draw selection rectangle in initial position ControlPaint.DrawReversibleFrame( RectangleToScreen(DrawRectangle.GetNormalizedRectangle(_startPoint, _lastPoint)), Color.Black, FrameStyle.Dashed); } }