Example #1
0
        public void DeleteTextEditor(ITextEditor textEditor)
        {
            if (textEditor == null)
            {
                return;
            }
            var item = GetTextEditorSetsViewItem(textEditor);

            if (item == null)
            {
                return;
            }
            item.IsEnabled = false;
            item.PrepareForClosing();
            Sets.Items?.Remove(item);

            if (item.ContextFlyout is TabContextFlyout tabContextFlyout)
            {
                tabContextFlyout.Dispose();
            }

            TextEditorUnloaded?.Invoke(this, textEditor);

            textEditor.Loaded                       -= TextEditor_Loaded;
            textEditor.Unloaded                     -= TextEditor_Unloaded;
            textEditor.KeyDown                      -= TextEditorKeyDown;
            textEditor.SelectionChanged             -= TextEditor_OnSelectionChanged;
            textEditor.FontZoomFactorChanged        -= TextEditor_OnFontZoomFactorChanged;
            textEditor.ModificationStateChanged     -= TextEditor_OnEditorModificationStateChanged;
            textEditor.ModeChanged                  -= TextEditor_OnModeChanged;
            textEditor.FileModificationStateChanged -= TextEditor_OnFileModificationStateChanged;
            textEditor.LineEndingChanged            -= TextEditor_OnLineEndingChanged;
            textEditor.EncodingChanged              -= TextEditor_OnEncodingChanged;
            textEditor.Dispose();
        }
Example #2
0
 private void TextEditor_Unloaded(object sender, RoutedEventArgs e)
 {
     if (!(sender is TextEditor textEditor))
     {
         return;
     }
     TextEditorUnloaded?.Invoke(this, textEditor);
 }