public LinkAnchorPointAdorner(UIElement adornedElement, LinkStroke linkStroke, CustomInkCanvas actualCanvas) : base(adornedElement) { adornedStroke = linkStroke; visualChildren = new VisualCollection(this); linkPreview = new Path(); linkPreview.Stroke = Brushes.Gray; linkPreview.StrokeThickness = 2; visualChildren.Add(linkPreview); this.linkStroke = linkStroke; canvas = actualCanvas; linkStrokeAnchor = this.linkStroke.path.Count; strokeBounds = linkStroke.GetStraightBounds(); center = this.linkStroke.GetCenter(); anchors = new List <Thumb>(); // Pour une ShapeStroke for (int i = 0; i < this.linkStroke.path.Count; i++) { anchors.Add(new Thumb()); } int index = 0; foreach (Thumb anchor in anchors) { anchor.Cursor = Cursors.ScrollAll; anchor.Width = 10; anchor.Height = 10; //anchor.Background = (Brush)new BrushConverter().ConvertFromString("#809dce"); anchor.Background = new LinearGradientBrush((Color)ColorConverter.ConvertFromString("#FFDDDDDD"), (Color)ColorConverter.ConvertFromString("#809dce"), 45); anchor.DragDelta += new DragDeltaEventHandler(dragHandle_DragDelta); anchor.DragCompleted += new DragCompletedEventHandler(dragHandle_DragCompleted); anchor.DragStarted += new DragStartedEventHandler(dragHandle_DragStarted); SetAnchorRenderTransfrom(index, linkStroke.path[index].x, linkStroke.path[index].y); visualChildren.Add(anchor); index++; } }
void Move_DragDelta(object sender, DragDeltaEventArgs e) { Vector dragVect = new Vector(e.HorizontalChange, e.VerticalChange); dragVect = rotation.Value.Transform(dragVect); if (dragVect.X != 0 || dragVect.Y != 0) { rotationPreview.CenterX = customStroke.GetCenter().X + dragVect.X; rotationPreview.CenterY = customStroke.GetCenter().Y + dragVect.Y; Rect rectangle = new Rect(customStroke.GetCustomBound().X + dragVect.X, customStroke.GetCustomBound().Y + dragVect.Y, customStroke.GetCustomBound().Width, customStroke.GetCustomBound().Height); if (customStroke is LinkStroke && (customStroke as LinkStroke).isAttached()) { horizontalChange = e.HorizontalChange; verticalChange = e.VerticalChange; LinkStroke linkStroke = customStroke.Clone() as LinkStroke; linkStroke.path = new List <Coordinates>(); foreach (Coordinates coord in (customStroke as LinkStroke).path) { linkStroke.path.Add(new Coordinates(coord.ToPoint())); } for (int i = 0; i < linkStroke.path.Count; i++) { if (i == 0 && linkStroke.isAttached() && linkStroke.from?.formId != null) { continue; } if (i == linkStroke.path.Count - 1 && linkStroke.isAttached() && linkStroke.to?.formId != null) { continue; } Coordinates coords = linkStroke.path[i]; coords.x += e.HorizontalChange; coords.y += e.VerticalChange; } rectangle = linkStroke.GetStraightBounds(); } generatePreview(rectangle); } }
public LinkElbowAdorner(Point mousePosition, int index, UIElement adornedElement, LinkStroke linkStroke, CustomInkCanvas actualCanvas) : base(adornedElement) { adornedStroke = linkStroke; initialMousePosition = mousePosition; indexInPath = index; this.linkStroke = linkStroke; canvas = actualCanvas; // rotation initiale de la stroke (pour dessiner le rectangle) // Bug. Cheat, but the geometry, the selection Rectangle (newRect) should be the right one.. geom of the stroke? strokeBounds = linkStroke.GetStraightBounds(); center = this.linkStroke.GetCenter(); anchors = new List <Thumb>(); // The linkstroke must already be selected if (!isOnLinkStrokeEnds(initialMousePosition)) { anchors.Add(new Thumb()); } visualChildren = new VisualCollection(this); foreach (Thumb anchor in anchors) { anchor.Cursor = Cursors.ScrollAll; anchor.Width = 8; anchor.Height = 8; anchor.Background = new LinearGradientBrush((Color)ColorConverter.ConvertFromString("#FFDDDDDD"), (Color)ColorConverter.ConvertFromString("#FF000000"), 45); SetAnchorRenderTransfrom(0, initialMousePosition.X, initialMousePosition.Y); anchor.DragDelta += new DragDeltaEventHandler(dragHandle_DragDelta); anchor.DragCompleted += new DragCompletedEventHandler(dragHandle_DragCompleted); anchor.DragStarted += new DragStartedEventHandler(dragHandle_DragStarted); visualChildren.Add(anchor); } }