diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2018-01-31 10:11:27 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2018-01-31 10:11:27 +0200 |
| commit | b55483f9f095b699728e0b587ceebfdf6409a48a (patch) | |
| tree | 1d424d3fc9f75154ecae30806b952fdfb029fce9 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI | |
| parent | e027cb9fdd17fe3be7bb2c385dc37061a7eea8bb (diff) | |
| parent | 2fa92ca3654ebb274482f9bad86231028d357e5a (diff) | |
| download | Tango-b55483f9f095b699728e0b587ceebfdf6409a48a.tar.gz Tango-b55483f9f095b699728e0b587ceebfdf6409a48a.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI')
11 files changed, 239 insertions, 33 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs index ca553de1e..50e57aab1 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs @@ -5,7 +5,7 @@ using System.Data; using System.Linq; using System.Threading.Tasks; using System.Windows; -using Tango.DAL.Observables; +using Tango.Integration.Observables; namespace Tango.MachineStudio.UI { diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs index 80e5e9762..82aba268d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs @@ -5,7 +5,7 @@ using System.Security.Authentication; using System.Text; using System.Threading.Tasks; using Tango.Core; -using Tango.DAL.Observables; +using Tango.Integration.Observables; using Tango.MachineStudio.Common.Authentication; namespace Tango.MachineStudio.UI.Authentication diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml index 83f41b785..3c6f70e1b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml @@ -13,25 +13,27 @@ <Grid> <Viewbox Stretch="Fill" UseLayoutRounding="True" SnapsToDevicePixels="True"> <Grid Width="1920" Height="1145"> - <sharedControls:MultiTransitionControl AlwaysFade="True" TransitionType="Zoom" x:Name="TransitionControl" x:FieldModifier="public"> - <sharedControls:MultiTransitionControl.Controls> - <ContentControl Tag="LoadingView"> - <views:LoadingView></views:LoadingView> - </ContentControl> - <ContentControl Tag="LoginView"> - <views:LoginView></views:LoginView> - </ContentControl> - <ContentControl Tag="MainView"> - <views:MainView></views:MainView> - </ContentControl> - <ContentControl Tag="ShutdownView"> - <views:ShutdownView></views:ShutdownView> - </ContentControl> - </sharedControls:MultiTransitionControl.Controls> - </sharedControls:MultiTransitionControl> + <Grid> + <sharedControls:MultiTransitionControl AlwaysFade="True" TransitionType="Zoom" x:Name="TransitionControl" x:FieldModifier="public"> + <sharedControls:MultiTransitionControl.Controls> + <ContentControl Tag="LoadingView"> + <views:LoadingView></views:LoadingView> + </ContentControl> + <ContentControl Tag="LoginView"> + <views:LoginView></views:LoginView> + </ContentControl> + <ContentControl Tag="MainView"> + <views:MainView></views:MainView> + </ContentControl> + <ContentControl Tag="ShutdownView"> + <views:ShutdownView></views:ShutdownView> + </ContentControl> + </sharedControls:MultiTransitionControl.Controls> + </sharedControls:MultiTransitionControl> - <Grid Background="Black" Opacity="0.7" x:Name="shadowGrid" Visibility="Hidden"> + <Grid Background="Black" Opacity="0.7" x:Name="shadowGrid" Visibility="Hidden"> + </Grid> </Grid> </Grid> </Viewbox> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs index 0e1bd829b..e08ee9b08 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs @@ -7,6 +7,7 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; using Tango.Core; +using Tango.Integration.Observables; using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Authentication; using Tango.MachineStudio.Common.Modules; @@ -44,7 +45,7 @@ namespace Tango.MachineStudio.UI.Modules /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> - private void _authenticationProvider_CurrentUserChanged(object sender, DAL.Observables.User e) + private void _authenticationProvider_CurrentUserChanged(object sender, User e) { LoadModules(); } 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 8ca933397..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(); @@ -166,6 +166,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; @@ -194,7 +198,7 @@ namespace Tango.MachineStudio.UI.Notifications context.OnShow(); }; - + dialog.ShowDialog(); MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; } @@ -284,5 +288,32 @@ namespace Tango.MachineStudio.UI.Notifications RaisePropertyChanged(nameof(HasTaskItems)); } + + /// <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/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(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs index 06b4dca7c..a59ecf8e0 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -14,6 +14,8 @@ using System.Collections; using Tango.Integration.Services; using Tango.Core; using Tango.Logging; +using Tango.MachineStudio.Common.Modules; +using Tango.MachineStudio.Common; namespace Tango.MachineStudio.UI.StudioApplication { @@ -24,17 +26,16 @@ namespace Tango.MachineStudio.UI.StudioApplication /// <seealso cref="Tango.MachineStudio.Common.StudioApplication.IStudioApplicationManager" /> public class DefaultStudioApplicationManager : ExtendedObject, IStudioApplicationManager { - /// <summary> - /// The navigation manager - /// </summary> private INavigationManager _navigationManager; + private IStudioModuleLoader _moduleLoader; /// <summary> /// Initializes a new instance of the <see cref="DefaultStudioApplicationManager" /> class. /// </summary> /// <param name="navigationManager">The navigation manager.</param> - public DefaultStudioApplicationManager(INavigationManager navigationManager) + public DefaultStudioApplicationManager(INavigationManager navigationManager, IStudioModuleLoader moduleLoader) { + _moduleLoader = moduleLoader; _navigationManager = navigationManager; } @@ -146,5 +147,30 @@ namespace Tango.MachineStudio.UI.StudioApplication }); } + + /// <summary> + /// Loads the specified module if permitted. + /// </summary> + /// <param name="moduleName">Name of the module.</param> + /// <param name="args">The arguments.</param> + public void RequestModule(string moduleName, object args) + { + IStudioModule module = _moduleLoader.UserModules.SingleOrDefault(x => x.Name == moduleName); + + if (module != null) + { + ServiceLocator.Current.GetInstance<ViewModels.MainViewVM>().StartModule(module); + + //Notify request listeners. + foreach (var vm in ServiceLocator.Current.GetAllInstancesByBase<IModuleRequestListener>()) + { + vm.OnRequestModule(module, args); + } + } + else + { + throw new InvalidOperationException("The module was not found or you do not have sufficient privileges."); + } + } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index 9b498cfb6..5490c2c2b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -120,6 +120,9 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </ApplicationDefinition> + <Compile Include="Notifications\TextInputBoxWindow.xaml.cs"> + <DependentUpon>TextInputBoxWindow.xaml</DependentUpon> + </Compile> <Compile Include="StudioApplication\DefaultStudioApplicationManager.cs" /> <Compile Include="Authentication\DefaultAuthenticationProvider.cs" /> <Compile Include="Modules\DefaultStudioModuleLoader.cs" /> @@ -172,6 +175,10 @@ <DependentUpon>MainWindow.xaml</DependentUpon> <SubType>Code</SubType> </Compile> + <Page Include="Notifications\TextInputBoxWindow.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Notifications\MessageBoxWindow.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -249,10 +256,6 @@ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> </ProjectReference> - <ProjectReference Include="..\..\Tango.DAL.Observables\Tango.DAL.Observables.csproj"> - <Project>{0ecd6da8-7aa6-48d9-8b65-279d176ad9af}</Project> - <Name>Tango.DAL.Observables</Name> - </ProjectReference> <ProjectReference Include="..\..\Tango.DAL.Remote\Tango.DAL.Remote.csproj"> <Project>{38197109-8610-4d3f-92b9-16d48df94d7c}</Project> <Name>Tango.DAL.Remote</Name> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs index 54e2f9196..55a54e8aa 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using Tango.Core.Helpers; -using Tango.DAL.Observables; +using Tango.Integration.Observables; using Tango.MachineStudio.Common.Modules; using Tango.MachineStudio.Common.Navigation; using Tango.MachineStudio.Common.Notifications; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index fdab1a93c..679ba5ff3 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -272,7 +272,7 @@ namespace Tango.MachineStudio.UI.ViewModels /// Starts the specified module. /// </summary> /// <param name="module">The module.</param> - private void StartModule(IStudioModule module) + internal void StartModule(IStudioModule module) { IsMenuOpened = false; |
