Beispiel #1
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();
        }