protected virtual Cursor CursorForHandle(ResizeHandle handle) { switch (handle) { case ResizeHandle.TopLeft: case ResizeHandle.BottomRight: return(Cursors.SizeNWSE); case ResizeHandle.TopRight: case ResizeHandle.BottomLeft: return(Cursors.SizeNESW); case ResizeHandle.Top: case ResizeHandle.Bottom: return(Cursors.SizeNS); case ResizeHandle.Left: case ResizeHandle.Right: return(Cursors.SizeWE); case ResizeHandle.Center: return(Cursors.SizeAll); default: return(Cursors.Default); } }
public bool TryGrab(Vector2 worldPosition) { _mouseDownRectangle = BoundingRectangle; _mouseDownPosition = worldPosition; DragHandle = GetResizeHandle(worldPosition); return(IsGrabbed); }
public static Cursor GetCursorType(this ResizeHandle handle) { switch (handle) { case ResizeHandle.TopLeft: return(Cursors.SizeNWSE); case ResizeHandle.Top: return(Cursors.SizeNS); case ResizeHandle.TopRight: return(Cursors.SizeNESW); case ResizeHandle.Left: return(Cursors.SizeWE); case ResizeHandle.Center: return(Cursors.SizeAll); case ResizeHandle.Right: return(Cursors.SizeWE); case ResizeHandle.BottomLeft: return(Cursors.SizeNESW); case ResizeHandle.Bottom: return(Cursors.SizeNS); case ResizeHandle.BottomRight: return(Cursors.SizeNWSE); default: throw new ArgumentOutOfRangeException("handle"); } }
private void UpdateCursor(ResizeHandle handle) { switch (this.m_toolmode) { case ToolMode.Select: this.Cursor = Cursors.Default; break; case ToolMode.Move: switch (handle) { case ResizeHandle.North | ResizeHandle.East: case ResizeHandle.South | ResizeHandle.West: this.Cursor = Cursors.SizeNESW; break; case ResizeHandle.North | ResizeHandle.West: case ResizeHandle.South | ResizeHandle.East: this.Cursor = Cursors.SizeNWSE; break; case ResizeHandle.West: case ResizeHandle.East: this.Cursor = Cursors.SizeWE; break; case ResizeHandle.North: case ResizeHandle.South: this.Cursor = Cursors.SizeNS; break; case ResizeHandle.Move: this.Cursor = Cursors.SizeAll; break; default: this.Cursor = Cursors.Default; break; } break; case ToolMode.Link: switch (handle) { case ResizeHandle.Move: // body -- attribute this.Cursor = Cursors.Cross; break; case ResizeHandle.None: this.Cursor = Cursors.No; break; default: // along edge -- inheritance this.Cursor = Cursors.UpArrow; break; } break; } }
protected override Cursor CursorForHandle(ResizeHandle handle) { var def = base.CursorForHandle(handle); return(_currentTool == null || handle == ResizeHandle.Center ? def : _currentTool.CursorForHandle(handle) ?? def); }
public static void ResizeElements(this UIElement element, double handleTop, double handleLeft) { Guid elementId = element.GetElementId(); element.ResizeElement(handleTop, handleLeft); UIElement canvasElement = canvaselements[elementId]; ResizeHandle handle = (ResizeHandle)element; double width = canvasElement.GetPropertyValue("Width").ToDouble(); double height = canvasElement.GetPropertyValue("Height").ToDouble(); foreach (UIElement item in canvaselements.Values.Where(c => c.GetElementId() != elementId)) { if (handle.ResizeHandleType == ResizeHandlesEnum.RightTop) { double topOffset = item.GetPropertyValue("ActualHeight").ToDouble() - height; Canvas.SetTop(item, (Canvas.GetTop(item) + topOffset)); } else if (handle.ResizeHandleType == ResizeHandlesEnum.LetfTop) { double topOffset = item.GetPropertyValue("ActualHeight").ToDouble() - height; double leftOffset = item.GetPropertyValue("ActualWidth").ToDouble() - width; Canvas.SetTop(item, (Canvas.GetTop(item) + topOffset)); Canvas.SetLeft(item, (Canvas.GetLeft(item) + leftOffset)); } else if (handle.ResizeHandleType == ResizeHandlesEnum.LeftBottom) { double leftOffset = item.GetPropertyValue("ActualWidth").ToDouble() - width; Canvas.SetLeft(item, (Canvas.GetLeft(item) + leftOffset)); } item.SetPropertyValue("Width", width); item.SetPropertyValue("Height", height); //Canvas.SetTop(item, (handleTop - HandleSize)); //Canvas.SetLeft(item, (handleLeft - HandleSize)); item.MoveHandles(); } }
private static bool HitTest(DocRectangle docRect, Point pt, out ResizeHandle handle) { handle = ResizeHandle.None; if (docRect == null) { return(false); } Rectangle rc = new Rectangle( (int)(docRect.X * Factor), (int)(docRect.Y * Factor), (int)(docRect.Width * Factor), (int)(docRect.Height * Factor)); bool contains = rc.Contains(pt); if (contains) { int W = pt.X - rc.Left; int N = pt.Y - rc.Top; int S = rc.Bottom - pt.Y; int E = rc.Right - pt.X; int rad = 5; if (E < rad) { handle |= ResizeHandle.East; } else if (W < rad) { handle |= ResizeHandle.West; } if (S < rad) { handle |= ResizeHandle.South; } else if (N < rad) { handle |= ResizeHandle.North; } if (handle == ResizeHandle.None) { handle = ResizeHandle.Move; } } return(contains); }
protected override void OnInitialize() { base.OnInitialize(); var rect1 = new Rectangle(100, 100, 100, 100); var resizeHandleTop = new ResizeHandle(rect1, new Ellipse(0, 0, 30, 30) { FillColor = Colors.Red.AdjustOpacity(0.5) }, 0, 0, ResizeDirections.Top); resizeHandleTop.InstallEditPolicy(new SnapGridPolicy()); rect1.AddHandle(resizeHandleTop); rect1.InstallEditPolicy(SelectionFeedbackPolicy); rect1.InstallEditPolicy(new DragFeedbackPolicy()); Canvas.AddFigure(rect1); var rect2 = new Rectangle(250, 100, 100, 100); rect2.AddHandle(new ResizeHandle(rect2, new Ellipse(0, 0, 30, 30), 0, 0, ResizeDirections.Top)); rect2.AddHandle(new ResizeHandle(rect2, new Ellipse(0, 0, 30, 30), 0, 0, ResizeDirections.Left)); rect2.InstallEditPolicy(SelectionFeedbackPolicy); Canvas.AddFigure(rect2); var rect3 = new Rectangle(400, 100, 100, 100); rect3.AddHandlesCornerDirections(Canvas, HandleSizes.Big, HandleShapeType.Round); rect3.InstallEditPolicy(SelectionFeedbackPolicy); Canvas.AddFigure(rect3); var rect4 = new Rectangle(100, 300, 100, 100); rect4.AddHandlesLeftRightDirections(Canvas, HandleSizes.Medium, HandleShapeType.Square); rect4.InstallEditPolicy(SelectionFeedbackPolicy); Canvas.AddFigure(rect4); var rect5 = new Rectangle(250, 300, 100, 100); rect5.AddHandlesAllDirections(Canvas, HandleSizes.Medium, HandleShapeType.Square); rect5.InstallEditPolicy(SelectionFeedbackPolicy); Canvas.AddFigure(rect5); var rect6 = new Rectangle(400, 300, 100, 100); rect6.AddHandlesLeftRightDirections(Canvas, HandleSizes.Medium, HandleShapeType.Square); rect6.AddHandlesTopBottomDirections(Canvas, HandleSizes.Medium, HandleShapeType.Round); rect6.InstallEditPolicy(SelectionFeedbackPolicy); Canvas.AddFigure(rect6); }
public void OnMouseDown(Point mousePosition, EditorOperationHitTest hitTest, IEditorOperationalContext context) { if (hitTest.ResizeHandle == null || element == null) { // Not resizing element = null; return; } Log.LogInformation($"Starting resize on {hitTest.ResizeHandle.Value} handle"); initialMousePosition = mousePosition; initialLocation = element.Layout.Location; initialSize = element.Layout.Size; mode = hitTest.ResizeHandle.Value; isResizing = true; }
protected override void SetCursorForHandle(MapViewport viewport, ResizeHandle handle) { var ct = handle.GetCursorType(); switch (handle) { case ResizeHandle.Top: case ResizeHandle.Bottom: ct = Cursors.SizeWE; break; case ResizeHandle.Left: case ResizeHandle.Right: ct = Cursors.SizeNS; break; } viewport.Control.Cursor = ct; }
private static void CreateHandles(Guid elementId) { foreach (ResizeHandlesEnum item in Enum.GetValues(typeof(ResizeHandlesEnum))) { if (item == ResizeHandlesEnum.None) { continue; } ResizeHandle thumb = new ResizeHandle(); thumb.Width = HandleSize; thumb.Height = HandleSize; thumb.Background = Brushes.LightBlue; thumb.ElemntId = elementId; thumb.ResizeHandleType = item; KeyValuePair <Guid, ResizeHandlesEnum> key = new KeyValuePair <Guid, ResizeHandlesEnum>(elementId, item); elementHandles.Add(key, thumb); } }
private void UpdateCursor(ResizeHandle handle) { switch(this.m_toolmode) { case ToolMode.Select: this.Cursor = Cursors.Default; break; case ToolMode.Move: switch (handle) { case ResizeHandle.North | ResizeHandle.East: case ResizeHandle.South | ResizeHandle.West: this.Cursor = Cursors.SizeNESW; break; case ResizeHandle.North | ResizeHandle.West: case ResizeHandle.South | ResizeHandle.East: this.Cursor = Cursors.SizeNWSE; break; case ResizeHandle.West: case ResizeHandle.East: this.Cursor = Cursors.SizeWE; break; case ResizeHandle.North: case ResizeHandle.South: this.Cursor = Cursors.SizeNS; break; case ResizeHandle.Move: this.Cursor = Cursors.SizeAll; break; default: this.Cursor = Cursors.Default; break; } break; case ToolMode.Link: switch (handle) { case ResizeHandle.Move: // body -- attribute this.Cursor = Cursors.Cross; break; case ResizeHandle.None: this.Cursor = Cursors.No; break; default: // along edge -- inheritance this.Cursor = Cursors.UpArrow; break; } break; } }
/// <summary> /// String consisting of the resize handles to display (defaults to undefined) /// </summary> public virtual Resizable.Builder Handles(ResizeHandle handles) { this.ToComponent().Handles = handles; return(this as Resizable.Builder); }
protected virtual Cursor CursorForHandle(ResizeHandle handle) { switch (handle) { case ResizeHandle.TopLeft: case ResizeHandle.BottomRight: return Cursors.SizeNWSE; case ResizeHandle.TopRight: case ResizeHandle.BottomLeft: return Cursors.SizeNESW; case ResizeHandle.Top: case ResizeHandle.Bottom: return Cursors.SizeNS; case ResizeHandle.Left: case ResizeHandle.Right: return Cursors.SizeWE; case ResizeHandle.Center: return Cursors.SizeAll; default: return Cursors.Default; } }
private static bool HitTest(DocRectangle docRect, Point pt, out ResizeHandle handle) { handle = ResizeHandle.None; if (docRect == null) return false; Rectangle rc = new Rectangle( (int)(docRect.X * Factor), (int)(docRect.Y * Factor), (int)(docRect.Width * Factor), (int)(docRect.Height * Factor)); bool contains = rc.Contains(pt); if(contains) { int W = pt.X - rc.Left; int N = pt.Y - rc.Top; int S = rc.Bottom - pt.Y; int E = rc.Right - pt.X; int rad = 5; if(E < rad) { handle |= ResizeHandle.East; } else if (W < rad) { handle |= ResizeHandle.West; } if(S < rad) { handle |= ResizeHandle.South; } else if (N < rad) { handle |= ResizeHandle.North; } if (handle == ResizeHandle.None) handle = ResizeHandle.Move; } return contains; }
/// <summary> /// Finds object at absolute point (regardless of scroll position or page) /// </summary> /// <param name="pt"></param> /// <returns></returns> private DocObject Pick(Point pt, out DocLine line, out ResizeHandle handle) { line = null; handle = ResizeHandle.None; if (this.m_schema == null) { return(null); } pt.X -= this.AutoScrollPosition.X; pt.Y -= this.AutoScrollPosition.Y; PointF ptFloat = new PointF(pt.X, pt.Y); foreach (DocType docType in this.m_schema.Types) { if (HitTest(docType.DiagramRectangle, pt, out handle)) { return(docType); } if (docType is DocSelect) { DocSelect docSel = (DocSelect)docType; foreach (DocLine docLine in docSel.Tree) { DocPoint docPoint = docLine.DiagramLine[docLine.DiagramLine.Count - 1]; PointF ptA = new PointF((float)(docPoint.X * Factor), (float)docPoint.Y * Factor); if (Math.Abs(ptFloat.X - ptA.X) < 4 && Math.Abs(ptFloat.Y - ptA.Y) <= 5) { handle = ResizeHandle.Move; line = docLine; return(docType); } } } } foreach (DocEntity docType in this.m_schema.Entities) { if (HitTest(docType.DiagramRectangle, pt, out handle)) { return(docType); } foreach (DocAttribute docAttr in docType.Attributes) { if (docAttr.DiagramLine != null) { for (int i = 0; i < docAttr.DiagramLine.Count - 1; i++) { PointF ptA = new PointF((float)(docAttr.DiagramLine[i].X * Factor), (float)docAttr.DiagramLine[i].Y * Factor); PointF ptB = new PointF((float)(docAttr.DiagramLine[i + 1].X * Factor), (float)docAttr.DiagramLine[i + 1].Y * Factor); PointF ptClosest = new PointF(); double distance = FindDistanceToSegment(ptFloat, ptA, ptB, out ptClosest); if (distance < 3.0) { return(docAttr); } } } } foreach (DocLine docLine in docType.Tree) { if (docLine.DiagramLine.Count > 0) { DocPoint docPoint = docLine.DiagramLine[docLine.DiagramLine.Count - 1]; PointF ptA = new PointF((float)(docPoint.X * Factor), (float)docPoint.Y * Factor); if (Math.Abs(ptFloat.X - ptA.X) < 4 && Math.Abs(ptFloat.Y - ptA.Y) <= 5) { line = docLine; handle = ResizeHandle.Move; return(docType); } } } } foreach (DocComment docType in this.m_schema.Comments) { if (HitTest(docType.DiagramRectangle, pt, out handle)) { return(docType); } } foreach (DocPageTarget docType in this.m_schema.PageTargets) { if (HitTest(docType.DiagramRectangle, pt, out handle)) { return(docType); } foreach (DocPageSource docSource in docType.Sources) { if (HitTest(docSource.DiagramRectangle, pt, out handle)) { return(docSource); } } } foreach (DocPrimitive docType in this.m_schema.Primitives) { if (HitTest(docType.DiagramRectangle, pt, out handle)) { return(docType); } } foreach (DocSchemaRef docSchemaRef in this.m_schema.SchemaRefs) { foreach (DocDefinitionRef docType in docSchemaRef.Definitions) { if (HitTest(docType.DiagramRectangle, pt, out handle)) { return(docType); } foreach (DocLine docLine in docType.Tree) { DocPoint docPoint = docLine.DiagramLine[docLine.DiagramLine.Count - 1]; PointF ptA = new PointF((float)(docPoint.X * Factor), (float)docPoint.Y * Factor); if (Math.Abs(ptFloat.X - ptA.X) < 4 && Math.Abs(ptFloat.Y - ptA.Y) <= 5) { handle = ResizeHandle.Move; line = docLine; return(docType); } } } } return(null); }
public void Release() { DragHandle = ResizeHandle.None; }
public InternalBoxResizeHandle(BoxDraggableState state, ResizeHandle handle) : base(state, handle) { }
protected virtual void SetCursorForHandle(MapViewport viewport, ResizeHandle handle) { viewport.Control.Cursor = handle.GetCursorType(); }
public BoxResizeHandle(BoxDraggableState state, ResizeHandle handle) { State = state; Handle = handle; HighlightedViewport = null; }
/// <summary> /// Finds object at absolute point (regardless of scroll position or page) /// </summary> /// <param name="pt"></param> /// <returns></returns> private DocObject Pick(Point pt, out DocLine line, out ResizeHandle handle) { line = null; handle = ResizeHandle.None; if (this.m_schema == null) return null; pt.X -= this.AutoScrollPosition.X; pt.Y -= this.AutoScrollPosition.Y; PointF ptFloat = new PointF(pt.X, pt.Y); foreach(DocType docType in this.m_schema.Types) { if (HitTest(docType.DiagramRectangle, pt, out handle)) return docType; if(docType is DocSelect) { DocSelect docSel = (DocSelect)docType; foreach (DocLine docLine in docSel.Tree) { DocPoint docPoint = docLine.DiagramLine[docLine.DiagramLine.Count - 1]; PointF ptA = new PointF((float)(docPoint.X * Factor), (float)docPoint.Y * Factor); if (Math.Abs(ptFloat.X - ptA.X) < 4 && Math.Abs(ptFloat.Y - ptA.Y) <= 5) { handle = ResizeHandle.Move; line = docLine; return docType; } } } } foreach (DocEntity docType in this.m_schema.Entities) { if (HitTest(docType.DiagramRectangle, pt, out handle)) return docType; foreach(DocAttribute docAttr in docType.Attributes) { if (docAttr.DiagramLine != null) { for(int i = 0; i < docAttr.DiagramLine.Count-1; i++) { PointF ptA = new PointF((float)(docAttr.DiagramLine[i].X * Factor), (float)docAttr.DiagramLine[i].Y * Factor); PointF ptB = new PointF((float)(docAttr.DiagramLine[i+1].X * Factor), (float)docAttr.DiagramLine[i+1].Y * Factor); PointF ptClosest = new PointF(); double distance = FindDistanceToSegment(ptFloat, ptA, ptB, out ptClosest); if(distance < 3.0) { return docAttr; } } } } foreach(DocLine docLine in docType.Tree) { if (docLine.DiagramLine.Count > 0) { DocPoint docPoint = docLine.DiagramLine[docLine.DiagramLine.Count - 1]; PointF ptA = new PointF((float)(docPoint.X * Factor), (float)docPoint.Y * Factor); if (Math.Abs(ptFloat.X - ptA.X) < 4 && Math.Abs(ptFloat.Y - ptA.Y) <= 5) { line = docLine; handle = ResizeHandle.Move; return docType; } } } } foreach (DocComment docType in this.m_schema.Comments) { if (HitTest(docType.DiagramRectangle, pt, out handle)) return docType; } foreach (DocPageTarget docType in this.m_schema.PageTargets) { if (HitTest(docType.DiagramRectangle, pt, out handle)) return docType; foreach(DocPageSource docSource in docType.Sources) { if (HitTest(docSource.DiagramRectangle, pt, out handle)) return docSource; } } foreach (DocPrimitive docType in this.m_schema.Primitives) { if (HitTest(docType.DiagramRectangle, pt, out handle)) return docType; } foreach (DocSchemaRef docSchemaRef in this.m_schema.SchemaRefs) { foreach (DocDefinitionRef docType in docSchemaRef.Definitions) { if (HitTest(docType.DiagramRectangle, pt, out handle)) return docType; foreach (DocLine docLine in docType.Tree) { DocPoint docPoint = docLine.DiagramLine[docLine.DiagramLine.Count - 1]; PointF ptA = new PointF((float)(docPoint.X * Factor), (float)docPoint.Y * Factor); if (Math.Abs(ptFloat.X - ptA.X) < 4 && Math.Abs(ptFloat.Y - ptA.Y) <= 5) { handle = ResizeHandle.Move; line = docLine; return docType; } } } } return null; }
public ResizeTransformHandle(BoxDraggableState state, ResizeHandle handle) : base(state, handle) { }
public RotateTransformHandle(BoxDraggableState state, ResizeHandle handle, RotationOrigin origin) : base(state, handle) { _origin = origin; }
/// <summary> /// A valid Ext.resizer.Resizer handles config string (defaults to 'all'). Only applies when resizable = true. /// </summary> public virtual TBuilder ResizeHandles(ResizeHandle resizeHandles) { this.ToComponent().ResizeHandles = resizeHandles; return(this as TBuilder); }
public static void ResizeElement(this UIElement element, double handleTop, double handleLeft) { if (element.GetType() != typeof(ResizeHandle)) { return; } ResizeHandle handle = (ResizeHandle)element; UIElement canvasElement = canvaselements[handle.ElemntId]; SetBounds(canvasElement); if (canvasElement.GetType().BaseType == typeof(ReportLineBase)) { minSizeParameter = 1; switch (handle.ResizeHandleType) { case ResizeHandlesEnum.LeftBottom: canvasElement.SetPropertyValue("StrokeThickness", CalculateBottomHeight(handleTop)); canvasElement.SetPropertyValue("Height", CalculateBottomHeight(handleTop)); canvasElement.SetPropertyValue("Width", CalculateLeftWidth(handleLeft)); canvasElement.SetPropertyValue("LineLength", DistanceConverter.ConvertPixelToCm(CalculateLeftWidth(handleLeft))); Canvas.SetLeft(canvasElement, (handleLeft + HandleSize)); break; case ResizeHandlesEnum.LetfTop: double leftTophicknes = (bottom - handleTop) - HandleSize; if (leftTophicknes < 1) { leftTophicknes = 1; } canvasElement.SetPropertyValue("StrokeThickness", leftTophicknes); Canvas.SetTop(canvasElement, (handleTop + HandleSize)); canvasElement.SetPropertyValue("Height", leftTophicknes); canvasElement.SetPropertyValue("Width", CalculateLeftWidth(handleLeft)); canvasElement.SetPropertyValue("LineLength", DistanceConverter.ConvertPixelToCm(CalculateLeftWidth(handleLeft))); Canvas.SetLeft(canvasElement, (handleLeft + HandleSize)); break; case ResizeHandlesEnum.RightBottom: canvasElement.SetPropertyValue("StrokeThickness", CalculateBottomHeight(handleTop)); canvasElement.SetPropertyValue("Height", CalculateBottomHeight(handleTop)); canvasElement.SetPropertyValue("Width", CalculateRightWidth(handleLeft)); canvasElement.SetPropertyValue("LineLength", DistanceConverter.ConvertPixelToCm(CalculateRightWidth(handleLeft))); break; case ResizeHandlesEnum.RightTop: double rightTopThicknes = (bottom - handleTop) - HandleSize; if (rightTopThicknes < 1) { rightTopThicknes = 1; } canvasElement.SetPropertyValue("StrokeThickness", rightTopThicknes); Canvas.SetTop(canvasElement, (handleTop + HandleSize)); canvasElement.SetPropertyValue("Height", rightTopThicknes); canvasElement.SetPropertyValue("Width", CalculateRightWidth(handleLeft)); canvasElement.SetPropertyValue("LineLength", DistanceConverter.ConvertPixelToCm(CalculateRightWidth(handleLeft))); break; } } else { minSizeParameter = 10; switch (handle.ResizeHandleType) { case ResizeHandlesEnum.LeftBottom: canvasElement.SetPropertyValue("Height", CalculateBottomHeight(handleTop)); canvasElement.SetPropertyValue("Width", CalculateLeftWidth(handleLeft)); Canvas.SetLeft(canvasElement, (handleLeft + HandleSize)); break; case ResizeHandlesEnum.LetfTop: canvasElement.SetPropertyValue("Height", CalculateTopHeight(handleTop)); Canvas.SetTop(canvasElement, (handleTop + HandleSize)); canvasElement.SetPropertyValue("Width", CalculateLeftWidth(handleLeft)); Canvas.SetLeft(canvasElement, (handleLeft + HandleSize)); break; case ResizeHandlesEnum.RightBottom: canvasElement.SetPropertyValue("Height", CalculateBottomHeight(handleTop)); canvasElement.SetPropertyValue("Width", CalculateRightWidth(handleLeft)); break; case ResizeHandlesEnum.RightTop: canvasElement.SetPropertyValue("Height", CalculateTopHeight(handleTop)); Canvas.SetTop(canvasElement, (handleTop + HandleSize)); canvasElement.SetPropertyValue("Width", CalculateRightWidth(handleLeft)); break; } } MoveHandles(canvasElement, handle.ResizeHandleType); }
private void CtlExpressG_MouseMove(object sender, MouseEventArgs e) { this.m_ptMove = e.Location; if (this.m_mousedown && this.m_toolmode == ToolMode.Move) { UpdateCursor(this.m_handle); Point ptLocation = e.Location; if (ptLocation.X < 0) { ptLocation.X = 0; } if (ptLocation.Y < 0) { ptLocation.Y = 0; } if (this.m_lineselection != null && this.m_selection is DocDefinition) { // moving tree node DocPoint docPoint = m_lineselection.DiagramLine[m_lineselection.DiagramLine.Count - 1]; docPoint.X = (ptLocation.X - this.AutoScrollPosition.X) / Factor; docPoint.Y = (ptLocation.Y - this.AutoScrollPosition.Y) / Factor; // layout the owning element LayoutDefinition((DocDefinition)this.m_selection); // layout lines to all subtypes foreach (DocLine docSub in this.m_lineselection.Tree) { LayoutNode(this.m_lineselection, docSub); } this.Redraw(); } else if (this.m_selection is DocDefinition) { float dx = (float)(ptLocation.X - this.m_ptDown.X); float dy = (float)(ptLocation.Y - this.m_ptDown.Y); // move or resize the object... DocDefinition docSelection = (DocDefinition)this.m_selection; if (this.m_pointmap.ContainsKey(docSelection)) { PointF ptSelection = this.m_pointmap[docSelection]; if ((this.m_handle & ResizeHandle.North) != 0) { double yTail = docSelection.DiagramRectangle.Y + docSelection.DiagramRectangle.Height; docSelection.DiagramRectangle.Y = ptSelection.Y + dy / Factor; docSelection.DiagramRectangle.Height = yTail - docSelection.DiagramRectangle.Y; } else if ((this.m_handle & ResizeHandle.South) != 0) { docSelection.DiagramRectangle.Height = m_selectionsize.Height + dy / Factor; } if ((this.m_handle & ResizeHandle.West) != 0) { double xTail = docSelection.DiagramRectangle.X + docSelection.DiagramRectangle.Width; docSelection.DiagramRectangle.X = ptSelection.X + dx / Factor; docSelection.DiagramRectangle.Width = xTail - docSelection.DiagramRectangle.X; } else if ((this.m_handle & ResizeHandle.East) != 0) { docSelection.DiagramRectangle.Width = m_selectionsize.Width + dx / Factor; } if (this.m_handle == ResizeHandle.Move) { docSelection.DiagramRectangle.X = ptSelection.X + dx / Factor; docSelection.DiagramRectangle.Y = ptSelection.Y + dy / Factor; } if (this.m_selection is DocDefinition) { LayoutDefinition((DocDefinition)this.m_selection); } } this.Redraw(); } else if (this.m_selection == null) { // draw box and highlight multiple within region this.m_multiselect.Clear(); Rectangle rc = CreateNormalizedRectangle(this.m_ptDown, this.m_ptMove); foreach (DocEntity docEntity in this.m_schema.Entities) { SelectWithinRectangle(docEntity, rc); } foreach (DocType docType in this.m_schema.Types) { SelectWithinRectangle(docType, rc); } foreach (DocPrimitive docType in this.m_schema.Primitives) { SelectWithinRectangle(docType, rc); } foreach (DocPageTarget docTarget in this.m_schema.PageTargets) { SelectWithinRectangle(docTarget, rc); foreach (DocPageSource docSource in docTarget.Sources) { SelectWithinRectangle(docSource, rc); } } foreach (DocSchemaRef docSchemaRef in this.m_schema.SchemaRefs) { foreach (DocDefinitionRef docRef in docSchemaRef.Definitions) { SelectWithinRectangle(docRef, rc); } } // don't select comments this.Invalidate(); } } else { ResizeHandle handle = ResizeHandle.None; DocObject highlight = this.Pick(e.Location, out this.m_linehighlight, out handle); if (this.m_highlight != highlight) { this.m_highlight = highlight; this.Invalidate(); } if (this.m_mousedown && this.m_toolmode == ToolMode.Link) { this.Invalidate(); } UpdateCursor(handle); } }
protected override void SetCursorForHandle(MapViewport viewport, ResizeHandle handle) { var ct = ToolCursors.RotateCursor; viewport.Control.Cursor = ct; }
protected override Cursor CursorForHandle(ResizeHandle handle) { var def = base.CursorForHandle(handle); return _currentTool == null || handle == ResizeHandle.Center ? def : _currentTool.CursorForHandle(handle) ?? def; }
/// <summary> /// Constructor /// </summary> /// <param name="obj"></param> public PathwayResizeHandler(PPathwayObject obj) { this.m_obj = obj; this.m_obj.VisibleChanged += new PPropertyEventHandler(Object_VisibleChanged); this.m_obj.HighLightChanged += new PPropertyEventHandler(Object_VisibleChanged); this.m_canvas = obj.Canvas; for (int i = 0; i < 8; i++) { ResizeHandle handle = new ResizeHandle(); handle.MouseEnter += new PInputEventHandler(ResizeHandle_MouseEnter); handle.MouseLeave += new PInputEventHandler(ResizeHandle_MouseLeave); handle.MouseDown += new PInputEventHandler(ResizeHandle_MouseDown); handle.MouseDrag += new PInputEventHandler(ResizeHandle_MouseDrag); handle.MouseUp += new PInputEventHandler(ResizeHandle_MouseUp); handle.Cursor = GetCursor(i); handle.HandlePosition = i; m_resizeHandles.Add(handle); } }