protected override void OnClosing(CancelEventArgs e) { var dialog = new YesNoDialog { Message = "Do you really want to close this application?" }; e.Cancel = dialog.ShowDialog() == false; }
private static void ShowErrorDialog(Exception ex) { YesNoDialogViewModel dialogViewModel = new YesNoDialogViewModel("Error", ex.ToString(), "OK", string.Empty, null, null); YesNoDialog dialog = new YesNoDialog(dialogViewModel); dialog.ShowDialog(); }
private async void RemoveTraining(object sender, RoutedEventArgs e) { var button = (Button)sender; var window = new YesNoDialog { Message = $"Are you sure that you want to delete this training?" }; var result = window.ShowDialog(); if (result == true) { await ViewModel.RemoveModel((TrainingModel)button.Tag); } }
private IEnumerator HandleDialogEvent(string name, string args, string dialog, int i) { newI = i; if (name.Equals("Lock Book")) { bool lockBook = System.Boolean.Parse(args.Trim()); left.enabled = !lockBook; right.enabled = !lockBook; leftLock.enabled = lockBook; rightLock.enabled = lockBook; yield return(new WaitForSeconds(0.1f)); result = true; done = true; yield return(true); } else if (name.Equals("Choice")) { string[] choices = args.Split(new char[] { ',' }); int yesChoice = System.Int32.Parse(choices [0].Trim()) - 1; int noChoice = System.Int32.Parse(choices [1].Trim()) - 1; YesNoDialog.dialog = yesNoDialog; yield return(StartCoroutine(YesNoDialog.ShowDialog(dialog))); if (YesNoDialog.Choice()) { newI = yesChoice; } else { newI = noChoice; } yield return(new WaitForSeconds(0.1f)); result = true; done = true; yield return(true); } result = false; done = true; yield return(false); }
private void UpdateCurrentRoomInternal([NotNull] ZoneViewModel newCurrentZone, [CanBeNull] RoomViewModel newCurrentRoom) { Assert.ArgumentNotNull(newCurrentZone, "newCurrentZone"); if (_currentlyRecordedRoute != null && newCurrentRoom != null) { var lastRoom = _currentlyRecordedRoute.RouteRoomIdentifiers.LastOrDefault(); if (lastRoom != newCurrentRoom.RoomId) { _currentlyRecordedRoute.RouteRoomIdentifiers.Add(newCurrentRoom.RoomId); if (_routeEndRoomIdentifiers.Contains(newCurrentRoom.RoomId) && newCurrentRoom.RoomId != _currentlyRecordedRoute.StartRoomId) { var existingRoute = _allRoutes.FirstOrDefault(r => r.StartRoomId == _currentlyRecordedRoute.StartRoomId && r.EndRoomId == newCurrentRoom.RoomId); existingRoute = existingRoute ?? _allRoutes.FirstOrDefault(r => r.EndRoomId == _currentlyRecordedRoute.StartRoomId && r.StartRoomId == newCurrentRoom.RoomId); _currentRoom = newCurrentRoom; _currentZone = newCurrentZone; if (existingRoute != null) { var yesNoDialog = new YesNoDialog { Owner = _mainWindow, Title = Resources.RouteAlreadyExistsTitle, TextToDisplay = string.Format(CultureInfo.InvariantCulture, Resources.RouteAlreadyExistsQuestion, existingRoute.StartName, existingRoute.EndName) }; var res = yesNoDialog.ShowDialog(); if (res.HasValue && res.Value) { StopRouteRecording(); StartNewRouteRecording(); _allRoutes.Remove(existingRoute); RebuildRouteIndexes(); } else { _currentlyRecordedRoute = null; StartNewRouteRecording(); } } else { StopRouteRecording(); StartNewRouteRecording(); } UpdateCurrentZoneRooms(); } Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action)(() => newCurrentRoom.IsPartOfRecordedRoute = true)); } } if (!string.IsNullOrEmpty(_currentRouteTarget) && newCurrentRoom != null) { var routesContainigCurrentRoom = _allRoutes.Where(r => r.RoomIdentifiersSet.Contains(newCurrentRoom.RoomId)); Route minRoute = null; int minDestinationLength = int.MaxValue; bool gotoStart = false; bool targetAchieved = false; foreach (var route in routesContainigCurrentRoom) { if (route.StartRoomId == newCurrentRoom.RoomId && string.Equals(_currentRouteTarget, route.StartName, StringComparison.CurrentCultureIgnoreCase)) { targetAchieved = true; break; } if (route.EndRoomId == newCurrentRoom.RoomId && string.Equals(_currentRouteTarget, route.EndName, StringComparison.CurrentCultureIgnoreCase)) { targetAchieved = true; break; } if (route.RoutePointsAvailableFromStart.ContainsKey(_currentRouteTarget)) { if (route.StartRoomId != newCurrentRoom.RoomId && route.RoutePointsAvailableFromStart[_currentRouteTarget] < minDestinationLength) { gotoStart = true; minDestinationLength = route.RoutePointsAvailableFromStart[_currentRouteTarget]; minRoute = route; } } if (route.RoutePointsAvailableFromEnd.ContainsKey(_currentRouteTarget)) { if (route.EndRoomId != newCurrentRoom.RoomId && route.RoutePointsAvailableFromEnd[_currentRouteTarget] < minDestinationLength) { gotoStart = false; minDestinationLength = route.RoutePointsAvailableFromEnd[_currentRouteTarget]; minRoute = route; } } } if (targetAchieved) { _rootModel.PushMessageToConveyor(new InfoMessage(string.Format(CultureInfo.InvariantCulture, Resources.RouteTargetAchieved, _currentRouteTarget), TextColor.BrightYellow)); StopRoutingToDestination(); } else if (minRoute == null) { _rootModel.PushMessageToConveyor(new ErrorMessage(string.Format(CultureInfo.InvariantCulture, Resources.RouteTargetIsNotAvailable, _currentRouteTarget))); StopRoutingToDestination(); } else if (_rootModel.GroupStatus.Count(gr => gr.InSameRoom) != _groupMembersCountOnRouteStart || _rootModel.GroupStatus.Any(gr => gr.InSameRoom && gr.MovesPercent < 2)) { _rootModel.PushMessageToConveyor(new ErrorMessage(Resources.RouteGroupMateLostOrTired)); StopRoutingToDestination(); } else { var currentRoomIndex = minRoute.RouteRoomIdentifiers.IndexOf(newCurrentRoom.RoomId); int nextRoomId = gotoStart ? minRoute.RouteRoomIdentifiers[currentRoomIndex - 1] : minRoute.RouteRoomIdentifiers[currentRoomIndex + 1]; var exit = newCurrentRoom.Room.Exits.FirstOrDefault(ex => ex.RoomId == nextRoomId); if (exit == null) { _rootModel.PushMessageToConveyor(new ErrorMessage(string.Format(CultureInfo.InvariantCulture, Resources.RouteTargetIsNotAvailable, _currentRouteTarget))); StopRoutingToDestination(); } else { GotoDirection(exit.Direction); } } } var prevZone = _currentZone; _currentRoom = newCurrentRoom; _currentZone = newCurrentZone; if (prevZone == null || prevZone.Id != _currentZone.Id) { UpdateCurrentZoneRooms(); } }
/// <summary> /// Message that requires user confirmation or denial (yes/no) /// </summary> /// <param name="text">message body</param> /// <param name="header">message header</param> /// <returns>true if yes, false if no</returns> public bool ShowYesNo(string text, string header) { YesNoDialog dlg = new YesNoDialog(text, header); return(dlg.ShowDialog() == DialogResult.Yes); }