public static DialogResult ShowFileSaveQuestion(string strFile, FileSaveOrigin fsOrigin, IntPtr hParent) { bool bFile = ((strFile != null) && (strFile.Length > 0)); if(WinUtil.IsAtLeastWindowsVista) { VistaTaskDialog dlg = new VistaTaskDialog(hParent); string strText = KPRes.DatabaseModifiedNoDot; if(bFile) strText += ":\r\n" + strFile; else strText += "."; dlg.CommandLinks = true; dlg.WindowTitle = PwDefs.ProductName; dlg.Content = strText; dlg.SetIcon(VtdCustomIcon.Question); bool bShowCheckBox = true; if(fsOrigin == FileSaveOrigin.Locking) { dlg.MainInstruction = KPRes.FileSaveQLocking; dlg.AddButton((int)DialogResult.Yes, KPRes.Save, KPRes.FileSaveQOpYesLocking); dlg.AddButton((int)DialogResult.No, KPRes.DiscardChanges, KPRes.FileSaveQOpNoLocking); dlg.AddButton((int)DialogResult.Cancel, KPRes.Cancel, KPRes.FileSaveQOpCancel + " " + KPRes.FileSaveQOpCancelLocking); } else if(fsOrigin == FileSaveOrigin.Exiting) { dlg.MainInstruction = KPRes.FileSaveQExiting; dlg.AddButton((int)DialogResult.Yes, KPRes.Save, KPRes.FileSaveQOpYesExiting); dlg.AddButton((int)DialogResult.No, KPRes.DiscardChanges, KPRes.FileSaveQOpNoExiting); dlg.AddButton((int)DialogResult.Cancel, KPRes.Cancel, KPRes.FileSaveQOpCancel + " " + KPRes.FileSaveQOpCancelExiting); } else { dlg.MainInstruction = KPRes.FileSaveQClosing; dlg.AddButton((int)DialogResult.Yes, KPRes.Save, KPRes.FileSaveQOpYesClosing); dlg.AddButton((int)DialogResult.No, KPRes.DiscardChanges, KPRes.FileSaveQOpNoClosing); dlg.AddButton((int)DialogResult.Cancel, KPRes.Cancel, KPRes.FileSaveQOpCancel + " " + KPRes.FileSaveQOpCancelClosing); bShowCheckBox = false; } if(Program.Config.Application.FileClosing.AutoSave) bShowCheckBox = false; if(bShowCheckBox) dlg.VerificationText = KPRes.AutoSaveAtExit; if(dlg.ShowDialog()) { if(bShowCheckBox && (dlg.Result == (int)DialogResult.Yes)) Program.Config.Application.FileClosing.AutoSave = dlg.ResultVerificationChecked; return (DialogResult)dlg.Result; } } string strMessage = (bFile ? (strFile + MessageService.NewParagraph) : string.Empty); strMessage += KPRes.DatabaseModifiedNoDot + "." + MessageService.NewParagraph + KPRes.SaveBeforeCloseQuestion; return MessageService.Ask(strMessage, KPRes.SaveBeforeCloseTitle, MessageBoxButtons.YesNoCancel); }
public static DialogResult ShowFileSaveQuestion(string strFile, FileSaveOrigin fsOrigin) { bool bFile = ((strFile != null) && (strFile.Length > 0)); if (WinUtil.IsAtLeastWindowsVista) { VistaTaskDialog dlg = new VistaTaskDialog(); string strText = KPRes.DatabaseModifiedNoDot; if (bFile) { strText += ":\r\n" + strFile; } else { strText += "."; } dlg.CommandLinks = true; dlg.WindowTitle = PwDefs.ShortProductName; dlg.Content = strText; dlg.SetIcon(VtdCustomIcon.Question); bool bShowCheckBox = true; if (fsOrigin == FileSaveOrigin.Locking) { dlg.MainInstruction = KPRes.FileSaveQLocking; dlg.AddButton((int)DialogResult.Yes, KPRes.SaveCmd, KPRes.FileSaveQOpYesLocking); dlg.AddButton((int)DialogResult.No, KPRes.DiscardChangesCmd, KPRes.FileSaveQOpNoLocking); dlg.AddButton((int)DialogResult.Cancel, KPRes.Cancel, KPRes.FileSaveQOpCancel + " " + KPRes.FileSaveQOpCancelLocking); } else if (fsOrigin == FileSaveOrigin.Exiting) { dlg.MainInstruction = KPRes.FileSaveQExiting; dlg.AddButton((int)DialogResult.Yes, KPRes.SaveCmd, KPRes.FileSaveQOpYesExiting); dlg.AddButton((int)DialogResult.No, KPRes.DiscardChangesCmd, KPRes.FileSaveQOpNoExiting); dlg.AddButton((int)DialogResult.Cancel, KPRes.Cancel, KPRes.FileSaveQOpCancel + " " + KPRes.FileSaveQOpCancelExiting); } else { dlg.MainInstruction = KPRes.FileSaveQClosing; dlg.AddButton((int)DialogResult.Yes, KPRes.SaveCmd, KPRes.FileSaveQOpYesClosing); dlg.AddButton((int)DialogResult.No, KPRes.DiscardChangesCmd, KPRes.FileSaveQOpNoClosing); dlg.AddButton((int)DialogResult.Cancel, KPRes.Cancel, KPRes.FileSaveQOpCancel + " " + KPRes.FileSaveQOpCancelClosing); bShowCheckBox = false; } if (Program.Config.Application.FileClosing.AutoSave) { bShowCheckBox = false; } if (bShowCheckBox) { dlg.VerificationText = KPRes.AutoSaveAtExit; } if (dlg.ShowDialog()) { if (bShowCheckBox && (dlg.Result == (int)DialogResult.Yes)) { Program.Config.Application.FileClosing.AutoSave = dlg.ResultVerificationChecked; } return((DialogResult)dlg.Result); } } string strMessage = (bFile ? (strFile + MessageService.NewParagraph) : string.Empty); strMessage += KPRes.DatabaseModifiedNoDot + "." + MessageService.NewParagraph + KPRes.SaveBeforeCloseQuestion; return(MessageService.Ask(strMessage, KPRes.SaveBeforeCloseTitle, MessageBoxButtons.YesNoCancel)); }