Beispiel #1
0
        protected override object CreateTileBrush(BaseFrameworkElement element)
        {
            DocumentNode documentNode = (DocumentNode)element.ViewModel.Document.DocumentContext.CreateNode(PlatformTypes.VisualBrush);

            return(element.ViewModel.CreateInstance(new DocumentNodePath(documentNode, documentNode)));
        }
Beispiel #2
0
        protected override bool OnClickEnd(Point pointerPosition, int clickCount)
        {
            ElementLayoutLockAdorner layoutLockAdorner   = (ElementLayoutLockAdorner)this.ActiveAdorner;
            SceneDocument            activeDocument      = this.ActiveDocument;
            BaseFrameworkElement     element             = layoutLockAdorner.Element;
            ILayoutDesigner          designerForChild    = this.ActiveSceneViewModel.GetLayoutDesignerForChild((SceneElement)element, true);
            HorizontalAlignment      horizontalAlignment = (HorizontalAlignment)element.GetComputedValue(BaseFrameworkElement.HorizontalAlignmentProperty);
            VerticalAlignment        verticalAlignment   = (VerticalAlignment)element.GetComputedValue(BaseFrameworkElement.VerticalAlignmentProperty);

            using (SceneEditTransaction editTransaction = activeDocument.CreateEditTransaction(StringTable.UndoUnitToggleLayoutAdorner))
            {
                bool flag1 = Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift);
                if (layoutLockAdorner.IsX)
                {
                    bool flag2 = horizontalAlignment == HorizontalAlignment.Left || horizontalAlignment == HorizontalAlignment.Stretch;
                    bool flag3 = horizontalAlignment == HorizontalAlignment.Right || horizontalAlignment == HorizontalAlignment.Stretch;
                    if (layoutLockAdorner.Type == ElementLayoutAdornerType.Left)
                    {
                        flag2 = !flag2;
                        if (!flag2 && !flag3 && !flag1)
                        {
                            flag3 = true;
                        }
                    }
                    else
                    {
                        flag3 = !flag3;
                        if (!flag2 && !flag3 && !flag1)
                        {
                            flag2 = true;
                        }
                    }
                    HorizontalAlignment alignment = !flag2 ? (flag3 ? HorizontalAlignment.Right : HorizontalAlignment.Center) : (flag3 ? HorizontalAlignment.Stretch : HorizontalAlignment.Left);
                    if (alignment != horizontalAlignment)
                    {
                        designerForChild.SetHorizontalAlignment(element, alignment);
                    }
                }
                else
                {
                    bool flag2 = verticalAlignment == VerticalAlignment.Top || verticalAlignment == VerticalAlignment.Stretch;
                    bool flag3 = verticalAlignment == VerticalAlignment.Bottom || verticalAlignment == VerticalAlignment.Stretch;
                    if (layoutLockAdorner.Type == ElementLayoutAdornerType.Top)
                    {
                        flag2 = !flag2;
                        if (!flag2 && !flag3 && !flag1)
                        {
                            flag3 = true;
                        }
                    }
                    else
                    {
                        flag3 = !flag3;
                        if (!flag2 && !flag3 && !flag1)
                        {
                            flag2 = true;
                        }
                    }
                    VerticalAlignment alignment = !flag2 ? (flag3 ? VerticalAlignment.Bottom : VerticalAlignment.Center) : (flag3 ? VerticalAlignment.Stretch : VerticalAlignment.Top);
                    if (alignment != verticalAlignment)
                    {
                        designerForChild.SetVerticalAlignment(element, alignment);
                    }
                }
                editTransaction.Commit();
            }
            return(base.OnClickEnd(pointerPosition, clickCount));
        }
 public TextFlowInsertionPointAdornerSet(ToolBehaviorContext toolContext, BaseFrameworkElement adornedElement, TextFlowInsertionPoint insertionPoint)
     : base(toolContext, (SceneElement)adornedElement)
 {
     this.insertionPoint = insertionPoint;
 }
 public AccessTextEditProxy(BaseFrameworkElement textSource)
     : base(textSource)
 {
 }
Beispiel #5
0
 protected override void OnContinueDrag(BaseFrameworkElement hitElement)
 {
     this.MoveDraggedElementsInContainer();
 }
 public override void SetChildRect(BaseFrameworkElement child, Rect rect, LayoutOverrides layoutOverrides, LayoutOverrides overridesToIgnore, LayoutOverrides nonExplicitOverrides, SetRectMode setRectMode)
 {
     overridesToIgnore |= LayoutOverrides.Margin;
     base.SetChildRect(child, rect, layoutOverrides, overridesToIgnore, nonExplicitOverrides, setRectMode);
 }
