private Point GetRelativeLocation(IEnumerable <WorkflowViewElement> draggedViews) { HashSet <WorkflowViewElement> viewElements = new HashSet <WorkflowViewElement>(draggedViews); if (!viewElements.Contains(this)) { viewElements.Add(this); } Dictionary <WorkflowViewElement, Point> locations = DragDropHelper.GetViewElementRelativeLocations(viewElements); return(locations[this]); }
public ViewElementDragShadow(UIElement owner, IEnumerable <WorkflowViewElement> viewElements, Point offset, double scaleFactor) : base(owner) { Dictionary <WorkflowViewElement, Point> locations = DragDropHelper.GetViewElementRelativeLocations(viewElements); Grid grid = new Grid(); foreach (WorkflowViewElement viewElement in viewElements) { Rect bounds = VisualTreeHelper.GetDescendantBounds(viewElement); Rectangle rectangle = new Rectangle() { Width = bounds.Width, Height = bounds.Height, Fill = new VisualBrush(viewElement), Margin = new Thickness(locations[viewElement].X, locations[viewElement].Y, 0, 0), VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left }; grid.Children.Add(rectangle); } grid.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); this.width = grid.DesiredSize.Width; this.height = grid.DesiredSize.Height; this.content = new Rectangle() { Width = this.width, Height = this.height, Fill = new VisualBrush(grid) { Opacity = 0.6 } }; this.InitializeCommon(offset, scaleFactor); }