aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs
blob: 8e0fd22200ccc2962d74f396380fae2f498bc261 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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;

namespace Tango.MachineStudio.UI.Notifications
{
    public class DefaultNotificationProvider : INotificationProvider
    {
        public bool ShowDialog<T>(PackIconKind icon, string title, object context) where T : FrameworkElement
        {
            return ShowDialog(icon, title, Activator.CreateInstance<T>(), context);
        }

        public bool ShowDialog(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;
        }
    }
}