Beispiel #7
0
 public FlowPanelInsertionPointAdornerSet(ToolBehaviorContext toolContext, BaseFrameworkElement adornedElement, FlowPanelInsertionPoint flowPanelInsertionPoint)
     : base(toolContext, (SceneElement)adornedElement)
 {
     this.flowPanelInsertionPoint = flowPanelInsertionPoint;
 }
Beispiel #8
0
 public virtual Rect GetChildRect(BaseFrameworkElement child)
 {
     return(child.ViewModel.DefaultView.GetActualBoundsInParent(child.Visual));
 }
Beispiel #9
0
 public void SetChildRect(BaseFrameworkElement child, Rect rect)
 {
     this.SetChildRect(child, this.PrepareLayoutRect(rect), LayoutOverrides.RecomputeDefault, LayoutOverrides.Width | LayoutOverrides.Height, LayoutOverrides.None, SetRectMode.Default);
 }
Beispiel #10
0
        public LayoutOverrides ComputeOverrides(BaseFrameworkElement element)
        {
            LayoutOperation layoutOperation = this.CreateLayoutOperation(element);

            return(this.InternalComputeOverrides(element, layoutOperation));
        }
Beispiel #11
0
 public LayoutConstraintMode GetHeightConstraintMode(BaseFrameworkElement parent, BaseFrameworkElement child)
 {
     return(this.GetHeightConstraintModeCore(parent == null ? (IViewVisual)null : parent.Visual as IViewVisual, child == null ? (IViewVisual)null : child.Visual as IViewVisual, child == null ? (parent == null ? (SceneView)null : parent.ViewModel.DefaultView) : child.ViewModel.DefaultView, false));
 }
 private static void SetElementRect(ILayoutDesigner layoutDesigner, BaseFrameworkElement element, Rect rect)
 {
     layoutDesigner.SetChildRect(element, rect, LayoutOverrides.HorizontalAlignment | LayoutOverrides.VerticalAlignment | LayoutOverrides.Width | LayoutOverrides.Height, LayoutOverrides.None, LayoutOverrides.None);
     element.ClearLocalValue(DesignTimeProperties.LayoutOverridesProperty);
 }
Beispiel #13
0
        private HashSet <SceneElement> PathPartDelete(SceneEditTransaction editTransaction)
        {
            HashSet <SceneElement> hashSet          = new HashSet <SceneElement>();
            PathPartSelectionSet   partSelectionSet = this.SceneViewModel.PathPartSelectionSet;
            Dictionary <PathEditMode, List <PathEditorTarget> > dictionary = new Dictionary <PathEditMode, List <PathEditorTarget> >();

            dictionary[PathEditMode.ClippingPath] = new List <PathEditorTarget>();
            dictionary[PathEditMode.ScenePath]    = new List <PathEditorTarget>();
            dictionary[PathEditMode.MotionPath]   = new List <PathEditorTarget>();
            Tool activeTool = this.SceneViewModel.DesignerContext.ToolManager.ActiveTool;

            if (activeTool != null)
            {
                foreach (PathPart pathPart in partSelectionSet.Selection)
                {
                    BaseFrameworkElement frameworkElement = pathPart.SceneElement as BaseFrameworkElement;
                    if (frameworkElement != null)
                    {
                        PathEditorTarget pathEditorTarget = activeTool.GetPathEditorTarget((Base2DElement)frameworkElement, pathPart.PathEditMode);
                        if (pathEditorTarget != null && !dictionary[pathPart.PathEditMode].Contains(pathEditorTarget))
                        {
                            dictionary[pathPart.PathEditMode].Add(pathEditorTarget);
                            hashSet.Add((SceneElement)frameworkElement);
                        }
                    }
                }
            }
            List <PathEditorTarget> list1 = new List <PathEditorTarget>();
            List <PathEditorTarget> list2 = new List <PathEditorTarget>();

            foreach (KeyValuePair <PathEditMode, List <PathEditorTarget> > keyValuePair in dictionary)
            {
                foreach (PathEditorTarget pathEditorTarget in keyValuePair.Value)
                {
                    pathEditorTarget.BeginEditing();
                    int count1 = pathEditorTarget.PathGeometry.Figures.Count;
                    ICollection <PathPart> selectionByElement = partSelectionSet.GetSelectionByElement((SceneElement)pathEditorTarget.EditingElement, keyValuePair.Key);
                    new DeleteCommand.SelectedComponentsRemover(pathEditorTarget).Execute(selectionByElement);
                    pathEditorTarget.EndEditing(false);
                    pathEditorTarget.PostDeleteAction();
                    if (keyValuePair.Key == PathEditMode.ScenePath)
                    {
                        if (!PathGeometryUtilities.IsEmpty(pathEditorTarget.PathGeometry))
                        {
                            PathElement pathElement = (PathElement)pathEditorTarget.EditingElement;
                            int         count2      = pathElement.PathGeometry.Figures.Count;
                            if (count1 == 1 && count2 > 1)
                            {
                                ISceneNodeCollection <SceneNode> collectionContainer = pathElement.GetCollectionContainer();
                                if (!collectionContainer.FixedCapacity.HasValue || collectionContainer.FixedCapacity.Value >= collectionContainer.Count - 1 + count2)
                                {
                                    list2.Add(pathEditorTarget);
                                }
                            }
                        }
                        else
                        {
                            list1.Add(pathEditorTarget);
                        }
                    }
                    pathEditorTarget.AddCriticalEdit();
                }
            }
            List <SceneElement> list3 = new List <SceneElement>();

            foreach (PathEditorTarget pathEditorTarget in list2)
            {
                PathElement pathElement1 = (PathElement)pathEditorTarget.EditingElement;
                using (this.SceneView.AdornerLayer.SuspendUpdates())
                {
                    this.SceneView.UpdateLayout();
                    foreach (PathElement pathElement2 in PathCommandHelper.ReleaseCompoundPaths(pathElement1, editTransaction))
                    {
                        list3.Add((SceneElement)pathElement2);
                    }
                }
            }
            foreach (PathEditorTarget pathEditorTarget in list1)
            {
                pathEditorTarget.RemovePath();
            }
            partSelectionSet.Clear();
            this.SceneViewModel.ElementSelectionSet.ExtendSelection((ICollection <SceneElement>)list3);
            foreach (SceneElement sceneElement in list3)
            {
                hashSet.Add(sceneElement);
            }
            return(hashSet);
        }
 public CenterPointAdornerSet(ToolBehaviorContext toolContext, BaseFrameworkElement adornedElement)
     : base(toolContext, (SceneElement)adornedElement)
 {
 }
 public DockPanelLayoutAdornerSet(ToolBehaviorContext toolContext, BaseFrameworkElement adornedElement)
     : base(toolContext, (SceneElement)adornedElement)
 {
 }
