//------------------------------------------------------
        //
        //  Privte Methods
        //
        //------------------------------------------------------

        #region Private Methods

        // Private helper that adds a new UIElementPropertyUndoUnit to the undo stack.
        private static void AddPrivate(ITextContainer textContainer, UIElement uiElement, DependencyProperty property, object newValue)
        {
            UndoManager undoManager = TextTreeUndo.GetOrClearUndoManager(textContainer);

            if (undoManager == null)
            {
                return;
            }

            object currentValue = uiElement.ReadLocalValue(property);

            if (currentValue is Expression)
            {
                // Can't undo when old value is an expression, so clear the stack.
                if (undoManager.IsEnabled)
                {
                    undoManager.Clear();
                }
                return;
            }

            if (currentValue.Equals(newValue))
            {
                // No property change.
                return;
            }

            undoManager.Add(new UIElementPropertyUndoUnit(uiElement, property, currentValue));
        }
        // Token: 0x06003E29 RID: 15913 RVA: 0x0011D570 File Offset: 0x0011B770
        internal static void CreateInsertUndoUnit(TextContainer tree, int symbolOffset, int symbolCount)
        {
            UndoManager orClearUndoManager = TextTreeUndo.GetOrClearUndoManager(tree);

            if (orClearUndoManager == null)
            {
                return;
            }
            orClearUndoManager.Add(new TextTreeInsertUndoUnit(tree, symbolOffset, symbolCount));
        }
        // Token: 0x06003E2D RID: 15917 RVA: 0x0011D670 File Offset: 0x0011B870
        internal static TextTreeExtractElementUndoUnit CreateExtractElementUndoUnit(TextContainer tree, TextTreeTextElementNode elementNode)
        {
            UndoManager orClearUndoManager = TextTreeUndo.GetOrClearUndoManager(tree);

            if (orClearUndoManager == null)
            {
                return(null);
            }
            TextTreeExtractElementUndoUnit textTreeExtractElementUndoUnit = new TextTreeExtractElementUndoUnit(tree, elementNode);

            orClearUndoManager.Add(textTreeExtractElementUndoUnit);
            return(textTreeExtractElementUndoUnit);
        }
        // Token: 0x06003E2B RID: 15915 RVA: 0x0011D5C0 File Offset: 0x0011B7C0
        internal static void CreatePropertyUndoUnit(TextElement element, DependencyPropertyChangedEventArgs e)
        {
            TextContainer textContainer      = element.TextContainer;
            UndoManager   orClearUndoManager = TextTreeUndo.GetOrClearUndoManager(textContainer);

            if (orClearUndoManager == null)
            {
                return;
            }
            PropertyRecord propertyRecord = default(PropertyRecord);

            propertyRecord.Property = e.Property;
            propertyRecord.Value    = ((e.OldValueSource == BaseValueSourceInternal.Local) ? e.OldValue : DependencyProperty.UnsetValue);
            orClearUndoManager.Add(new TextTreePropertyUndoUnit(textContainer, element.TextElementNode.GetSymbolOffset(textContainer.Generation) + 1, propertyRecord));
        }
        // Token: 0x06003E2C RID: 15916 RVA: 0x0011D638 File Offset: 0x0011B838
        internal static TextTreeDeleteContentUndoUnit CreateDeleteContentUndoUnit(TextContainer tree, TextPointer start, TextPointer end)
        {
            if (start.CompareTo(end) == 0)
            {
                return(null);
            }
            UndoManager orClearUndoManager = TextTreeUndo.GetOrClearUndoManager(tree);

            if (orClearUndoManager == null)
            {
                return(null);
            }
            TextTreeDeleteContentUndoUnit textTreeDeleteContentUndoUnit = new TextTreeDeleteContentUndoUnit(tree, start, end);

            orClearUndoManager.Add(textTreeDeleteContentUndoUnit);
            return(textTreeDeleteContentUndoUnit);
        }
예제 #6
0
        // Token: 0x06002F10 RID: 12048 RVA: 0x000D4A50 File Offset: 0x000D2C50
        private static void AddPrivate(ITextContainer textContainer, UIElement uiElement, DependencyProperty property, object newValue)
        {
            UndoManager orClearUndoManager = TextTreeUndo.GetOrClearUndoManager(textContainer);

            if (orClearUndoManager == null)
            {
                return;
            }
            object obj = uiElement.ReadLocalValue(property);

            if (obj is Expression)
            {
                if (orClearUndoManager.IsEnabled)
                {
                    orClearUndoManager.Clear();
                }
                return;
            }
            if (obj.Equals(newValue))
            {
                return;
            }
            orClearUndoManager.Add(new UIElementPropertyUndoUnit(uiElement, property, obj));
        }