private void SnappedEdgesOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs) { if (notifyCollectionChangedEventArgs.Action == NotifyCollectionChangedAction.Remove) { foreach (Edge removedEdge in notifyCollectionChangedEventArgs.OldItems) { var adorner = EdgeAdorners[removedEdge]; DesignSurface.RemoveAdorner(adorner); EdgeAdorners.Remove(removedEdge); } } if (notifyCollectionChangedEventArgs.Action == NotifyCollectionChangedAction.Add) { foreach (Edge addedEdge in notifyCollectionChangedEventArgs.NewItems) { var edgeAdorner = ServiceLocator.UIElementFactory.CreateEdgeAdorner(DesignSurface, WrappedSelectedItems, addedEdge); EdgeAdorners.Add(addedEdge, edgeAdorner); DesignSurface.AddAdorner(edgeAdorner); } } if (notifyCollectionChangedEventArgs.Action == NotifyCollectionChangedAction.Reset) { foreach (var adorner in EdgeAdorners.Values) { DesignSurface.RemoveAdorner(adorner); } EdgeAdorners.Clear(); } }
private void AddSelectionAdorner(ICanvasItem canvasItem) { var selectionAdorner = ServiceLocator.UIElementFactory.CreateSelectionAdorner(DesignSurface, canvasItem); DesignSurface.AddAdorner(selectionAdorner); SelectionAdorners.Add(canvasItem, selectionAdorner); }