예제 #1
0
 public void UpdateTranslation(ILayoutDesigner layoutDesigner, Rect unionOfBounds)
 {
     if (this.element.ViewObject == null || this.Bounds.IsEmpty || this.Bounds.Width <= 0.0 && this.Bounds.Height <= 0.0)
     {
         return;
     }
     using (layoutDesigner.SuppressLayoutRounding)
         layoutDesigner.SetLayoutFromCache(this.element, this.cache, unionOfBounds);
 }
예제 #2
0
        private void NestContents(SceneNode node)
        {
            SceneElement sceneElement1 = (SceneElement)node;
            ISceneNodeCollection <SceneNode> destinationCollection = this.DestinationCollection;
            int count = destinationCollection.Count;

            SceneElement[]      sceneElementArray      = new SceneElement[count];
            LayoutCacheRecord[] layoutCacheRecordArray = new LayoutCacheRecord[count];
            ILayoutDesigner     designerForParent1     = this.SceneNode.ViewModel.GetLayoutDesignerForParent(this.SceneElement, true);
            Rect empty = Rect.Empty;

            for (int index = 0; index < count; ++index)
            {
                BaseFrameworkElement frameworkElement = destinationCollection[index] as BaseFrameworkElement;
                if (frameworkElement != null)
                {
                    layoutCacheRecordArray[index] = designerForParent1.CacheLayout(frameworkElement);
                    empty.Union(designerForParent1.GetChildRect(frameworkElement));
                }
            }
            for (int index = 0; index < count; ++index)
            {
                SceneNode    child         = destinationCollection[index];
                SceneElement sceneElement2 = child as SceneElement;
                if (sceneElement2 != null)
                {
                    sceneElementArray[index] = sceneElement2;
                }
                this.SceneNode.ViewModel.RemoveElement(child);
            }
            destinationCollection.Add((SceneNode)sceneElement1);
            for (int index = 0; index < count; ++index)
            {
                if (sceneElementArray[index] != null)
                {
                    sceneElement1.DefaultContent.Add((SceneNode)sceneElementArray[index]);
                }
            }
            this.SceneNode.ViewModel.Document.OnUpdatedEditTransaction();
            this.SceneNode.DesignerContext.ActiveView.UpdateLayout();
            ILayoutDesigner designerForParent2 = this.SceneNode.ViewModel.GetLayoutDesignerForParent(sceneElement1, true);

            for (int index = 0; index < count; ++index)
            {
                if (sceneElementArray[index] != null && layoutCacheRecordArray[index] != null)
                {
                    designerForParent2.SetLayoutFromCache((BaseFrameworkElement)sceneElementArray[index], layoutCacheRecordArray[index], empty);
                }
            }
            if (sceneElementArray.Length != 1)
            {
                return;
            }
            VisualStateManagerSceneNode.MoveStates(sceneElementArray[0], sceneElement1);
        }
예제 #3
0
        protected void AdjustLayoutAfterReparenting(ICollection <BaseFrameworkElement> reparentedElements)
        {
            ILayoutDesigner designerForParent = this.LayoutContainer.ViewModel.GetLayoutDesignerForParent((SceneElement)this.LayoutContainer, true);

            for (int index = 0; index < this.Context.DraggedElements.Count; ++index)
            {
                BaseFrameworkElement element = this.Context.DraggedElements[index];
                if (element.IsAttached && element.IsViewObjectValid && reparentedElements.Contains(element))
                {
                    designerForParent.SetLayoutFromCache(element, this.Context.LayoutCacheRecords[index], this.Context.BoundsOfAllElements);
                }
            }
        }
예제 #4
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);
        }
예제 #5
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);
        }