예제 #1
0
 public bool TryReplace(object source, SmartInsertionPoint insertionPoint, ISceneNodeCollection <SceneNode> destinationCollection)
 {
     if (insertionPoint != null && insertionPoint.SceneNode != null && (insertionPoint.SceneNode.ViewModel != null && destinationCollection != null) && destinationCollection.Count > 0 && destinationCollection.FixedCapacity.HasValue)
     {
         int?fixedCapacity = destinationCollection.FixedCapacity;
         int count         = destinationCollection.Count;
         if ((fixedCapacity.GetValueOrDefault() != count ? 0 : (fixedCapacity.HasValue ? true : false)) != 0)
         {
             this.IsReplacingChild = true;
             this.HideSplitter     = true;
             this.ReplacedChild    = destinationCollection[destinationCollection.Count - 1];
             SceneNode node  = source as SceneNode;
             Asset     asset = source as Asset;
             if (asset != null)
             {
                 node = asset.CreatePrototypeInstance((ISceneInsertionPoint)insertionPoint);
             }
             if (node != null && insertionPoint.ShouldNestContents(node))
             {
                 this.IsNestingContents = true;
             }
             return(true);
         }
     }
     return(false);
 }
        private SceneNode InsertNode(SceneNode node)
        {
            SmartInsertionPoint smartInsertionPoint = SmartInsertionPoint.From(this.InsertionPoint);

            if (smartInsertionPoint == null)
            {
                return((SceneNode)null);
            }
            smartInsertionPoint.Insert(node);
            return(node);
        }
예제 #3
0
 protected override bool OnQueryCanDrop(TimelineDragDescriptor descriptor)
 {
     if (!this.SourceData.CanCreateInstance(this.InsertionPoint))
     {
         return(false);
     }
     descriptor.DisableCopy();
     descriptor.SetCreateIn(this.InsertionPoint);
     descriptor.TryReplace((object)this.SourceData, SmartInsertionPoint.From(this.InsertionPoint), this.DestinationCollection);
     return(descriptor.CanDrop);
 }
예제 #4
0
        private SceneNode InsertBehavior(BehaviorNode behaviorNode)
        {
            SmartInsertionPoint smartInsertionPoint = SmartInsertionPoint.From(this.InsertionPoint);

            if (smartInsertionPoint == null)
            {
                return((SceneNode)null);
            }
            smartInsertionPoint.Insert((SceneNode)behaviorNode);
            return((SceneNode)behaviorNode);
        }
예제 #5
0
 protected ISceneInsertionPoint GetInsertionPoint(object data, DragDropContext context)
 {
     this.CheckNullArgument(data, "data");
     if (context.Target != null)
     {
         ISceneInsertionPoint insertionPoint = context.Target.GetInsertionPoint(data, context);
         if (insertionPoint != null)
         {
             return((ISceneInsertionPoint)SmartInsertionPoint.From(insertionPoint, context.Descriptor.DropIndex));
         }
     }
     return((ISceneInsertionPoint)null);
 }
예제 #6
0
        protected override DragDropEffects OnHandleDrop(DragDropEffects dropEffects)
        {
            if (!this.TryValidateDropAction())
            {
                return(DragDropEffects.None);
            }
            int index = SmartInsertionPoint.From(this.InsertionPoint).Index;

            if ((dropEffects & DragDropEffects.Copy) != DragDropEffects.None)
            {
                this.Copy(index);
            }
            else if ((dropEffects & DragDropEffects.Move) != DragDropEffects.None)
            {
                this.Move(index);
            }
            return(DragDropEffects.None);
        }
예제 #7
0
 protected override bool OnQueryCanDrop(TimelineDragDescriptor descriptor)
 {
     descriptor.DisableInBetween();
     if (!this.InsertionPoint.CanInsert((ITypeId)this.SourceData.Type))
     {
         return(false);
     }
     if (descriptor.AllowCopy)
     {
         descriptor.SetCopyInto(this.InsertionPoint);
     }
     else
     {
         descriptor.SetMoveInto(this.InsertionPoint);
     }
     descriptor.TryReplace((object)this.SourceData, SmartInsertionPoint.From(this.InsertionPoint), this.DestinationCollection);
     return(true);
 }
예제 #8
0
        public static SmartInsertionPoint From(ISceneInsertionPoint reference, int index)
        {
            SmartInsertionPoint smartInsertionPoint = reference as SmartInsertionPoint;

            if (smartInsertionPoint != null)
            {
                if (index < 0 || smartInsertionPoint.index == index)
                {
                    return(smartInsertionPoint);
                }
                return(new SmartInsertionPoint(index, smartInsertionPoint.reference));
            }
            if (reference != null)
            {
                return(new SmartInsertionPoint(index, reference));
            }
            return((SmartInsertionPoint)null);
        }
