From afc7a07d285e08d905c58dd5978441c155b2f296 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 19 Dec 2017 10:25:40 +0200 Subject: MERGE. --- .../Notifications/DefaultNotificationProvider.cs | 104 ++++++++++++++++++++- 1 file changed, 100 insertions(+), 4 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..b1ba03109 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,49 @@ using System.Windows; using MaterialDesignThemes.Wpf; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.UI.Windows; +using System.Windows.Media; +using Tango.Core; +using System.Collections.ObjectModel; namespace Tango.MachineStudio.UI.Notifications { - public class DefaultNotificationProvider : INotificationProvider + public class DefaultNotificationProvider : ExtendedObject, INotificationProvider { - public bool ShowDialog(PackIconKind icon, string title, object context) where T : FrameworkElement + public ObservableCollection TaskItems { get; private set; } + + public bool HasTaskItems { - return ShowDialog(icon, title, Activator.CreateInstance(), context); + get { return TaskItems.Count > 0; } } - public bool ShowDialog(PackIconKind icon, string title, FrameworkElement content, object context) + private TaskItem _currentTaskItem; + + public TaskItem CurrentTaskItem + { + get { return _currentTaskItem; } + set { _currentTaskItem = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(HasTaskItems)); } + } + + public DefaultNotificationProvider() + { + TaskItems = new ObservableCollection(); + } + + public bool ShowModalWindow(PackIconKind icon, string title, object context) where T : FrameworkElement + { + return ShowModalWindow(icon, title, Activator.CreateInstance(), 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 +60,69 @@ 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, true).Value; + } + + public void ShowWarnning(string message) + { + ShowDialog(PackIconKind.Exclamation, Brushes.DarkOrange, message, false); + } + + public void PushTaskItem(TaskItem taskItem) + { + TaskItems.Add(taskItem); + CurrentTaskItem = taskItem; + } + + public TaskItem PushTaskItem(string message) + { + TaskItem item = new TaskItem(this); + item.Message = message; + PushTaskItem(item); + return item; + } + + public void PopTaskItem(TaskItem taskItem) + { + TaskItems.Remove(taskItem); + + if (TaskItems.Count > 0) + { + CurrentTaskItem = TaskItems.Last(); + } + + RaisePropertyChanged(nameof(HasTaskItems)); + } } } -- cgit v1.3.1