/// <summary> /// Rotates the strokes to the same angle as outline. /// </summary> void rotateHandle_DragCompleted(object sender, DragCompletedEventArgs e) { if (rotation == null) { return; } visualChildren.Remove(rotatePreview); (linkStroke as LinkStroke).RotateStroke(rotation.Angle - lastAngle); DrawingService.UpdateLinks(new StrokeCollection { linkStroke }); strokeBounds = linkStroke.GetBounds(); center = linkStroke.GetCenter(); // Save the angle of the last rotation. lastAngle = 0; linkStroke.rotation = 0; canvas.RefreshChildren(); // Redraw rotateHandle. InvalidateArrange(); }
public LinkRotateAdorner(UIElement adornedElement, LinkStroke strokeToRotate, CustomInkCanvas actualCanvas) : base(adornedElement) { adornedStroke = strokeToRotate; linkStroke = strokeToRotate; 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 = strokeToRotate.GetCustomBound(); center = linkStroke.GetCenter(); lastAngle = linkStroke.rotation; rotation = new RotateTransform(linkStroke.rotation, center.X, center.Y); visualChildren = new VisualCollection(this); rotateHandle = new Thumb(); rotateHandle.Cursor = Cursors.Hand; rotateHandle.Width = 10; rotateHandle.Height = 10; rotateHandle.Background = new LinearGradientBrush((Color)ColorConverter.ConvertFromString("#FFc8d4ea"), (Color)ColorConverter.ConvertFromString("#FF809dce"), 45); rotateHandle.DragDelta += new DragDeltaEventHandler(rotateHandle_DragDelta); rotateHandle.DragCompleted += new DragCompletedEventHandler(rotateHandle_DragCompleted); TransformGroup transform = new TransformGroup(); transform.Children.Add(new RotateTransform(rotation.Angle, rotateHandle.Width / 2, rotateHandle.Height / 2)); transform.Children.Add(new TranslateTransform(-canvas.ActualWidth / 2 + strokeBounds.X + strokeBounds.Width / 2, -canvas.ActualHeight / 2 + strokeBounds.Y - HANDLEMARGIN)); rotateHandle.RenderTransform = transform; line = new Path(); line.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF809dce")); line.StrokeThickness = 1; line.RenderTransform = rotation; visualChildren.Add(line); visualChildren.Add(rotateHandle); pathPreview.IsClosed = false; rotatePreview = new Path(); rotatePreview.Data = new PathGeometry(); rotatePreview.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFBBBBBB")); rotatePreview.StrokeThickness = 2; visualChildren.Add(rotatePreview); }
protected override Size ArrangeOverride(Size finalSize) { if (strokeBounds.IsEmpty) { return(finalSize); } center = linkStroke.GetCenter(); for (int i = 0; i < anchors.Count; i++) { ArrangeAnchor(i, -center.X + initialMousePosition.X, -center.Y + initialMousePosition.Y); } return(finalSize); }
protected override Size ArrangeOverride(Size finalSize) { if (strokeBounds.IsEmpty) { return(finalSize); } center = linkStroke.GetCenter(); List <Coordinates> strokePath = linkStroke.path; for (int i = 0; i < linkStroke.path.Count; i++) { ArrangeAnchor(i, -center.X + strokePath[i].x, -center.Y + strokePath[i].y); } return(finalSize); }