private async void ButtonAddProfile_Click(object sender, RoutedEventArgs e) { var dialog = new ProfileDialog(); var dialogResult = await dialog.ShowAsync(); if (dialogResult == ContentDialogResult.Primary) { var profile = dialog.Result; if (profile != null) { var existingElement = ProfileExists(profile); if (existingElement != null) { var yesNoDialog = new YesNoDialog("Profil bereits vorhanden", string.Format("Das Profil mit der Profilnummer '{0:s}', einer Länge von '{1:s}' und der Farbe '{2:s}' ist bereits vorhanden. " + "Soll das vorhandene Profil geändert werden?", profile.ProfileNumber, profile.Length, profile.Surface)); await yesNoDialog.ShowAsync(); if (yesNoDialog.Result == YesNoDialogType.Yes) { existingElement.Count += profile.Count; existingElement.Amount += profile.Amount; await UpdateProfile(existingElement); } return; } if (PlantOrder != null) { profile.PlantOrderId = PlantOrder.Id; } if (FileEntry != null) { profile.Filename = FileEntry.Name; } var profileId = await Proxy.CreateProfile(profile); if (profileId > 0) { profile.ProfileId = profileId; var element = AutoMapperConfiguration.Map(profile); ElementCollection.Add(element); } else { var errorDialog = new InfoDialog("Beim Anlegen des Profil's ist ein Fehler aufgetreten!", "Information", InfoDialogType.Error); await errorDialog.ShowAsync(); } } } }
private async void ButtonDeleteFilter_Click(object sender, RoutedEventArgs e) { if (sender is Button button && button.DataContext is ElementFilterModel filter) { var yesNoDialog = new YesNoDialog("Filter löschen?", "Soll der Filter " + Environment.NewLine + Environment.NewLine + $"Eigenschaft: {filter.PropertyText}" + Environment.NewLine + $"Aktion: {filter.ActionText}" + Environment.NewLine + $"Filter: {filter.Filter}" + Environment.NewLine + Environment.NewLine + "wirklich gelöscht werden?"); await yesNoDialog.ShowAsync(); if (yesNoDialog.Result == Dialogs.Core.Enums.YesNoDialogType.Yes) { } } }
private async void ButtonCreateFilter_Click(object sender, RoutedEventArgs e) { var filter = TextBoxFilter.Text; if (string.IsNullOrWhiteSpace(filter)) { var infoDialog = new InfoDialog("Das Feld für den gesuchten Wert muss ausgefüllt sein!"); await infoDialog.ShowAsync(); return; } var yesNoDialog = new YesNoDialog("Filter speichern?", "Soll der Filter für dieses Projekt gespeichert werden?" + Environment.NewLine + Environment.NewLine + "[Ja] Der Filter wird gespeichert, wird unter 'Bekannte Filter' hinzugefügt und ist für dieses Projekt jeder Zeit abrufbar" + Environment.NewLine + Environment.NewLine + "[Nein] Der Filter wird unter 'Bekannte Filter' hinzugefügt, ist jedoch nach Beenden dieser Sitzung nicht mehr verfügbar" + Environment.NewLine + Environment.NewLine + "[Abbrechen] Der Filter wird nicht erstellt"); await yesNoDialog.ShowAsync(); if (yesNoDialog.Result != Dialogs.Core.Enums.YesNoDialogType.Abort && PlantOrder != null) { var selectedProperty = (ComboBoxFilterProperty.SelectedItem as ComboBoxItem).Tag.ToString(); var selectedAction = (ComboBoxFilterAction.SelectedItem as ComboBoxItem).Tag.ToString(); var elementFilter = new ElementFilterModel() { Action = selectedAction, PropertyName = selectedProperty, Filter = filter, EmployeeId = CurrentEmployee.EmployeeId, PlantOrderId = PlantOrder.Id }; FilterCollection.Add(elementFilter); TextBoxFilter.Text = string.Empty; FilterFlyout.Hide(); Filter(selectedProperty, selectedAction, filter); FilterCollection.SelectedFilter = elementFilter; if (yesNoDialog.Result == Dialogs.Core.Enums.YesNoDialogType.Yes) { elementFilter.FilterId = await Proxy.UpsertElementFilter(elementFilter); } } }
/// <summary> /// Display the Yes No dialog /// </summary> /// <param name="message">The message</param> /// <param name="yesAction">The action executed if the 'yes' button is tapped</param> /// <param name="noAction">The action executed if the 'no' button is tapped</param> /// <param name="title">The title used for the dialog</param> private async void ShowYesNoDialog(string message, Action yesAction, Action noAction, string title = null) { var dialog = new YesNoDialog() { Title = title, Message = message }; ContentDialogResult result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary) { yesAction(); } else { noAction(); } }
/// <summary> /// A yes or no input box. /// </summary> /// <param name="message"></param> /// <param name="title"></param> /// <param name="primaryButtonText"></param> /// <param name="secondaryButtonText"></param> public static async Task <bool> InputBox(string message, string title, string primaryButtonText = "Yes", string secondaryButtonText = "No") { var confirmDialog = new YesNoDialog() { Title = title, Content = message, PrimaryButtonText = primaryButtonText, SecondaryButtonText = secondaryButtonText }; var result = await confirmDialog.ShowAsync(); if (result == ContentDialogResult.Secondary) { return(false); } return(true); }
private async void MenuItemDeleteDivision_Click(object sender, RoutedEventArgs e) { if (DataGridDivision.SelectedItem is DivisionModel division) { var dialog = new YesNoDialog("Abteilung löschen?", $"Soll die Abteilung '{division.Name}' wirklich gelöscht werden?"); await dialog.ShowAsync(); if (dialog.Result == YesNoDialogType.Yes) { var result = await Proxy.DeleteDivision(division.DivisionId); if (result) { ShowNofificationMessage($"{division.Name} wurde gelöscht"); Divisions.Remove(division); } else { ShowNofificationMessage($"{division.Name} konnte nicht gelöscht werden", true); } } } }
private async void ButtonDelete_Click(object sender, RoutedEventArgs e) { if (sender is Button button && button.DataContext is ElementModel element) { var yesNoDialog = new YesNoDialog("Profil löschen?", string.Format("Bist Du sicher, dass das Profil mit der Profilnummer '{0:s}' gelöscht werden soll?", element.Position)); await yesNoDialog.ShowAsync(); if (yesNoDialog.Result == YesNoDialogType.Yes) { var result = await Proxy.DeleteProfileAsync(element.Id); if (!result) { var dialog = new InfoDialog(string.Format("Das Profil mit der Profilnummer '{0:s}' konnte nicht gelöscht werden!", element.Position)); await dialog.ShowAsync(); } else { ElementCollection.Remove(element); } } } }