diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2017-12-19 10:25:40 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2017-12-19 10:25:40 +0200 |
| commit | afc7a07d285e08d905c58dd5978441c155b2f296 (patch) | |
| tree | a2f4f51ef2747ae3a2aded2637a352ce8ef85934 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs | |
| parent | ad35c9c2df0001157ea13312382f3cdfdad67f06 (diff) | |
| download | Tango-afc7a07d285e08d905c58dd5978441c155b2f296.tar.gz Tango-afc7a07d285e08d905c58dd5978441c155b2f296.zip | |
MERGE.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs | 104 |
1 files changed, 100 insertions, 4 deletions
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<T>(PackIconKind icon, string title, object context) where T : FrameworkElement + public ObservableCollection<TaskItem> TaskItems { get; private set; } + + public bool HasTaskItems { - return ShowDialog(icon, title, Activator.CreateInstance<T>(), 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<TaskItem>(); + } + + public bool ShowModalWindow<T>(PackIconKind icon, string title, object context) where T : FrameworkElement + { + return ShowModalWindow(icon, title, Activator.CreateInstance<T>(), 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)); + } } } |
