Example #1
0
        private Dictionary <KeyValuePair <SceneElement, IPropertyId>, SceneElementCollection> SortSelectionByParentAndZOrder(ICollection <SceneElement> selection)
        {
            Dictionary <KeyValuePair <SceneElement, IPropertyId>, SceneElementCollection> dictionary = new Dictionary <KeyValuePair <SceneElement, IPropertyId>, SceneElementCollection>();

            foreach (SceneElement sceneElement in (IEnumerable <SceneElement>)selection)
            {
                SceneElement parentElement = sceneElement.ParentElement;
                IPropertyId  propertyId    = (IPropertyId)parentElement.GetPropertyForChild((SceneNode)sceneElement);
                KeyValuePair <SceneElement, IPropertyId> key = new KeyValuePair <SceneElement, IPropertyId>(parentElement, propertyId);
                SceneElementCollection elementCollection;
                if (!dictionary.TryGetValue(key, out elementCollection))
                {
                    elementCollection = new SceneElementCollection();
                    dictionary.Add(key, elementCollection);
                }
                elementCollection.Add(sceneElement);
            }
            if (this.requiresSortedList)
            {
                ZOrderComparer <SceneElement> zorderComparer = new ZOrderComparer <SceneElement>(this.SceneViewModel.RootNode);
                foreach (KeyValuePair <KeyValuePair <SceneElement, IPropertyId>, SceneElementCollection> keyValuePair in dictionary)
                {
                    keyValuePair.Value.Sort((IComparer <SceneElement>)zorderComparer);
                }
            }
            return(dictionary);
        }
Example #2
0
 public AdornerElementSet(SceneElement element)
 {
     this.elements = new SceneElementCollection();
     this.elements.Add(element);
     this.primaryElementIndex   = 0;
     this.renderTransformOrigin = new Point(0.5, 0.5);
 }
 public override void Execute()
 {
     using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(StringTable.UndoUnitReleaseCompoundPath))
     {
         SceneElementSelectionSet   elementSelectionSet = this.SceneViewModel.ElementSelectionSet;
         ICollection <SceneElement> collection          = (ICollection <SceneElement>)elementSelectionSet.Selection;
         elementSelectionSet.Clear();
         SceneElementCollection elementCollection = new SceneElementCollection();
         foreach (SceneElement sceneElement in (IEnumerable <SceneElement>)collection)
         {
             PathElement pathElement1 = sceneElement as PathElement;
             if (ReleaseCompoundPathCommand.GetFigureCount(pathElement1) > 1)
             {
                 foreach (PathElement pathElement2 in PathCommandHelper.ReleaseCompoundPaths(pathElement1, editTransaction))
                 {
                     elementCollection.Add((SceneElement)pathElement2);
                 }
             }
             else
             {
                 elementCollection.Add(sceneElement);
             }
         }
         elementSelectionSet.SetSelection((ICollection <SceneElement>)elementCollection, (SceneElement)null);
         editTransaction.Commit();
     }
 }
        protected override void ReorderElements(ISceneNodeCollection <SceneNode> childCollection, SceneElementCollection selectedChildren)
        {
            if (childCollection.Count == selectedChildren.Count)
            {
                return;
            }
            int num1 = childCollection.Count - 1;

            for (int index = selectedChildren.Count - 1; index >= 0; --index)
            {
                SceneElement sceneElement = selectedChildren[index];
                int          num2         = childCollection.IndexOf((SceneNode)sceneElement);
                if (num2 < num1 && !selectedChildren.Contains(childCollection[num2 + 1] as SceneElement))
                {
                    sceneElement.Remove();
                    childCollection.Insert(num2 + 1, (SceneNode)sceneElement);
                }
            }
        }
Example #5
0
        protected override void ReorderElements(ISceneNodeCollection <SceneNode> childCollection, SceneElementCollection selectedChildren)
        {
            if (childCollection.Count == selectedChildren.Count)
            {
                return;
            }
            int count = childCollection.Count;

            for (int index = 0; index < selectedChildren.Count; ++index)
            {
                SceneElement sceneElement = selectedChildren[index];
                sceneElement.Remove();
                childCollection.Add((SceneNode)sceneElement);
            }
        }
Example #6
0
 public AdornerElementSet(SceneElementCollection elements)
 {
     this.elements              = elements;
     this.primaryElementIndex   = 0;
     this.renderTransformOrigin = new Point(0.5, 0.5);
 }
