private void CleanupLogicAndInputListener() { Logic?.Dispose(); _inputListener?.Dispose(); Logic = null; _inputListener = null; }
protected void OnKeyboardAction(object oSender, char?key, KeyEventType eventType) { Logic = Logic ?? throw new Exception($"{nameof(OnKeyboardAction)} in {nameof(CocoJumperBaseCommand)}, {nameof(Logic)} is null"); if (Logic.KeyboardAction(key, eventType) == CocoJumperKeyboardActionResult.Finished) { CleanupLogicAndInputListener(); } }
protected void Execute(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); IVsTextView textView = _vsTextManager.GetActiveView(); IWpfTextView wpfTextView = _editorAdaptersFactoryService.GetWpfTextView(textView); CocoJumperCommandPackage cocoJumperCommandPackage = (CocoJumperCommandPackage)_package; CleanupLogicAndInputListener(); WpfViewProvider renderer = new WpfViewProvider(wpfTextView); Logic = new CocoJumperLogic(renderer, cocoJumperCommandPackage); _inputListener = new InputListener(textView); _inputListener.KeyPressEvent += OnKeyboardAction; ExecutePostAction(); }