/// Profileを閉じる public bool CloseProfile() { // 編集がされていなければそのまま[閉じる]ことが可能 if (!this.HasModified) { return(true); } // Event: ProfileClosing var action = CloseActions.Save; { var profileName = this.HasSaved ? this.RuntimeOptions.ProfileName : "Untitled"; var args = new ProfileClosingEventArgs(action, profileName); var handler = this.OnProfileClosing; if (handler != null) { handler(this, args); } action = args.Action; } // Actionごとに動作を変える switch (action) { case CloseActions.Save: return(this.SaveProfile(SaveActions.Save)); case CloseActions.Abandon: return(true); case CloseActions.Cancel: return(false); default: Debug.Fail("switch"); throw new System.ArgumentException(); } }
/// Profileを閉じる public bool CloseProfile() { // 編集がされていなければそのまま[閉じる]ことが可能 if (!this.HasModified) return true; // Event: ProfileClosing var action = CloseActions.Save; { var profileName = this.HasSaved ? this.RuntimeOptions.ProfileName : "Untitled"; var args = new ProfileClosingEventArgs(action, profileName); var handler = this.OnProfileClosing; if (handler != null) handler(this, args); action = args.Action; } // Actionごとに動作を変える switch (action) { case CloseActions.Save: return this.SaveProfile(SaveActions.Save); case CloseActions.Abandon: return true; case CloseActions.Cancel: return false; default: Debug.Fail("switch"); throw new System.ArgumentException(); } }
/// @copybrief SCFF::Common::ClientApplication::OnProfileClosing /// @param[in] sender 使用しない /// @param[in,out] e e.Actionに動作を指定する void OnProfileClosing(object sender, ProfileClosingEventArgs e) { var message = string.Format("Do you want to save changes to {0}?", e.ProfileName); var result = MessageBox.Show(message, "SCFF.GUI", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning, MessageBoxResult.Yes); switch (result) { case MessageBoxResult.Yes: e.Action = CloseActions.Save; break; case MessageBoxResult.No: e.Action = CloseActions.Abandon; break; case MessageBoxResult.Cancel: e.Action = CloseActions.Cancel; break; } }