예제 #1
0
        // Common handler for all list editing commands
        private static void OnListCommand(object target, ExecutedRoutedEventArgs args)
        {
            TextEditor This = TextEditor._GetTextEditor(target);

            if (This == null || !This._IsEnabled || This.IsReadOnly || !This.AcceptsRichContent || !(This.Selection is TextSelection))
            {
                return;
            }

            TextEditorTyping._FlushPendingInputItems(This);

            if (!TextRangeEditLists.IsListOperationApplicable((TextSelection)This.Selection))
            {
                return;
            }

            using (This.Selection.DeclareChangeBlock())
            {
                TextSelection thisSelection = (TextSelection)This.Selection;

                ListItem parentListItem    = TextPointerBase.GetListItem(thisSelection.Start);
                ListItem immediateListItem = TextPointerBase.GetImmediateListItem(thisSelection.Start);
                List     list = parentListItem == null ? null : (List)parentListItem.Parent;

                // Forget previously suggested horizontal position
                TextEditorSelection._ClearSuggestedX(This);

                // Execute the command
                if (args.Command == EditingCommands.ToggleBullets)
                {
                    ToggleBullets(thisSelection, parentListItem, immediateListItem, list);
                }
                else if (args.Command == EditingCommands.ToggleNumbering)
                {
                    ToggleNumbering(thisSelection, parentListItem, immediateListItem, list);
                }
                else if (args.Command == EditingCommands.RemoveListMarkers)
                {
                    TextRangeEditLists.ConvertListItemsToParagraphs(thisSelection);
                }
                else if (args.Command == EditingCommands.IncreaseIndentation)
                {
                    IncreaseIndentation(thisSelection, parentListItem, immediateListItem);
                }
                else if (args.Command == EditingCommands.DecreaseIndentation)
                {
                    DecreaseIndentation(thisSelection, parentListItem, immediateListItem);
                }
                else
                {
                    Invariant.Assert(false);
                }
            }
        }
        // Token: 0x06003874 RID: 14452 RVA: 0x000FCCBC File Offset: 0x000FAEBC
        private static void OnListCommand(object target, ExecutedRoutedEventArgs args)
        {
            TextEditor textEditor = TextEditor._GetTextEditor(target);

            if (textEditor == null || !textEditor._IsEnabled || textEditor.IsReadOnly || !textEditor.AcceptsRichContent || !(textEditor.Selection is TextSelection))
            {
                return;
            }
            TextEditorTyping._FlushPendingInputItems(textEditor);
            if (!TextRangeEditLists.IsListOperationApplicable((TextSelection)textEditor.Selection))
            {
                return;
            }
            using (textEditor.Selection.DeclareChangeBlock())
            {
                TextSelection textSelection     = (TextSelection)textEditor.Selection;
                ListItem      listItem          = TextPointerBase.GetListItem(textSelection.Start);
                ListItem      immediateListItem = TextPointerBase.GetImmediateListItem(textSelection.Start);
                List          list = (listItem == null) ? null : ((List)listItem.Parent);
                TextEditorSelection._ClearSuggestedX(textEditor);
                if (args.Command == EditingCommands.ToggleBullets)
                {
                    TextEditorLists.ToggleBullets(textSelection, listItem, immediateListItem, list);
                }
                else if (args.Command == EditingCommands.ToggleNumbering)
                {
                    TextEditorLists.ToggleNumbering(textSelection, listItem, immediateListItem, list);
                }
                else if (args.Command == EditingCommands.RemoveListMarkers)
                {
                    TextRangeEditLists.ConvertListItemsToParagraphs(textSelection);
                }
                else if (args.Command == EditingCommands.IncreaseIndentation)
                {
                    TextEditorLists.IncreaseIndentation(textSelection, listItem, immediateListItem);
                }
                else if (args.Command == EditingCommands.DecreaseIndentation)
                {
                    TextEditorLists.DecreaseIndentation(textSelection, listItem, immediateListItem);
                }
                else
                {
                    Invariant.Assert(false);
                }
            }
        }