Beispiel #16
0
        public void SetChildRect(BaseFrameworkElement child, Rect rect, bool setWidth, bool setHeight)
        {
            LayoutOverrides overridesToIgnore = (LayoutOverrides)(0 | (setWidth ? 16 : 0) | (setHeight ? 32 : 0));

            this.SetChildRect(child, this.PrepareLayoutRect(rect), LayoutOverrides.RecomputeDefault, overridesToIgnore, LayoutOverrides.None, SetRectMode.Default);
        }
 protected override LayoutOperation CreateLayoutOperation(BaseFrameworkElement child)
 {
     return((LayoutOperation) new CanvasLayoutOperation((ILayoutDesigner)this, child));
 }
Beispiel #18
0
 public void SetChildRect(BaseFrameworkElement child, Rect rect, LayoutOverrides layoutOverrides, LayoutOverrides overridesToIgnore, LayoutOverrides nonExplicitOverrides)
 {
     this.SetChildRect(child, rect, layoutOverrides, overridesToIgnore, nonExplicitOverrides, SetRectMode.Default);
 }
Beispiel #19
0
 protected override double GetActualSize(BaseFrameworkElement element)
 {
     return(element.GetComputedTightBounds().Height);
 }
Beispiel #20
0
 protected virtual LayoutOperation CreateLayoutOperation(BaseFrameworkElement child)
 {
     return(new LayoutOperation((ILayoutDesigner)this, child));
 }
 public MotionPathAdornerSet(ToolBehaviorContext toolContext, BaseFrameworkElement adornedElement)
     : base(toolContext, (SceneElement)adornedElement)
 {
 }
