aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2018-02-20 16:45:00 +0200
committerAvi Levkovich <avi@twine-s.com>2018-02-20 16:45:00 +0200
commit6c208c90bc45aff4a7fa214356a42fe7757c5e6f (patch)
tree0d77bc6a0ecfbb53cf42c5462ee19212197ee1bd /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications
parentb0823127f152fe97a6e8fce29e427c7f3db9cf5a (diff)
parent1a573aaa346ec4b8bd58a0e35ab9df571a09b855 (diff)
downloadTango-6c208c90bc45aff4a7fa214356a42fe7757c5e6f.tar.gz
Tango-6c208c90bc45aff4a7fa214356a42fe7757c5e6f.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.cs168
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DialogWindow.xaml.cs2
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml44
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml.cs99
4 files changed, 302 insertions, 11 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 d4d053eaf..1ea22c587 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs
@@ -13,31 +13,68 @@ using System.Collections.ObjectModel;
namespace Tango.MachineStudio.UI.Notifications
{
+ /// <summary>
+ /// Represents the default Machine Studio <see cref="INotificationProvider">Notification Provider</see>.
+ /// </summary>
+ /// <seealso cref="Tango.Core.ExtendedObject" />
+ /// <seealso cref="Tango.MachineStudio.Common.Notifications.INotificationProvider" />
public class DefaultNotificationProvider : ExtendedObject, INotificationProvider
{
+ /// <summary>
+ /// The view types
+ /// </summary>
private static List<Type> viewTypes;
+ /// <summary>
+ /// Gets the collection of active task items.
+ /// </summary>
public ObservableCollection<TaskItem> TaskItems { get; private set; }
+ /// <summary>
+ /// Gets the collection of active bar items.
+ /// </summary>
+ public ObservableCollection<BarItem> BarItems { get; private set; }
+
+ /// <summary>
+ /// Gets a value indicating whether there are any queued task items.
+ /// </summary>
public bool HasTaskItems
{
get { return TaskItems.Count > 0; }
}
+ /// <summary>
+ /// The current task item
+ /// </summary>
private TaskItem _currentTaskItem;
+ /// <summary>
+ /// Gets the current displayed task item.
+ /// </summary>
public TaskItem CurrentTaskItem
{
get { return _currentTaskItem; }
set { _currentTaskItem = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(HasTaskItems)); }
}
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DefaultNotificationProvider"/> class.
+ /// </summary>
public DefaultNotificationProvider()
{
TaskItems = new ObservableCollection<TaskItem>();
+ BarItems = new ObservableCollection<BarItem>();
}
- public bool? ShowDialog(PackIconKind icon, Brush iconColor, string message, bool hasCancel)
+ /// <summary>
+ /// Display a message box.
+ /// </summary>
+ /// <param name="icon">The icon.</param>
+ /// <param name="iconColor">Color of the icon.</param>
+ /// <param name="message">The message.</param>
+ /// <param name="hasCancel">if set to <c>true</c> displays the cancel button.</param>
+ /// <returns></returns>
+ public bool? ShowMessageBox(PackIconKind icon, Brush iconColor, string message, bool hasCancel)
{
MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible;
@@ -55,6 +92,13 @@ namespace Tango.MachineStudio.UI.Notifications
return result;
}
+ /// <summary>
+ /// Creates a new instance of the specified View type and displays it as a modal dialog.
+ /// </summary>
+ /// <typeparam name="View">The type of the view.</typeparam>
+ /// <typeparam name="VM">The type of the view model.</typeparam>
+ /// <param name="onAccept">Accept button callback.</param>
+ /// <param name="onCancel">Cancel button callback.</param>
public void ShowModalDialog<View, VM>(Action<VM> onAccept, Action onCancel) where View : FrameworkElement where VM : DialogViewVM
{
var view = Activator.CreateInstance<View>();
@@ -68,7 +112,7 @@ namespace Tango.MachineStudio.UI.Notifications
dialog.DataContext = context;
Action onAcceptAction = null;
- onAcceptAction = new Action(() =>
+ onAcceptAction = new Action(() =>
{
dialog.Close();
onAccept(context);
@@ -76,7 +120,7 @@ namespace Tango.MachineStudio.UI.Notifications
});
Action onCancelAction = null;
- onCancelAction = new Action(() =>
+ onCancelAction = new Action(() =>
{
dialog.Close();
@@ -97,6 +141,13 @@ namespace Tango.MachineStudio.UI.Notifications
MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden;
}
+ /// <summary>
+ /// Creates a new view by a naming convention of the specified view model type.
+ /// </summary>
+ /// <typeparam name="VM">The type of the view model.</typeparam>
+ /// <param name="onAccept">Accept button callback.</param>
+ /// <param name="onCancel">Cancel button callback.</param>
+ /// <exception cref="NullReferenceException">Could not locate view " + viewName</exception>
public void ShowModalDialog<VM>(Action<VM> onAccept, Action onCancel) where VM : DialogViewVM
{
String viewName = typeof(VM).Name.Replace("VM", "");
@@ -121,6 +172,10 @@ namespace Tango.MachineStudio.UI.Notifications
view.Loaded += (x, y) =>
{
VM context = view.DataContext as VM;
+ if (context == null)
+ {
+ context = Activator.CreateInstance<VM>();
+ }
dialog.DataContext = context;
Action onAcceptAction = null;
@@ -149,42 +204,73 @@ namespace Tango.MachineStudio.UI.Notifications
context.OnShow();
};
-
+
dialog.ShowDialog();
MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden;
}
+ /// <summary>
+ /// Creates a new view by a naming convention of the specified view model type.
+ /// </summary>
+ /// <typeparam name="VM">The type of the view model.</typeparam>
+ /// <param name="onAccept">Accept button callback.</param>
public void ShowModalDialog<VM>(Action<VM> onAccept) where VM : DialogViewVM
{
ShowModalDialog<VM>(onAccept, null);
}
+ /// <summary>
+ /// Shows an error message box.
+ /// </summary>
+ /// <param name="message">The message.</param>
public void ShowError(string message)
{
- ShowDialog(PackIconKind.Exclamation, Brushes.Red, message, false);
+ ShowMessageBox(PackIconKind.Exclamation, Brushes.Red, message, false);
}
+ /// <summary>
+ /// Shows an information message box.
+ /// </summary>
+ /// <param name="message">The message.</param>
public void ShowInfo(string message)
{
- ShowDialog(PackIconKind.Information, Brushes.Black, message, false);
+ ShowMessageBox(PackIconKind.Information, Brushes.Black, message, false);
}
+ /// <summary>
+ /// Shows a question message box.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ /// <returns></returns>
public bool ShowQuestion(string message)
{
- return ShowDialog(PackIconKind.CommentQuestionOutline, Brushes.Black, message, true).Value;
+ return ShowMessageBox(PackIconKind.CommentQuestionOutline, Brushes.Black, message, true).Value;
}
- public void ShowWarnning(string message)
+ /// <summary>
+ /// Shows warning message box.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ public void ShowWarning(string message)
{
- ShowDialog(PackIconKind.Exclamation, Brushes.DarkOrange, message, false);
+ ShowMessageBox(PackIconKind.Exclamation, Brushes.DarkOrange, message, false);
}
+ /// <summary>
+ /// Pushes the specified task item to the queue.
+ /// </summary>
+ /// <param name="taskItem">The task item.</param>
public void PushTaskItem(TaskItem taskItem)
{
TaskItems.Add(taskItem);
CurrentTaskItem = taskItem;
}
+ /// <summary>
+ /// Create and push a new task item from the specified message.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ /// <returns></returns>
public TaskItem PushTaskItem(string message)
{
TaskItem item = new TaskItem(this);
@@ -193,6 +279,10 @@ namespace Tango.MachineStudio.UI.Notifications
return item;
}
+ /// <summary>
+ /// Removed the specified task item from the queue.
+ /// </summary>
+ /// <param name="taskItem">The task item.</param>
public void PopTaskItem(TaskItem taskItem)
{
TaskItems.Remove(taskItem);
@@ -204,5 +294,65 @@ namespace Tango.MachineStudio.UI.Notifications
RaisePropertyChanged(nameof(HasTaskItems));
}
+
+ /// <summary>
+ /// Pushes the specified bar item.
+ /// </summary>
+ /// <param name="barItem">The bar item.</param>
+ /// <returns></returns>
+ public BarItem PushBarItem(BarItem barItem)
+ {
+ BarItems.Add(barItem);
+ return barItem;
+ }
+
+ /// <summary>
+ /// Creates and push a new bar item from the specified framework element.
+ /// </summary>
+ /// <param name="element">The element.</param>
+ /// <returns></returns>
+ public BarItem PushBarItem(FrameworkElement element)
+ {
+ BarItem item = new BarItem(this);
+ item.Element = element;
+ PushBarItem(item);
+ return item;
+ }
+
+ /// <summary>
+ /// Removed the specified bar item.
+ /// </summary>
+ /// <param name="barItem">The bar item.</param>
+ public void PopBarItem(BarItem barItem)
+ {
+ BarItems.Remove(barItem);
+ }
+
+ /// <summary>
+ /// Shows a dialog with a text input field and returns the response.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ /// <param name="hint">Text field hint.</param>
+ /// <param name="defaultResponse">Optional default response.</param>
+ /// <returns></returns>
+ public string ShowTextInput(string message, string hint, string defaultResponse = null)
+ {
+ MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible;
+
+ TextInputBoxWindow dlg = new TextInputBoxWindow()
+ {
+ Owner = Application.Current.MainWindow,
+ Message = message,
+ IconKind = PackIconKind.Pencil,
+ IconColor = Brushes.DimGray,
+ Hint = hint,
+ Response = defaultResponse
+ };
+
+ var result = dlg.ShowDialog();
+
+ MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden;
+ return (result.Value ? dlg.Response : null);
+ }
}
}
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 d1bc0564b..8ed1a4946 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
@@ -36,7 +36,5 @@ namespace Tango.MachineStudio.UI.Windows
// Using a DependencyProperty as the backing store for InnerContent. This enables animation, styling, binding, etc...
public static readonly DependencyProperty InnerContentProperty =
DependencyProperty.Register("InnerContent", typeof(FrameworkElement), typeof(DialogWindow), new PropertyMetadata(null));
-
-
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml
new file mode 100644
index 000000000..d2aad7cee
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml
@@ -0,0 +1,44 @@
+<Window x:Class="Tango.MachineStudio.UI.Notifications.TextInputBoxWindow"
+ 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 Style="{StaticResource MaterialDesignFlatButton}" IsCancel="False" Margin="0 8 8 0" Click="OnCancelClicked">
+ CANCEL
+ </Button>
+ </StackPanel>
+ <Grid>
+ <StackPanel VerticalAlignment="Top" Margin="0 30 0 0">
+ <StackPanel Orientation="Horizontal">
+ <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>
+
+ <TextBox x:Name="txtText" Margin="60 0 20 0" materialDesign:HintAssist.Hint="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=Hint}" Text="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=Response,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"></TextBox>
+ </StackPanel>
+ </Grid>
+ </DockPanel>
+ </Border>
+ </Grid>
+</Window>
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml.cs
new file mode 100644
index 000000000..d774c14eb
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml.cs
@@ -0,0 +1,99 @@
+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 TextInputBoxWindow.xaml
+ /// </summary>
+ public partial class TextInputBoxWindow : Window
+ {
+ public TextInputBoxWindow()
+ {
+ InitializeComponent();
+ this.Loaded += TextInputBoxWindow_Loaded;
+ }
+
+ private void TextInputBoxWindow_Loaded(object sender, RoutedEventArgs e)
+ {
+ DoubleAnimation ani = new DoubleAnimation();
+ ani.To = 1;
+ ani.Duration = TimeSpan.FromSeconds(0.5);
+ this.BeginAnimation(Window.OpacityProperty, ani);
+
+ txtText.Focus();
+ }
+
+
+
+ public String Hint
+ {
+ get { return (String)GetValue(HintProperty); }
+ set { SetValue(HintProperty, value); }
+ }
+ public static readonly DependencyProperty HintProperty =
+ DependencyProperty.Register("Hint", typeof(String), typeof(TextInputBoxWindow), new PropertyMetadata(null));
+
+
+
+ public String Response
+ {
+ get { return (String)GetValue(ResponseProperty); }
+ set { SetValue(ResponseProperty, value); }
+ }
+ public static readonly DependencyProperty ResponseProperty =
+ DependencyProperty.Register("Response", typeof(String), typeof(TextInputBoxWindow), new PropertyMetadata(null));
+
+
+
+ public String Message
+ {
+ get { return (String)GetValue(MessageProperty); }
+ set { SetValue(MessageProperty, value); }
+ }
+ public static readonly DependencyProperty MessageProperty =
+ DependencyProperty.Register("Message", typeof(String), typeof(TextInputBoxWindow), 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(TextInputBoxWindow), 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(TextInputBoxWindow), new PropertyMetadata(PackIconKind.Information));
+
+ private void OnOKClicked(object sender, RoutedEventArgs e)
+ {
+ DialogResult = true;
+ Close();
+ }
+
+ private void OnCancelClicked(object sender, RoutedEventArgs e)
+ {
+ DialogResult = false;
+ Close();
+ }
+ }
+}