Exemplo n.º 1
0
 private AdornerLayer.ElementInfo GetOrCreateElementInfo(AdornerElementSet adornerElementSet)
 {
     AdornerLayer.ElementInfo elementInfo = this.GetElementInfo(adornerElementSet);
     if (elementInfo == null)
     {
         elementInfo = new AdornerLayer.ElementInfo();
         this.elementMap.Add(adornerElementSet, elementInfo);
     }
     return(elementInfo);
 }
Exemplo n.º 2
0
            public void Update(AdornerElementSet adornerElementSet, AdornerLayer adornerLayer, AdornerLayer.ElementInfoUpdateSource source)
            {
                SceneElement primaryElement = adornerElementSet.PrimaryElement;
                bool         flag           = false;

                if (!adornerLayer.SceneView.IsInArtboard(primaryElement))
                {
                    return;
                }
                Size size2 = primaryElement.Visual != null?adornerLayer.SceneView.GetRenderSize(primaryElement.Visual) : Size.Empty;

                Transform transform             = (Transform) new MatrixTransform(adornerElementSet.CalculatePrimaryElementTransformMatrixToAdornerLayer());
                Matrix    matrix                = transform == null ? Matrix.Identity : transform.Value;
                Point     renderTransformOrigin = adornerElementSet.RenderTransformOrigin;

                if (!AdornerLayer.ElementInfo.AreClose(renderTransformOrigin, this.sharedCenter) || !AdornerLayer.ElementInfo.AreClose(this.lastRenderSize, size2) || (this.primaryElementMatrix != matrix || adornerElementSet.IsPrimaryTransformNonAffine))
                {
                    flag = true;
                    this.sharedCenter         = renderTransformOrigin;
                    this.lastRenderSize       = size2;
                    this.primaryElementMatrix = matrix;
                }
                ISceneInsertionPoint sceneInsertionPoint = adornerElementSet.PrimaryElement.ViewModel.ActiveSceneInsertionPoint;

                if (flag || source == AdornerLayer.ElementInfoUpdateSource.LayoutUpdated && adornerElementSet.NeedsUpdate)
                {
                    adornerElementSet.Update();
                    this.matrix = adornerElementSet.GetTransformMatrixToAdornerLayer();
                    foreach (AdornerSet adornerSet in this.adornerSets)
                    {
                        this.UpdateMatrix(adornerSet, adornerLayer);
                    }
                    if (this.adornerSet3DContainer != null)
                    {
                        this.adornerSet3DContainer.SetMatrix(this.matrix);
                    }
                    if (sceneInsertionPoint != null && primaryElement.ParentElement is GridElement && (primaryElement.ParentElement == sceneInsertionPoint.SceneElement && primaryElement.ViewModel.IsInGridDesignMode))
                    {
                        adornerLayer.InvalidateAdornerVisuals(primaryElement.ParentElement);
                    }
                }
                if (!(primaryElement is Base3DElement) || sceneInsertionPoint == null)
                {
                    return;
                }
                Base3DElement base3Delement = sceneInsertionPoint.SceneElement as Base3DElement;

                if (base3Delement == null)
                {
                    return;
                }
                adornerLayer.InvalidateAdornerVisuals((SceneElement)base3Delement);
            }
Exemplo n.º 3
0
 internal AdornerSet(ToolBehaviorContext toolContext, AdornerElementSet adornedElementSet, AdornerSetOrder order)
 {
     if (toolContext == null)
     {
         throw new ArgumentNullException("toolContext");
     }
     if (adornedElementSet == null)
     {
         throw new ArgumentNullException("adornedElementSet");
     }
     this.order             = order;
     this.toolContext       = toolContext;
     this.adornedElementSet = adornedElementSet;
 }
Exemplo n.º 4
0
 private void RemoveAllAdornerSets(AdornerElementSet adornerElementSet)
 {
     AdornerLayer.ElementInfo elementInfo = this.GetElementInfo(adornerElementSet);
     foreach (AdornerSet adornerSet in elementInfo.AdornerSets)
     {
         this.children.Remove((Visual)adornerSet);
         adornerSet.OnRemove();
     }
     if (elementInfo.AdornerSet3DContainer != null)
     {
         this.children.Remove((Visual)elementInfo.AdornerSet3DContainer);
         this.adornerSet3DContainers.Remove(elementInfo.AdornerSet3DContainer);
     }
     this.elementMap.Remove(adornerElementSet);
 }
Exemplo n.º 5
0
        private void AddAdornerSet2D(AdornerSet adornerSet2D)
        {
            AdornerElementSet elementSet = adornerSet2D.ElementSet;

            if (elementSet == null)
            {
                throw new InvalidOperationException(ExceptionStringTable.AdornerElementSetMayNotBeNull);
            }
            if (adornerSet2D.Parent != this)
            {
                this.children.Add((Visual)adornerSet2D);
            }
            AdornerLayer.ElementInfo createElementInfo = this.GetOrCreateElementInfo(elementSet);
            createElementInfo.Update(elementSet, this, AdornerLayer.ElementInfoUpdateSource.Explicit);
            createElementInfo.AddAdornerSet(adornerSet2D);
        }
