aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views
diff options
context:
space:
mode:
authorRoy <roy.mail.net@gmail.com>2018-04-21 19:49:05 +0300
committerRoy <roy.mail.net@gmail.com>2018-04-21 19:49:05 +0300
commit0dec8a74239cff769836cae577fbd84824070e83 (patch)
treed6cc24ee53454b3f17f1580e90de38238555b6bd /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views
parent4df1724226c0d0941b970dbe71b1476e3c3e9902 (diff)
downloadTango-0dec8a74239cff769836cae577fbd84824070e83.tar.gz
Tango-0dec8a74239cff769836cae577fbd84824070e83.zip
Implemented NavigationControl for better performance!!!
Redesign of machine studio module initialization.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml7
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml.cs24
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml134
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml.cs26
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ShutdownView.xaml.cs5
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml.cs5
6 files changed, 84 insertions, 117 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml
index 84ba597f2..7f54263b7 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml
@@ -5,6 +5,7 @@
xmlns:rules="clr-namespace:Tango.MachineStudio.Common.ValidationRules;assembly=Tango.MachineStudio.Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:helpers="clr-namespace:Tango.SharedUI.Helpers;assembly=Tango.SharedUI"
xmlns:local="clr-namespace:Tango.MachineStudio.UI.Views"
mc:Ignorable="d"
d:DesignHeight="720" d:DesignWidth="1280" DataContext="{Binding LoginViewVM, Source={StaticResource Locator}}" Background="Transparent">
@@ -15,7 +16,7 @@
<UserControl.InputBindings>
- <KeyBinding Key="Return" Command="{Binding LoginCommand}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=Password}"></KeyBinding>
+ <KeyBinding Key="Return" Command="{Binding LoginCommand}"></KeyBinding>
</UserControl.InputBindings>
<Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="40">
@@ -31,10 +32,10 @@
</DockPanel>
<DockPanel Margin="0 20 0 0">
<materialDesign:PackIcon Margin="0 0 0 0" Width="20" Height="20" VerticalAlignment="Top" Foreground="{Binding ElementName=txtPass, Path=BorderBrush}" Kind="Key" />
- <PasswordBox x:Name="txtPass" PasswordChanged="txtPass_PasswordChanged" Margin="5 0 0 0" materialDesign:HintAssist.FloatingScale="0.50" materialDesign:HintAssist.Hint="Password" materialDesign:TextFieldAssist.TextBoxViewMargin="1 0 1 0" FontSize="20" Style="{StaticResource MaterialDesignFloatingHintPasswordBox}" AutomationProperties.IsRequiredForForm="True" />
+ <PasswordBox x:Name="txtPass" helpers:PasswordHelper.Attach="True" helpers:PasswordHelper.Password="{Binding Password,Mode=TwoWay}" Margin="5 0 0 0" materialDesign:HintAssist.FloatingScale="0.50" materialDesign:HintAssist.Hint="Password" materialDesign:TextFieldAssist.TextBoxViewMargin="1 0 1 0" FontSize="20" Style="{StaticResource MaterialDesignFloatingHintPasswordBox}" AutomationProperties.IsRequiredForForm="True" />
</DockPanel>
<CheckBox Margin="25 20 0 0" IsChecked="{Binding RememberMe}">Remember me</CheckBox>
- <Button Margin="25 20 0 0" Height="50" Command="{Binding LoginCommand}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=Password}" Content="LOGIN">
+ <Button Margin="25 20 0 0" Height="50" Command="{Binding LoginCommand}" Content="LOGIN">
</Button>
</StackPanel>
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml.cs
index 027e37682..bf1dd389d 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml.cs
@@ -22,26 +22,15 @@ namespace Tango.MachineStudio.UI.Views
/// <summary>
/// Interaction logic for LoginView.xaml
/// </summary>
- public partial class LoginView : UserControl, ITransitionView
+ public partial class LoginView : UserControl
{
- private Rfc2898Cryptographer cryptographer;
-
public LoginView()
{
InitializeComponent();
-
- cryptographer = new Rfc2898Cryptographer();
- }
-
- public String Password
- {
- get { return (String)GetValue(PasswordProperty); }
- set { SetValue(PasswordProperty, value); }
+ this.Loaded += LoginView_Loaded;
}
- public static readonly DependencyProperty PasswordProperty =
- DependencyProperty.Register("Password", typeof(String), typeof(LoginView), new PropertyMetadata(null));
- public void OnTransitionCompleted()
+ private void LoginView_Loaded(object sender, RoutedEventArgs e)
{
txtEmail.Focus();
@@ -49,13 +38,6 @@ namespace Tango.MachineStudio.UI.Views
{
txtPass.Focus();
}
-
- txtPass.Password = cryptographer.Decrypt(SettingsManager.Default.MachineStudio.LastLoginPassword);
- }
-
- private void txtPass_PasswordChanged(object sender, RoutedEventArgs e)
- {
- Password = txtPass.Password;
}
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml
index a841a72cb..dd3d122b6 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml
@@ -38,14 +38,14 @@
</Style>
</Grid.Style>
- <materialDesign:DrawerHost IsLeftDrawerOpen="{Binding ElementName=MenuToggleButton, Path=IsChecked}">
+ <materialDesign:DrawerHost IsLeftDrawerOpen="{Binding Source={x:Reference MenuToggleButton}, Path=IsChecked}">
<materialDesign:DrawerHost.LeftDrawerContent>
<DockPanel LastChildFill="False">
<StackPanel MinWidth="300" DockPanel.Dock="Top">
<Grid>
<ToggleButton Style="{StaticResource MaterialDesignHamburgerToggleButton}"
HorizontalAlignment="Right" Margin="16"
- IsChecked="{Binding ElementName=MenuToggleButton, Path=IsChecked, Mode=TwoWay}" />
+ IsChecked="{Binding Source={x:Reference MenuToggleButton}, Path=IsChecked, Mode=TwoWay}" />
<StackPanel Margin="5 0 0 0" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
<Image Source="/Images/account.png" RenderOptions.BitmapScalingMode="Fant" VerticalAlignment="Center" Width="50" Height="50"></Image>
@@ -330,77 +330,73 @@
</Grid.RowDefinitions>
<Grid Grid.Row="1">
- <controls:MultiTransitionControl x:Name="TransitionControl" AlwaysFade="True" TransitionType="Zoom">
- <controls:MultiTransitionControl.Controls>
- <ContentControl Tag="Home">
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="150"/>
- <RowDefinition Height="*"/>
- </Grid.RowDefinitions>
- <Grid>
- <StackPanel Margin="30 20" HorizontalAlignment="Left">
- <TextBlock FontSize="35">Welcome to Machine Studio</TextBlock>
- <TextBlock HorizontalAlignment="Left" Margin="350 5 0 0" FontStyle="Italic" FontSize="16">The below modules are displayed according to your user roles and permissions.</TextBlock>
- </StackPanel>
- </Grid>
+ <controls:NavigationControl x:Name="TransitionControl" TransitionAlwaysFades="True" TransitionType="Zoom">
+ <Grid controls:NavigationControl.NavigationName="Home">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="150"/>
+ <RowDefinition Height="*"/>
+ </Grid.RowDefinitions>
+ <Grid>
+ <StackPanel Margin="30 20" HorizontalAlignment="Left">
+ <TextBlock FontSize="35">Welcome to Machine Studio</TextBlock>
+ <TextBlock HorizontalAlignment="Left" Margin="350 5 0 0" FontStyle="Italic" FontSize="16">The below modules are displayed according to your user roles and permissions.</TextBlock>
+ </StackPanel>
+ </Grid>
- <Grid Grid.Row="2">
- <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
- <ItemsControl ItemsSource="{Binding StudioModuleLoader.UserModules}" Margin="10">
- <ItemsControl.ItemsPanel>
- <ItemsPanelTemplate>
- <WrapPanel IsItemsHost="True"></WrapPanel>
- </ItemsPanelTemplate>
- </ItemsControl.ItemsPanel>
+ <Grid Grid.Row="2">
+ <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
+ <ItemsControl ItemsSource="{Binding StudioModuleLoader.UserModules}" Margin="10">
+ <ItemsControl.ItemsPanel>
+ <ItemsPanelTemplate>
+ <WrapPanel IsItemsHost="True"></WrapPanel>
+ </ItemsPanelTemplate>
+ </ItemsControl.ItemsPanel>
- <ItemsControl.ItemTemplate>
- <DataTemplate>
- <materialDesign:Card Width="300" Margin="10" Height="400" Visibility="{Binding InNewWindow,Converter={StaticResource BooleanToVisibilityInverseConverter}}">
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="180" />
- <RowDefinition Height="*" />
- <RowDefinition Height="Auto" />
- </Grid.RowDefinitions>
- <Image Source="{Binding Image,Mode=OneWay}" Stretch="Fill" RenderOptions.BitmapScalingMode="Fant" />
- <Rectangle VerticalAlignment="Bottom" Stroke="Silver"></Rectangle>
- <Button AutomationProperties.AutomationId="{Binding Name}" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.StartModuleCommand}" CommandParameter="{Binding}" Grid.Row="0" Margin="0,0,20,-35" HorizontalAlignment="Right" Width="70" Height="70" VerticalAlignment="Bottom" Style="{StaticResource MaterialDesignFloatingActionMiniButton}" ToolTip="Start This Module">
- <materialDesign:PackIcon Kind="Play" Width="30" Height="30" />
- </Button>
- <StackPanel Grid.Row="1" Margin="8,24,8,0">
- <TextBlock FontWeight="Bold" FontSize="20" Text="{Binding Name,Mode=OneWay}"></TextBlock>
- <TextBlock VerticalAlignment="Center" Margin="0 5 0 0" FontSize="14" TextWrapping="Wrap" Text="{Binding Description,Mode=OneWay}"></TextBlock>
- </StackPanel>
- <StackPanel Grid.Row="2" Margin="8" HorizontalAlignment="Right" Orientation="Horizontal">
- <materialDesign:PopupBox Padding="2,0,2,0" Style="{StaticResource MaterialDesignToolPopupBox}">
- <StackPanel>
- <Button Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.OpenModuleInWindowCommand}" CommandParameter="{Binding}">
- <StackPanel Orientation="Horizontal">
- <materialDesign:PackIcon Kind="ArrowTopRight" Width="24" Height="24" />
- <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">Start in new window</TextBlock>
- </StackPanel>
- </Button>
- <Button>
- <StackPanel Orientation="Horizontal">
- <materialDesign:PackIcon Kind="Settings" Width="24" Height="24" />
- <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">Settings</TextBlock>
- </StackPanel>
- </Button>
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <materialDesign:Card Width="300" Margin="10" Height="400" Visibility="{Binding InNewWindow,Converter={StaticResource BooleanToVisibilityInverseConverter}}">
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="180" />
+ <RowDefinition Height="*" />
+ <RowDefinition Height="Auto" />
+ </Grid.RowDefinitions>
+ <Image Source="{Binding Image,Mode=OneWay}" Stretch="Fill" RenderOptions.BitmapScalingMode="Fant" />
+ <Rectangle VerticalAlignment="Bottom" Stroke="Silver"></Rectangle>
+ <Button Tag="{Binding}" AutomationProperties.AutomationId="{Binding Name}" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.StartModuleCommand}" CommandParameter="{Binding}" Grid.Row="0" Margin="0,0,20,-35" HorizontalAlignment="Right" Width="70" Height="70" VerticalAlignment="Bottom" Style="{StaticResource MaterialDesignFloatingActionMiniButton}" ToolTip="Start this module">
+ <materialDesign:PackIcon Kind="Play" Width="30" Height="30" />
+ </Button>
+ <StackPanel Grid.Row="1" Margin="8,24,8,0">
+ <TextBlock FontWeight="Bold" FontSize="20" Text="{Binding Name,Mode=OneWay}"></TextBlock>
+ <TextBlock VerticalAlignment="Center" Margin="0 5 0 0" FontSize="14" TextWrapping="Wrap" Text="{Binding Description,Mode=OneWay}"></TextBlock>
+ </StackPanel>
+ <StackPanel Grid.Row="2" Margin="8" HorizontalAlignment="Right" Orientation="Horizontal">
+ <materialDesign:PopupBox Padding="2,0,2,0" Style="{StaticResource MaterialDesignToolPopupBox}">
+ <StackPanel>
+ <Button Command="{Binding RelativeSource={RelativeSource AncestorType=local:MainView},Path=DataContext.OpenModuleInWindowCommand}" CommandParameter="{Binding}">
+ <StackPanel Orientation="Horizontal">
+ <materialDesign:PackIcon Kind="ArrowTopRight" Width="24" Height="24" />
+ <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">Start in new window</TextBlock>
+ </StackPanel>
+ </Button>
+ <Button>
+ <StackPanel Orientation="Horizontal">
+ <materialDesign:PackIcon Kind="Settings" Width="24" Height="24" />
+ <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">Settings</TextBlock>
</StackPanel>
- </materialDesign:PopupBox>
+ </Button>
</StackPanel>
- </Grid>
- </materialDesign:Card>
- </DataTemplate>
- </ItemsControl.ItemTemplate>
- </ItemsControl>
- </ScrollViewer>
- </Grid>
- </Grid>
- </ContentControl>
- </controls:MultiTransitionControl.Controls>
- </controls:MultiTransitionControl>
+ </materialDesign:PopupBox>
+ </StackPanel>
+ </Grid>
+ </materialDesign:Card>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ </ScrollViewer>
+ </Grid>
+ </Grid>
+ </controls:NavigationControl>
</Grid>
</Grid>
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml.cs
index 442d11cdd..df1f97f23 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml.cs
@@ -26,6 +26,7 @@ using System.Threading;
using Tango.Core.Helpers;
using Tango.SharedUI.Helpers;
using Tango.Logging;
+using static Tango.SharedUI.Controls.NavigationControl;
namespace Tango.MachineStudio.UI.Views
{
@@ -44,15 +45,8 @@ namespace Tango.MachineStudio.UI.Views
_loader.ModulesLoaded += Loader_ModulesLoaded;
}
- public void NavigateToModule(IStudioModule module)
- {
- TransitionControl.AutoNavigate(module != null ? module.Name : "Home");
- }
-
private void Loader_ModulesLoaded(object sender, EventArgs e)
{
- TransitionControl.Controls.RemoveAll((x) => x.Tag.ToString() != "Home");
-
Task.Factory.StartNew(() =>
{
LogManager.Default.Log("Loading modules views...");
@@ -74,15 +68,12 @@ namespace Tango.MachineStudio.UI.Views
ThreadsHelper.InvokeUI(() =>
{
- Grid grid = new Grid();
- grid.Children.Add(module.MainView);
-
- TransitionControl.Controls.Add(new ContentControl()
+ if (!TransitionControl.Elements.ToList().Exists(x => x.GetType() == module.MainViewType))
{
- Tag = module.Name,
- Content = grid,
- Visibility = Visibility.Hidden,
- });
+ FrameworkElement view = Activator.CreateInstance(module.MainViewType) as FrameworkElement;
+ NavigationControl.SetNavigationName(view, module.Name);
+ TransitionControl.Elements.Add(view);
+ }
_loader.UserModules.Add(module);
});
@@ -92,11 +83,6 @@ namespace Tango.MachineStudio.UI.Views
Thread.Sleep(100);
}
- ThreadsHelper.InvokeUI(() =>
- {
- TransitionControl.RefreshControls();
- });
-
item.Pop();
});
}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ShutdownView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ShutdownView.xaml.cs
index afe6d3800..e1e16592b 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ShutdownView.xaml.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ShutdownView.xaml.cs
@@ -13,20 +13,21 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using static Tango.SharedUI.Controls.MultiTransitionControl;
+using static Tango.SharedUI.Controls.NavigationControl;
namespace Tango.MachineStudio.UI.Views
{
/// <summary>
/// Interaction logic for ShutdownView.xaml
/// </summary>
- public partial class ShutdownView : UserControl, ITransitionView
+ public partial class ShutdownView : UserControl, INavigationView
{
public ShutdownView()
{
InitializeComponent();
}
- public void OnTransitionCompleted()
+ public void OnNavigated()
{
progressRing.IsActive = true;
}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml.cs
index 75b74f65d..deb4dfdbe 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml.cs
@@ -14,13 +14,14 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using Tango.MachineStudio.UI.ViewModels;
using static Tango.SharedUI.Controls.MultiTransitionControl;
+using static Tango.SharedUI.Controls.NavigationControl;
namespace Tango.MachineStudio.UI.Views
{
/// <summary>
/// Interaction logic for UpdateView.xaml
/// </summary>
- public partial class UpdateView : UserControl, ITransitionView
+ public partial class UpdateView : UserControl, INavigationView
{
private UpdateViewVM _vm;
@@ -34,7 +35,7 @@ namespace Tango.MachineStudio.UI.Views
};
}
- public void OnTransitionCompleted()
+ public void OnNavigated()
{
_vm.OnNavigatedInto();
}