private void ReleaseClippingPath(SceneElement sceneElement, SceneEditTransaction editTransaction)
        {
            if (sceneElement.IsSet(Base2DElement.ClipProperty) != PropertyState.Set)
            {
                return;
            }
            SceneNode sceneNode = (SceneNode)sceneElement;

            for (SceneNode parent = sceneElement.Parent; parent != null; parent = parent.Parent)
            {
                PanelElement panelElement = parent as PanelElement;
                if (panelElement != null)
                {
                    MatrixTransform matrixTransform        = new MatrixTransform(sceneElement.GetComputedTransformToElement((SceneElement)panelElement));
                    PathGeometry    pathGeometry1          = new PathGeometry();
                    System.Windows.Media.Geometry geometry = (System.Windows.Media.Geometry)sceneElement.GetLocalOrDefaultValueAsWpf(Base2DElement.ClipProperty);
                    if (geometry != null)
                    {
                        pathGeometry1 = PathGeometryUtilities.TransformGeometry(geometry, (Transform)matrixTransform);
                    }
                    PathElement pathElement = (PathElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.Path);
                    using (pathElement.ViewModel.ForceBaseValue())
                    {
                        this.DesignerContext.AmbientPropertyManager.ApplyAmbientProperties((SceneNode)pathElement);
                        pathElement.SetValueAsWpf(ShapeElement.StrokeProperty, (object)Brushes.Black);
                        pathElement.ClearValue(ShapeElement.FillProperty);
                        pathElement.ClearValue(ShapeElement.StrokeThicknessProperty);
                        panelElement.Children.Insert(panelElement.Children.IndexOf(sceneNode) + 1, (SceneNode)pathElement);
                        ReferenceStep singleStep1 = (ReferenceStep)pathElement.ProjectContext.ResolveProperty(Base2DElement.ClipProperty);
                        ReferenceStep singleStep2 = (ReferenceStep)pathElement.ProjectContext.ResolveProperty(PathElement.DataProperty);
                        PathCommandHelper.MoveVertexAnimations(sceneElement, new PropertyReference(singleStep1), (SceneElement)pathElement, new PropertyReference(singleStep2), (Transform)matrixTransform);
                        Rect bounds            = PathCommandHelper.InflateRectByStrokeWidth(pathGeometry1.Bounds, pathElement, false);
                        Rect maxAnimatedExtent = PathCommandHelper.FindMaxAnimatedExtent((SceneElement)pathElement, bounds, new PropertyReference(singleStep2));
                        editTransaction.Update();
                        Vector vector = new Vector(-maxAnimatedExtent.Left, -maxAnimatedExtent.Top);
                        panelElement.LayoutDesigner.SetChildRect((BaseFrameworkElement)pathElement, maxAnimatedExtent);
                        Transform    transform     = (Transform) new TranslateTransform(vector.X, vector.Y);
                        PathGeometry pathGeometry2 = PathGeometryUtilities.TransformGeometry((System.Windows.Media.Geometry)pathGeometry1, transform);
                        pathElement.PathGeometry = pathGeometry2;
                        PathCommandHelper.TransformPointKeyframes((SceneElement)pathElement, new PropertyReference(singleStep2), transform);
                        pathElement.SetValueAsWpf(ShapeElement.StretchProperty, (object)(Stretch)(pathElement.HasVertexAnimations ? 0 : 1));
                        break;
                    }
                }
                else
                {
                    sceneNode = parent;
                }
            }
        }
        public override void Execute()
        {
            AnimationEditor      animationEditor  = this.SceneViewModel.AnimationEditor;
            SceneElement         pathTarget       = this.GetPathTarget(this.SceneViewModel.ElementSelectionSet);
            BaseFrameworkElement frameworkElement = (BaseFrameworkElement)this.GetAnimationTarget(this.SceneViewModel.ElementSelectionSet);

            if (frameworkElement == null)
            {
                SceneElement root = this.SceneViewModel.ActiveEditingContainer as SceneElement;
                if (root != null)
                {
                    frameworkElement = PathTargetDialog.ChooseMotionPathTarget(root, pathTarget);
                }
            }
            if (frameworkElement == null)
            {
                return;
            }
            PathGeometry geometry = PathConversionHelper.ConvertToPathGeometry(pathTarget);

            if (PathGeometryUtilities.TotalSegmentCount(geometry) == 0)
            {
                this.DesignerContext.MessageDisplayService.ShowError(StringTable.ConvertToMotionPathNoSegmentsMessage);
            }
            else
            {
                using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(StringTable.ConvertToMotionPathUndo, false))
                {
                    StoryboardTimelineSceneNode targetTimeline = this.GetTargetTimeline();
                    if (targetTimeline == null)
                    {
                        this.SceneViewModel.AnimationEditor.CreateNewTimeline(TriggerCreateBehavior.Default);
                    }
                    else if (targetTimeline != this.SceneViewModel.ActiveStoryboardTimeline)
                    {
                        this.SceneViewModel.SetActiveStoryboardTimeline(targetTimeline.StoryboardContainer, targetTimeline, (TriggerBaseNode)null);
                    }
                    this.SceneViewModel.ElementSelectionSet.Clear();
                    Point        elementCoordinates = frameworkElement.RenderTransformOriginInElementCoordinates;
                    Matrix       matrix             = new TranslateTransform(-elementCoordinates.X, -elementCoordinates.Y).Value;
                    Transform    transform          = (Transform) new MatrixTransform(pathTarget.GetComputedTransformToElement((SceneElement)frameworkElement) * frameworkElement.GetEffectiveRenderTransform(false) * matrix);
                    PathGeometry path          = PathGeometryUtilities.TransformGeometry((System.Windows.Media.Geometry)geometry, transform);
                    double       animationTime = animationEditor.AnimationTime;
                    animationEditor.SetMotionPath((SceneElement)frameworkElement, path, new double?(animationTime), new double?(animationTime + 2.0));
                    this.SceneViewModel.ElementSelectionSet.SetSelection((SceneElement)frameworkElement);
                    editTransaction.Commit();
                }
            }
        }
        private Transform GetGeometryTransform(SceneElement clipper, SceneElement elementToBeClipped)
        {
            Transform identity = Transform.Identity;

            return(elementToBeClipped == null?clipper.GetComputedValueAsWpf(Base2DElement.RenderTransformProperty) as Transform : (Transform) new MatrixTransform(clipper.GetComputedTransformToElement(elementToBeClipped)));
        }