// Be sure to call the base class constructor. public EditionAdorner(UIElement adornedElement, CustomStroke stroke, CustomInkCanvas canvas) : base(adornedElement) { adornedStroke = stroke; this.stroke = stroke; this.canvas = canvas; Point center = stroke.GetCenter(); if (stroke is ShapeStroke) { rotationDelete = new RotateTransform((stroke as ShapeStroke).shapeStyle.rotation, -20 - (stroke as ShapeStroke).shapeStyle.width / 2, 20 + (stroke as ShapeStroke).shapeStyle.height / 2); } else { rotationDelete = new RotateTransform(0, 0, 0); } if (stroke is ShapeStroke) { rotationEdit = new RotateTransform((stroke as ShapeStroke).shapeStyle.rotation, -(stroke as ShapeStroke).shapeStyle.width / 2, 20 + (stroke as ShapeStroke).shapeStyle.height / 2); } else { rotationEdit = new RotateTransform(0, 0, 0); } rectangleEdit = new Rect(stroke.GetCustomBound().TopRight.X, stroke.GetCustomBound().TopRight.Y - 20, 20, 20); rectangleDelete = new Rect(stroke.GetCustomBound().TopRight.X + 20, stroke.GetCustomBound().TopRight.Y - 20, 20, 20); AddButtons(stroke, canvas); }
// Be sure to call the base class constructor. public RemoteSelectionAdorner(UIElement adornedElement, CustomStroke stroke, CustomInkCanvas canvas) : base(adornedElement) { adornedStroke = stroke; this.stroke = stroke; this.canvas = canvas; visualChildren = new VisualCollection(this); border = new Path(); if (stroke is ShapeStroke) { Point center = stroke.GetCenter(); RotateTransform rotation = new RotateTransform((stroke as ShapeStroke).shapeStyle.rotation, center.X, center.Y); fill = new RectangleGeometry(stroke.GetCustomBound(), 0, 0, rotation); border.Data = fill; border.StrokeThickness = 2; } else { border.Data = stroke.GetGeometry(); border.StrokeThickness = (stroke as LinkStroke).getThickness(); } border.Stroke = (Brush) new BrushConverter().ConvertFromString("#CC7F7F"); visualChildren.Add(border); }
public AnchorPointAdorner(UIElement adornedElement, CustomStroke customStroke, CustomInkCanvas actualCanvas) : base(adornedElement) { adornedStroke = customStroke; visualChildren = new VisualCollection(this); linkPreview = new Path(); linkPreview.Stroke = Brushes.Gray; linkPreview.StrokeThickness = 2; visualChildren.Add(linkPreview); shapeStroke = customStroke as ShapeStroke; 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 = customStroke.GetCustomBound(); Point center = customStroke.GetCenter(); rotation = new RotateTransform((customStroke as ShapeStroke).shapeStyle.rotation, center.X, center.Y); anchors = new List <Thumb>(); anchors.Add(new Thumb()); anchors.Add(new Thumb()); anchors.Add(new Thumb()); anchors.Add(new Thumb()); foreach (Thumb anchor in anchors) { anchor.Cursor = Cursors.ScrollAll; anchor.Width = 6; anchor.Height = 6; anchor.Background = Brushes.DodgerBlue; anchor.BorderBrush = Brushes.Black; anchor.BorderThickness = new Thickness(2); anchor.Margin = new Thickness(0); anchor.DragStarted += new DragStartedEventHandler(dragHandle_DragStarted); anchor.DragDelta += new DragDeltaEventHandler(dragHandle_DragDelta); anchor.DragCompleted += new DragCompletedEventHandler(dragHandle_DragCompleted); visualChildren.Add(anchor); } cheatAnchors = new List <StrokeAnchorPointThumb>(); cheatAnchors.Add(new StrokeAnchorPointThumb(shapeStroke, canvas, 0)); cheatAnchors.Add(new StrokeAnchorPointThumb(shapeStroke, canvas, 1)); cheatAnchors.Add(new StrokeAnchorPointThumb(shapeStroke, canvas, 2)); cheatAnchors.Add(new StrokeAnchorPointThumb(shapeStroke, canvas, 3)); foreach (Thumb cheatAnchor in cheatAnchors) { cheatAnchor.Cursor = Cursors.SizeNWSE; cheatAnchor.Width = 1; cheatAnchor.Height = 1; canvas.Children.Add(cheatAnchor); } strokeBounds = customStroke.GetCustomBound(); }
public void SaveCanvasToFile(CustomInkCanvas canvas) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Bitmap (*.bmp)|*.bmp"; if (saveFileDialog.ShowDialog() == true) { canvas.SaveToBitmap(saveFileDialog.FileName); } }
public RotateAdorner(UIElement adornedElement, CustomStroke strokeToRotate, CustomInkCanvas actualCanvas) : base(adornedElement) { adornedStroke = strokeToRotate; stroke = 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 = stroke.GetCenter(); rotation = new RotateTransform((stroke as ShapeStroke).shapeStyle.rotation, center.X, center.Y); visualChildren = new VisualCollection(this); line = new Path(); line.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF809dce")); line.StrokeThickness = 1; line.Data = new LineGeometry(new Point(center.X, center.Y - strokeBounds.Height / 2 - 10), new Point(center.X, center.Y - strokeBounds.Height / 2 - HANDLEMARGIN)); line.RenderTransform = rotation; visualChildren.Add(line); 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 + HANDLEMARGIN + stroke.GetCustomBound().Height / 2)); transform.Children.Add(new TranslateTransform(-canvas.ActualWidth / 2 + strokeBounds.X + strokeBounds.Width / 2, -canvas.ActualHeight / 2 + strokeBounds.Y - HANDLEMARGIN)); rotateHandle.RenderTransform = transform; visualChildren.Add(rotateHandle); rotatePreview = new Path(); rotatePreview.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFBBBBBB")); rotatePreview.StrokeThickness = 1; visualChildren.Add(rotatePreview); }
// Be sure to call the base class constructor. public DottedPathAdorner(UIElement adornedElement, LinkStroke stroke, CustomInkCanvas canvas) : base(adornedElement) { adornedStroke = stroke; linkStroke = stroke; this.canvas = canvas; visualChildren = new VisualCollection(this); strokeBounds = stroke.GetCustomBound(); linkPath = new Path(); linkPath.Stroke = (Brush) new BrushConverter().ConvertFromString(stroke.style.color); linkPath.StrokeThickness = stroke.DrawingAttributes.Height; linkPath.StrokeDashArray = new DoubleCollection { 1, 0.5 }; linkPath.IsHitTestVisible = false; linkPath.Fill = Brushes.Black; arrowGeom = new PathGeometry(); lineGeom = new LineGeometry(); for (int i = 1; i < linkStroke.path.Count - 1; i++) { lineGeom.StartPoint = linkStroke.path[i - 1].ToPoint(); lineGeom.EndPoint = linkStroke.path[i].ToPoint(); arrowGeom.AddGeometry(lineGeom); } AddRelationArrows1(); linkPath.Data = arrowGeom; arrowGeom = new PathGeometry(); AddRelationArrows(); arrow = new Path(); arrow.Data = arrowGeom; arrow.Stroke = (Brush) new BrushConverter().ConvertFromString(stroke.style.color); arrow.StrokeThickness = 2; if (linkStroke.linkType == 1 || linkStroke.linkType == 2 && linkStroke.style?.thickness != 0) { arrow.StrokeThickness = 3; } arrow.IsHitTestVisible = false; arrow.Fill = Brushes.Black; visualChildren.Add(linkPath); visualChildren.Add(arrow); }
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++; } }
private void AddButtons(CustomStroke stroke, CustomInkCanvas canvas) { visualChildren = new VisualCollection(this); editButton = new EditionButton(stroke, canvas); editButton.Cursor = Cursors.Hand; editButton.Width = 20; editButton.Height = 20; editButton.Background = Brushes.White; BitmapImage img = new BitmapImage(); img.BeginInit(); img.UriSource = new Uri("../../Resources/pencil.png", UriKind.Relative); img.EndInit(); System.Windows.Controls.Image image = new System.Windows.Controls.Image(); image.Source = img; editButton.Content = image; visualChildren.Add(editButton); deleteButton = new DeleteButton(new StrokeCollection { stroke }, canvas); deleteButton.Cursor = Cursors.Hand; deleteButton.Width = 20; deleteButton.Height = 20; deleteButton.Background = Brushes.White; BitmapImage img2 = new BitmapImage(); img2.BeginInit(); img2.UriSource = new Uri("../../Resources/trash.png", UriKind.Relative); img2.EndInit(); System.Windows.Controls.Image image2 = new System.Windows.Controls.Image(); image2.Source = img2; deleteButton.Content = image2; visualChildren.Add(deleteButton); }
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); } }
public ClassTextBox(ClassStroke stroke, CustomInkCanvas canvas) : base() { IsHitTestVisible = false; this.canvas = canvas; selectedStroke = stroke; ShapeStyle shapeStyle = stroke.shapeStyle; tb1 = new CustomTextBox(stroke.name, shapeStyle.width, 20); tb1.TextAlignment = TextAlignment.Center; tb2 = new CustomTextBox(getString(stroke.attributes), shapeStyle.width, (shapeStyle.height - 20) / 2); tb2.MinLines = 3; tb3 = new CustomTextBox(getString(stroke.methods), shapeStyle.width, (shapeStyle.height - 20) / 2); tb3.MinLines = 3; if (stroke.shapeStyle.backgroundColor != null) { tb1.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(stroke.shapeStyle.backgroundColor)); tb2.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(stroke.shapeStyle.backgroundColor)); tb3.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(stroke.shapeStyle.backgroundColor)); } if (stroke.shapeStyle.borderColor != null) { tb1.BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(stroke.shapeStyle.borderColor)); tb2.BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(stroke.shapeStyle.borderColor)); tb3.BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(stroke.shapeStyle.borderColor)); } Orientation = Orientation.Vertical; Children.Add(tb1); Children.Add(tb2); Children.Add(tb3); }
public EditionButton(CustomStroke stroke, CustomInkCanvas canvas) : base() { this.stroke = stroke; this.canvas = canvas; }
public void SendCanvas(CustomInkCanvas canvas) { this.Canvas = canvas; }
public StrokeResizePointThumb(CustomStroke stroke, CustomInkCanvas canvas, int number) : base() { this.stroke = stroke; this.canvas = canvas; this.number = number; }
public StrokeAnchorPointThumb(ShapeStroke stroke, CustomInkCanvas canvas, int number) : base() { this.stroke = stroke; this.canvas = canvas; this.number = number; }
public void SwitchInkMode(InkMode mode) { CustomInkCanvas.SwitchInkMode(mode); }
public LeftAlignButton(StrokeCollection strokes, CustomInkCanvas canvas) : base() { this.strokes = strokes; this.canvas = canvas; }
public SelectionMultipleAdorner(UIElement adornedElement, StrokeCollection strokes, CustomInkCanvas actualCanvas) : base(adornedElement) { adornedStroke = null; visualChildren = new VisualCollection(this); strokesSelected = strokes; foreach (CustomStroke stroke in strokesSelected) { if (stroke is ShapeStroke) { RotateTransform rotation = new RotateTransform((stroke as ShapeStroke).shapeStyle.rotation, stroke.GetCenter().X, stroke.GetCenter().Y); Path path = new Path(); path.Data = new RectangleGeometry(stroke.GetCustomBound(), 0, 0, rotation); path.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF809dce")); path.StrokeThickness = 2; shapeBorders.Add(path); visualChildren.Add(path); } if (stroke is LinkStroke) { Path path = new Path(); path.Data = stroke.GetGeometry(); path.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF809dce")); path.StrokeThickness = (stroke as LinkStroke).getThickness(); shapeBorders.Add(path); visualChildren.Add(path); } } double maxX = -9999999; double minX = 9999999; double maxY = -9999999; double minY = 9999999; foreach (CustomStroke stroke in strokesSelected) { if (stroke.GetEditingBounds().X < minX) { minX = stroke.GetEditingBounds().X; } if (stroke.GetEditingBounds().X + stroke.GetEditingBounds().Width > maxX) { maxX = stroke.GetEditingBounds().X + stroke.GetEditingBounds().Width; } if (stroke.GetEditingBounds().Y < minY) { minY = stroke.GetEditingBounds().Y; } if (stroke.GetEditingBounds().Y + stroke.GetEditingBounds().Height > maxY) { maxY = stroke.GetEditingBounds().Y + stroke.GetEditingBounds().Height; } } strokeBounds = new Rect(new Point(minX, minY), new Point(maxX, maxY)); moveThumb = new Thumb(); moveThumb.Cursor = Cursors.SizeAll; moveThumb.Height = strokeBounds.Height; moveThumb.Width = strokeBounds.Width; moveThumb.Background = Brushes.Transparent; moveThumb.DragDelta += new DragDeltaEventHandler(Move_DragDelta); moveThumb.DragCompleted += new DragCompletedEventHandler(Move_DragCompleted); moveThumb.DragStarted += new DragStartedEventHandler(All_DragStarted); visualChildren.Add(moveThumb); resizePreview = new Path(); resizePreview.Stroke = Brushes.Gray; resizePreview.StrokeDashArray = new DoubleCollection { 5, 2 }; resizePreview.StrokeThickness = 1; visualChildren.Add(resizePreview); canvas = actualCanvas; outerBoundPath = new Path(); outerBoundPath.Stroke = Brushes.Black; outerBoundPath.StrokeDashArray = new DoubleCollection { 5, 2 }; outerBoundPath.StrokeThickness = 1; outerBoundPath.Data = new RectangleGeometry(strokeBounds); visualChildren.Add(outerBoundPath); deleteButton = new DeleteButton(strokes, canvas); deleteButton.Cursor = Cursors.Hand; deleteButton.Width = 20; deleteButton.Height = 20; deleteButton.Background = Brushes.White; BitmapImage img2 = new BitmapImage(); img2.BeginInit(); img2.UriSource = new Uri("../../Resources/trash.png", UriKind.Relative); img2.EndInit(); System.Windows.Controls.Image image2 = new System.Windows.Controls.Image(); image2.Source = img2; deleteButton.Content = image2; visualChildren.Add(deleteButton); centerAlignButton = new CenterAlignButton(strokes, canvas); centerAlignButton.Cursor = Cursors.Hand; centerAlignButton.Width = 20; centerAlignButton.Height = 20; centerAlignButton.Background = Brushes.White; BitmapImage img3 = new BitmapImage(); img3.BeginInit(); img3.UriSource = new Uri("../../Resources/NewLook/horizontal-align-center.png", UriKind.Relative); img3.EndInit(); System.Windows.Controls.Image image3 = new System.Windows.Controls.Image(); image3.Source = img3; centerAlignButton.Content = image3; visualChildren.Add(centerAlignButton); leftAlignButton = new LeftAlignButton(strokes, canvas); leftAlignButton.Cursor = Cursors.Hand; leftAlignButton.Width = 20; leftAlignButton.Height = 20; leftAlignButton.Background = Brushes.White; BitmapImage img4 = new BitmapImage(); img4.BeginInit(); img4.UriSource = new Uri("../../Resources/NewLook/left-align.png", UriKind.Relative); img4.EndInit(); System.Windows.Controls.Image image4 = new System.Windows.Controls.Image(); image4.Source = img4; leftAlignButton.Content = image4; visualChildren.Add(leftAlignButton); rectangleCenter = new Rect(strokeBounds.X + strokeBounds.Width / 2 - 10, strokeBounds.Y - 20, 20, 20); rectangleLeftAlign = new Rect(strokeBounds.X, strokeBounds.Y - 20, 20, 20); rectangleDelete = new Rect(strokeBounds.TopRight.X - 20, strokeBounds.TopRight.Y - 20, 20, 20); }
public ResizeAdorner(UIElement adornedElement, CustomStroke customStroke, CustomInkCanvas actualCanvas) : base(adornedElement) { if (customStroke is LinkStroke) { WIDTH_LEGER = 1; } adornedStroke = customStroke; visualChildren = new VisualCollection(this); if (customStroke is ShapeStroke) { strokeBounds = customStroke.GetCustomBound(); } else { strokeBounds = (customStroke as LinkStroke).GetStraightBounds(); } resizePreview = new Path(); resizePreview.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFBBBBBB")); resizePreview.StrokeThickness = 1; visualChildren.Add(resizePreview); this.customStroke = customStroke; canvas = actualCanvas; Point center = customStroke.GetCenter(); if (customStroke is ShapeStroke) { rotation = new RotateTransform((customStroke as ShapeStroke).shapeStyle.rotation, center.X, center.Y); } else { rotation = new RotateTransform(0, center.X, center.Y); } while (rotation.Angle < 0) { rotation.Angle += 360; } outerBoundPath = new Path(); outerBoundPath.Stroke = Brushes.Black; outerBoundPath.StrokeDashArray = new DoubleCollection { 5, 2 }; outerBoundPath.StrokeThickness = 1; Rect rect = customStroke.GetCustomBound(); rect.X -= MARGIN; rect.Y -= MARGIN; rect.Width += MARGIN * 2; rect.Height += MARGIN * 2; outerBoundPath.Data = new RectangleGeometry(rect, 0, 0, rotation); visualChildren.Add(outerBoundPath); moveThumb = new Thumb(); moveThumb.Cursor = Cursors.SizeAll; moveThumb.Height = strokeBounds.Height + MARGIN * 2; moveThumb.Width = strokeBounds.Width + MARGIN * 2; moveThumb.Background = Brushes.Transparent; moveThumb.DragDelta += new DragDeltaEventHandler(Move_DragDelta); moveThumb.DragCompleted += new DragCompletedEventHandler(Move_DragCompleted); moveThumb.DragStarted += new DragStartedEventHandler(All_DragStarted); moveThumb.PreviewMouseUp += new MouseButtonEventHandler(LeftMouseUp); TransformGroup transform = new TransformGroup(); transform.Children.Add(new RotateTransform(rotation.Angle, moveThumb.Width / 2, moveThumb.Height / 2)); transform.Children.Add(new TranslateTransform(-canvas.ActualWidth / 2 + strokeBounds.Width / 2 + strokeBounds.X, -canvas.ActualHeight / 2 + strokeBounds.Height / 2 + strokeBounds.Y)); moveThumb.RenderTransform = transform; visualChildren.Add(moveThumb); unitX = rotation.Value.Transform(unitX); unitY = rotation.Value.Transform(unitY); // RenderTransform = rotation; anchors = new List <Thumb>(); anchors.Add(new Thumb()); anchors.Add(new Thumb()); anchors.Add(new Thumb()); anchors.Add(new Thumb()); anchors.Add(new Thumb()); anchors.Add(new Thumb()); anchors.Add(new Thumb()); anchors.Add(new Thumb()); int index = 0; foreach (Thumb anchor in anchors) { anchor.Width = 8; anchor.Height = 8; anchor.Background = new LinearGradientBrush((Color)ColorConverter.ConvertFromString("#FFc8d4ea"), (Color)ColorConverter.ConvertFromString("#FF809dce"), 45); anchor.BorderBrush = Brushes.Black; if (rotation.Angle % 360 >= 360 - 45 / 2 || rotation.Angle % 360 <= 45 / 2) { switch (index) { case 0: anchor.DragDelta += new DragDeltaEventHandler(Top_DragDelta); anchor.Cursor = Cursors.SizeNS; break; case 1: anchor.DragDelta += new DragDeltaEventHandler(Right_DragDelta); anchor.Cursor = Cursors.SizeWE; break; case 2: anchor.DragDelta += new DragDeltaEventHandler(Bottom_DragDelta); anchor.Cursor = Cursors.SizeNS; break; case 3: anchor.DragDelta += new DragDeltaEventHandler(Left_DragDelta); anchor.Cursor = Cursors.SizeWE; break; case 4: anchor.DragDelta += new DragDeltaEventHandler(TopLeft_DragDelta); anchor.Cursor = Cursors.SizeNWSE; break; case 5: anchor.DragDelta += new DragDeltaEventHandler(TopRight_DragDelta); anchor.Cursor = Cursors.SizeNESW; break; case 6: anchor.DragDelta += new DragDeltaEventHandler(BottomLeft_DragDelta); anchor.Cursor = Cursors.SizeNESW; break; case 7: anchor.DragDelta += new DragDeltaEventHandler(BottomRight_DragDelta); anchor.Cursor = Cursors.SizeNWSE; break; default: break; } } else if (rotation.Angle % 360 > 45 / 2 && rotation.Angle % 360 <= 90 - 45 / 2) { switch (index) { case 0: anchor.DragDelta += new DragDeltaEventHandler(Top_DragDelta); anchor.Cursor = Cursors.SizeNESW; break; case 1: anchor.DragDelta += new DragDeltaEventHandler(Right_DragDelta); anchor.Cursor = Cursors.SizeNWSE; break; case 2: anchor.DragDelta += new DragDeltaEventHandler(Bottom_DragDelta); anchor.Cursor = Cursors.SizeNESW; break; case 3: anchor.DragDelta += new DragDeltaEventHandler(Left_DragDelta); anchor.Cursor = Cursors.SizeNWSE; break; case 4: anchor.DragDelta += new DragDeltaEventHandler(TopLeft_DragDelta); anchor.Cursor = Cursors.SizeNS; break; case 5: anchor.DragDelta += new DragDeltaEventHandler(TopRight_DragDelta); anchor.Cursor = Cursors.SizeWE; break; case 6: anchor.DragDelta += new DragDeltaEventHandler(BottomLeft_DragDelta); anchor.Cursor = Cursors.SizeWE; break; case 7: anchor.DragDelta += new DragDeltaEventHandler(BottomRight_DragDelta); anchor.Cursor = Cursors.SizeNS; break; default: break; } } else if (rotation.Angle % 360 > 90 - 45 / 2 && rotation.Angle % 360 <= 90 + 45 / 2) { switch (index) { case 0: anchor.DragDelta += new DragDeltaEventHandler(Top_DragDelta); anchor.Cursor = Cursors.SizeWE; break; case 1: anchor.DragDelta += new DragDeltaEventHandler(Right_DragDelta); anchor.Cursor = Cursors.SizeNS; break; case 2: anchor.DragDelta += new DragDeltaEventHandler(Bottom_DragDelta); anchor.Cursor = Cursors.SizeWE; break; case 3: anchor.DragDelta += new DragDeltaEventHandler(Left_DragDelta); anchor.Cursor = Cursors.SizeNS; break; case 4: anchor.DragDelta += new DragDeltaEventHandler(TopLeft_DragDelta); anchor.Cursor = Cursors.SizeNESW; break; case 5: anchor.DragDelta += new DragDeltaEventHandler(TopRight_DragDelta); anchor.Cursor = Cursors.SizeNWSE; break; case 6: anchor.DragDelta += new DragDeltaEventHandler(BottomLeft_DragDelta); anchor.Cursor = Cursors.SizeNWSE; break; case 7: anchor.DragDelta += new DragDeltaEventHandler(BottomRight_DragDelta); anchor.Cursor = Cursors.SizeNESW; break; default: break; } } else if (rotation.Angle % 360 > 90 + 45 / 2 && rotation.Angle % 360 <= 135 + 45 / 2) { switch (index) { case 0: anchor.DragDelta += new DragDeltaEventHandler(Top_DragDelta); anchor.Cursor = Cursors.SizeNWSE; break; case 1: anchor.DragDelta += new DragDeltaEventHandler(Right_DragDelta); anchor.Cursor = Cursors.SizeNESW; break; case 2: anchor.DragDelta += new DragDeltaEventHandler(Bottom_DragDelta); anchor.Cursor = Cursors.SizeNWSE; break; case 3: anchor.DragDelta += new DragDeltaEventHandler(Left_DragDelta); anchor.Cursor = Cursors.SizeNESW; break; case 4: anchor.DragDelta += new DragDeltaEventHandler(TopLeft_DragDelta); anchor.Cursor = Cursors.SizeWE; break; case 5: anchor.DragDelta += new DragDeltaEventHandler(TopRight_DragDelta); anchor.Cursor = Cursors.SizeNS; break; case 6: anchor.DragDelta += new DragDeltaEventHandler(BottomLeft_DragDelta); anchor.Cursor = Cursors.SizeNS; break; case 7: anchor.DragDelta += new DragDeltaEventHandler(BottomRight_DragDelta); anchor.Cursor = Cursors.SizeWE; break; default: break; } } else if (rotation.Angle % 360 > 180 - 45 / 2 && rotation.Angle % 360 <= 180 + 45 / 2) { switch (index) { case 0: anchor.DragDelta += new DragDeltaEventHandler(Top_DragDelta); anchor.Cursor = Cursors.SizeNS; break; case 1: anchor.DragDelta += new DragDeltaEventHandler(Right_DragDelta); anchor.Cursor = Cursors.SizeWE; break; case 2: anchor.DragDelta += new DragDeltaEventHandler(Bottom_DragDelta); anchor.Cursor = Cursors.SizeNS; break; case 3: anchor.DragDelta += new DragDeltaEventHandler(Left_DragDelta); anchor.Cursor = Cursors.SizeWE; break; case 4: anchor.DragDelta += new DragDeltaEventHandler(TopLeft_DragDelta); anchor.Cursor = Cursors.SizeNWSE; break; case 5: anchor.DragDelta += new DragDeltaEventHandler(TopRight_DragDelta); anchor.Cursor = Cursors.SizeNESW; break; case 6: anchor.DragDelta += new DragDeltaEventHandler(BottomLeft_DragDelta); anchor.Cursor = Cursors.SizeNESW; break; case 7: anchor.DragDelta += new DragDeltaEventHandler(BottomRight_DragDelta); anchor.Cursor = Cursors.SizeNWSE; break; default: break; } } else if (rotation.Angle % 360 > 225 - 45 / 2 && rotation.Angle % 360 <= 225 + 45 / 2) { switch (index) { case 0: anchor.DragDelta += new DragDeltaEventHandler(Top_DragDelta); anchor.Cursor = Cursors.SizeNESW; break; case 1: anchor.DragDelta += new DragDeltaEventHandler(Right_DragDelta); anchor.Cursor = Cursors.SizeNWSE; break; case 2: anchor.DragDelta += new DragDeltaEventHandler(Bottom_DragDelta); anchor.Cursor = Cursors.SizeNESW; break; case 3: anchor.DragDelta += new DragDeltaEventHandler(Left_DragDelta); anchor.Cursor = Cursors.SizeNWSE; break; case 4: anchor.DragDelta += new DragDeltaEventHandler(TopLeft_DragDelta); anchor.Cursor = Cursors.SizeNS; break; case 5: anchor.DragDelta += new DragDeltaEventHandler(TopRight_DragDelta); anchor.Cursor = Cursors.SizeWE; break; case 6: anchor.DragDelta += new DragDeltaEventHandler(BottomLeft_DragDelta); anchor.Cursor = Cursors.SizeWE; break; case 7: anchor.DragDelta += new DragDeltaEventHandler(BottomRight_DragDelta); anchor.Cursor = Cursors.SizeNS; break; default: break; } } else if (rotation.Angle % 360 > 270 - 45 / 2 && rotation.Angle % 360 <= 270 + 45 / 2) { switch (index) { case 0: anchor.DragDelta += new DragDeltaEventHandler(Top_DragDelta); anchor.Cursor = Cursors.SizeWE; break; case 1: anchor.DragDelta += new DragDeltaEventHandler(Right_DragDelta); anchor.Cursor = Cursors.SizeNS; break; case 2: anchor.DragDelta += new DragDeltaEventHandler(Bottom_DragDelta); anchor.Cursor = Cursors.SizeWE; break; case 3: anchor.DragDelta += new DragDeltaEventHandler(Left_DragDelta); anchor.Cursor = Cursors.SizeNS; break; case 4: anchor.DragDelta += new DragDeltaEventHandler(TopLeft_DragDelta); anchor.Cursor = Cursors.SizeNESW; break; case 5: anchor.DragDelta += new DragDeltaEventHandler(TopRight_DragDelta); anchor.Cursor = Cursors.SizeNWSE; break; case 6: anchor.DragDelta += new DragDeltaEventHandler(BottomLeft_DragDelta); anchor.Cursor = Cursors.SizeNWSE; break; case 7: anchor.DragDelta += new DragDeltaEventHandler(BottomRight_DragDelta); anchor.Cursor = Cursors.SizeNESW; break; default: break; } } else { switch (index) { case 0: anchor.DragDelta += new DragDeltaEventHandler(Top_DragDelta); anchor.Cursor = Cursors.SizeNWSE; break; case 1: anchor.DragDelta += new DragDeltaEventHandler(Right_DragDelta); anchor.Cursor = Cursors.SizeNESW; break; case 2: anchor.DragDelta += new DragDeltaEventHandler(Bottom_DragDelta); anchor.Cursor = Cursors.SizeNWSE; break; case 3: anchor.DragDelta += new DragDeltaEventHandler(Left_DragDelta); anchor.Cursor = Cursors.SizeNESW; break; case 4: anchor.DragDelta += new DragDeltaEventHandler(TopLeft_DragDelta); anchor.Cursor = Cursors.SizeWE; break; case 5: anchor.DragDelta += new DragDeltaEventHandler(TopRight_DragDelta); anchor.Cursor = Cursors.SizeNS; break; case 6: anchor.DragDelta += new DragDeltaEventHandler(BottomLeft_DragDelta); anchor.Cursor = Cursors.SizeNS; break; case 7: anchor.DragDelta += new DragDeltaEventHandler(BottomRight_DragDelta); anchor.Cursor = Cursors.SizeWE; break; default: break; } } anchor.DragStarted += new DragStartedEventHandler(All_DragStarted); anchor.DragCompleted += new DragCompletedEventHandler(All_DragCompleted); if (!(customStroke is LinkStroke) || !(customStroke as LinkStroke).isAttached()) { visualChildren.Add(anchor); } double xOffset = 0; double yOffset = 0; switch (index) { case 0: //Top xOffset = strokeBounds.Width / 2; yOffset = -MARGIN; break; case 1: //Right xOffset = strokeBounds.Width + MARGIN; yOffset = strokeBounds.Height / 2; break; case 2: //Bottom xOffset = strokeBounds.Width / 2; yOffset = strokeBounds.Height + MARGIN; break; case 3: //Left xOffset = -MARGIN; yOffset = strokeBounds.Height / 2; break; case 4: //TopLeft xOffset = -MARGIN; yOffset = -MARGIN; break; case 5: //TopRight xOffset = strokeBounds.Width + MARGIN; yOffset = -MARGIN; break; case 6: //BottomLeft xOffset = -MARGIN; yOffset = strokeBounds.Height + MARGIN; break; case 7: //BottomRight xOffset = strokeBounds.Width + MARGIN; yOffset = strokeBounds.Height + MARGIN; break; default: break; } ArrangeAnchor(anchor, xOffset, yOffset); index++; } rotationPreview = rotation.Clone(); }