Exemple #1
0
        private static void TransferPathFigureAnimations(PathElement oldElement, PathElement newElement, PropertyReference pathProperty, int oldFigureIndex, int newFigureIndex, Transform transform)
        {
            PathAnimationMovePackage animationMove = new PathAnimationMovePackage();

            PathCommandHelper.TransferPathFigureAnimations(oldElement, newElement, pathProperty, oldFigureIndex, newFigureIndex, transform, animationMove);
            animationMove.AddAndRemove();
        }
Exemple #2
0
        public static List <PathElement> ReleaseCompoundPaths(PathElement pathElement, SceneEditTransaction editTransaction)
        {
            List <PathElement> list              = new List <PathElement>();
            PathGeometry       pathGeometry1     = pathElement.PathGeometry;
            Transform          geometryTransform = pathElement.GeometryTransform;
            ISceneNodeCollection <SceneNode> collectionContainer = pathElement.GetCollectionContainer();
            int num            = collectionContainer.IndexOf((SceneNode)pathElement);
            int oldFigureIndex = 0;

            foreach (PathFigure original in pathGeometry1.Figures)
            {
                PathFigure   pathFigure    = PathFigureUtilities.Copy(original, geometryTransform);
                PathGeometry pathGeometry2 = new PathGeometry();
                if (pathGeometry1.Transform != null && pathGeometry1.Transform.Value != Matrix.Identity)
                {
                    pathGeometry2.Transform = pathGeometry1.Transform.Clone();
                }
                if (pathGeometry2.FillRule != pathGeometry1.FillRule)
                {
                    pathGeometry2.FillRule = pathGeometry1.FillRule;
                }
                pathGeometry2.Figures.Add(pathFigure);
                DocumentNode node         = pathElement.DocumentNode.Clone(pathElement.DocumentContext);
                PathElement  pathElement1 = (PathElement)pathElement.ViewModel.GetSceneNode(node);
                collectionContainer.Insert(num++, (SceneNode)pathElement1);
                Rect extent = pathGeometry2.Bounds;
                extent = PathCommandHelper.InflateRectByStrokeWidth(extent, pathElement1, false);
                Vector vector = new Vector(-extent.Left, -extent.Top);
                PathCommandHelper.ReplacePathGeometry(pathElement1, pathGeometry2, editTransaction);
                Matrix transformToElement = pathElement.GetComputedTransformToElement((SceneElement)pathElement1);
                transformToElement.OffsetX += vector.X;
                transformToElement.OffsetY += vector.Y;
                PropertyReference propertyReference = PathCommandHelper.GetPathDataPropertyReference(pathElement.Platform);
                PathCommandHelper.TransferPathFigureAnimations(pathElement, pathElement1, propertyReference, oldFigureIndex, 0, (Transform) new MatrixTransform(transformToElement));
                PathCommandHelper.AdjustPathForAnimations(pathElement1, editTransaction);
                list.Add(pathElement1);
                ++oldFigureIndex;
            }
            string name = pathElement.Name;

            pathElement.ViewModel.ElementSelectionSet.RemoveSelection((SceneElement)pathElement);
            pathElement.ViewModel.AnimationEditor.DeleteAllAnimationsInSubtree((SceneElement)pathElement);
            pathElement.Remove();
            foreach (SceneNode sceneNode in list)
            {
                sceneNode.Name = name;
            }
            return(list);
        }
Exemple #3
0
        public static void MakeCompoundPath(PathElement mainElement, List <PathElement> otherElements, SceneEditTransaction editTransaction)
        {
            PathElement              pathElement       = otherElements[otherElements.Count - 1];
            ISceneElementCollection  elementCollection = (ISceneElementCollection) new SceneElementCollection();
            PathAnimationMovePackage animationMove     = new PathAnimationMovePackage();
            PathGeometry             pathGeometry      = new PathGeometry();

            System.Windows.Media.Geometry geometry1 = (System.Windows.Media.Geometry)mainElement.TransformedGeometry;
            pathGeometry.AddGeometry(geometry1);
            foreach (PathElement oldElement in otherElements)
            {
                System.Windows.Media.Geometry geometry2 = (System.Windows.Media.Geometry)oldElement.TransformedGeometry;
                Matrix    transformToElement            = oldElement.GetComputedTransformToElement((SceneElement)mainElement);
                bool      isIdentity = transformToElement.IsIdentity;
                Transform transform  = isIdentity ? Transform.Identity : (Transform) new MatrixTransform(transformToElement);
                transform.Freeze();
                if (!isIdentity)
                {
                    GeometryGroup geometryGroup = new GeometryGroup();
                    geometryGroup.Children.Add(geometry2);
                    geometryGroup.Transform = transform;
                    geometry2 = (System.Windows.Media.Geometry)geometryGroup;
                }
                int count = pathGeometry.Figures.Count;
                pathGeometry.AddGeometry(geometry2);
                int num = pathGeometry.Figures.Count - count;
                PropertyReference propertyReference = PathCommandHelper.GetPathDataPropertyReference(oldElement.Platform);
                for (int oldFigureIndex = 0; oldFigureIndex < num; ++oldFigureIndex)
                {
                    PathCommandHelper.TransferPathFigureAnimations(oldElement, mainElement, propertyReference, oldFigureIndex, count + oldFigureIndex, transform, animationMove);
                }
                elementCollection.Add((SceneElement)oldElement);
            }
            animationMove.Remove();
            Transform transform1 = PathCommandHelper.ReplacePathGeometry(mainElement, pathGeometry, editTransaction);

            animationMove.ApplyTransformToNewAnimations(transform1);
            animationMove.Add();
            PathCommandHelper.AdjustPathForAnimations(mainElement, editTransaction);
            foreach (SceneElement element in (IEnumerable <SceneElement>)elementCollection)
            {
                element.ViewModel.AnimationEditor.DeleteAllAnimationsInSubtree(element);
                element.ViewModel.RemoveElement((SceneNode)element);
            }
        }