Beispiel #22
0
        public void Start(ToolBehaviorContext toolContext, BaseFrameworkElement targetElement, IList <BaseFrameworkElement> ignoredElements)
        {
            if (this.IsStarted)
            {
                this.Stop();
            }
            this.toolContext = toolContext;
            if (this.toolContext.View.ViewModel.UsingEffectDesigner)
            {
                return;
            }
            this.container     = (Base2DElement)null;
            this.targetElement = (SceneElement)targetElement;
            if (targetElement == null)
            {
                ISceneInsertionPoint sceneInsertionPoint = this.toolContext.View.ViewModel.ActiveSceneInsertionPoint;
                if (sceneInsertionPoint != null)
                {
                    this.container = sceneInsertionPoint.SceneElement as Base2DElement;
                }
            }
            else if (!this.IsTransformed((SceneElement)targetElement))
            {
                this.container = targetElement.ParentElement as Base2DElement;
            }
            ILayoutDesigner layoutDesigner = targetElement == null?this.toolContext.View.ViewModel.GetLayoutDesignerForParent((SceneElement)this.container, true) : this.toolContext.View.ViewModel.GetLayoutDesignerForChild(this.targetElement, true);

            BaseFrameworkElement parent = this.container as BaseFrameworkElement;
            bool leftRight = layoutDesigner.GetWidthConstraintMode(parent, targetElement) != LayoutConstraintMode.CanvasLike;
            bool topBottom = layoutDesigner.GetHeightConstraintMode(parent, targetElement) != LayoutConstraintMode.CanvasLike;

            if (!leftRight && !topBottom)
            {
                this.container = (Base2DElement)null;
            }
            if (this.container == null)
            {
                return;
            }
            this.snapLineRenderer.Attach(toolContext, (SceneElement)this.container);
            Rect actualBounds = this.toolContext.View.GetActualBounds(this.container.ViewObject);

            this.AddSnapLines(actualBounds, true, leftRight, topBottom);
            GridElement gridElement = this.container as GridElement;

            if (gridElement != null)
            {
                double x = 0.0;
                foreach (ColumnDefinitionNode columnDefinitionNode in (IEnumerable <ColumnDefinitionNode>)gridElement.ColumnDefinitions)
                {
                    x += columnDefinitionNode.ComputedWidth;
                    Point p1 = new Point(x, actualBounds.Top);
                    Point p2 = new Point(x, actualBounds.Bottom);
                    this.snapLines.Add(new SnapLine(p1, p2, SnapLineOrientation.Vertical, SnapLineLocation.Minimum, true));
                    this.snapLines.Add(new SnapLine(p1, p2, SnapLineOrientation.Vertical, SnapLineLocation.Maximum, true));
                }
                double y = 0.0;
                foreach (RowDefinitionNode rowDefinitionNode in (IEnumerable <RowDefinitionNode>)gridElement.RowDefinitions)
                {
                    y += rowDefinitionNode.ComputedHeight;
                    Point p1 = new Point(actualBounds.Left, y);
                    Point p2 = new Point(actualBounds.Right, y);
                    this.snapLines.Add(new SnapLine(p1, p2, SnapLineOrientation.Horizontal, SnapLineLocation.Minimum, true));
                    this.snapLines.Add(new SnapLine(p1, p2, SnapLineOrientation.Horizontal, SnapLineLocation.Maximum, true));
                }
            }
            if (!(this.container is PanelElement))
            {
                return;
            }
            foreach (SceneNode sceneNode in (IEnumerable <SceneNode>)((PanelElement)this.container).Children)
            {
                BaseFrameworkElement frameworkElement = sceneNode as BaseFrameworkElement;
                if (frameworkElement != null && frameworkElement != targetElement && frameworkElement.IsViewObjectValid && ((ignoredElements == null || !ignoredElements.Contains(frameworkElement)) && !this.IsTransformed((SceneElement)frameworkElement)))
                {
                    Rect actualBoundsInParent = this.toolContext.View.GetActualBoundsInParent(frameworkElement.ViewObject);
                    this.AddSnapLines(actualBoundsInParent, false, leftRight, topBottom);
                    double baseline = this.toolContext.View.GetBaseline((SceneNode)frameworkElement);
                    if (!double.IsNaN(baseline))
                    {
                        this.snapLines.Add(new SnapLine(new Point(actualBoundsInParent.Left, actualBoundsInParent.Top + baseline), new Point(actualBoundsInParent.Right, actualBoundsInParent.Top + baseline), SnapLineOrientation.Horizontal, SnapLineLocation.Baseline, false));
                    }
                }
            }
        }
 public GridRowColumnAdornerSet(ToolBehaviorContext toolContext, BaseFrameworkElement adornedElement)
     : base(toolContext, adornedElement)
 {
 }
Beispiel #24
0
 protected abstract IAdornerSet CreateRectangleGeometryAdornerSet(ToolBehaviorContext toolContext, BaseFrameworkElement element);
Beispiel #25
0
 protected TextEditProxy(BaseFrameworkElement textSource)
 {
     this.textSource = textSource;
 }
