Example #1
0
 public static SceneElement GetSelectionRoot(SceneViewModel viewModel)
 {
     return((SceneElement)viewModel.FindPanelClosestToActiveEditingContainer() ?? viewModel.ActiveEditingContainer as SceneElement);
 }
Example #2
0
        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();
                }
            }
        }