private void ApplyChanges(SceneDocument sceneDocument)
        {
            List <DocumentCompositeNode> list = new List <DocumentCompositeNode>();

            for (int index = this.documentNodesToModify.Count - 1; index >= 0; --index)
            {
                DocumentCompositeNode documentCompositeNode = this.documentNodesToModify[index];
                if (documentCompositeNode.DocumentRoot == this.CurrentDocument.DocumentRoot)
                {
                    list.Add(documentCompositeNode);
                    this.documentNodesToModify.RemoveAt(index);
                }
            }
            if (this.IsKilled || list.Count == 0)
            {
                return;
            }
            SceneView sceneView   = this.GetSceneView(sceneDocument);
            string    description = string.Format((IFormatProvider)CultureInfo.CurrentCulture, this.SampleData.IsEnabledAtRuntime ? StringTable.SampleDataEnableTransaction : StringTable.SampleDataDisableTransaction, new object[1]
            {
                (object)this.SampleData.Name
            });

            using (SceneEditTransaction editTransaction = sceneDocument.CreateEditTransaction(description))
            {
                using (sceneView.ViewModel.AnimationEditor.DeferKeyFraming())
                {
                    foreach (DocumentCompositeNode documentCompositeNode in list)
                    {
                        IProperty    dataContextProperty = DataContextHelper.GetDataContextProperty(documentCompositeNode.Type);
                        IProperty    property            = DesignTimeProperties.ResolveDesignTimePropertyKey(DesignTimeProperties.DesignDataContextProperty, documentCompositeNode.PlatformMetadata);
                        DocumentNode documentNode1       = documentCompositeNode.Properties[(IPropertyId)dataContextProperty];
                        DocumentNode documentNode2       = documentCompositeNode.Properties[(IPropertyId)property];
                        SceneNode    sceneNode           = sceneView.ViewModel.GetSceneNode((DocumentNode)documentCompositeNode);
                        if (documentNode2 == null)
                        {
                            sceneNode.ClearValue((IPropertyId)dataContextProperty);
                        }
                        else
                        {
                            sceneNode.SetValue((IPropertyId)dataContextProperty, (object)documentNode2);
                        }
                        if (documentNode1 == null)
                        {
                            sceneNode.ClearValue((IPropertyId)property);
                        }
                        else
                        {
                            sceneNode.SetValue((IPropertyId)property, (object)documentNode1);
                        }
                    }
                    editTransaction.Commit();
                }
            }
        }
Exemplo n.º 2
0
        private BehaviorTriggerBaseNode FindExistingTriggerMatchingPropertyChange(PropertyReference propertyReference, object newValue, Modification modification)
        {
            SceneNode sceneNode = this.ViewModel.GetSceneNode(this.ParentTrigger.DocumentNode.Clone(this.DocumentContext));

            switch (modification)
            {
            case Modification.SetValue:
                sceneNode.SetValue(propertyReference, newValue);
                break;

            case Modification.ClearValue:
                sceneNode.ClearValue(propertyReference);
                break;
            }
            return(this.FindExistingTriggerMatchingDocumentNode(sceneNode.DocumentNode));
        }
Exemplo n.º 3
0
        public static void SetHasExtendedVisualStateManager(SceneNode ownerNode, bool set)
        {
            ProjectContext   projectContext  = ownerNode.ProjectContext as ProjectContext;
            IAssemblyService assemblyService = ownerNode.DesignerContext.AssemblyService;

            if (set)
            {
                if (!VisualStateManagerSceneNode.EnsureExtendedAssemblyReferences((ITypeResolver)projectContext, assemblyService, ownerNode.DesignerContext.ViewUpdateManager))
                {
                    return;
                }
                ownerNode.SetValueAsSceneNode(VisualStateManagerSceneNode.CustomVisualStateManagerProperty, ownerNode.ViewModel.CreateSceneNode(ProjectNeutralTypes.ExtendedVisualStateManager));
            }
            else
            {
                ownerNode.ClearValue(VisualStateManagerSceneNode.CustomVisualStateManagerProperty);
            }
        }
Exemplo n.º 4
0
        protected override void ModifyValue(PropertyReferenceProperty property, object valueToSet, Modification modification, int index)
        {
            if (this.ViewModel == null)
            {
                return;
            }
            string description = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.PropertyChangeUndoDescription, new object[1]
            {
                (object)((PropertyEntry)property).get_PropertyName()
            });

            if (!this.ViewModel.DefaultView.Document.IsEditable)
            {
                return;
            }
            using (SceneEditTransaction editTransaction = this.ViewModel.CreateEditTransaction(description, false, SceneEditTransactionType.NestedInAutoClosing))
            {
                try
                {
                    foreach (SceneNode sceneNode1 in this.Objects)
                    {
                        PropertyReference propertyReference1 = SceneNodeObjectSet.FilterProperty(sceneNode1, property.Reference);
                        if (propertyReference1 != null)
                        {
                            SceneNode sceneNode2 = sceneNode1;
                            if (this.ShouldAllowAnimation)
                            {
                                SceneNode         ancestor           = (SceneNode)null;
                                PropertyReference propertyReference2 = propertyReference1;
                                if (this.FindAncestor(sceneNode1, out ancestor, ref propertyReference2, new Predicate <SceneNode>(SceneNodeObjectSetBase.IsAnimationParent)))
                                {
                                    sceneNode2         = ancestor;
                                    propertyReference1 = propertyReference2;
                                }
                            }
                            using (SceneNode.DisableEnsureTransform(PlatformTypes.TransformGroup.IsAssignableFrom((ITypeId)propertyReference1.LastStep.DeclaringType)))
                            {
                                if (modification == Modification.InsertValue)
                                {
                                    sceneNode2.InsertValue(propertyReference1, index, valueToSet);
                                }
                                else if (modification == Modification.ClearValue)
                                {
                                    this.ClearAnimations(sceneNode2, propertyReference1);
                                    sceneNode2.ClearValue(propertyReference1);
                                }
                                else if (modification == Modification.RemoveValue)
                                {
                                    SceneElement element = sceneNode2.GetLocalValueAsSceneNode(propertyReference1).GetChildren()[index] as SceneElement;
                                    if (element != null)
                                    {
                                        element.ViewModel.AnimationEditor.DeleteAllAnimationsInSubtree(element);
                                    }
                                    sceneNode2.RemoveValueAt(propertyReference1, index);
                                }
                                else if (modification == Modification.SetValue)
                                {
                                    this.ClearAnimations(sceneNode2, propertyReference1);
                                    using (LayoutRoundingHelper.IsUseLayoutRoundingProperty(sceneNode2, (IProperty)propertyReference1.LastStep) ? sceneNode2.ViewModel.ForceDefaultSetValue() : (IDisposable)null)
                                        sceneNode2.SetValue(propertyReference1, valueToSet);
                                }
                                LayoutRoundingHelper.ExplicitlyChangeLayoutRounding(sceneNode2, propertyReference1);
                            }
                        }
                    }
                    editTransaction.Commit();
                }
                catch (Exception ex)
                {
                    if (editTransaction != null)
                    {
                        editTransaction.Cancel();
                    }
                    int num = (int)this.DesignerContext.MessageDisplayService.ShowMessage(new MessageBoxArgs()
                    {
                        Message = StringTable.InvalidPropertyValueErrorNoException,
                        Button  = MessageBoxButton.OK,
                        Image   = MessageBoxImage.Hand
                    });
                }
            }
            this.TransactionContext.UpdateTransaction();
        }