Exemplo n.º 1
0
 protected override void OnBeginDrag()
 {
     if (this.DraggedElements.Count > MoveStrategy.GetMaxChildrenForElement((SceneElement)this.LayoutContainer, (IProperty)null))
     {
         throw new InvalidOperationException(ExceptionStringTable.BehaviorCannotHandleMultipleElements);
     }
     this.PrepareDraggedElementsForDragging();
 }
Exemplo n.º 2
0
        protected override void UpdateInsertionPoint()
        {
            IViewPanel viewPanel = MoveStrategy.GetContainerHost((SceneElement)this.LayoutContainer) as IViewPanel;

            this.ClearAdorner();
            this.InsertionPoint.Element = this.LayoutContainer;
            bool isCursorAtEnd = true;

            this.InsertionPoint.Index         = FlowPanelLayoutUtilities.GetInsertionIndex((SceneElement)this.LayoutContainer, this.ActiveView.TransformPoint((IViewObject)this.ActiveView.HitTestRoot, this.LayoutContainer.Visual, this.DragCurrentPosition), out isCursorAtEnd);
            this.InsertionPoint.IsCursorAtEnd = isCursorAtEnd;
            this.AdornerSet = (AdornerSet) new FlowPanelInsertionPointAdornerSet(this.ToolContext, this.LayoutContainer, (FlowPanelInsertionPoint)this.InsertionPoint);
            this.ActiveView.AdornerLayer.Add((IAdornerSet)this.AdornerSet);
        }
Exemplo n.º 3
0
        private static MoveStrategy CreateForLayoutMode(MoveStrategyContext context, SceneElement hitElement)
        {
            SceneElement sceneElement = hitElement;

            while (sceneElement != null)
            {
                BaseFrameworkElement frameworkElement = sceneElement as BaseFrameworkElement;
                if (frameworkElement != null && context.RootNode.IsAncestorOf((SceneNode)frameworkElement))
                {
                    if (!MoveStrategyFactory.CanMoveInside(context, frameworkElement))
                    {
                        sceneElement = frameworkElement.ParentElement;
                        continue;
                    }
                    MoveStrategy byParentType = MoveStrategyFactory.CreateByParentType(context, frameworkElement);
                    if (byParentType != null)
                    {
                        bool flag = false;
                        ItemsControlElement   itemsControlElement   = frameworkElement.ParentElement as ItemsControlElement;
                        ContentControlElement contentControlElement = frameworkElement as ContentControlElement;
                        if (itemsControlElement != null && contentControlElement != null && (ItemsControlElement.ItemsProperty.Equals((object)itemsControlElement.GetPropertyForChild((SceneNode)frameworkElement)) && (itemsControlElement.ViewObject as IViewItemsControl).IsItemItsOwnContainer(contentControlElement.ViewObject)))
                        {
                            flag = true;
                        }
                        if (!flag)
                        {
                            IProperty contentProperty    = MoveStrategyFactory.GetContentProperty(context, (SceneNode)frameworkElement);
                            int       childrenForElement = MoveStrategy.GetMaxChildrenForElement((SceneElement)frameworkElement, contentProperty);
                            if (context.DraggedElements.Count <= childrenForElement && (childrenForElement != 1 || context.DraggedElements.Count != 1 || (!frameworkElement.IsAncestorOf((SceneNode)context.DraggedElements[0]) || context.DraggedElements[0].Parent == frameworkElement)))
                            {
                                byParentType.LayoutContainer = frameworkElement;
                                return(byParentType);
                            }
                        }
                    }
                }
                if (sceneElement != context.RootNode)
                {
                    sceneElement = sceneElement.ParentElement;
                }
                else
                {
                    break;
                }
            }
            return((MoveStrategy)null);
        }
Exemplo n.º 4
0
        public static MoveStrategy Create(MoveStrategyContext context, SceneElement hitElement, bool constraining)
        {
            MoveStrategy moveStrategy = (MoveStrategy)null;

            if (context.IsRecordingKeyframes)
            {
                moveStrategy = MoveStrategyFactory.CreateForAnimationMode(context);
            }
            if (moveStrategy == null)
            {
                moveStrategy = MoveStrategyFactory.CreateForLayoutMode(context, hitElement);
            }
            if (moveStrategy != null)
            {
                moveStrategy.IsConstraining = constraining;
            }
            return(moveStrategy);
        }
