From 27fe2f3f63191ecefbb00f16acf2b8b089a30d83 Mon Sep 17 00:00:00 2001 From: Roy Date: Fri, 15 Dec 2017 03:34:09 +0200 Subject: Added Login. Implemented message boxes through notification provider. Implemented VM auto validation using data annotation. --- .../Notifications/DefaultNotificationProvider.cs | 54 ++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs index 8e0fd2220..fae8dc7d5 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs @@ -7,17 +7,27 @@ using System.Windows; using MaterialDesignThemes.Wpf; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.UI.Windows; +using System.Windows.Media; namespace Tango.MachineStudio.UI.Notifications { public class DefaultNotificationProvider : INotificationProvider { - public bool ShowDialog(PackIconKind icon, string title, object context) where T : FrameworkElement + public bool ShowModalWindow(PackIconKind icon, string title, object context) where T : FrameworkElement { - return ShowDialog(icon, title, Activator.CreateInstance(), context); + return ShowModalWindow(icon, title, Activator.CreateInstance(), context); } - public bool ShowDialog(PackIconKind icon, string title, FrameworkElement content, object context) + public bool? ShowModalWindow(Window window) + { + window.Owner = Application.Current.MainWindow; + MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; + bool result = window.ShowDialog().Value; + MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; + return result; + } + + public bool ShowModalWindow(PackIconKind icon, string title, FrameworkElement content, object context) { DialogWindow dialog = new DialogWindow(content); dialog.DataContext = context; @@ -28,5 +38,43 @@ namespace Tango.MachineStudio.UI.Notifications MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; return result; } + + public bool? ShowDialog(PackIconKind icon, Brush iconColor, string message, bool hasCancel) + { + MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; + + var result = new MessageBoxWindow() + { + Owner = Application.Current.MainWindow, + Message = message, + IconKind = icon, + IconColor = iconColor, + HasCancel = hasCancel + + }.ShowDialog(); + + MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; + return result; + } + + public void ShowError(string message) + { + ShowDialog(PackIconKind.Exclamation, Brushes.Red, message, false); + } + + public void ShowInfo(string message) + { + ShowDialog(PackIconKind.Information, Brushes.Black, message, false); + } + + public bool ShowQuestion(string message) + { + return ShowDialog(PackIconKind.CommentQuestionOutline, Brushes.Black, message, false).Value; + } + + public void ShowWarnning(string message) + { + ShowDialog(PackIconKind.Exclamation, Brushes.DarkOrange, message, false); + } } } -- cgit v1.3.1