From 2a51f05523c1397b77eca5e5188520919205638c Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 13 Dec 2017 15:19:55 +0200 Subject: Successfully separated Machine Studio to modules... --- .../Notifications/DefaultNotificationProvider.cs | 32 ++++++++++++ .../Notifications/DialogWindow.xaml | 32 ++++++++++++ .../Notifications/DialogWindow.xaml.cs | 58 ++++++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications') 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..8e0fd2220 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs @@ -0,0 +1,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(PackIconKind icon, string title, object context) where T : FrameworkElement + { + return ShowDialog(icon, title, Activator.CreateInstance(), 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; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml new file mode 100644 index 000000000..f23776ec2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml.cs new file mode 100644 index 000000000..c946d2b88 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml.cs @@ -0,0 +1,58 @@ +using MahApps.Metro.Controls; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; +using Tango.Core.Commands; + +namespace Tango.MachineStudio.UI.Windows +{ + /// + /// Interaction logic for DialogWindow.xaml + /// + public partial class DialogWindow : MetroWindow + { + public DialogWindow() + { + InitializeComponent(); + } + + + + public String InnerTitle + { + get { return (String)GetValue(InnerTitleProperty); } + set { SetValue(InnerTitleProperty, value); } + } + public static readonly DependencyProperty InnerTitleProperty = + DependencyProperty.Register("InnerTitle", typeof(String), typeof(DialogWindow), new PropertyMetadata(null)); + + + + public DialogWindow(FrameworkElement content) : this() + { + presenter.Content = content; + } + + private void OnOKClicked(object sender, RoutedEventArgs e) + { + DialogResult = true; + Close(); + } + + private void OnCancelClicked(object sender, RoutedEventArgs e) + { + DialogResult = false; + Close(); + } + } +} -- cgit v1.3.1