Exemplo n.º 5
0
        private static MoveStrategy CreateByParentType(MoveStrategyContext context, BaseFrameworkElement parentContainer)
        {
            MoveStrategyFactory.MoveStrategyTypeHandlerFactory orCreateCache = DesignSurfacePlatformCaches.GetOrCreateCache <MoveStrategyFactory.MoveStrategyTypeHandlerFactory>(parentContainer.Platform.Metadata, DesignSurfacePlatformCaches.MoveStrategyFactoryCache);
            ItemsControlElement itemsControlElement = parentContainer as ItemsControlElement;
            TextBlockElement    textBlockElement    = parentContainer as TextBlockElement;
            Type type = (Type)null;

            if (itemsControlElement != null && itemsControlElement.ItemsHost != null)
            {
                type = orCreateCache.GetHandlerType((ITypeResolver)itemsControlElement.ProjectContext, itemsControlElement.ItemsHost.GetIType((ITypeResolver)parentContainer.ProjectContext), true);
            }
            if (type == (Type)null)
            {
                type = orCreateCache.GetHandlerType((ITypeResolver)parentContainer.ProjectContext, parentContainer.Type, false);
            }
            if (type == typeof(GenericMoveStrategy))
            {
                ILayoutDesigner designerForParent = parentContainer.ViewModel.GetLayoutDesignerForParent((SceneElement)parentContainer, true);
                if ((designerForParent.GetWidthConstraintMode(parentContainer, (BaseFrameworkElement)null) & LayoutConstraintMode.CanvasLike) == LayoutConstraintMode.NonOverlappingGridlike && (designerForParent.GetHeightConstraintMode(parentContainer, (BaseFrameworkElement)null) & LayoutConstraintMode.CanvasLike) == LayoutConstraintMode.NonOverlappingGridlike)
                {
                    type = typeof(LayoutMoveStrategy);
                }
            }
            if (textBlockElement != null && !parentContainer.ViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.SupportsTextBlockInlineUIContainer))
            {
                type = (Type)null;
            }
            if (!(type != (Type)null))
            {
                return((MoveStrategy)null);
            }
            MoveStrategy moveStrategy = (MoveStrategy)Activator.CreateInstance(type, new object[1]
            {
                (object)context
            });

            moveStrategy.LayoutContainer = parentContainer;
            return(moveStrategy);
        }
Exemplo n.º 6
0
        protected override void UpdateInsertionPoint()
        {
            this.ClearAdorner();
            this.InsertionPoint.Element = this.LayoutContainer;
            ITextFlowSceneNode textFlowSceneNode = this.InsertionPoint.Element as ITextFlowSceneNode;
            Point            mousePosition       = this.InsertionPoint.Element.ViewModel.DefaultView.GetMousePosition(this.Pointer, MoveStrategy.GetContainerHost((SceneElement)this.InsertionPoint.Element));
            IViewTextPointer positionFromPoint   = textFlowSceneNode.GetPositionFromPoint(mousePosition);
            IViewTextPointer position            = positionFromPoint != null?positionFromPoint.GetInsertionPosition(LogicalDirection.Forward) : textFlowSceneNode.ContentEnd.GetNextInsertionPosition(LogicalDirection.Backward);

            this.InsertionPoint.IsCursorAtEnd = false;
            if (textFlowSceneNode.ContentStart == null)
            {
                this.InsertionPoint.IsCursorAtEnd = true;
            }
            else
            {
                this.InsertionPoint.Index = textFlowSceneNode.ContentStart.GetOffsetToPosition(position);
                this.AdornerSet           = (AdornerSet) new TextFlowInsertionPointAdornerSet(this.ToolContext, this.LayoutContainer, (TextFlowInsertionPoint)this.InsertionPoint);
                this.ActiveView.AdornerLayer.Add((IAdornerSet)this.AdornerSet);
            }
        }