diff options
| author | Avi Levkovich <avi@twine-s.com> | 2017-12-19 12:28:20 +0200 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2017-12-19 12:28:20 +0200 |
| commit | 76aa983631df4fa5b16b170e2f6dd845c5ac9531 (patch) | |
| tree | 6b2b4d0776c54536ec07aabc6be94857dcee91fc /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs | |
| parent | 6bf71c81050b824398dc82ce4b69cdf71fb4a2f7 (diff) | |
| parent | b421701fd5cf000a16cab9b1fe9eda812ccce8c3 (diff) | |
| download | Tango-76aa983631df4fa5b16b170e2f6dd845c5ac9531.tar.gz Tango-76aa983631df4fa5b16b170e2f6dd845c5ac9531.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
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 | 128 |
1 files changed, 128 insertions, 0 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 new file mode 100644 index 000000000..b1ba03109 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +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 : ExtendedObject, INotificationProvider + { + public ObservableCollection<TaskItem> TaskItems { get; private set; } + + public bool HasTaskItems + { + get { return TaskItems.Count > 0; } + } + + 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; + dialog.InnerTitle = title; + dialog.Owner = Application.Current.MainWindow; + MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; + bool result = dialog.ShowDialog().Value; + 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)); + } + } +} |
