From 8ae0f3da19c537eff30e19a1fe99cce51b3116f1 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 23 Jan 2018 17:58:59 +0200 Subject: A lot of work on Developer Module and Jobs related DB tables. --- .../Notifications/DefaultNotificationProvider.cs | 33 +++++++- .../Notifications/TextInputBoxWindow.xaml | 44 ++++++++++ .../Notifications/TextInputBoxWindow.xaml.cs | 99 ++++++++++++++++++++++ 3 files changed, 173 insertions(+), 3 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/TextInputBoxWindow.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 index 448625f27..31fb4b1e0 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs @@ -106,7 +106,7 @@ namespace Tango.MachineStudio.UI.Notifications dialog.DataContext = context; Action onAcceptAction = null; - onAcceptAction = new Action(() => + onAcceptAction = new Action(() => { dialog.Close(); onAccept(context); @@ -114,7 +114,7 @@ namespace Tango.MachineStudio.UI.Notifications }); Action onCancelAction = null; - onCancelAction = new Action(() => + onCancelAction = new Action(() => { dialog.Close(); @@ -198,7 +198,7 @@ namespace Tango.MachineStudio.UI.Notifications context.OnShow(); }; - + dialog.ShowDialog(); MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; } @@ -288,5 +288,32 @@ namespace Tango.MachineStudio.UI.Notifications RaisePropertyChanged(nameof(HasTaskItems)); } + + /// + /// Shows a dialog with a text input field and returns the response. + /// + /// The message. + /// Text field hint. + /// Optional default response. + /// + 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/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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 +{ + /// + /// Interaction logic for TextInputBoxWindow.xaml + /// + 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(); + } + } +} -- cgit v1.3.1