public MainWindowViewModel()
        {
            MessageBoxCommand = new DelegateCommand(async() =>
            {
                var info = new MessageBoxNotification()
                {
                    Title   = "Confirm",
                    Content = "aaaaaaaaaaaaaaaaaaaaaaaaaa\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\ncccccc",
                    Icon    = MessageBoxNotification.IconType.Question,
                    Button  = MessageBoxNotification.ButtonType.OkCancel
                };

                var result = await MessageBoxRequest.RaiseAsync(info);
                Debug.WriteLine(result.Confirmed);
            });

            var notify = new SubWindowNotification();

            SubWindowShowCommand = new DelegateCommand(() =>
            {
                SubWindowRequest.Raise(notify);
            });

            SubWindowCloseCommand = new DelegateCommand(() =>
            {
                notify.DoClosing();
            });
        }
        public void PromptYesNoCancel(string text, string title = "Yes or No?",
                                      MessageBoxImage icon      = MessageBoxImage.Question,
                                      Action yesAction          = null, Action noAction = null, Action cancelAction = null)
        {
            MessageBoxRequest?.Invoke(this, new MessageBoxEventArgs(text)
            {
                Title    = title,
                Icon     = icon,
                Buttons  = MessageBoxButton.YesNoCancel,
                Callback = (r) =>
                {
                    switch (r)
                    {
                    case MessageBoxResult.Yes:
                        yesAction?.Invoke();
                        break;

                    case MessageBoxResult.No:
                        noAction?.Invoke();
                        break;

                    case MessageBoxResult.Cancel:
                        cancelAction?.Invoke();
                        break;
                    }
                }
            });
        }
Exemple #3
0
 public void PromptConfirmRevert(Action <MessageBoxResult> callback)
 {
     MessageBoxRequest?.Invoke(this, new MessageBoxEventArgs(
                                   "Reverting the file will cause you to lose all unsaved changes.\n\n" +
                                   "Continue?", "Revert File",
                                   MessageBoxButton.YesNo, MessageBoxImage.Warning, callback: callback));
 }
        private void Speichern(object obj)
        {
            try
            {
                NotenSaveAble();


                foreach (Leistung l in LstLeistungen)
                {
                    l.LetzteÄnderung = DateTime.Now;
                    DBZugriff.Current.Speichern(l, false);
                }
                DBZugriff.Current.Save();

                try
                {
                    CloseAfterSaveRequesting?.Invoke(this, new EventArgs());
                }
                catch (Exception e)
                {
                    Trace.WriteLine("[LeiEdit] InvokeFailed: " + e.ToString());
                }
            }
            catch (Exception e)
            {
                MessageBoxRequest?.Invoke(this, new MessageBoxEventArgs(new Action <System.Windows.MessageBoxResult>((MessageBoxResult) => { }),

                                                                        "Fehler beim Speichern: " + e.Message,
                                                                        "Fehler",
                                                                        System.Windows.MessageBoxButton.OK,
                                                                        System.Windows.MessageBoxImage.Error));

                Trace.WriteLine("[LeiEdit] Speichern: " + e.ToString());
            }
        }
Exemple #5
0
 public void PromptExternalChangesDetected(Action <MessageBoxResult> callback)
 {
     MessageBoxRequest?.Invoke(this, new MessageBoxEventArgs(
                                   "The file has been modified on disk.\n\n" +
                                   "Do you want to reload the file? You will lose all unsaved changes.",
                                   "External Changes Detected",
                                   MessageBoxButton.YesNo, MessageBoxImage.Warning, callback: callback));
 }
Exemple #6
0
        private async Task <MessageBoxButtons> HandleShowRequest(MessageBoxRequest request)
        {
            this.request          = request;
            this.resultCompletion = new TaskCompletionSource <MessageBoxButtons>();

            StateHasChanged();

            await messageBox.ShowAsync();

            return(await this.resultCompletion.Task);
        }
 /// <summary>
 /// Ein Zeugnisfach löschen und aus der Liste entfernen
 /// </summary>
 /// <param name="obj"></param>
 private void OnLoeschen(object obj)
 {
     MessageBoxRequest?.Invoke(this, new MessageBoxEventArgs()
     {
         Caption          = "Sind Sie sicher?",
         MessageBoxText   = $"Wollen sie das Zeugnisfach {SelectedZFach.Bez} wirklich löschen?",
         MessageBoxButton = System.Windows.MessageBoxButton.YesNo,
         MessageBoxImage  = System.Windows.MessageBoxImage.Question,
         ResultAction     = (result) =>
         {
             if (result == System.Windows.MessageBoxResult.Yes)
             {
                 SelectedZFach.Loeschen();
                 Zfaecher.Remove(SelectedZFach);
             }
         }
     });
 }
Exemple #8
0
 public void PromptYesNo(string message,
                         string title          = "Yes or No?",
                         MessageBoxImage image = MessageBoxImage.Question,
                         Action yesCallback    = null,
                         Action noCallback     = null)
 {
     MessageBoxRequest?.Invoke(this, new MessageBoxEventArgs(
                                   message,
                                   title: title,
                                   icon: image,
                                   buttons: MessageBoxButton.YesNo,
                                   callback: (r) =>
     {
         if (r == MessageBoxResult.Yes)
         {
             yesCallback?.Invoke();
         }
         else
         {
             noCallback?.Invoke();
         }
     }));
 }
