/// <summary> /// Rotates the strokes to the same angle as outline. /// </summary> void rotateHandle_DragCompleted(object sender, DragCompletedEventArgs e) { if (rotation == null) { return; } // Rotate the strokes to match the new angle. Matrix mat = new Matrix(); mat.RotateAt(rotation.Angle - lastAngle, center.X, center.Y); AdornedStrokes.Transform(mat, true); // Save the angle of the last rotation. lastAngle = rotation.Angle; // Redraw rotateHandle. this.InvalidateArrange(); }
public RotatingStrokesAdorner(UIElement adornedElement) : base(adornedElement) { visualChildren = new VisualCollection(this); rotateHandle = new Thumb(); rotateHandle.Cursor = Cursors.SizeNWSE; rotateHandle.Width = 20; rotateHandle.Height = 20; rotateHandle.Background = Brushes.Blue; rotateHandle.DragDelta += new DragDeltaEventHandler(rotateHandle_DragDelta); rotateHandle.DragCompleted += new DragCompletedEventHandler(rotateHandle_DragCompleted); outline = new Path(); outline.Stroke = Brushes.Blue; outline.StrokeThickness = 1; visualChildren.Add(outline); visualChildren.Add(rotateHandle); strokeBounds = AdornedStrokes.GetBounds(); }