/// <summary> /// Show question dialog. /// </summary> /// <param name="objectName">Name of object to deleting.</param> /// <param name="typeNameObjectResource">Type name object in string resources.</param> /// <param name="typeNameObjectsResource">Type name objects in string resources.</param> /// <returns>User choice "Yes" - true.</returns> static private bool _ShowDialog(string objectName, string typeNameObjectResource, string typeNameObjectsResource) { Debug.Assert(!string.IsNullOrEmpty(typeNameObjectResource)); Debug.Assert(!string.IsNullOrEmpty(typeNameObjectsResource)); string typeNameObject = ((string)App.Current.FindResource(typeNameObjectResource)).ToLower(); string title = string.Format((string)App.Current.FindResource("DeletingDialogTitleFormat"), typeNameObject); string message = null; if (!string.IsNullOrEmpty(objectName)) { message = string.Format((string)App.Current.FindResource("DeletingDialogTextOne"), objectName, typeNameObject); } else { string typeNameObjects = ((string)App.Current.FindResource(typeNameObjectsResource)).ToLower(); message = string.Format((string)App.Current.FindResource("DeletingDialogTextSome"), typeNameObjects); } bool dontAsk = false; MessageBoxExButtonType result = MessageBoxEx.Show(App.Current.MainWindow, message, title, System.Windows.Forms.MessageBoxButtons.YesNo, MessageBoxImage.Question, (string)App.Current.FindResource("DeletingDialogCheckBoxText"), ref dontAsk); if (dontAsk) { // update response Properties.Settings.Default.IsAllwaysAskBeforeDeletingEnabled = false; Properties.Settings.Default.Save(); } return(MessageBoxExButtonType.Yes == result); }
/// <summary> /// Show dialog, where user can choose update routes or not. /// </summary> /// <returns>"True" if user decided to update routes, "false" otherwise.</returns> private bool _ShowDialog() { // Get strings from resources. string question = (string)App.Current.FindResource("DefaultRoutesApplyingDialogText"); string checboxLabel = (string)App.Current.FindResource("BreaksApplyingDialogCheckbox"); string title = (string)App.Current.FindResource("DefaultRoutesApplyingDialogTitle"); // Flag - show this dialog in future or not. bool dontAsk = true; // Show dialog and convert result to bool. MessageBoxExButtonType pressedButton = MessageBoxEx.Show(App.Current.MainWindow, question, title, System.Windows.Forms.MessageBoxButtons.YesNo, MessageBoxImage.Question, checboxLabel, ref dontAsk); bool result = (pressedButton == MessageBoxExButtonType.Yes); // If user checked checbox - we dont need to show this dialog in future, so // update corresponding settings. if (dontAsk) { Properties.Settings.Default. IsAlwaysAskAboutApplyingDefaultRoutesToSheduledRoutes = false; Settings.Default.ApplyDefaultRoutesToSheduledRoutes = result; Properties.Settings.Default.Save(); } // Return user choice. return(result); }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Does cancel operation. /// Block operation. Show real stop question. /// </summary> public void Cancel() { _worker.Suspend(); // show real stop question App currentApp = App.Current; string text = currentApp.FindString("ImportProcessCanceledQuestion"); string caption = currentApp.FindString("ApplicationTitle"); MessageBoxExButtonType result = MessageBoxEx.Show(currentApp.MainWindow, text, caption, System.Windows.Forms.MessageBoxButtons.YesNo, MessageBoxImage.Question); // user choice "Yes" do cancel if (MessageBoxExButtonType.Yes == result) { if (_worker.IsBusy) { _worker.CancelAsync(); } } _worker.Resume(); }
/// <summary> /// Gets button localized caption by button type. /// </summary> /// <param name="button">Button type.</param> /// <returns>Caption text from resources.</returns> private string _GetButtonCaption(MessageBoxExButtonType button) { string resourceName = null; switch (button) { case MessageBoxExButtonType.Ok: resourceName = "ButtonHeaderOk"; break; case MessageBoxExButtonType.Cancel: resourceName = "ButtonHeaderCancel"; break; case MessageBoxExButtonType.Yes: resourceName = "ButtonHeaderYes"; break; case MessageBoxExButtonType.No: resourceName = "ButtonHeaderNo"; break; case MessageBoxExButtonType.Abort: resourceName = "ButtonHeaderAbort"; break; case MessageBoxExButtonType.Retry: resourceName = "ButtonHeaderRetry"; break; case MessageBoxExButtonType.Ignore: resourceName = "ButtonHeaderIgnore"; break; default: Debug.Assert(false); // NOTE: not supported break; } Debug.Assert(null != resourceName); return((string)App.Current.FindResource(resourceName)); }
/// <summary> /// Check that routes should be sent to feature services. /// </summary> /// <returns>'True' if routes must be send, 'false' otherwise.</returns> private bool _RoutesMustBeSent() { var date = (DateTime)_sendRoutesTask.GetDeploymentDate(); // If we haven't sent routes before - we could sent it now without asking user. if (App.Current.Tracker.CheckRoutesHasntBeenSent( _sendRoutesTask.QueryRoutesToBeSent(), (DateTime)date)) { return(true); } // Ask user that he want to sent new routes to feature server and overwrite existing ones. MessageBoxExButtonType pressedButton = MessageBoxEx.Show(App.Current.MainWindow, Properties.Resources.OverwriteFeatureServiceRoutesMessageBoxText, Properties.Resources.OverwriteFeatureServiceRoutesMessageBoxCaption, System.Windows.Forms.MessageBoxButtons.YesNo, MessageBoxImage.Question); // Return his answer. return(pressedButton == MessageBoxExButtonType.Yes); }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// public static bool Check(Schedule schedule, ICollection <Route> routes, ICollection <Order> orders) { Debug.Assert(null != schedule); Debug.Assert(null != routes); Debug.Assert(null != orders); bool doesProcessStart = true; if (Properties.Settings.Default.IsRoutingConstraintCheckEnabled) { ICollection <MessageDetail> details = _Check(schedule, routes, orders); if (0 < details.Count) { Debug.Assert(schedule.PlannedDate.HasValue); DateTime date = schedule.PlannedDate.Value; string text = App.Current.GetString("ConstraintsCheckerHeadMessageFmt", date.ToShortDateString()); App.Current.Messenger.AddWarning(text, details); bool ignoreCheck = false; MessageBoxExButtonType result = MessageBoxEx.Show(App.Current.MainWindow, App.Current.FindString("ConstraintsCannotBeMetText"), App.Current.FindString("ConstraintsCannotBeMetTitle"), System.Windows.Forms.MessageBoxButtons.YesNo, MessageBoxImage.Warning, App.Current.FindString("ConstraintsCannotBeMetCheckBoxText"), ref ignoreCheck); if (ignoreCheck) { // update response Properties.Settings.Default.IsRoutingConstraintCheckEnabled = false; Properties.Settings.Default.Save(); } doesProcessStart = (MessageBoxExButtonType.Yes == result); } } return(doesProcessStart); }
/// <summary> /// Shows warning virtual location detected. /// </summary> /// <returns>TRUE if clicked 'OK'.</returns> private static bool _ShowVirtualLocationDialog() { string applicationName = App.Current.FindString("ApplicationTitle"); string title = App.Current.GetString("VirtualLocationDialogTitleFmt", applicationName); bool dontAsk = false; MessageBoxExButtonType result = MessageBoxEx.Show(App.Current.MainWindow, App.Current.FindString("VirtualLocationDialogText"), title, System.Windows.Forms.MessageBoxButtons.OKCancel, MessageBoxImage.Warning, App.Current.FindString("VirtualLocationDialogCheckBoxText"), ref dontAsk); if (dontAsk) { // update response Properties.Settings.Default.WarnUserIfVirtualLocationDetected = false; Properties.Settings.Default.Save(); } return(MessageBoxExButtonType.Ok == result); }
/// <summary> /// Add a standard button to the message box. /// </summary> /// <param name="button">The standard button to add.</param> /// <param name="isCancelResult">The return value for this button in case if dialog /// closes without pressing any button.</param> private void _AddButton(MessageBoxExButtonType buttonType, bool isCancelResult) { // The text of the button. string caption = _GetButtonCaption(buttonType); // Text must be not null. Debug.Assert(!string.IsNullOrEmpty(caption)); // Create button. MessageBoxExButton button = new MessageBoxExButton(); button.Caption = caption; // The return value in case this button is clicked. button.Value = buttonType; if (isCancelResult) { button.IsCancelButton = true; } // Add a custom button to the message box. _msgBox.Buttons.Add(button); }
/// <summary> /// Gets button localized caption by button type. /// </summary> /// <param name="button">Button type.</param> /// <returns>Caption text from resources.</returns> private string _GetButtonCaption(MessageBoxExButtonType button) { string resourceName = null; switch(button) { case MessageBoxExButtonType.Ok: resourceName = "ButtonHeaderOk"; break; case MessageBoxExButtonType.Cancel: resourceName = "ButtonHeaderCancel"; break; case MessageBoxExButtonType.Yes: resourceName = "ButtonHeaderYes"; break; case MessageBoxExButtonType.No: resourceName = "ButtonHeaderNo"; break; case MessageBoxExButtonType.Abort: resourceName = "ButtonHeaderAbort"; break; case MessageBoxExButtonType.Retry: resourceName = "ButtonHeaderRetry"; break; case MessageBoxExButtonType.Ignore: resourceName = "ButtonHeaderIgnore"; break; default: Debug.Assert(false); // NOTE: not supported break; } Debug.Assert(null != resourceName); return (string)App.Current.FindResource(resourceName); }
/// <summary> /// Add a standard button to the message box. /// </summary> /// <param name="button">The standard button to add.</param> /// <param name="isCancelResult">The return value for this button in case if dialog /// closes without pressing any button.</param> private void _AddButton(MessageBoxExButtonType buttonType, bool isCancelResult) { // The text of the button. string caption = _GetButtonCaption(buttonType); // Text must be not null. Debug.Assert(!string.IsNullOrEmpty(caption)); // Create button. MessageBoxExButton button = new MessageBoxExButton(); button.Caption = caption; // The return value in case this button is clicked. button.Value = buttonType; if (isCancelResult) button.IsCancelButton = true; // Add a custom button to the message box. _msgBox.Buttons.Add(button); }