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 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); }