// 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(); }
private void noNewStrokeLinkedToProcessOrClassCheck(CustomStroke newAnchoredStroke) { if (newAnchoredStroke.isProccessStroke()) { ShowMessage("Roles, artifacts and activities cannot be linked to nothing."); } else if (newAnchoredStroke is ClassStroke && linkStroke.isLinkAggCompHeritage()) { ShowMessage("Aggregation, composition and heritage links must be between two classes."); } }
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); }
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 EditionButton(CustomStroke stroke, CustomInkCanvas canvas) : base() { this.stroke = stroke; this.canvas = canvas; }
public virtual CustomStroke CloneRotated(double rotation) { CustomStroke newStroke = (CustomStroke)Clone(); return(newStroke); }
public StrokeResizePointThumb(CustomStroke stroke, CustomInkCanvas canvas, int number) : base() { this.stroke = stroke; this.canvas = canvas; this.number = number; }
void dragHandle_DragCompleted(object sender, DragCompletedEventArgs e) { Point actualPos = Mouse.GetPosition(this); if (actualPos.X < 0 || actualPos.Y < 0) { canvas.isUpdatingLink = false; visualChildren.Remove(linkPreview); InvalidateArrange(); return; } CustomStroke newAnchoredStroke = null; int number = 0; foreach (UIElement thumb in canvas.Children) { if (thumb.GetType() == typeof(StrokeAnchorPointThumb)) { Point thumbPosition = thumb.TransformToAncestor(canvas).Transform(new Point(0, 0)); StrokeAnchorPointThumb cheatThumb = thumb as StrokeAnchorPointThumb; double y = thumbPosition.Y - actualPos.Y; double x = thumbPosition.X - actualPos.X; double distBetweenPoints = (Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2))); if (distBetweenPoints <= 10) { newAnchoredStroke = cheatThumb.stroke; actualPos = thumbPosition; number = cheatThumb.number; } } } if (newAnchoredStroke != null) { //anchoredShapeStroke if (linkStrokeAnchor == 0) //from is changing { if (anchoredShapeStroke != null) // there is a to { if (anchoredShapeStroke.isProccessStroke()) { if (anchoredShapeStroke is ActorStroke) { ShowMessage("No shape can point to a role"); } else if (anchoredShapeStroke is ActivityStroke) { if (newAnchoredStroke.GetType() != typeof(ActorStroke) && newAnchoredStroke.GetType() != typeof(ArtifactStroke)) { ShowMessage("Only roles or artifacts can point to an activity."); } } else if (anchoredShapeStroke is ArtifactStroke) { ShowMessage("A link cannot point to a role"); } } else if (anchoredShapeStroke is ClassStroke && linkStroke.isLinkAggCompHeritage()) { if (!(newAnchoredStroke is ClassStroke)) { ShowMessage("Aggregation, composition and heritage links must be between two classes."); } } else if (newAnchoredStroke.isProccessStroke()) { ShowMessage("Roles, artifacts and activities must be linked between themselves."); } } else // there is no to { noNewStrokeLinkedToProcessOrClassCheck(newAnchoredStroke); } } else // to is changing { CustomStroke fromStroke = anchoredShapeStroke; if (fromStroke != null) // there is a from { if (fromStroke is ActorStroke) { if (!(newAnchoredStroke is ActivityStroke)) { ShowMessage("A role can only be linked to an activity."); } } else if (fromStroke is ArtifactStroke) { if (!(newAnchoredStroke is ActivityStroke)) { ShowMessage("An artifact can only be linked to an activity."); } } else if (fromStroke is ActivityStroke) { if (!(newAnchoredStroke is ArtifactStroke)) { ShowMessage("An activity can only be linked to an artifact."); } } else if (newAnchoredStroke != null && newAnchoredStroke.isProccessStroke()) { ShowMessage("Roles, artifacts and activities must be linked between themselves."); } else if (fromStroke is ClassStroke && linkStroke.isLinkAggCompHeritage()) { if (!(newAnchoredStroke is ClassStroke)) { ShowMessage("Aggregation, composition and heritage links must be between two classes."); } } } else // there is no from { noNewStrokeLinkedToProcessOrClassCheck(newAnchoredStroke); } } } else // no newAnchoredStroke { if (anchoredShapeStroke != null && anchoredShapeStroke.isProccessStroke()) { ShowMessage("Roles, artifacts and activities cannot be linked to nothing."); } if (anchoredShapeStroke != null && anchoredShapeStroke is ClassStroke && linkStroke.isLinkAggCompHeritage()) { ShowMessage("Aggregation, composition and heritage links must be between two classes."); } //if (linkStrokeAnchor == 0) //from is changing to nothing. No from //{ //} //else //to is changing to nothing. Not to. //{ //} } // voir fonction du anchorPointAdorner if (!hasFailed) { canvas.updateLink(linkStrokeAnchor, linkStroke, newAnchoredStroke as ShapeStroke, number, actualPos); } else { StrokeCollection selectedStrokes = new StrokeCollection { canvas.GetSelectedStrokes() }; canvas.Select(new StrokeCollection { }); canvas.Select(selectedStrokes); } //TODO eliminate preview visualChildren.Remove(linkPreview); InvalidateArrange(); }
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(); }