Exemplo n.º 6
0
        private void UpdateElementInfo(SceneElement sceneElement, AdornerLayer.ElementInfoUpdateSource source)
        {
            if (this.elementMap.Count == 0)
            {
                return;
            }
            List <AdornerElementSet> list = new List <AdornerElementSet>(1);

            if (sceneElement != null)
            {
                IList <AdornerElementSet> containingElement = this.GetAdornerElementSetsContainingElement(sceneElement);
                if (!sceneElement.IsAttached)
                {
                    foreach (AdornerElementSet adornerElementSet in (IEnumerable <AdornerElementSet>)containingElement)
                    {
                        list.Add(adornerElementSet);
                    }
                }
                else
                {
                    foreach (AdornerElementSet adornerElementSet in (IEnumerable <AdornerElementSet>)containingElement)
                    {
                        this.GetElementInfo(adornerElementSet).Update(adornerElementSet, this, source);
                    }
                }
            }
            else
            {
                foreach (KeyValuePair <AdornerElementSet, AdornerLayer.ElementInfo> keyValuePair in this.elementMap)
                {
                    AdornerElementSet key = keyValuePair.Key;
                    if (!key.IsAttached)
                    {
                        list.Add(key);
                    }
                    else
                    {
                        keyValuePair.Value.Update(key, this, source);
                    }
                }
            }
            foreach (AdornerElementSet adornerElementSet in list)
            {
                this.RemoveAllAdornerSets(adornerElementSet);
            }
        }
Exemplo n.º 7
0
 internal AdornerSet3D(ToolBehaviorContext toolContext, Base3DElement adornedElement, AdornerSetOrder order)
 {
     if (toolContext == null)
     {
         throw new ArgumentNullException("toolContext");
     }
     if (adornedElement == null)
     {
         throw new ArgumentNullException("adornedElement");
     }
     this.toolContext       = toolContext;
     this.adornedElementSet = toolContext.View.Artboard.AdornerLayer.CreateOrGetAdornerElementSetForElement((SceneElement)adornedElement);
     this.order             = order;
     this.adornerSetVisual  = new ModelVisual3D();
     this.adornerSetVisual.SetValue(FrameworkElement.NameProperty, (object)"adornerSet3DVisual");
     this.adornerSetVisual.Transform = (Transform3D) new MatrixTransform3D();
 }
Exemplo n.º 8
0
        private void RemoveAdornerSet2D(AdornerSet adornerSet2D)
        {
            AdornerElementSet elementSet = adornerSet2D.ElementSet;

            if (elementSet == null)
            {
                throw new InvalidOperationException(ExceptionStringTable.AdornerElementSetMayNotBeNull);
            }
            AdornerLayer.ElementInfo elementInfo = this.GetElementInfo(elementSet);
            if (elementInfo != null && elementInfo.RemoveAdornerSet(adornerSet2D))
            {
                if (elementInfo.IsEmpty)
                {
                    this.elementMap.Remove(elementSet);
                }
                this.children.Remove((Visual)adornerSet2D);
            }
            adornerSet2D.OnRemove();
        }
Exemplo n.º 9
0
        public AdornerElementSet CreateOrGetAdornerElementSetForElement(SceneElement element)
        {
            IList <AdornerElementSet> containingElement = this.GetAdornerElementSetsContainingElement(element);

            if (containingElement.Count >= 1)
            {
                foreach (AdornerElementSet adornerElementSet in (IEnumerable <AdornerElementSet>)containingElement)
                {
                    if (!adornerElementSet.AdornsMultipleElements)
                    {
                        return(adornerElementSet);
                    }
                }
            }
            AdornerElementSet adornerElementSet1 = new AdornerElementSet(element);

            this.adornerElementSets.Add(adornerElementSet1);
            return(adornerElementSet1);
        }
Exemplo n.º 10
0
 private AdornerLayer.ElementInfo GetElementInfo(AdornerElementSet adornerElementSet)
 {
     AdornerLayer.ElementInfo elementInfo = (AdornerLayer.ElementInfo)null;
     this.elementMap.TryGetValue(adornerElementSet, out elementInfo);
     return(elementInfo);
 }
Exemplo n.º 11
0
 internal AnimatableAdornerSet(ToolBehaviorContext toolContext, AdornerElementSet adornedElementSet, AdornerSetOrder order)
     : base(toolContext, adornedElementSet, order)
 {
     this.activeAnimations = new List <AdornerAnimation>();
 }
Exemplo n.º 12
0
 internal AnimatableAdornerSet(ToolBehaviorContext toolContext, AdornerElementSet adornedElementSet)
     : this(toolContext, adornedElementSet, AdornerSetOrderTokens.MediumPriority)
 {
 }