Example #7
0
 protected abstract void ReorderElements(ISceneNodeCollection <SceneNode> childCollection, SceneElementCollection selectedChildren);
 protected override void ReorderElements(ISceneNodeCollection <SceneNode> childCollection, SceneElementCollection selectedChildren)
 {
     if (childCollection.Count == selectedChildren.Count)
     {
         return;
     }
     for (int index = 0; index < selectedChildren.Count; ++index)
     {
         SceneElement sceneElement = selectedChildren[index];
         int          num          = childCollection.IndexOf((SceneNode)sceneElement);
         if (num > 0 && !selectedChildren.Contains(childCollection[num - 1] as SceneElement))
         {
             sceneElement.Remove();
             childCollection.Insert(num - 1, (SceneNode)sceneElement);
         }
     }
 }
Example #9
0
 protected override void ReorderElements(ISceneNodeCollection <SceneNode> childCollection, SceneElementCollection selectedChildren)
 {
     if (childCollection.Count == selectedChildren.Count)
     {
         return;
     }
     for (int index = selectedChildren.Count - 1; index >= 0; --index)
     {
         SceneElement sceneElement = selectedChildren[index];
         sceneElement.Remove();
         childCollection.Insert(0, (SceneNode)sceneElement);
     }
 }
Example #10
0
 public override void Execute()
 {
     using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(this.undoDescription))
     {
         this.ConvertSelectedElementsToPathIfNecessary();
         editTransaction.Update();
         this.SceneViewModel.DefaultView.UpdateLayout();
         SceneElementSelectionSet      elementSelectionSet   = this.SceneViewModel.ElementSelectionSet;
         SceneElement                  primarySelection      = elementSelectionSet.PrimarySelection;
         System.Windows.Media.Geometry renderedGeometryAsWpf = this.SceneView.GetRenderedGeometryAsWpf(primarySelection);
         if (renderedGeometryAsWpf == null)
         {
             return;
         }
         this.Initialize(renderedGeometryAsWpf);
         SceneElementCollection elementCollection = new SceneElementCollection();
         foreach (SceneElement shapeElement in elementSelectionSet.Selection)
         {
             if (shapeElement != primarySelection)
             {
                 elementCollection.Add(shapeElement);
                 System.Windows.Media.Geometry secondaryGeometry = this.SceneView.GetRenderedGeometryAsWpf(shapeElement);
                 if (secondaryGeometry == null)
                 {
                     return;
                 }
                 Matrix transformToElement = shapeElement.GetComputedTransformToElement(primarySelection);
                 if (!transformToElement.IsIdentity)
                 {
                     MatrixTransform matrixTransform = new MatrixTransform(transformToElement);
                     matrixTransform.Freeze();
                     GeometryGroup geometryGroup = new GeometryGroup();
                     geometryGroup.Children.Add(secondaryGeometry);
                     geometryGroup.Transform = (Transform)matrixTransform;
                     secondaryGeometry       = (System.Windows.Media.Geometry)geometryGroup;
                 }
                 this.Combine(secondaryGeometry);
             }
         }
         PathGeometry result = this.GetResult();
         BooleanCommand.CleanUpPathGeometry(ref result);
         PathGeometry pathGeometry = PathConversionHelper.RemoveDegeneratePoints((System.Windows.Media.Geometry)result);
         elementSelectionSet.Clear();
         PathGeometryUtilities.CollapseSingleSegmentsToPolySegments(pathGeometry);
         PathElement pathElement = (PathElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.Path);
         Dictionary <IPropertyId, SceneNode> properties = (Dictionary <IPropertyId, SceneNode>)null;
         using (this.SceneViewModel.DisableUpdateChildrenOnAddAndRemove())
         {
             this.SceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree(primarySelection);
             properties = SceneElementHelper.StoreProperties((SceneNode)primarySelection);
             ISceneNodeCollection <SceneNode> collectionContainer = primarySelection.GetCollectionContainer();
             int index = collectionContainer.IndexOf((SceneNode)primarySelection);
             collectionContainer[index] = (SceneNode)pathElement;
         }
         foreach (SceneElement element in elementCollection)
         {
             this.SceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree(element);
             element.Remove();
         }
         using (this.SceneViewModel.ForceBaseValue())
         {
             if (properties != null)
             {
                 SceneElementHelper.ApplyProperties((SceneNode)pathElement, properties);
             }
             pathElement.SetValueAsWpf(ShapeElement.StretchProperty, (object)Stretch.Fill);
             PathCommandHelper.ReplacePathGeometry(pathElement, pathGeometry, editTransaction);
         }
         elementSelectionSet.SetSelection((SceneElement)pathElement);
         editTransaction.Commit();
     }
 }