コード例 #1
0
ファイル: NotepadsCore.cs プロジェクト: C7C7/Notepads
        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();
        }
コード例 #2
0
 private void TextEditor_Unloaded(object sender, RoutedEventArgs e)
 {
     if (!(sender is TextEditor textEditor))
     {
         return;
     }
     TextEditorUnloaded?.Invoke(this, textEditor);
 }