Beispiel #26
0
        public override void Execute(object arg)
        {
            ITypeId type = this.Type;

            if (type is ProjectNeutralTypeId && !this.SceneViewModel.ProjectContext.PlatformMetadata.IsSupported((ITypeResolver)this.SceneViewModel.ProjectContext, type))
            {
                return;
            }
            using (SceneEditTransaction editTransaction = this.DesignerContext.ActiveDocument.CreateEditTransaction(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.UndoUnitLayoutPaneChangeLayoutType, new object[1]
            {
                (object)this.Type.Name
            })))
            {
                bool           flag1 = false;
                SceneViewModel activeSceneViewModel         = this.DesignerContext.ActiveSceneViewModel;
                ReadOnlyCollection <SceneElement> selection = this.DesignerContext.SelectionManager.ElementSelectionSet.Selection;
                SceneElement        primarySelection1       = this.DesignerContext.SelectionManager.ElementSelectionSet.PrimarySelection;
                List <SceneElement> list                 = new List <SceneElement>();
                bool                 flag2               = false;
                bool                 flag3               = false;
                bool                 flag4               = false;
                SceneElement         sceneElement1       = (SceneElement)null;
                IStoryboardContainer storyboardContainer = (IStoryboardContainer)null;
                SceneElement         primarySelection2   = (SceneElement)null;
                this.DesignerContext.SelectionManager.ElementSelectionSet.Clear();
                List <SceneElement> elements = new List <SceneElement>();
                elements.AddRange((IEnumerable <SceneElement>)selection);
                ElementUtilities.SortElementsByDepth(elements);
                foreach (SceneElement sceneElement2 in elements)
                {
                    ITypeId typeId1 = (ITypeId)null;
                    foreach (ITypeId typeId2 in ChangeLayoutTypeFlyoutCommand.LayoutTypes)
                    {
                        if (typeId2.IsAssignableFrom((ITypeId)sceneElement2.Type))
                        {
                            typeId1 = typeId2;
                            break;
                        }
                    }
                    if (typeId1 == null)
                    {
                        list.Add(sceneElement2);
                    }
                    else
                    {
                        if (activeSceneViewModel.LockedInsertionPoint != null)
                        {
                            if (activeSceneViewModel.LockedInsertionPoint.SceneElement == sceneElement2)
                            {
                                flag2 = true;
                            }
                            else if (sceneElement2.IsAncestorOf((SceneNode)activeSceneViewModel.ActiveSceneInsertionPoint.SceneElement))
                            {
                                sceneElement1 = activeSceneViewModel.ActiveSceneInsertionPoint.SceneElement;
                                flag2         = true;
                            }
                        }
                        if (primarySelection1 == sceneElement2)
                        {
                            flag4 = true;
                        }
                        if (!flag3 && activeSceneViewModel.ActiveStoryboardContainer == sceneElement2)
                        {
                            activeSceneViewModel.SetActiveStoryboardTimeline((IStoryboardContainer)null, (StoryboardTimelineSceneNode)null, (TriggerBaseNode)null);
                            flag3 = true;
                        }
                        using (sceneElement2.ViewModel.ForceBaseValue())
                        {
                            BaseFrameworkElement     parent1           = sceneElement2 as BaseFrameworkElement;
                            List <LayoutCacheRecord> layoutCache       = (List <LayoutCacheRecord>)null;
                            ILayoutDesigner          designerForParent = activeSceneViewModel.GetLayoutDesignerForParent(sceneElement2, true);
                            if (parent1 != null)
                            {
                                layoutCache = designerForParent.GetCurrentRects(parent1);
                            }
                            SceneElement elementContainingChildren = (SceneElement)null;
                            SceneElement sceneElement3             = ChangeLayoutTypeCommand.ChangeLayoutType(sceneElement2, type, ref elementContainingChildren);
                            editTransaction.Update();
                            if (sceneElement3.IsViewObjectValid)
                            {
                                this.SceneViewModel.DefaultView.UpdateLayout();
                                BaseFrameworkElement parent2 = elementContainingChildren as BaseFrameworkElement;
                                if (parent2 != null && parent2.IsViewObjectValid && layoutCache != null)
                                {
                                    activeSceneViewModel.GetLayoutDesignerForParent(elementContainingChildren, true).SetCurrentRects(parent2, layoutCache);
                                }
                                if (flag2 && sceneElement1 == null)
                                {
                                    sceneElement1 = elementContainingChildren;
                                }
                                if (flag3 && storyboardContainer == null)
                                {
                                    storyboardContainer = (IStoryboardContainer)sceneElement3;
                                }
                                if (flag4 && primarySelection2 == null)
                                {
                                    primarySelection2 = sceneElement3;
                                }
                                list.Add(sceneElement3);
                            }
                            flag1 = true;
                        }
                    }
                }
                if (flag2 && sceneElement1 != null)
                {
                    activeSceneViewModel.SetLockedInsertionPoint(sceneElement1);
                }
                if (flag3 && storyboardContainer != null)
                {
                    activeSceneViewModel.SetActiveStoryboardTimeline(storyboardContainer, (StoryboardTimelineSceneNode)null, (TriggerBaseNode)null);
                }
                this.DesignerContext.SelectionManager.ElementSelectionSet.SetSelection((ICollection <SceneElement>)list, primarySelection2);
                if (flag1)
                {
                    editTransaction.Commit();
                }
                else
                {
                    editTransaction.Cancel();
                }
            }
        }
 public FlowDocumentEditProxy(BaseFrameworkElement textSource)
     : base(textSource)
 {
 }
        public override void Execute()
        {
            BaseFrameworkElement selectedElement = this.SelectedElement;

            if (selectedElement == null)
            {
                return;
            }
            IType type1 = this.SceneViewModel.ProjectContext.ResolveType(PlatformTypes.Style);

            CreateResourceModel.ContextFlags contextFlags = this.SceneViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.SupportsImplicitStyles) ? CreateResourceModel.ContextFlags.CanApplyAutomatically : CreateResourceModel.ContextFlags.None;
            if (this.SceneViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.SupportsImplicitStyles))
            {
                contextFlags = CreateResourceModel.ContextFlags.CanApplyAutomatically;
            }
            CreateResourceModel createResourceModel = new CreateResourceModel(this.SceneViewModel, this.DesignerContext.ResourceManager, type1.RuntimeType, this.DefaultContainerType.RuntimeType, PlatformTypes.Style.Name, (SceneElement)null, (SceneNode)selectedElement, contextFlags);

            if (this.ShowUI)
            {
                bool?nullable = this.CreateDialog(createResourceModel).ShowDialog();
                if ((!nullable.GetValueOrDefault() ? 1 : (!nullable.HasValue ? true : false)) != 0)
                {
                    return;
                }
            }
            using (this.SceneViewModel.DisableUpdateChildrenOnAddAndRemove())
            {
                using (SceneEditTransaction editTransaction1 = this.SceneViewModel.CreateEditTransaction(this.UndoString, false))
                {
                    using (this.SceneViewModel.ForceBaseValue())
                    {
                        using (this.SceneViewModel.DisableDrawIntoState())
                        {
                            this.SceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree((SceneElement)selectedElement);
                            this.SceneViewModel.ElementSelectionSet.Clear();
                            IDocumentContext documentContext = this.SceneViewModel.Document.DocumentContext;
                            IProjectContext  projectContext  = this.SceneViewModel.Document.ProjectContext;
                            Type             type2           = (Type)null;
                            if (createResourceModel.TargetTypeAsset != null && createResourceModel.TargetTypeAsset.EnsureTypeReferenced(this.SceneViewModel.ProjectContext as ProjectContext))
                            {
                                type2 = createResourceModel.TargetTypeAsset.Type.RuntimeType;
                            }
                            if (type2 == (Type)null)
                            {
                                type2 = createResourceModel.TargetType;
                            }
                            IType type3 = projectContext.GetType(type2);
                            DocumentCompositeNode documentCompositeNode1 = (DocumentCompositeNode)selectedElement.DocumentNode;
                            this.SceneViewModel.GetLayoutDesignerForChild((SceneElement)selectedElement, true).ClearUnusedLayoutProperties(selectedElement);
                            DocumentCompositeNode visualTreeNode            = documentContext.CreateNode((ITypeId)documentCompositeNode1.Type);
                            Dictionary <IProperty, DocumentNode> dictionary = new Dictionary <IProperty, DocumentNode>();
                            bool addRenderTransforms = false;
                            foreach (IPropertyId propertyId in this.GetLayoutProperties((SceneElement)selectedElement, addRenderTransforms))
                            {
                                IProperty property = this.DesignerContext.ActiveSceneViewModel.ProjectContext.ResolveProperty(propertyId);
                                if (property != null && documentCompositeNode1.Properties.Contains(property))
                                {
                                    dictionary.Add(property, documentCompositeNode1.Properties[(IPropertyId)property].Clone(documentContext));
                                    documentCompositeNode1.ClearValue((IPropertyId)property);
                                }
                            }
                            foreach (KeyValuePair <IProperty, DocumentNode> keyValuePair in (IEnumerable <KeyValuePair <IProperty, DocumentNode> >)documentCompositeNode1.Properties)
                            {
                                IPropertyId index = (IPropertyId)keyValuePair.Key;
                                DependencyPropertyReferenceStep propertyReferenceStep = index as DependencyPropertyReferenceStep;
                                if ((propertyReferenceStep == null || !propertyReferenceStep.IsAttachable || propertyReferenceStep.MemberType == MemberType.DesignTimeProperty) && (!index.Equals((object)BaseFrameworkElement.WidthProperty) && !index.Equals((object)BaseFrameworkElement.HeightProperty)))
                                {
                                    visualTreeNode.Properties[index] = keyValuePair.Value.Clone(documentContext);
                                }
                            }
                            if (documentCompositeNode1.SupportsChildren)
                            {
                                foreach (DocumentNode documentNode in (IEnumerable <DocumentNode>)documentCompositeNode1.Children)
                                {
                                    visualTreeNode.Children.Add(documentNode.Clone(documentContext));
                                }
                            }
                            if (!PlatformTypes.Panel.IsAssignableFrom((ITypeId)documentCompositeNode1.Type))
                            {
                                GridElement gridElement = (GridElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.Grid);
                                SceneNode   sceneNode   = this.SceneViewModel.GetSceneNode((DocumentNode)visualTreeNode);
                                gridElement.Children.Add(sceneNode);
                                visualTreeNode = (DocumentCompositeNode)gridElement.DocumentNode;
                            }
                            StyleNode styleNode = (StyleNode)this.SceneViewModel.CreateSceneNode(PlatformTypes.Style);
                            styleNode.StyleTargetTypeId = type3;
                            SetterSceneNode setterSceneNode = (SetterSceneNode)this.SceneViewModel.CreateSceneNode(PlatformTypes.Setter);
                            DependencyPropertyReferenceStep propertyReferenceStep1 = (DependencyPropertyReferenceStep)this.SceneViewModel.ProjectContext.ResolveProperty(ControlElement.TemplateProperty);
                            setterSceneNode.Property = propertyReferenceStep1;
                            BaseFrameworkElement  frameworkElement       = (BaseFrameworkElement)this.SceneViewModel.CreateSceneNode(type2);
                            DocumentCompositeNode documentCompositeNode2 = (DocumentCompositeNode)frameworkElement.DocumentNode;
                            this.AddPresenterIfNecessary(visualTreeNode, (SceneElement)frameworkElement);
                            ControlTemplateElement controlTemplateElement = (ControlTemplateElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.ControlTemplate);
                            controlTemplateElement.ControlTemplateTargetTypeId = (ITypeId)type3;
                            controlTemplateElement.DefaultInsertionPoint.Insert(this.SceneViewModel.GetSceneNode((DocumentNode)visualTreeNode));
                            if (PlatformTypes.Button.Equals((object)type3) && controlTemplateElement.CanEditTriggers && this.SceneViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf))
                            {
                                DocumentCompositeNode node = documentContext.CreateNode(typeof(TriggerCollection));
                                node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, ButtonProperties.IsFocusedProperty, (object)true));
                                node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, ButtonProperties.IsDefaultedProperty, (object)true));
                                node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, BaseFrameworkElement.IsMouseOverProperty, (object)true));
                                node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, ButtonProperties.IsPressedProperty, (object)true));
                                node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, BaseFrameworkElement.IsEnabledProperty, (object)false));
                                controlTemplateElement.SetLocalValue(ControlTemplateElement.ControlTemplateTriggersProperty, (DocumentNode)node);
                            }
                            setterSceneNode.SetValueAsSceneNode(SetterSceneNode.ValueProperty, (SceneNode)controlTemplateElement);
                            styleNode.Setters.Add((SceneNode)setterSceneNode);
                            bool useStaticResource = !JoltHelper.TypeSupported((ITypeResolver)this.SceneViewModel.ProjectContext, PlatformTypes.DynamicResource);
                            int  index1            = -1;
                            if (useStaticResource && selectedElement.DocumentContext == createResourceModel.CurrentResourceSite.DocumentContext)
                            {
                                index1 = createResourceModel.IndexInResourceSite(selectedElement.DocumentNode);
                            }
                            IList <DocumentCompositeNode> referencedResources = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.FindReferencedResources((DocumentNode)documentCompositeNode1);
                            foreach (KeyValuePair <IProperty, DocumentNode> keyValuePair in dictionary)
                            {
                                documentCompositeNode2.Properties[(IPropertyId)keyValuePair.Key] = keyValuePair.Value;
                            }
                            IList <SceneNode> nodes = (IList <SceneNode>) new List <SceneNode>();
                            nodes.Add((SceneNode)frameworkElement);
                            SceneNode parent           = selectedElement.Parent;
                            IProperty propertyForChild = parent.GetPropertyForChild((SceneNode)selectedElement);
                            ISceneNodeCollection <SceneNode> collectionForProperty = parent.GetCollectionForProperty((IPropertyId)propertyForChild);
                            int index2 = collectionForProperty.IndexOf((SceneNode)selectedElement);
                            collectionForProperty[index2] = (SceneNode)frameworkElement;
                            if (createResourceModel.SelectedResourceDictionary != null)
                            {
                                ResourceContainer instance = createResourceModel.SelectedResourceDictionary.Instance;
                                if (instance != null && instance.DocumentNode == documentCompositeNode1)
                                {
                                    createResourceModel = new CreateResourceModel(this.SceneViewModel, this.DesignerContext.ResourceManager, type1.RuntimeType, type2, PlatformTypes.Style.Name, (SceneElement)frameworkElement, (SceneNode)null, contextFlags);
                                }
                            }
                            if (createResourceModel.CurrentResourceSite != null && !PlatformTypes.PlatformsCompatible(createResourceModel.CurrentResourceSite.DocumentContext.TypeResolver.PlatformMetadata, styleNode.DocumentNode.PlatformMetadata))
                            {
                                editTransaction1.Cancel();
                                return;
                            }
                            DocumentCompositeNode resource = createResourceModel.CreateResource(styleNode.DocumentNode, StyleNode.TargetTypeProperty, index1);
                            if (resource == null)
                            {
                                editTransaction1.Cancel();
                                return;
                            }
                            DocumentNode            resourceReference = createResourceModel.CreateResourceReference(this.SceneViewModel.Document.DocumentContext, resource, useStaticResource);
                            DefaultTypeInstantiator typeInstantiator  = new DefaultTypeInstantiator(this.SceneView);
                            if (resourceReference != null)
                            {
                                documentCompositeNode2.Properties[BaseFrameworkElement.StyleProperty] = resourceReference;
                            }
                            foreach (KeyValuePair <IProperty, DocumentNode> keyValuePair in (IEnumerable <KeyValuePair <IProperty, DocumentNode> >)documentCompositeNode1.Properties)
                            {
                                IPropertyId index3 = (IPropertyId)keyValuePair.Key;
                                DependencyPropertyReferenceStep propertyReferenceStep2 = index3 as DependencyPropertyReferenceStep;
                                if (propertyReferenceStep2 != null && propertyReferenceStep2.IsAttachable && propertyReferenceStep2.MemberType != MemberType.DesignTimeProperty)
                                {
                                    documentCompositeNode2.Properties[index3] = keyValuePair.Value.Clone(documentContext);
                                }
                            }
                            DocumentCompositeNode hostNode  = createResourceModel.CurrentResourceSite.HostNode;
                            SceneViewModel        viewModel = this.SceneViewModel.GetViewModel(hostNode.DocumentRoot, false);
                            using (SceneEditTransaction editTransaction2 = viewModel.CreateEditTransaction(this.UndoString))
                            {
                                Microsoft.Expression.DesignSurface.Utility.ResourceHelper.CopyResourcesToNewResourceSite(referencedResources, viewModel, hostNode, resource, createResourceModel.IndexInResourceSite((DocumentNode)resource));
                                editTransaction2.Commit();
                            }
                            editTransaction1.Update();
                            if (this.SceneView.IsValid)
                            {
                                typeInstantiator.ApplyAfterInsertionDefaultsToElements(nodes, (SceneNode)null);
                            }
                            this.SceneView.CandidateEditingContainer = frameworkElement.DocumentNodePath;
                            editTransaction1.Update();
                            this.SceneViewModel.ElementSelectionSet.ExtendSelection((SceneElement)frameworkElement);
                            this.PostProcessing((SceneNode)selectedElement, (SceneNode)frameworkElement, resource);
                            if (frameworkElement.GetComputedValue(ControlElement.TemplateProperty) != null)
                            {
                                this.ActivateTemplateEditingMode((SceneElement)frameworkElement);
                            }
                            else
                            {
                                UIThreadDispatcherHelper.BeginInvoke(DispatcherPriority.ApplicationIdle, (Delegate) new Action <SceneElement>(this.ActivateTemplateEditingMode), (object)frameworkElement);
                            }
                            this.SceneView.CandidateEditingContainer = (DocumentNodePath)null;
                        }
                        editTransaction1.Commit();
                    }
                }
            }
        }
 protected TextBoxEditProxyBase(BaseFrameworkElement textSource)
     : base(textSource)
 {
     this.ProxyPlatform = textSource.DesignerContext.DesignerDefaultPlatformService.DefaultPlatform;
     this.textBox       = this.ProxyPlatform.ViewTextObjectFactory.CreateTextBox();
 }
 protected override void OnContinueDrag(BaseFrameworkElement hitElement)
 {
     this.MoveDraggedElementsWithTempTransform();
 }