private static bool CanMoveInside(MoveStrategyContext context, BaseFrameworkElement candidateContainer) { if (context.PrimarySelection == null) { return(false); } IProperty contentProperty = MoveStrategyFactory.GetContentProperty(context, (SceneNode)candidateContainer); if (contentProperty == null) { return(false); } PropertySceneInsertionPoint insertionPoint = new PropertySceneInsertionPoint((SceneElement)candidateContainer, contentProperty); ControlTemplateElement controlTemplateElement; if (candidateContainer.IsLockedOrAncestorLocked || candidateContainer.IsHiddenOrCollapsedOrAncestorHiddenOrCollapsed || (context.SelectedElements.Count == 0 || Enumerable.Any <SceneElement>((IEnumerable <SceneElement>)context.SelectedElements, (Func <SceneElement, bool>)(element => !insertionPoint.CanInsert((ITypeId)element.TrueTargetTypeId)))) || ProjectNeutralTypes.TabItem.IsAssignableFrom((ITypeId)candidateContainer.Type) || (candidateContainer.Name == "PART_ContentHost" && typeof(ScrollViewer).IsAssignableFrom(candidateContainer.TargetType) && ((controlTemplateElement = context.RootNode as ControlTemplateElement) != null && typeof(TextBoxBase).IsAssignableFrom(controlTemplateElement.TargetElementType)) || candidateContainer.IsPlaceholder)) { return(false); } foreach (SceneNode sceneNode in context.DraggedElements) { if (sceneNode.IsAncestorOf((SceneNode)candidateContainer)) { return(false); } } return(true); }
private static IProperty GetContentProperty(MoveStrategyContext context, SceneNode candidateContainer) { IProperty property = (IProperty)null; if (context.PrimarySelection != null && context.PrimarySelection.Parent != null && context.PrimarySelection.Parent.Equals((object)candidateContainer)) { property = candidateContainer.GetPropertyForChild((SceneNode)context.PrimarySelection); } return(property ?? candidateContainer.DefaultContentProperty); }
public static MoveStrategyContext FromSelection(ToolBehavior toolBehavior, SceneElement primarySelection, IList <SceneElement> selectedElements, IList <BaseFrameworkElement> draggedElements, Vector duplicationOffset, Point referencePoint) { MoveStrategyContext moveStrategyContext = new MoveStrategyContext(); moveStrategyContext.ToolBehaviorContext = toolBehavior.ToolBehaviorContext; moveStrategyContext.Transaction = (IToolBehaviorTransaction)toolBehavior; moveStrategyContext.MouseDevice = toolBehavior.MouseDevice; moveStrategyContext.PrimarySelection = primarySelection; moveStrategyContext.SelectedElements = new ReadOnlyCollection <SceneElement>(selectedElements ?? (IList <SceneElement>) new List <SceneElement>()); moveStrategyContext.DraggedElements = new ReadOnlyCollection <BaseFrameworkElement>(draggedElements ?? (IList <BaseFrameworkElement>) new List <BaseFrameworkElement>()); moveStrategyContext.DuplicationOffset = duplicationOffset; moveStrategyContext.SnapshotDraggedElements(moveStrategyContext.ActiveView, referencePoint); return(moveStrategyContext); }
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); }
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); }
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); }
private static MoveStrategy CreateForAnimationMode(MoveStrategyContext context) { BaseFrameworkElement frameworkElement = (BaseFrameworkElement)null; if (context.DraggedElements.Count != 0) { SceneNode parent = context.DraggedElements[0].Parent; while (parent != null && !(parent is BaseFrameworkElement)) { parent = parent.Parent; } frameworkElement = parent as BaseFrameworkElement; } if (frameworkElement == null || !context.RootNode.IsAncestorOf((SceneNode)frameworkElement)) { return((MoveStrategy)null); } LayoutMoveStrategy layoutMoveStrategy = new LayoutMoveStrategy(context); layoutMoveStrategy.EnableAnimationMode = true; layoutMoveStrategy.LayoutContainer = frameworkElement; return((MoveStrategy)layoutMoveStrategy); }
protected BaseFlowMoveStrategy(MoveStrategyContext context, BaseFlowInsertionPoint insertionPoint) : base(context) { this.insertionPoint = insertionPoint; }
internal InplaceMoveStrategy(MoveStrategyContext context) : base(context) { }
public LayoutMoveStrategy(MoveStrategyContext context) : base(context) { }
public GenericMoveStrategy(MoveStrategyContext context) : base(context) { }
public DockPanelMoveStrategy(MoveStrategyContext context) : base(context) { }
public FlowPanelMoveStrategy(MoveStrategyContext context) : base(context, (BaseFlowInsertionPoint) new FlowPanelInsertionPoint()) { }
public TextFlowMoveStrategy(MoveStrategyContext context) : base(context, (BaseFlowInsertionPoint) new TextFlowInsertionPoint()) { }
public MoveStrategy(MoveStrategyContext context) { this.Context = context; }