private void ApplicationStartup(object sender, StartupEventArgs e) { Exit += (o, args) => ExitAction.Invoke(); Window.Show(); InitializationAction.Invoke(); // DataBase.GetCollection<AlgorithmResult>().DeleteAll(); }
private void UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { MessageBox.Show("Возникло исключение: " + e.Exception.Message + "\n Приложение будет закрыто", "Исключение", MessageBoxButton.OK, MessageBoxImage.Warning); ExitAction.Invoke(); }
void ExitToolBarItem_Clicked(object sender, EventArgs e) { if (ViewModel.Order.IsOpen) { ExitAndDiscardAction.Invoke(); } else { ExitAction.Invoke(); } }
private void InitCommands() { SelectRootFolderCommand = new DelegateCommand(SelectRootFolder); SaveCommand = new DelegateCommand<MusicFileTag>(Save); SearchOnlineCommand = new AsyncCommand(SearchOnline); TagFromFileNameCommand = new DelegateCommand(this.TagFromFilename); SaveFromFNCommand = new DelegateCommand(this.SaveFromFN); ExitCommand = new DelegateCommand(() => ExitAction.Invoke()); OpenAboutCommand = new DelegateCommand(this.OpenAbout); ClearCommand = new DelegateCommand(this.ClearList); ClearSelectionCommand = new DelegateCommand(() => ClearSelectionAction.Invoke()); }
/// <summary> /// Displays help via the LineWriter action /// </summary> /// <param name="options"></param> /// <typeparam name="T"></typeparam> public virtual void DisplayHelp <T>(CommandlineArgument[] options) { if (ShowedHelp) { return; } ShowedHelp = true; var head = GenerateHelpHead <T>(); var headSpacer = head.Any() ? OneLine : NoLines; var body = GenerateArgumentHelp <T>(options.Where( o => !o.IsImplicit || o.Key == CommandlineArgument.HELP_FLAG_KEY ).ToArray()); var footer = GenerateHelpFooter <T>(); var footerSpacer = footer.Any() ? OneLine : NoLines; var negateMessage = options.Any(o => o.IsFlag && !o.IsImplicit) ? new[] { "", NegateMessage } : NoLines; headSpacer.And(head) .And(headSpacer) .And(body) .And(negateMessage) .And(footerSpacer) .And(footer) .And("") .ForEach(s => LineWriter(s.TrimEnd())); if (ExitOnError) { ExitAction?.Invoke(ExitCodes.SHOWED_HELP); } ShowedHelp = true; }
public void TryExit() { ExitAction?.Invoke(); }
/// <summary> /// Invokes ExitAction event. /// </summary> /// <param name="symbol"></param> public void OnExitAction(TInSymbol symbol) { ExitAction?.Invoke(this, new ActionEventArgs(symbol)); }
public static void RaiseOnExit() => OnExit?.Invoke();