public static void HandleDebugKeys(this SpectrumGenericToolWindowViewModel vm, KeyEventArgs args) { if (!vm.VmPaused) { return; } if (args.Key == Key.F5 && Keyboard.Modifiers == ModifierKeys.None) { // --- Run vm.MachineViewModel.StartDebugVm(); args.Handled = true; } else if (args.Key == Key.F11 && Keyboard.Modifiers == ModifierKeys.None) { // --- Step into vm.MachineViewModel.StepInto(); args.Handled = true; } else if (args.Key == Key.System && args.SystemKey == Key.F10 && Keyboard.Modifiers == ModifierKeys.None) { // --- Step over vm.MachineViewModel.StepOver(); args.Handled = true; } if (args.Handled) { SpectNetPackage.UpdateCommandUi(); } }
/// <summary> /// Override this method to execute the command /// </summary> protected override void OnExecute() { var cancel = IsCancelled = false; PrepareCommandOnMainThread(ref cancel); if (cancel) { IsCancelled = true; return; } JoinableTaskFactory.RunAsync(async() => { try { await Task.Yield(); // get off the caller's callstack. await ExecuteAsync(); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); CompleteOnMainThread(); } catch (OperationCanceledException) { // --- This exception is expected because we signaled the cancellation token IsCancelled = true; OnCancellation(); } catch (AggregateException ex) { // --- ignore AggregateException containing only OperationCanceledExceptionI if (ex.InnerException is OperationCanceledException) { IsCancelled = true; OnCancellation(); } else { OnException(ex); } } catch (Exception ex) { var x = 1; } finally { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); await FinallyOnMainThreadAsync(); if (UpdateUiWhenComplete) { SpectNetPackage.UpdateCommandUi(); } } }); }
/// <summary> /// Updates the command UI whenever the selected item has changed. /// </summary> private void OnSelectedItemChanged(object sender, EventArgs e) { SpectNetPackage.UpdateCommandUi(); }
/// <summary> /// Respond to changes in any test file's contents /// </summary> private void OnTestFileChanged(object sender, FileChangedEventArgs e) { Caption = BaseCaption + "*"; Vm.HasAnyTestFileChanged = true; SpectNetPackage.UpdateCommandUi(); }