/// <summary> /// /// </summary> /// <param name="e"></param> protected override void OnFormClosing(FormClosingEventArgs e) { base.OnFormClosing(e); var temporaryEventHolder = PreCloseRequest; if (temporaryEventHolder != null) { var args = new ViewPreCloseEventArgs(e.Cancel); temporaryEventHolder(this, args); e.Cancel = args.CancelViewClose; } }
private void ViewPreCloseRequestHandler(object sender, ViewPreCloseEventArgs e) { var currentSubtitles = subtitlesManager.CurrentSubtitles; if ((!currentSubtitles.IsSaved) && (!String.IsNullOrEmpty(currentSubtitles.Content))) { ViewCloseCancellationToken mainViewCloseCancellationToken = new ViewCloseCancellationToken(e.CancelViewClose); ISaveBeforeCloseView view = new SaveBeforeCloseView(); SaveBeforeClosePresenter presenter = new SaveBeforeClosePresenter(ViewManager, view, subtitlesManager, mainViewCloseCancellationToken); ViewManager.AddView(view); ViewManager.ShowView(view); //Zamyka się sam. ViewManager.RemoveView(view); e.CancelViewClose = mainViewCloseCancellationToken.Cancel; } }