private void InitializeDrag(Point dragStartPosition) { SceneViewModel viewModel = this.ActiveView.ViewModel; this.CreateSubTransaction(); this.dragStartPosition = dragStartPosition; this.ComputeDraggedElements(); if (this.draggedElements == null || this.draggedElements.Count == 0) { this.moveStrategy = (MoveStrategy)null; this.dragContainer = (BaseFrameworkElement)null; this.CancelDrag(); } else { this.moveStrategy = (MoveStrategy)null; this.moveStrategyContext = MoveStrategyContext.FromSelection((ToolBehavior)this, this.primarySelection, this.selectedElements, this.draggedElements, this.DuplicationOffset, this.dragStartPosition); this.dragContainer = (BaseFrameworkElement)null; bool flag = false; SceneElement sceneElement1 = (SceneElement)null; foreach (SceneElement sceneElement2 in (IEnumerable <SceneElement>) this.selectedElements) { BaseFrameworkElement frameworkElement = (BaseFrameworkElement)null; BaseFrameworkElement editingContainer = viewModel.FindPanelClosestToActiveEditingContainer(); if (editingContainer != null && editingContainer.IsAncestorOf((SceneNode)sceneElement2)) { frameworkElement = editingContainer; } if (!flag) { flag = true; this.dragContainer = frameworkElement; sceneElement1 = sceneElement2.ParentElement; } else if (sceneElement2.ParentElement != sceneElement1) { this.dragContainer = (BaseFrameworkElement)null; break; } if (frameworkElement != this.dragContainer) { this.dragContainer = (BaseFrameworkElement)null; break; } } if (this.dragContainer != null) { this.moveStrategy = MoveStrategyFactory.Create(this.moveStrategyContext, this.draggedElements[0].ParentElement, this.IsShiftDown); if (this.moveStrategy != null) { this.moveStrategy.BeginDrag(dragStartPosition); this.ToolBehaviorContext.SnappingEngine.Start(this.ToolBehaviorContext, this.primaryDraggedElement, this.draggedElements); } else { this.CancelDrag(); } } else { this.CancelDrag(); } } }
private bool InternalOnDrag(Point dragStartPosition, Point dragCurrentPosition, bool scrollNow) { if (this.dragCancelled) { return(true); } this.EnsureEditTransaction(); if (!this.HasMouseMovedAfterDown) { this.InitializeDrag(dragStartPosition); } if (this.dragCancelled || this.dragContainer == null) { return(true); } Point point = dragCurrentPosition; dragCurrentPosition = this.SnapPrimarySelectionBounds(dragStartPosition, dragCurrentPosition); Point dragStartPosition1 = dragStartPosition; this.dragCurrentPosition = dragCurrentPosition; Vector vector = this.dragCurrentPosition - this.dragStartPosition; this.ActiveView.EnsureVisible(dragStartPosition + vector, scrollNow); BaseFrameworkElement hitElement = this.GetHitElement(point, this.draggedElements) ?? this.dragContainer; if (this.ActiveSceneViewModel.FindPanelClosestToRoot() != this.dragContainer || hitElement.GetType() == typeof(Viewport3DElement)) { hitElement = this.dragContainer; } MoveStrategy moveStrategy = MoveStrategyFactory.Create(this.moveStrategyContext, (SceneElement)hitElement, this.IsShiftDown); bool flag = this.enableReparenting && this.moveStrategy != null && (moveStrategy != null && moveStrategy.LayoutContainer != null) && moveStrategy.LayoutContainer != this.moveStrategy.LayoutContainer && moveStrategy.LayoutContainer.IsViewObjectValid; if (flag && this.IsAltDown) { this.ProvisionalContainer = (BaseFrameworkElement)null; this.ToolBehaviorContext.SnappingEngine.Stop(); this.moveStrategy.EndDrag(false); this.ReplaceSubTransaction(); this.UpdateEditTransaction(); if (moveStrategy != null) { this.moveStrategy = moveStrategy; this.moveStrategy.BeginDrag(dragStartPosition1); if (!this.moveStrategy.LayoutContainer.IsViewObjectValid) { this.CancelDrag(); return(true); } this.moveStrategy.ContinueDrag(dragCurrentPosition, hitElement); this.ToolBehaviorContext.SnappingEngine.Start(this.ToolBehaviorContext, this.primaryDraggedElement, this.draggedElements); } } else if (moveStrategy != null) { if (!flag) { this.ProvisionalContainer = (BaseFrameworkElement)null; } else { this.ProvisionalContainer = moveStrategy.LayoutContainer; this.SetTextCuePosition(dragCurrentPosition); } if (this.moveStrategy == null) { this.moveStrategy = moveStrategy; this.moveStrategy.BeginDrag(dragStartPosition); this.ToolBehaviorContext.SnappingEngine.Start(this.ToolBehaviorContext, this.primaryDraggedElement, this.draggedElements); } this.moveStrategy.ContinueDrag(dragCurrentPosition, hitElement); } else if (this.moveStrategy != null) { this.moveStrategy.ContinueDrag(dragCurrentPosition, hitElement); } this.UpdateEditTransaction(); if (this.moveStrategy != null && !this.moveStrategy.LayoutContainer.IsViewObjectValid) { this.CancelDrag(); } return(true); }