aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2017-12-19 10:25:40 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2017-12-19 10:25:40 +0200
commitafc7a07d285e08d905c58dd5978441c155b2f296 (patch)
treea2f4f51ef2747ae3a2aded2637a352ce8ef85934 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications
parentad35c9c2df0001157ea13312382f3cdfdad67f06 (diff)
downloadTango-afc7a07d285e08d905c58dd5978441c155b2f296.tar.gz
Tango-afc7a07d285e08d905c58dd5978441c155b2f296.zip
MERGE.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs104
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml10
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml.cs12
-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, 236 insertions, 13 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));
+ }
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml
index f23776ec2..2a8dd9f28 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml
@@ -12,17 +12,9 @@
<Border Margin="16">
<DockPanel LastChildFill="True">
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" VerticalAlignment="Top">
- <materialDesign:PackIcon Kind="TableEdit" VerticalAlignment="Center" Width="32" Height="32" Foreground="{StaticResource AccentColorBrush}" />
+ <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>
- <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right" DockPanel.Dock="Bottom">
- <Button Style="{StaticResource MaterialDesignFlatButton}" IsDefault="True" Margin="0 8 8 0" Command="{Binding DialogOKCommand}" Click="OnOKClicked">
- ACCEPT
- </Button>
- <Button Style="{StaticResource MaterialDesignFlatButton}" IsCancel="True" Margin="0 8 8 0" Command="{Binding DialogCancelCommand}" Click="OnCancelClicked">
- CANCEL
- </Button>
- </StackPanel>
<ScrollViewer Margin="0 10 0 10" VerticalScrollBarVisibility="Auto" Padding="5">
<ContentPresenter x:Name="presenter"></ContentPresenter>
</ScrollViewer>
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
index c946d2b88..31dd3d644 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml.cs
@@ -1,4 +1,5 @@
using MahApps.Metro.Controls;
+using MaterialDesignThemes.Wpf;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -38,6 +39,17 @@ namespace Tango.MachineStudio.UI.Windows
+ 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;
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();
+ }
+ }
+}