void OnBringToFront(object sender, EventArgs args) { OnBringTo(tools => { // move SelectedTool next to last overlapped tool int lIndex = tools.Max(t => DrawingTools.IndexOf(t)); return(lIndex + 1); }); }
void OnBringToBack(object sender, EventArgs args) { OnBringTo(tools => { // move SelectedTool prior to first overlapped tool int lIndex = tools.Min(t => DrawingTools.IndexOf(t)); return(lIndex); }); }
protected override void OnMouseMove(MouseEventArgs pArgs) { base.OnMouseMove(pArgs); Point lLocation = GetScrollablePoint(pArgs.Location); switch (pArgs.Button) { case MouseButtons.Right: return; case MouseButtons.None: Cursor lCurrentCursor = Cursors.Hand; if (SelectedToolboxItem == null && PickingTool == null) { DrawingTools.Any(e => { Cursor lCursor = e.Tracker.GetCursor(lLocation); bool lRet = false; if (lCursor != Cursors.Default) { lCurrentCursor = lCursor; lRet = true; } return(lRet); }); } else { lCurrentCursor = Cursors.Cross; } Cursor.Current = lCurrentCursor; break; case MouseButtons.Left: if (FullDragMode) { return; } bool lRunDefault = true; if (SelectedTool != null) { DrawingTracker lTracker = SelectedTool.Tracker; lRunDefault = false; // stretching on tracker. if (lTracker.IsResizing) { InvalidateRect(lTracker.SurroundingRect); lTracker.Resize(lLocation); InvalidateRect(lTracker.SurroundingRect); } else if (DragBoxFromMouseDown != Rectangle.Empty) { // start DragDrop on selected tool object. if (!DragBoxFromMouseDown.Contains(lLocation)) { int dx = GraphicsMapper.Instance.TransformInt(DraggingPoint.X - SelectedTool.SurroundingRect.Left, CoordinateSpace.Device, CoordinateSpace.Page); int dy = GraphicsMapper.Instance.TransformInt(DraggingPoint.Y - SelectedTool.SurroundingRect.Top, CoordinateSpace.Device, CoordinateSpace.Page); using (new DragImage(SelectedTool.GetDraggingImage(LayerWidth, LayerHeight), dx, dy)) { int lIndex = DrawingTools.IndexOf(SelectedTool); DoDragDrop(lIndex.ToString(), DragDropEffects.All); DraggingPoint = Point.Empty; DragBoxFromMouseDown = Rectangle.Empty; } } } else { lRunDefault = true; } } // update current Cursor. if (lRunDefault) { if (PickingTool == null) { ToolboxItem lItem = SelectedToolboxItem; // update cursor by hitTest on each drawing tool. if (lItem != null && DragBoxFromMouseDown != Rectangle.Empty) { // create toolbox item if (!DragBoxFromMouseDown.Contains(lLocation)) { PickingTool = lItem.CreateComponents(DesignerHost).FirstOrDefault() as DrawingTool; PickingTool.CreatePersistence(); PickingTool.StartResize(lLocation); } } } } break; } if (PickingTool != null) { InvalidateRect(PickingTool.SurroundingRect); PickingTool.Resize(lLocation); InvalidateRect(PickingTool.SurroundingRect); } }