public static tvMessageBoxResults Show( Window aoWindow , string asMessageText , string asMessageCaption , tvMessageBoxButtons aeTvMessageBoxButtons , tvMessageBoxIcons aeTvMessageBoxIcon , tvMessageBoxCheckBoxTypes aeTvMessageBoxCheckBoxType , tvProfile aoProfile , string asProfilePromptKey , tvMessageBoxResults aeTvMessageBoxResultsOverride ) { return(tvMessageBox.Show( aoWindow , asMessageText , asMessageCaption , aeTvMessageBoxButtons , aeTvMessageBoxIcon , false , aeTvMessageBoxCheckBoxType , aoProfile , asProfilePromptKey , aeTvMessageBoxResultsOverride )); }
public static void ShowBriefly( Window aoWindow , string asMessageText , string asMessageCaption , tvMessageBoxIcons aeTvMessageBoxIcon , int aiCloseAfterMS ) { tvMessageBox loMsgBox = new tvMessageBox(); loMsgBox.MessageText.Text = asMessageText; // Use some parent window attributes, if available. if (null != aoWindow) { // Use the parent window's icon. loMsgBox.Icon = aoWindow.Icon; // Use the given asMessageCaption as the MsgBox title, if not null. // Otherwise use the parent window title with an added question mark. loMsgBox.Title = null != asMessageCaption ? asMessageCaption : aoWindow.Title + "?"; } // Display the MsgBox header / title (ie. the caption), if provided. if (null != asMessageCaption) { loMsgBox.MessageTitle.Content = asMessageCaption; loMsgBox.MessageTitle.Visibility = Visibility.Visible; } loMsgBox.SelectButtons(tvMessageBoxButtons.OK); loMsgBox.SelectIcon(aeTvMessageBoxIcon); loMsgBox.Show(); if (aiCloseAfterMS > 0) { DateTime ldtCloseTime = DateTime.Now.AddMilliseconds(aiCloseAfterMS); while (DateTime.Now < ldtCloseTime) { System.Windows.Forms.Application.DoEvents(); System.Threading.Thread.Sleep(200); if (loMsgBox.bDialogAccepted) { break; } } loMsgBox.Close(); } }
public static tvMessageBoxResults Show( Window aoWindow , string asMessageText , tvMessageBoxButtons aeTvMessageBoxButtons , tvMessageBoxIcons aeTvMessageBoxIcon ) { return(tvMessageBox.Show( aoWindow , asMessageText , null , aeTvMessageBoxButtons , aeTvMessageBoxIcon , false )); }
public static tvMessageBoxResults ShowModeless( Window aoWindow , string asMessageText , string asMessageCaption , tvMessageBoxButtons aeTvMessageBoxButtons , tvMessageBoxIcons aeTvMessageBoxIcon ) { return(tvMessageBox.Show( aoWindow , asMessageText , asMessageCaption , aeTvMessageBoxButtons , aeTvMessageBoxIcon , true )); }
private void SelectIcon(tvMessageBoxIcons aeTvMessageBoxIcon) { switch (aeTvMessageBoxIcon) { case tvMessageBoxIcons.Alert: this.AlertIcon.Visibility = Visibility.Visible; break; case tvMessageBoxIcons.Done: this.OkIcon.Visibility = Visibility.Visible; break; case tvMessageBoxIcons.Error: this.ErrorIcon.Visibility = Visibility.Visible; break; case tvMessageBoxIcons.Exclamation: this.DefaultIcon.Visibility = Visibility.Visible; break; case tvMessageBoxIcons.Question: this.HelpIcon.Visibility = Visibility.Visible; break; case tvMessageBoxIcons.Information: this.InfoIcon.Visibility = Visibility.Visible; break; case tvMessageBoxIcons.None: break; case tvMessageBoxIcons.Ok: this.OkIcon.Visibility = Visibility.Visible; break; case tvMessageBoxIcons.Stop: this.ErrorIcon.Visibility = Visibility.Visible; break; case tvMessageBoxIcons.Warning: this.AlertIcon.Visibility = Visibility.Visible; break; } }
public static tvMessageBoxResults Show( Window aoWindow , string asMessageText , string asMessageCaption , tvMessageBoxButtons aeTvMessageBoxButtons , tvMessageBoxIcons aeTvMessageBoxIcon , bool abShowModeless ) { return(tvMessageBox.Show( aoWindow , asMessageText , asMessageCaption , aeTvMessageBoxButtons , aeTvMessageBoxIcon , abShowModeless , tvMessageBoxCheckBoxTypes.None , null , null , tvMessageBoxResults.None )); }
public static tvMessageBoxResults ShowModeless( Window aoWindow , string asMessageText , string asMessageCaption , tvMessageBoxButtons aeTvMessageBoxButtons , tvMessageBoxIcons aeTvMessageBoxIcon , tvMessageBoxCheckBoxTypes aeTvMessageBoxCheckBoxType , tvProfile aoProfile , string asProfilePromptKey ) { return(tvMessageBox.Show( aoWindow , asMessageText , asMessageCaption , aeTvMessageBoxButtons , aeTvMessageBoxIcon , true , aeTvMessageBoxCheckBoxType , aoProfile , asProfilePromptKey , tvMessageBoxResults.None )); }
public static void ShowBriefly( Window aoWindow , string asMessageText , string asMessageCaption , tvMessageBoxIcons aeTvMessageBoxIcon , int aiCloseAfterMS ) { tvMessageBox loMsgBox = new tvMessageBox(); loMsgBox.MessageText.Text = asMessageText; // Use some parent window attributes, if available. if ( null != aoWindow ) { // Use the parent window's icon. loMsgBox.Icon = aoWindow.Icon; // Use the given asMessageCaption as the MsgBox title, if not null. // Otherwise use the parent window title with an added question mark. loMsgBox.Title = null != asMessageCaption ? asMessageCaption : aoWindow.Title + "?"; } // Display the MsgBox header / title (ie. the caption), if provided. if ( null != asMessageCaption ) { loMsgBox.MessageTitle.Content = asMessageCaption; loMsgBox.MessageTitle.Visibility = Visibility.Visible; } loMsgBox.SelectButtons(tvMessageBoxButtons.OK); loMsgBox.SelectIcon(aeTvMessageBoxIcon); loMsgBox.Show(); if ( aiCloseAfterMS > 0 ) { DateTime ldtCloseTime = DateTime.Now.AddMilliseconds(aiCloseAfterMS); while ( DateTime.Now < ldtCloseTime ) { System.Windows.Forms.Application.DoEvents(); System.Threading.Thread.Sleep(200); if ( loMsgBox.bDialogAccepted ) break; } loMsgBox.Close(); } }
public static tvMessageBoxResults Show( Window aoWindow , string asMessageText , string asMessageCaption , tvMessageBoxButtons aeTvMessageBoxButtons , tvMessageBoxIcons aeTvMessageBoxIcon , bool abShowModeless , tvMessageBoxCheckBoxTypes aeTvMessageBoxCheckBoxType , tvProfile aoProfile , string asProfilePromptKey , tvMessageBoxResults aeTvMessageBoxResultsOverride ) { tvMessageBoxResults liTvMessageBoxResult = tvMessageBoxResults.None; string lsPromptAnswerKey = null; bool lbUseCheckBox = tvMessageBoxCheckBoxTypes.None != aeTvMessageBoxCheckBoxType; if ( lbUseCheckBox ) { // Insert the prompt key prefix if it's not already there. A common prefix // is necessary to allow for the removal of all prompt keys as needed. if ( !asProfilePromptKey.StartsWith(msProfilePromptKeyPrefix) ) { // Strip leading hyphen. if ( asProfilePromptKey.StartsWith("-") ) asProfilePromptKey = asProfilePromptKey.Substring(1, asProfilePromptKey.Length - 1); // Insert prefix. asProfilePromptKey = msProfilePromptKeyPrefix + asProfilePromptKey; } // Make the answer key from the prompt key and the prompt key suffix. lsPromptAnswerKey = asProfilePromptKey + msProfilePromptKeySuffix; // Only the first display of a modeless dialog can contain a checkbox. // Why? Because the first prompt is not modeless. That's the only way // to capture the checkbox value. BTW, "lbUseCheckBox" is reset here // for use outside of this block to avoid the default setting next. if ( abShowModeless ) lbUseCheckBox = !aoProfile.ContainsKey(asProfilePromptKey); if ( !aoProfile.bValue(asProfilePromptKey, false) && aoProfile.ContainsKey(lsPromptAnswerKey) ) { // Do not prompt. Return the previous stored answer instead. return (tvMessageBoxResults)aoProfile.iValue( lsPromptAnswerKey, (int)tvMessageBoxResults.None); } } if ( null == asMessageCaption ) { // No caption provided. Let's try to get one another way. if ( null != aoWindow ) // Try window title first. asMessageCaption = aoWindow.Title; else if ( null != Application.Current ) // Next try for application name. asMessageCaption = Application.Current.MainWindow.Name; } if ( null != aoWindow ) aoWindow.Cursor = null; // Turn off wait cursor in parent window. tvMessageBox loMsgBox = new tvMessageBox(); loMsgBox.MessageText.Text = asMessageText; // Use some parent window attributes, if available. if ( null != aoWindow ) { // Use the parent window's icon. loMsgBox.Icon = aoWindow.Icon; // Use the given asMessageCaption as the MsgBox title, if not null. // Otherwise use the parent window title with an added question mark. loMsgBox.Title = null != asMessageCaption ? asMessageCaption : aoWindow.Title + "?"; } // Display the MsgBox header / title (ie. the caption), if provided. if ( null != asMessageCaption ) { loMsgBox.MessageTitle.Content = asMessageCaption; loMsgBox.MessageTitle.Visibility = Visibility.Visible; } loMsgBox.SelectButtons(aeTvMessageBoxButtons); loMsgBox.SelectIcon(aeTvMessageBoxIcon); if ( lbUseCheckBox ) { switch (aeTvMessageBoxCheckBoxType) { case tvMessageBoxCheckBoxTypes.DontAsk: loMsgBox.chkDontAsk.Visibility = Visibility.Visible; break; case tvMessageBoxCheckBoxTypes.SkipThis: loMsgBox.chkSkipThis.Visibility = Visibility.Visible; break; } } if ( !abShowModeless ) { loMsgBox.ShowDialog(); } else { // It can only be modeless after the checkbox has been stored. if ( lbUseCheckBox ) loMsgBox.ShowDialog(); else loMsgBox.Show(); } if ( lbUseCheckBox ) { bool lbCheckBoxValue = false; switch (aeTvMessageBoxCheckBoxType) { case tvMessageBoxCheckBoxTypes.DontAsk: lbCheckBoxValue = (bool)loMsgBox.chkDontAsk.IsChecked; break; case tvMessageBoxCheckBoxTypes.SkipThis: lbCheckBoxValue = (bool)loMsgBox.chkSkipThis.IsChecked; break; } // Use the answer override whenever not "none". This value is // necessary for certain stored answers that don't make sense // in a given context (eg. both "skip this" and "cancel" selected). if ( tvMessageBoxResults.None == aeTvMessageBoxResultsOverride ) aeTvMessageBoxResultsOverride = loMsgBox.eTvMessageBoxResult; // Reverse the boolean. "Don't ask" or "Skip this" means "Don't prompt". aoProfile[asProfilePromptKey] = !lbCheckBoxValue; aoProfile[lsPromptAnswerKey] = (int)aeTvMessageBoxResultsOverride; aoProfile.Save(); } liTvMessageBoxResult = loMsgBox.eTvMessageBoxResult; return liTvMessageBoxResult; }
public static tvMessageBoxResults Show( Window aoWindow , string asMessageText , string asMessageCaption , tvMessageBoxButtons aeTvMessageBoxButtons , tvMessageBoxIcons aeTvMessageBoxIcon , tvMessageBoxCheckBoxTypes aeTvMessageBoxCheckBoxType , tvProfile aoProfile , string asProfilePromptKey , tvMessageBoxResults aeTvMessageBoxResultsOverride ) { return tvMessageBox.Show( aoWindow , asMessageText , asMessageCaption , aeTvMessageBoxButtons , aeTvMessageBoxIcon , false , aeTvMessageBoxCheckBoxType , aoProfile , asProfilePromptKey , aeTvMessageBoxResultsOverride ); }
public static tvMessageBoxResults Show( Window aoWindow , string asMessageText , string asMessageCaption , tvMessageBoxButtons aeTvMessageBoxButtons , tvMessageBoxIcons aeTvMessageBoxIcon , bool abShowModeless ) { return tvMessageBox.Show( aoWindow , asMessageText , asMessageCaption , aeTvMessageBoxButtons , aeTvMessageBoxIcon , abShowModeless , tvMessageBoxCheckBoxTypes.None , null , null , tvMessageBoxResults.None ); }
public static tvMessageBoxResults Show( Window aoWindow , string asMessageText , tvMessageBoxButtons aeTvMessageBoxButtons , tvMessageBoxIcons aeTvMessageBoxIcon ) { return tvMessageBox.Show( aoWindow , asMessageText , null , aeTvMessageBoxButtons , aeTvMessageBoxIcon , false ); }
private tvMessageBoxResults Show( string asMessageText , string asMessageCaption , tvMessageBoxButtons aetvMessageBoxButtons , tvMessageBoxIcons aetvMessageBoxIcon , tvMessageBoxCheckBoxTypes aetvMessageBoxCheckBoxType , string asProfilePromptKey , tvMessageBoxResults aetvMessageBoxResult ) { if ( this.bNoPrompts ) moDoGoPcBackup.LogIt(asMessageText); tvMessageBoxResults ltvMessageBoxResults = tvMessageBoxResults.None; if ( !this.bNoPrompts ) ltvMessageBoxResults = tvMessageBox.Show( this , asMessageText , asMessageCaption , aetvMessageBoxButtons , aetvMessageBoxIcon , tvMessageBoxCheckBoxTypes.SkipThis , moProfile , asProfilePromptKey , aetvMessageBoxResult ); return ltvMessageBoxResults; }
private void SelectIcon(tvMessageBoxIcons aeTvMessageBoxIcon) { switch ( aeTvMessageBoxIcon ) { case tvMessageBoxIcons.Alert: this.AlertIcon.Visibility = Visibility.Visible; break; case tvMessageBoxIcons.Done: this.OkIcon.Visibility = Visibility.Visible; break; case tvMessageBoxIcons.Error: this.ErrorIcon.Visibility = Visibility.Visible; break; case tvMessageBoxIcons.Exclamation: this.DefaultIcon.Visibility = Visibility.Visible; break; case tvMessageBoxIcons.Question: this.HelpIcon.Visibility = Visibility.Visible; break; case tvMessageBoxIcons.Information: this.InfoIcon.Visibility = Visibility.Visible; break; case tvMessageBoxIcons.None: break; case tvMessageBoxIcons.Ok: this.OkIcon.Visibility = Visibility.Visible; break; case tvMessageBoxIcons.Stop: this.ErrorIcon.Visibility = Visibility.Visible; break; case tvMessageBoxIcons.Warning: this.AlertIcon.Visibility = Visibility.Visible; break; } }
public static tvMessageBoxResults ShowModeless( Window aoWindow , string asMessageText , string asMessageCaption , tvMessageBoxButtons aeTvMessageBoxButtons , tvMessageBoxIcons aeTvMessageBoxIcon ) { return tvMessageBox.Show( aoWindow , asMessageText , asMessageCaption , aeTvMessageBoxButtons , aeTvMessageBoxIcon , true ); }
public static tvMessageBoxResults ShowModeless( Window aoWindow , string asMessageText , string asMessageCaption , tvMessageBoxButtons aeTvMessageBoxButtons , tvMessageBoxIcons aeTvMessageBoxIcon , tvMessageBoxCheckBoxTypes aeTvMessageBoxCheckBoxType , tvProfile aoProfile , string asProfilePromptKey ) { return tvMessageBox.Show( aoWindow , asMessageText , asMessageCaption , aeTvMessageBoxButtons , aeTvMessageBoxIcon , true , aeTvMessageBoxCheckBoxType , aoProfile , asProfilePromptKey , tvMessageBoxResults.None ); }
public static tvMessageBoxResults Show( Window aoWindow , string asMessageText , string asMessageCaption , tvMessageBoxButtons aeTvMessageBoxButtons , tvMessageBoxIcons aeTvMessageBoxIcon , bool abShowModeless , tvMessageBoxCheckBoxTypes aeTvMessageBoxCheckBoxType , tvProfile aoProfile , string asProfilePromptKey , tvMessageBoxResults aeTvMessageBoxResultsOverride ) { tvMessageBoxResults liTvMessageBoxResult = tvMessageBoxResults.None; string lsPromptAnswerKey = null; bool lbUseCheckBox = tvMessageBoxCheckBoxTypes.None != aeTvMessageBoxCheckBoxType; if (lbUseCheckBox) { // Insert the prompt key prefix if it's not already there. A common prefix // is necessary to allow for the removal of all prompt keys as needed. if (!asProfilePromptKey.StartsWith(msProfilePromptKeyPrefix)) { // Strip leading hyphen. if (asProfilePromptKey.StartsWith("-")) { asProfilePromptKey = asProfilePromptKey.Substring(1, asProfilePromptKey.Length - 1); } // Insert prefix. asProfilePromptKey = msProfilePromptKeyPrefix + asProfilePromptKey; } // Make the answer key from the prompt key and the prompt key suffix. lsPromptAnswerKey = asProfilePromptKey + msProfilePromptKeySuffix; // Only the first display of a modeless dialog can contain a checkbox. // Why? Because the first prompt is not modeless. That's the only way // to capture the checkbox value. BTW, "lbUseCheckBox" is reset here // for use outside of this block to avoid the default setting next. if (abShowModeless) { lbUseCheckBox = !aoProfile.ContainsKey(asProfilePromptKey); } if (!aoProfile.bValue(asProfilePromptKey, false) && aoProfile.ContainsKey(lsPromptAnswerKey)) { // Do not prompt. Return the previous stored answer instead. return((tvMessageBoxResults)aoProfile.iValue( lsPromptAnswerKey, (int)tvMessageBoxResults.None)); } } if (null == asMessageCaption) { // No caption provided. Let's try to get one another way. if (null != aoWindow) // Try window title first. { asMessageCaption = aoWindow.Title; } else if (null != Application.Current && null != Application.Current.MainWindow) // Next try for application name. { asMessageCaption = Application.Current.MainWindow.Name; } else { asMessageCaption = System.IO.Path.GetFileNameWithoutExtension(Application.ResourceAssembly.Location); } } if (null != aoWindow) { aoWindow.Cursor = null; // Turn off wait cursor in parent window. } tvMessageBox loMsgBox = new tvMessageBox(); loMsgBox.MessageText.Text = asMessageText; // Use some parent window attributes, if available. if (null != aoWindow) { // Use the parent window's icon. loMsgBox.Icon = aoWindow.Icon; // Use the given asMessageCaption as the MsgBox title, if not null. // Otherwise use the parent window title with an added question mark. loMsgBox.Title = null != asMessageCaption ? asMessageCaption : aoWindow.Title + "?"; } // Display the MsgBox header / title (ie. the caption), if provided. if (null != asMessageCaption) { loMsgBox.MessageTitle.Content = asMessageCaption; loMsgBox.MessageTitle.Visibility = Visibility.Visible; } loMsgBox.SelectButtons(aeTvMessageBoxButtons); loMsgBox.SelectIcon(aeTvMessageBoxIcon); if (lbUseCheckBox) { switch (aeTvMessageBoxCheckBoxType) { case tvMessageBoxCheckBoxTypes.DontAsk: loMsgBox.chkDontAsk.Visibility = Visibility.Visible; break; case tvMessageBoxCheckBoxTypes.SkipThis: loMsgBox.chkSkipThis.Visibility = Visibility.Visible; break; } } if (!abShowModeless) { loMsgBox.ShowDialog(); } else { // It can only be modeless after the checkbox has been stored. if (lbUseCheckBox) { loMsgBox.ShowDialog(); } else { loMsgBox.Show(); } } if (lbUseCheckBox) { bool lbCheckBoxValue = false; switch (aeTvMessageBoxCheckBoxType) { case tvMessageBoxCheckBoxTypes.DontAsk: lbCheckBoxValue = (bool)loMsgBox.chkDontAsk.IsChecked; break; case tvMessageBoxCheckBoxTypes.SkipThis: lbCheckBoxValue = (bool)loMsgBox.chkSkipThis.IsChecked; break; } // Use the answer override whenever not "none". This value is // necessary for certain stored answers that don't make sense // in a given context (eg. both "skip this" and "cancel" selected). if (tvMessageBoxResults.None == aeTvMessageBoxResultsOverride) { aeTvMessageBoxResultsOverride = loMsgBox.eTvMessageBoxResult; } // Reverse the boolean. "Don't ask" or "Skip this" means "Don't prompt". aoProfile[asProfilePromptKey] = !lbCheckBoxValue; aoProfile[lsPromptAnswerKey] = (int)aeTvMessageBoxResultsOverride; aoProfile.Save(); } liTvMessageBoxResult = loMsgBox.eTvMessageBoxResult; return(liTvMessageBoxResult); }
private tvMessageBoxResults ShowModeless( string asMessageText , string asMessageCaption , tvMessageBoxButtons aetvMessageBoxButtons , tvMessageBoxIcons aetvMessageBoxIcon , string asProfilePromptKey ) { this.LogIt(asMessageText); tvMessageBoxResults ltvMessageBoxResults = tvMessageBoxResults.None; if ( null != this.oUI ) this.oUI.Dispatcher.BeginInvoke((Action)(() => { ltvMessageBoxResults = tvMessageBox.ShowModeless( this.oUI , asMessageText , asMessageCaption , aetvMessageBoxButtons , aetvMessageBoxIcon , tvMessageBoxCheckBoxTypes.SkipThis , moProfile , asProfilePromptKey ); } )); System.Windows.Forms.Application.DoEvents(); return ltvMessageBoxResults; }
// This collection of "Show" methods allows for pop-up messages // to be suppressed and written to the log file instead. private tvMessageBoxResults Show( string asMessageText , string asMessageCaption , tvMessageBoxButtons aetvMessageBoxButtons , tvMessageBoxIcons aetvMessageBoxIcon ) { if ( this.bNoPrompts ) moDoGoPcBackup.LogIt(asMessageText); tvMessageBoxResults ltvMessageBoxResults = tvMessageBoxResults.None; if ( !this.bNoPrompts ) ltvMessageBoxResults = tvMessageBox.Show( this , asMessageText , asMessageCaption , aetvMessageBoxButtons , aetvMessageBoxIcon ); return ltvMessageBoxResults; }