aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2017-12-19 12:28:20 +0200
committerAvi Levkovich <avi@twine-s.com>2017-12-19 12:28:20 +0200
commit76aa983631df4fa5b16b170e2f6dd845c5ac9531 (patch)
tree6b2b4d0776c54536ec07aabc6be94857dcee91fc /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications
parent6bf71c81050b824398dc82ce4b69cdf71fb4a2f7 (diff)
parentb421701fd5cf000a16cab9b1fe9eda812ccce8c3 (diff)
downloadTango-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')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs128
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml24
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml.cs70
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml40
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml.cs83
5 files changed, 345 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));
+ }
+ }
+}
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..2a8dd9f28
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml
@@ -0,0 +1,24 @@
+<mahapps:MetroWindow x:Class="Tango.MachineStudio.UI.Windows.DialogWindow"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls"
+ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:local="clr-namespace:Tango.MachineStudio.UI.Windows"
+ mc:Ignorable="d"
+ Title="Machine Studio" Height="450" Width="650" EnableDWMDropShadow="True" ShowCloseButton="False" WindowTransitionsEnabled="False" ShowMaxRestoreButton="False" ShowMinButton="False" TitleCaps="False" BorderThickness="1" WindowStartupLocation="CenterOwner">
+ <Grid>
+ <Border Margin="16">
+ <DockPanel LastChildFill="True">
+ <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" VerticalAlignment="Top">
+ <materialDesign:PackIcon Kind="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=IconKind}" VerticalAlignment="Center" Width="32" Height="32" Foreground="{StaticResource AccentColorBrush}" />
+ <TextBlock Margin="10 0 0 0" Foreground="{StaticResource AccentColorBrush}" FontSize="16" Text="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=InnerTitle}"></TextBlock>
+ </StackPanel>
+ <ScrollViewer Margin="0 10 0 10" VerticalScrollBarVisibility="Auto" Padding="5">
+ <ContentPresenter x:Name="presenter"></ContentPresenter>
+ </ScrollViewer>
+ </DockPanel>
+ </Border>
+ </Grid>
+</mahapps:MetroWindow>
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..31dd3d644
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml.cs
@@ -0,0 +1,70 @@
+using MahApps.Metro.Controls;
+using MaterialDesignThemes.Wpf;
+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
+{
+ /// <summary>
+ /// Interaction logic for DialogWindow.xaml
+ /// </summary>
+ 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 PackIconKind IconKind
+ {
+ get { return (PackIconKind)GetValue(IconKindProperty); }
+ set { SetValue(IconKindProperty, value); }
+ }
+ public static readonly DependencyProperty IconKindProperty =
+ DependencyProperty.Register("IconKind", typeof(PackIconKind), typeof(DialogWindow), new PropertyMetadata(PackIconKind.Information));
+
+
+
+
+ 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();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml
new file mode 100644
index 000000000..4f3b826fe
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml
@@ -0,0 +1,40 @@
+<Window x:Class="Tango.MachineStudio.UI.Notifications.MessageBoxWindow"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:local="clr-namespace:Tango.MachineStudio.UI.Notifications"
+ xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls"
+ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
+ mc:Ignorable="d"
+ Title="Machine Studio" MinHeight="220" MaxHeight="600" SizeToContent="Height" Width="570" Opacity="0" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterOwner" Background="Transparent">
+
+ <Window.Resources>
+ <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"></BooleanToVisibilityConverter>
+ </Window.Resources>
+
+ <Grid>
+ <Border Background="White" CornerRadius="10" Padding="10" Margin="20">
+ <Border.Effect>
+ <DropShadowEffect ShadowDepth="0" BlurRadius="10"></DropShadowEffect>
+ </Border.Effect>
+ <DockPanel LastChildFill="True">
+ <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right" DockPanel.Dock="Bottom">
+ <Button Style="{StaticResource MaterialDesignFlatButton}" IsDefault="True" Margin="0 8 8 0" Click="OnOKClicked">
+ ACCEPT
+ </Button>
+ <Button Visibility="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=HasCancel,Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource MaterialDesignFlatButton}" IsCancel="True" Margin="0 8 8 0" Click="OnCancelClicked">
+ CANCEL
+ </Button>
+ </StackPanel>
+ <Grid>
+ <StackPanel Orientation="Horizontal" VerticalAlignment="Top" Margin="0 30 0 0">
+ <materialDesign:PackIcon Kind="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=IconKind}" VerticalAlignment="Top" Width="50" Height="50" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=IconColor}" />
+ <TextBlock Padding="0 10 0 0" TextWrapping="Wrap" Margin="10 0 0 0" VerticalAlignment="Top" FontSize="14" Text="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=Message}" Width="400"></TextBlock>
+ </StackPanel>
+ </Grid>
+ </DockPanel>
+ </Border>
+ </Grid>
+</Window>
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml.cs
new file mode 100644
index 000000000..7ce4965ef
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/MessageBoxWindow.xaml.cs
@@ -0,0 +1,83 @@
+using MahApps.Metro.Controls;
+using MaterialDesignThemes.Wpf;
+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.Animation;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace Tango.MachineStudio.UI.Notifications
+{
+ /// <summary>
+ /// Interaction logic for MessageBoxWindow.xaml
+ /// </summary>
+ public partial class MessageBoxWindow : Window
+ {
+ public MessageBoxWindow()
+ {
+ InitializeComponent();
+ this.Loaded += MessageBoxWindow_Loaded;
+ }
+
+ private void MessageBoxWindow_Loaded(object sender, RoutedEventArgs e)
+ {
+ DoubleAnimation ani = new DoubleAnimation();
+ ani.To = 1;
+ ani.Duration = TimeSpan.FromSeconds(0.5);
+ this.BeginAnimation(Window.OpacityProperty, ani);
+ }
+
+ public String Message
+ {
+ get { return (String)GetValue(MessageProperty); }
+ set { SetValue(MessageProperty, value); }
+ }
+ public static readonly DependencyProperty MessageProperty =
+ DependencyProperty.Register("Message", typeof(String), typeof(MessageBoxWindow), new PropertyMetadata(null));
+
+ public Brush IconColor
+ {
+ get { return (Brush)GetValue(IconColorProperty); }
+ set { SetValue(IconColorProperty, value); }
+ }
+ public static readonly DependencyProperty IconColorProperty =
+ DependencyProperty.Register("IconColor", typeof(Brush), typeof(MessageBoxWindow), new PropertyMetadata(Brushes.Black));
+
+ public PackIconKind IconKind
+ {
+ get { return (PackIconKind)GetValue(IconKindProperty); }
+ set { SetValue(IconKindProperty, value); }
+ }
+ public static readonly DependencyProperty IconKindProperty =
+ DependencyProperty.Register("IconKind", typeof(PackIconKind), typeof(MessageBoxWindow), new PropertyMetadata(PackIconKind.Information));
+
+ public bool HasCancel
+ {
+ get { return (bool)GetValue(HasCancelProperty); }
+ set { SetValue(HasCancelProperty, value); }
+ }
+ public static readonly DependencyProperty HasCancelProperty =
+ DependencyProperty.Register("HasCancel", typeof(bool), typeof(MessageBoxWindow), new PropertyMetadata(false));
+
+ private void OnOKClicked(object sender, RoutedEventArgs e)
+ {
+ DialogResult = true;
+ Close();
+ }
+
+ private void OnCancelClicked(object sender, RoutedEventArgs e)
+ {
+ DialogResult = false;
+ Close();
+ }
+ }
+}