예제 #9
0
        private SceneNode Copy(SceneNode node, ref int index)
        {
            SceneElement sceneElement1 = node as SceneElement;
            DocumentNode node1         = sceneElement1.DocumentNode.Clone(sceneElement1.DocumentContext);
            SceneElement sceneElement2 = (SceneElement)null;
            bool         flag          = false;

            if (node1 != null)
            {
                sceneElement2 = this.ViewModel.GetSceneNode(node1) as SceneElement;
                if (sceneElement2 != null)
                {
                    if (sceneElement1.ParentElement != this.TargetNode)
                    {
                        DocumentCompositeNode documentCompositeNode = (DocumentCompositeNode)sceneElement2.DocumentNode;
                        documentCompositeNode.ClearValue(DesignTimeProperties.ClassProperty);
                        documentCompositeNode.ClearValue(DesignTimeProperties.SubclassProperty);
                        documentCompositeNode.ClearValue(DesignTimeProperties.ClassModifierProperty);
                        flag = true;
                    }
                    SmartInsertionPoint.From(this.InsertionPoint, index).Insert((SceneNode)sceneElement2);
                    if (flag)
                    {
                        BaseFrameworkElement element        = sceneElement2 as BaseFrameworkElement;
                        ILayoutDesigner      layoutDesigner = element == null ? (ILayoutDesigner)null : this.ViewModel.GetLayoutDesignerForChild((SceneElement)element, true);
                        if (layoutDesigner != null)
                        {
                            this.ViewModel.Document.OnUpdatedEditTransaction();
                            LayoutCacheRecord layoutCacheRecord;
                            if (element.ViewObject != null && sceneElement1 is BaseFrameworkElement && this.layoutCache.TryGetValue((SceneNode)sceneElement1, out layoutCacheRecord))
                            {
                                layoutDesigner.SetLayoutFromCache(element, layoutCacheRecord, this.boundsOfAllElements);
                            }
                        }
                    }
                }
            }
            if (index != -1)
            {
                ++index;
            }
            return((SceneNode)sceneElement2);
        }
예제 #10
0
        private bool CanDrop(SceneNode node, TimelineDragDescriptor descriptor)
        {
            SceneElement sceneElement;

            if (!descriptor.AllowCopy && !descriptor.AllowMove || ((sceneElement = node as SceneElement) == null || !this.InsertionPoint.CanInsert((ITypeId)sceneElement.Type)))
            {
                return(false);
            }
            if (descriptor.AllowCopy)
            {
                descriptor.SetCopyInto(this.InsertionPoint);
            }
            else
            {
                if (sceneElement.IsAncestorOf(this.TargetNode))
                {
                    return(false);
                }
                descriptor.SetMoveInto(this.InsertionPoint);
            }
            descriptor.TryReplace((object)sceneElement, SmartInsertionPoint.From(this.InsertionPoint), this.DestinationCollection);
            return(true);
        }
        protected override bool OnQueryCanDrop(TimelineDragDescriptor descriptor)
        {
            descriptor.DisableInBetween();
            if (!this.InsertionPoint.CanInsert((ITypeId)this.SourceData.Type))
            {
                return(false);
            }
            if (descriptor.AllowCopy)
            {
                descriptor.SetCopyInto(this.InsertionPoint);
            }
            else
            {
                descriptor.SetMoveInto(this.InsertionPoint);
            }
            DocumentNodePath valueAsDocumentNode = this.TargetNode.GetLocalValueAsDocumentNode(Base2DElement.EffectProperty);

            if (valueAsDocumentNode != null && valueAsDocumentNode.Node == this.SourceData.DocumentNode)
            {
                return(false);
            }
            descriptor.TryReplace((object)this.SourceData, SmartInsertionPoint.From(this.InsertionPoint), this.DestinationCollection);
            return(true);
        }
예제 #12
0
        private SceneNode Move(SceneNode node, ref int index)
        {
            SceneElement sceneElement = node as SceneElement;
            ISceneNodeCollection <SceneNode> destinationCollection = this.DestinationCollection;
            bool flag = destinationCollection.Contains((SceneNode)sceneElement);
            BaseFrameworkElement element         = sceneElement as BaseFrameworkElement;
            ILayoutDesigner      layoutDesigner1 = element == null ? (ILayoutDesigner)null : this.ViewModel.GetLayoutDesignerForChild((SceneElement)element, false);

            if (sceneElement.IsAttached)
            {
                if (flag)
                {
                    if (destinationCollection.IndexOf((SceneNode)sceneElement) < index)
                    {
                        --index;
                    }
                    layoutDesigner1 = (ILayoutDesigner)null;
                }
                this.TargetNode.ViewModel.RemoveElement((SceneNode)sceneElement);
                this.ViewModel.Document.OnUpdatedEditTransaction();
            }
            SmartInsertionPoint.From(this.InsertionPoint, index).Insert((SceneNode)sceneElement);
            this.ViewModel.Document.OnUpdatedEditTransaction();
            ILayoutDesigner   layoutDesigner2 = element == null ? (ILayoutDesigner)null : this.ViewModel.GetLayoutDesignerForChild((SceneElement)element, false);
            LayoutCacheRecord layoutCacheRecord;

            if (layoutDesigner1 != null && layoutDesigner2 != null && (element != null && this.layoutCache.TryGetValue((SceneNode)element, out layoutCacheRecord)))
            {
                layoutDesigner2.SetLayoutFromCache(element, layoutCacheRecord, this.boundsOfAllElements);
            }
            if (index != -1)
            {
                ++index;
            }
            return((SceneNode)sceneElement);
        }
예제 #13
0
 public static SmartInsertionPoint From(ISceneInsertionPoint reference)
 {
     return(SmartInsertionPoint.From(reference, -1));
 }