Exemple #9
0
 public void PromptOkCancel(string message,
                            string title          = "Accept?",
                            MessageBoxImage image = MessageBoxImage.Question,
                            Action okCallback     = null,
                            Action cancelCallback = null)
 {
     MessageBoxRequest?.Invoke(this, new MessageBoxEventArgs(
                                   message,
                                   title: title,
                                   icon: image,
                                   buttons: MessageBoxButton.OKCancel,
                                   callback: (r) =>
     {
         if (r == MessageBoxResult.OK)
         {
             okCallback?.Invoke();
         }
         if (r == MessageBoxResult.Cancel)
         {
             cancelCallback?.Invoke();
         }
     }));
 }
        public void PromptOkCancel(string text, string title = "Confirm?",
                                   MessageBoxImage icon      = MessageBoxImage.Question,
                                   Action okAction           = null, Action cancelAction = null)
        {
            MessageBoxRequest?.Invoke(this, new MessageBoxEventArgs(text)
            {
                Title    = title,
                Icon     = icon,
                Buttons  = MessageBoxButton.OKCancel,
                Callback = (r) =>
                {
                    switch (r)
                    {
                    case MessageBoxResult.OK:
                        okAction?.Invoke();
                        break;

                    case MessageBoxResult.Cancel:
                        cancelAction?.Invoke();
                        break;
                    }
                }
            });
        }
 public Task <MessageBoxButtons> ShowAsync(MessageBoxRequest request)
 {
     return(OnShowAsync.Invoke(request));
 }
Exemple #12
0
 public void PromptSaveChanges(Action <MessageBoxResult> callback)
 {
     MessageBoxRequest?.Invoke(this, new MessageBoxEventArgs(
                                   "Do you want to save your changes?", "Save Changes?",
                                   MessageBoxButton.YesNoCancel, MessageBoxImage.Question, callback: callback));
 }
Exemple #13
0
 public void ShowError(string text, string title = "Error")
 {
     MessageBoxRequest?.Invoke(this, new MessageBoxEventArgs(
                                   text, title, icon: MessageBoxImage.Error));
 }
Exemple #14
0
 public void ShowWarning(string text, string title = "Warning")
 {
     MessageBoxRequest?.Invoke(this, new MessageBoxEventArgs(
                                   text, title, icon: MessageBoxImage.Warning));
 }
Exemple #15
0
 public void ShowInfo(string text, string title = "Information")
 {
     MessageBoxRequest?.Invoke(this, new MessageBoxEventArgs(
                                   text, title, icon: MessageBoxImage.Information));
 }
 protected virtual void ShowMessageBox(Action <MessageBoxResult> resultAction, string messageBoxText, string caption = "", MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.None, MessageBoxOptions options = MessageBoxOptions.None)
 {
     MessageBoxRequest?.Invoke(this, new MessageBoxEventArgs(resultAction, messageBoxText, caption, button, icon, defaultResult, options));
 }
Exemple #17
0
        private void OnDateiImportieren(object obj)
        {
            bool fileFound = true;

            try
            {
                DateiPfad.ToString();
            }

            catch (Exception)
            {
                // Fehlermeldung, wenn keine Datei gefunden oder falscher Dateipfad angegeben.
                MessageBoxRequest?.Invoke(this, new MessageBoxEventArgs()
                {
                    Caption          = "Datei nicht gefunden!",
                    MessageBoxText   = "Datei nicht gefunden oder keine Datei ausgewählt!",
                    MessageBoxImage  = System.Windows.MessageBoxImage.Information,
                    MessageBoxButton = System.Windows.MessageBoxButton.OK,
                });
                fileFound = false;
            }

            if (fileFound)
            {
                try
                {
                    Importstatistik rueckmeldung = null;

                    // bestimmen um welche Dateiart es sich handelt und diese entsprechend importieren
                    switch (DateiTyp.Content.ToString())
                    {
                    case "Klassen":
                        rueckmeldung = DateiZugriff.ImportKlassen(DateiPfad, SelektierteSchule);
                        break;

                    case "Schüler":
                        rueckmeldung = DateiZugriff.ImportSchueler(DateiPfad);
                        break;

                    case "Lehrer":
                        rueckmeldung = DateiZugriff.ImportLehrer(DateiPfad);
                        break;

                    default:
                        break;
                    }

                    // Erfolgsmeldung
                    if (rueckmeldung != null)
                    {
                        MessageBoxRequest?.Invoke(this, new MessageBoxEventArgs()
                        {
                            Caption          = "Datei-Import abgeschlossen",
                            MessageBoxText   = $"{DateiTyp.Content.ToString()}-Datei erfolgreich importiert!\r\n\r\n{rueckmeldung?.ToString()}",
                            MessageBoxImage  = System.Windows.MessageBoxImage.Information,
                            MessageBoxButton = System.Windows.MessageBoxButton.OK,
                        });
                    }

                    DateiPfad = "";
                }
                catch (Exception e)
                {
                    // Fehlermeldung
                    MessageBoxRequest?.Invoke(this, new MessageBoxEventArgs()
                    {
                        Caption          = "Datei-Import konnte nicht abgeschlossen werden...",
                        MessageBoxText   = e.Message,
                        MessageBoxImage  = System.Windows.MessageBoxImage.Exclamation,
                        MessageBoxButton = System.Windows.MessageBoxButton.OK
                    });
                }
            }
        }
Exemple #18
0
 // um Lehrer zu entfernen
 private void OnBtnLehrerEntfernen(object obj)
 {
     MessageBoxRequest?.Invoke(this, new MessageBoxEventArgs(DoLehrerEntfernen, "Wirklich entfernen?", "Sind Sie sicher?", MessageBoxButton.YesNo, MessageBoxImage.Question));
 }
 public void ShowMessageBox(MessageBoxEventArgs e)
 {
     MessageBoxRequest?.Invoke(this, e);
 }