private void canvas_Drop(object sender, DragEventArgs e) { SpaceObject so = null; if (e.Data.GetDataPresent(typeof(SpaceObject))) { so = e.Data.GetData(typeof(SpaceObject)) as SpaceObject; } else if (e.Data.GetDataPresent(typeof(BorderAdorner))) { so = SelectedSpaceObject as SpaceObject; } else if (e.Data.GetDataPresent(typeof(GroupBox))) { GroupBox obj = e.Data.GetData(typeof(GroupBox)) as GroupBox; if (obj != null) { UnmappableObject newObj = new UnmappableObject(); newObj.CommandName = obj.Tag as string; AddSpaceObjectEvents(newObj); //Need only to add delete support at this point. CommandsAndConditions.Add(newObj); } } if (so != null) { FrameworkElement dscope = DragHelper.GetDragScope(so); DragAdorner adorner = null; if (dscope != null) { adorner = DragHelper.GetDragAdorner(dscope); } bool DoAdd = false; if (so.Tag == null) { SpaceObject so2 = new SpaceObject(); so2.ObjectType = so.ObjectType; so2.Tag = "xxx"; SetSpaceObjectSize(so2); AddSpaceObjectEvents(so2); //so2.ObjectName = "test"; so = so2; //so.X = Canvas.GetLeft(so); //so.Z = Canvas.GetTop(so); //Raise added (needs to get to Xml)) DoAdd = true; } if (!canvas.Children.Contains(so)) { canvas.Children.Add(so); } //Point wrkP = DragHelper.GetRelativeMousePoint(so); no Point wrkP = e.GetPosition(canvas); if (adorner != null) { //wrkP = new Point( // adorner.LeftOffset - (ItemPool.ActualWidth + gridSplit.ActualWidth) + canvasScroll.HorizontalOffset, // adorner.TopOffset + canvasScroll.VerticalOffset); wrkP = new Point( adorner.LeftOffset + canvasScroll.HorizontalOffset, adorner.TopOffset + canvasScroll.VerticalOffset); } so.X = wrkP.X / zoomFactor; so.Z = wrkP.Y / zoomFactor; Canvas.SetTop(so, wrkP.Y); Canvas.SetLeft(so, wrkP.X); if (DoAdd) { this.RaiseEvent(new RoutedEventArgs(ObjectAddedEvent, so)); } else { this.RaiseEvent(new RoutedEventArgs(ObjectMovedEvent, so)); } //this.Dispatcher.BeginInvoke(new Action<SpaceObject>(SetSpaceObjectSize), System.Windows.Threading.DispatcherPriority.Loaded, so); } }