Пример #1
0
        private void OnBeginTransactionCore(object originalSource, object parameter)
        {
            if (this.ActiveDocument == null)
            {
                return;
            }
            FrameworkElement element = originalSource as FrameworkElement;

            if (element != null)
            {
                this.HookEditEndingHandlers(element);
            }
            string description = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.PropertyChangeUndoDescription, new object[1]
            {
                (object)"Property"
            });
            string str = parameter as string;
            PropertyTransactionParameters transactionParameters = parameter as PropertyTransactionParameters;
            SceneEditTransactionType      transactionType       = SceneEditTransactionType.AutoCommitting;

            if (transactionParameters != null)
            {
                description     = transactionParameters.TransactionDescription;
                transactionType = transactionParameters.TransactionType;
            }
            else if (str != null)
            {
                description = str;
            }
            else
            {
                PropertyContainer propertyContainer;
                if ((propertyContainer = PropertyEditingHelper.GetPropertyContainer(originalSource)) != null)
                {
                    description = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.PropertyChangeUndoDescription, new object[1]
                    {
                        (object)propertyContainer.get_PropertyEntry().get_PropertyName()
                    });
                }
            }
            this.editTransactions.Push(this.ActiveDocument.CreateEditTransaction(description, false, transactionType));
        }
Пример #2
0
        public SceneEditTransaction CreateEditTransaction(string description, bool hidden, SceneEditTransactionType transactionType)
        {
            if (this.autoClosingTransactionStack.Count > 0 && transactionType != SceneEditTransactionType.NestedInAutoClosing)
            {
                bool flag = false;
                foreach (KeyValuePair <SceneEditTransaction, SceneEditTransactionType> keyValuePair in this.autoClosingTransactionStack)
                {
                    if (keyValuePair.Value == SceneEditTransactionType.NestedInAutoClosing)
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    KeyValuePair <SceneEditTransaction, SceneEditTransactionType> keyValuePair = this.autoClosingTransactionStack.Pop();
                    if (keyValuePair.Value == SceneEditTransactionType.AutoCommitting)
                    {
                        keyValuePair.Key.Commit();
                    }
                    else
                    {
                        keyValuePair.Key.Cancel();
                    }
                }
            }
            IUndoTransaction undo = this.UndoService.CreateUndo(description, hidden);

            ++this.openEditTransactionCount;
            SceneEditTransaction key = new SceneEditTransaction(this.designerContext.ExternalChanges, this, undo);

            if (this.autoClosingTransactionStack.Count > 0 || transactionType == SceneEditTransactionType.AutoCommitting || transactionType == SceneEditTransactionType.AutoCancelling)
            {
                this.autoClosingTransactionStack.Push(new KeyValuePair <SceneEditTransaction, SceneEditTransactionType>(key, transactionType));
            }
            return(key);
        }