public IRegisteredCommandElement Register(UIElement sourceElement, object target) { if (sourceElement == null) throw new ArgumentNullException(nameof(sourceElement)); if (target == null) throw new ArgumentNullException(nameof(target)); var coll = new KeyShortcutCollection(); foreach (var provider in commandInfoProviders) coll.Add(provider.Value, target); var cmdElem = new RegisteredCommandElement(this, sourceElement, coll, target); foreach (var c in commandTargetFilterProviders) { var filter = c.Value.Create(target); if (filter == null) continue; cmdElem.AddFilter(filter, c.Metadata.Order); } return cmdElem; }
public void Close() { if (IsClosed) { throw new InvalidOperationException(); } mouseHoverHelper.OnClosed(); StopRefreshTimer(); RegisteredCommandElement.Unregister(); TextViewModel.Dispose(); IsClosed = true; Closed?.Invoke(this, EventArgs.Empty); (aggregateClassifier as IDisposable)?.Dispose(); TextCaret.Dispose(); Selection.Dispose(); (FormattedLineSource as IDisposable)?.Dispose(); physicalLineCache.Dispose(); textLayer.Dispose(); foreach (var physLine in visiblePhysicalLines) { physLine.Dispose(); } visiblePhysicalLines.Clear(); (__lineTransformProvider as IDisposable)?.Dispose(); Loaded -= WpfTextView_Loaded; Options.OptionChanged -= EditorOptions_OptionChanged; TextBuffer.ChangedLowPriority -= TextBuffer_ChangedLowPriority; TextViewModel.DataModel.ContentTypeChanged -= DataModel_ContentTypeChanged; aggregateClassifier.ClassificationChanged -= AggregateClassifier_ClassificationChanged; textAndAdornmentSequencer.SequenceChanged -= TextAndAdornmentSequencer_SequenceChanged; classificationFormatMap.ClassificationFormatMappingChanged -= ClassificationFormatMap_ClassificationFormatMappingChanged; editorFormatMap.FormatMappingChanged -= EditorFormatMap_FormatMappingChanged; if (metroWindow != null) { metroWindow.WindowDPIChanged -= MetroWindow_WindowDPIChanged; } }