diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-03-20 16:23:17 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-03-20 16:23:17 +0200 |
| commit | db9308c46379fb324678ba04771dbee4edae4b17 (patch) | |
| tree | a443967e7baeff8924e1aeb85ff4de3b5050510a /Software/Visual_Studio | |
| parent | 88ac356fd2d30e016bb884697e7b67f8ede51d2b (diff) | |
| download | Tango-db9308c46379fb324678ba04771dbee4edae4b17.tar.gz Tango-db9308c46379fb324678ba04771dbee4edae4b17.zip | |
working on PPC Technician module .
Diffstat (limited to 'Software/Visual_Studio')
23 files changed, 463 insertions, 90 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/logging.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/logging.png Binary files differnew file mode 100644 index 000000000..580bcb046 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/logging.png diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/system.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/system.png Binary files differnew file mode 100644 index 000000000..48c8ce83d --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Images/system.png diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj index 2a4c1d39c..5b34c38a1 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj @@ -72,7 +72,15 @@ <DesignTimeSharedInput>True</DesignTimeSharedInput> </Compile> <Compile Include="ViewModelLocator.cs" /> + <Compile Include="ViewModels\CatalogViewVM.cs" /> + <Compile Include="ViewModels\LoggingViewVM.cs" /> <Compile Include="ViewModels\MainViewVM.cs" /> + <Compile Include="Views\CatalogView.xaml.cs"> + <DependentUpon>CatalogView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\LoggingView.xaml.cs"> + <DependentUpon>LoggingView.xaml</DependentUpon> + </Compile> <Compile Include="Views\MainView.xaml.cs"> <DependentUpon>MainView.xaml</DependentUpon> </Compile> @@ -96,6 +104,10 @@ <Project>{A34EE0F0-649D-41C8-8489-B6F1CC6924EE}</Project> <Name>Tango.Core</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Logging\Tango.Logging.csproj"> + <Project>{BC932DBD-7CDB-488C-99E4-F02CF441F55E}</Project> + <Name>Tango.Logging</Name> + </ProjectReference> <ProjectReference Include="..\..\..\Tango.SharedUI\Tango.SharedUI.csproj"> <Project>{8491D07B-C1F6-4B62-A412-41B9FD2D6538}</Project> <Name>Tango.SharedUI</Name> @@ -114,6 +126,14 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="Views\CatalogView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="Views\LoggingView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Views\MainView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -122,5 +142,11 @@ <ItemGroup> <Resource Include="Images\technician_module.png" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\logging.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\system.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs index 3a4c8d829..3c6f874e0 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModelLocator.cs @@ -16,6 +16,8 @@ namespace Tango.PPC.Technician static ViewModelLocator() { TangoIOC.Default.Register<MainViewVM>(); + TangoIOC.Default.Register<LoggingViewVM>(); + TangoIOC.Default.Register<CatalogViewVM>(); } /// <summary> @@ -28,5 +30,27 @@ namespace Tango.PPC.Technician return TangoIOC.Default.GetInstance<MainViewVM>(); } } + + /// <summary> + /// Gets the logging view VM. + /// </summary> + public static LoggingViewVM LoggingViewVM + { + get + { + return TangoIOC.Default.GetInstance<LoggingViewVM>(); + } + } + + /// <summary> + /// Gets the logging view VM. + /// </summary> + public static CatalogViewVM CatalogViewVM + { + get + { + return TangoIOC.Default.GetInstance<CatalogViewVM>(); + } + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/CatalogViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/CatalogViewVM.cs new file mode 100644 index 000000000..97bae6f5b --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/CatalogViewVM.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.PPC.Common; + +namespace Tango.PPC.Technician.ViewModels +{ + public class CatalogViewVM : PPCViewModel + { + /// <summary> + /// Gets or sets the navigation command. + /// </summary> + public RelayCommand<String> NavigationCommand { get; set; } + + /// <summary> + /// Initializes a new instance of the <see cref="CatalogViewVM"/> class. + /// </summary> + public CatalogViewVM() + { + NavigationCommand = new RelayCommand<string>(NavigateToView); + } + + public override void OnApplicationStarted() + { + + } + + /// <summary> + /// Navigates to the specified view name. + /// </summary> + /// <param name="view">The view.</param> + private void NavigateToView(string view) + { + NavigationManager.NavigateTo<TechnicianModule>(view); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/LoggingViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/LoggingViewVM.cs new file mode 100644 index 000000000..b46c6477e --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/LoggingViewVM.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Logging; +using Tango.PPC.Common; + +namespace Tango.PPC.Technician.ViewModels +{ + public class LoggingViewVM : PPCViewModel + { + public SynchronizedObservableCollection<LogItemBase> ApplicationLogs { get; set; } + public SynchronizedObservableCollection<LogItemBase> EmbeddedLogs { get; set; } + + public LoggingViewVM() + { + ApplicationLogs = new SynchronizedObservableCollection<LogItemBase>(); + EmbeddedLogs = new SynchronizedObservableCollection<LogItemBase>(); + LogManager.NewLog += LogManager_NewLog; + } + + private void LogManager_NewLog(object sender, LogItemBase log) + { + ApplicationLogs.Insert(0, log); + + var now = DateTime.Now; + + try + { + foreach (var l in ApplicationLogs.ToList()) + { + if (l.TimeStamp.Date < DateTime.Now.Date) + { + ApplicationLogs.Remove(l); + } + } + } + catch + { + //I don't know if this will cause an exception but I'm tired. + } + } + + public override void OnApplicationStarted() + { + + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/MainViewVM.cs index 893d495fc..d63a89f3b 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/MainViewVM.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.PPC.Common; +using Tango.PPC.Technician.Views; namespace Tango.PPC.Technician.ViewModels { @@ -13,5 +14,11 @@ namespace Tango.PPC.Technician.ViewModels { } + + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + NavigationManager.NavigateTo<TechnicianModule>(nameof(CatalogView)); + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml new file mode 100644 index 000000000..79d753474 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml @@ -0,0 +1,51 @@ +<UserControl x:Class="Tango.PPC.Technician.Views.CatalogView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:sys="clr-namespace:System;assembly=mscorlib" + xmlns:vm="clr-namespace:Tango.PPC.Technician.ViewModels" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:global="clr-namespace:Tango.PPC.Technician" + xmlns:local="clr-namespace:Tango.PPC.Technician.Views" + mc:Ignorable="d" + d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:CatalogViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.CatalogViewVM}"> + <Grid Background="{StaticResource TangoMidBackgroundBrush}"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + + <Border Padding="20" Background="{StaticResource TangoPrimaryBackgroundBrush}" BorderThickness="0 0 0 1" BorderBrush="{StaticResource TangoDividerBrush}"> + <Border.Effect> + <DropShadowEffect Color="Silver" ShadowDepth="0" BlurRadius="20" Opacity="1" /> + </Border.Effect> + <TextBlock VerticalAlignment="Center" FontSize="{StaticResource TangoHeaderFontSize}" FontWeight="SemiBold">Technician Mode</TextBlock> + </Border> + + <Grid Grid.Row="1" VerticalAlignment="Top" Margin="20"> + <UniformGrid Columns="2"> + <touch:TouchButton Command="{Binding NavigationCommand}" CommandParameter="LoggingView" Width="250" Height="250" Style="{StaticResource TangoHollowButton}" Padding="20"> + <DockPanel> + <TextBlock Margin="0 10 0 0" DockPanel.Dock="Bottom" HorizontalAlignment="Center" FontSize="{StaticResource TangoExpanderHeaderFontSize}">Logging</TextBlock> + <Image Width="128" Source="../Images/logging.png" /> + </DockPanel> + </touch:TouchButton> + + <touch:TouchButton Width="250" Height="250" Style="{StaticResource TangoHollowButton}" Padding="20"> + <DockPanel> + <TextBlock Margin="0 10 0 0" DockPanel.Dock="Bottom" HorizontalAlignment="Center" FontSize="{StaticResource TangoExpanderHeaderFontSize}">System</TextBlock> + <Image Width="128" Source="../Images/system.png" /> + </DockPanel> + </touch:TouchButton> + + <touch:TouchButton Margin="0 60 0 0" Width="250" Height="250" Style="{StaticResource TangoHollowButton}" Padding="20"> + <DockPanel> + <TextBlock Margin="0 10 0 0" DockPanel.Dock="Bottom" HorizontalAlignment="Center" FontSize="{StaticResource TangoExpanderHeaderFontSize}">Coming soon...</TextBlock> + <!--<Image Width="128" Source="../Images/system.png" />--> + </DockPanel> + </touch:TouchButton> + </UniformGrid> + </Grid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml.cs new file mode 100644 index 000000000..d5e0398fb --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/CatalogView.xaml.cs @@ -0,0 +1,28 @@ +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.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Technician.Views +{ + /// <summary> + /// Interaction logic for CatalogView.xaml + /// </summary> + public partial class CatalogView : UserControl + { + public CatalogView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/LoggingView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/LoggingView.xaml new file mode 100644 index 000000000..db82a5ad0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/LoggingView.xaml @@ -0,0 +1,101 @@ +<UserControl x:Class="Tango.PPC.Technician.Views.LoggingView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="clr-namespace:Tango.PPC.Technician.Views" + xmlns:sys="clr-namespace:System;assembly=mscorlib" + xmlns:vm="clr-namespace:Tango.PPC.Technician.ViewModels" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:global="clr-namespace:Tango.PPC.Technician" + mc:Ignorable="d" + d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:LoggingViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.LoggingViewVM}"> + + <Grid Background="{StaticResource TangoMidBackgroundBrush}"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + + <Border Padding="20" Background="{StaticResource TangoPrimaryBackgroundBrush}" BorderThickness="0 0 0 1" BorderBrush="{StaticResource TangoDividerBrush}"> + <Border.Effect> + <DropShadowEffect Color="Silver" ShadowDepth="0" BlurRadius="20" Opacity="1" /> + </Border.Effect> + <TextBlock VerticalAlignment="Center" FontSize="{StaticResource TangoHeaderFontSize}" FontWeight="SemiBold">Logging</TextBlock> + </Border> + + <Grid Grid.Row="1"> + + <DockPanel> + <DockPanel DockPanel.Dock="Top"> + <touch:TouchNavigationLinks Margin="20" FontSize="{StaticResource TangoNavigationLinksFontSize}"> + <sys:String>Application</sys:String> + <sys:String>Embedded</sys:String> + </touch:TouchNavigationLinks> + + <touch:TouchDatePicker Visibility="Collapsed" SelectedDate="12/15/2018" Height="40" /> + </DockPanel> + + <Grid Margin="20"> + <touch:TouchNativeListBox ItemsSource="{Binding ApplicationLogs}" SelectionMode="Single"> + <ListBox.ItemContainerStyle> + <Style TargetType="ListBoxItem" BasedOn="{StaticResource TangoTouchNativeListBoxItem}"> + <Setter Property="Height" Value="125"></Setter> + <Style.Triggers> + <Trigger Property="IsSelected" Value="True"> + <Setter Property="Height" Value="Auto"></Setter> + </Trigger> + </Style.Triggers> + </Style> + </ListBox.ItemContainerStyle> + <ListBox.ItemTemplate> + <DataTemplate> + <Border Background="{StaticResource TangoPrimaryBackgroundBrush}" BorderThickness="1" Margin="5" Padding="5" CornerRadius="5" IsHitTestVisible="False"> + <Border.Style> + <Style TargetType="Border"> + <Setter Property="BorderBrush" Value="{StaticResource TangoLightBorderBrush}"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding Category}" Value="Warning"> + <Setter Property="BorderBrush" Value="{StaticResource TangoWarningBrush}"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Category}" Value="Error"> + <Setter Property="BorderBrush" Value="{StaticResource TangoErrorBrush}"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Category}" Value="Critical"> + <Setter Property="BorderBrush" Value="{StaticResource TangoErrorBrush}"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Border.Style> + <StackPanel> + <TextBlock> + <Run>Time:</Run> + <Run Text="{Binding TimeStamp,Mode=OneWay}" FontWeight="SemiBold"></Run> + </TextBlock> + <TextBlock Margin="0 2 0 0"> + <Run>File:</Run> + <Run Text="{Binding RelativeCallerFile,Mode=OneWay}" FontWeight="SemiBold"></Run> + </TextBlock> + <TextBlock Margin="0 2 0 0"> + <Run>Method:</Run> + <Run Text="{Binding CallerMethodName,Mode=OneWay}" FontWeight="SemiBold"></Run> + </TextBlock> + <TextBlock Margin="0 2 0 0"> + <Run>Line:</Run> + <Run Text="{Binding CallerLineNumber,Mode=OneWay}" FontWeight="SemiBold"></Run> + </TextBlock> + <TextBlock Margin="0 2 0 0" TextTrimming="WordEllipsis"> + <Run>Message:</Run> + <Run Text="{Binding Message,Mode=OneWay}" FontWeight="SemiBold"></Run> + </TextBlock> + </StackPanel> + </Border> + </DataTemplate> + </ListBox.ItemTemplate> + </touch:TouchNativeListBox> + </Grid> + </DockPanel> + + </Grid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/LoggingView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/LoggingView.xaml.cs new file mode 100644 index 000000000..9c12f7f13 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/LoggingView.xaml.cs @@ -0,0 +1,28 @@ +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.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Technician.Views +{ + /// <summary> + /// Interaction logic for LoggingView.xaml + /// </summary> + public partial class LoggingView : UserControl + { + public LoggingView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml index 5e9401742..66e16588b 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Views/MainView.xaml @@ -7,39 +7,14 @@ xmlns:vm="clr-namespace:Tango.PPC.Technician.ViewModels" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:global="clr-namespace:Tango.PPC.Technician" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:local="clr-namespace:Tango.PPC.Technician.Views" mc:Ignorable="d" d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> <Grid Background="{StaticResource TangoMidBackgroundBrush}"> - <Grid.RowDefinitions> - <RowDefinition Height="Auto"/> - <RowDefinition Height="1*"/> - </Grid.RowDefinitions> - - <Border Padding="20" Background="{StaticResource TangoPrimaryBackgroundBrush}" BorderThickness="0 0 0 1" BorderBrush="{StaticResource TangoDividerBrush}"> - <Border.Effect> - <DropShadowEffect Color="Silver" ShadowDepth="0" BlurRadius="20" Opacity="1" /> - </Border.Effect> - <TextBlock VerticalAlignment="Center" FontSize="{StaticResource TangoHeaderFontSize}" FontWeight="SemiBold">Logs</TextBlock> - </Border> - - <Grid Grid.Row="1"> - - <DockPanel> - <DockPanel DockPanel.Dock="Top"> - <touch:TouchNavigationLinks Margin="20" FontSize="{StaticResource TangoNavigationLinksFontSize}"> - <sys:String>Application</sys:String> - <sys:String>Embedded</sys:String> - </touch:TouchNavigationLinks> - - <touch:TouchDatePicker SelectedDate="12/15/2018" Height="40" /> - </DockPanel> - - <Grid> - - </Grid> - </DockPanel> - - </Grid> + <controls:NavigationControl TransitionAlwaysFades="True" TransitionType="Zoom" TransitionDuration="00:00:0.2"> + <local:CatalogView/> + <local:LoggingView/> + </controls:NavigationControl> </Grid> </UserControl> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs index ff3f65221..2d76b202f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Application/IPPCApplicationManager.cs @@ -78,7 +78,7 @@ namespace Tango.PPC.Common.Application /// <summary> /// Enteres the application technician mode. /// </summary> - void EnterTechnicianMode(); + void EnterTechnicianMode(bool displayNotification = true); /// <summary> /// Exits the application technician mode. diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index 409dd1cfc..32181a753 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -77,6 +77,11 @@ namespace Tango.PPC.Common public bool EnableWatchDog { get; set; } /// <summary> + /// Gets or sets a value indicating whether to enable the technician mode when the application starts. + /// </summary> + public bool EnableTechnicianModeByDefault { get; set; } + + /// <summary> /// Gets the machine service address. /// </summary> /// <returns></returns> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml index 05cd998e6..62f248a8c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml @@ -14,6 +14,7 @@ <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchButton.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchIconButton.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Styles/TouchListBox.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchNativeListBox.xaml" /> <!--PPC--> <ResourceDictionary Source="pack://application:,,,/Tango.PPC.Common;component/Resources/Colors.xaml"/> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index 261dbe6d4..ba1b44c8a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -335,6 +335,11 @@ namespace Tango.PPC.UI.PPCApplication LogManager.Log($"Invoking {vm.GetType().Name}.OnApplicationReady..."); vm.OnApplicationReady(); } + + if (SettingsManager.Default.GetOrCreate<PPCSettings>().EnableTechnicianModeByDefault) + { + EnterTechnicianMode(false); + } }); } @@ -418,24 +423,32 @@ namespace Tango.PPC.UI.PPCApplication /// <summary> /// Enteres the application technician mode. /// </summary> - public async void EnterTechnicianMode() + public async void EnterTechnicianMode(bool displayNotification = true) { - var vm = await _notificationProvider.ShowDialog<TechnicianModeLoginViewVM>(); - - if (vm.DialogResult) + if (displayNotification) { - if (vm.Password == "Aa123456") - { - IsInTechnicianMode = true; - _moduleLoader.AllModules.ToList().ForEach(x => x.OnTechnicianEntered()); - await _notificationProvider.ShowInfo("Technician mode is now enabled."); - } - else + var vm = await _notificationProvider.ShowDialog<TechnicianModeLoginViewVM>(); + + if (vm.DialogResult) { - await _notificationProvider.ShowError("Invalid technician mode password."); - EnterTechnicianMode(); + if (vm.Password == "Aa123456") + { + IsInTechnicianMode = true; + _moduleLoader.AllModules.ToList().ForEach(x => x.OnTechnicianEntered()); + await _notificationProvider.ShowInfo("Technician mode is now enabled."); + } + else + { + await _notificationProvider.ShowError("Invalid technician mode password."); + EnterTechnicianMode(); + } } } + else + { + IsInTechnicianMode = true; + _moduleLoader.AllModules.ToList().ForEach(x => x.OnTechnicianEntered()); + } } /// <summary> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs index 3cb790e65..9e8a9fe34 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -115,6 +115,12 @@ namespace Tango.PPC.UI.ViewModels /// Gets or sets the power command. /// </summary> public RelayCommand PowerCommand { get; set; } + + /// <summary> + /// Gets or sets the restart application command. + /// </summary> + public RelayCommand RestartApplicationCommand { get; set; } + #endregion #region Constructors @@ -139,6 +145,7 @@ namespace Tango.PPC.UI.ViewModels }); PowerCommand = new RelayCommand(() => IsPowerOpened = true); + RestartApplicationCommand = new RelayCommand(RestartApplication); } #endregion @@ -221,6 +228,17 @@ namespace Tango.PPC.UI.ViewModels } } + /// <summary> + /// Restarts the application. + /// </summary> + private async void RestartApplication() + { + if (await NotificationProvider.ShowQuestion("Are you sure you want to restart the application?")) + { + ApplicationManager.Restart(); + } + } + #endregion #region Override Methods diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml index 2a2f3e8b5..4079777f7 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -158,7 +158,7 @@ </Grid.ColumnDefinitions> <Image Source="/Images/power-tablet.png" Margin="30" /> - <touch:TouchButton Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Padding="50 20" Height="Auto" Style="{StaticResource TangoLinkButton}" Foreground="{StaticResource TangoPrimaryBackgroundBrush}" FontSize="{StaticResource TangoTitleFontSize}">Restart</touch:TouchButton> + <touch:TouchButton Command="{Binding RestartApplicationCommand}" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Padding="50 20" Height="Auto" Style="{StaticResource TangoLinkButton}" Foreground="{StaticResource TangoPrimaryBackgroundBrush}" FontSize="{StaticResource TangoTitleFontSize}">Restart</touch:TouchButton> </Grid> </Grid> </Border> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs index 2156e45ca..777083b67 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml.cs @@ -52,24 +52,28 @@ namespace Tango.PPC.UI.Views private void OnMouseOrTouchDown(object sender, MouseOrTouchEventArgs e) { - techPressElement.CaptureMouse(); - - if (e.TouchDevice != null) - { - techPressElement.CaptureTouch(e.TouchDevice); - } + //if (e.TouchDevice != null) + //{ + // techPressElement.CaptureTouch(e.TouchDevice); + //} + //else + //{ + // techPressElement.CaptureMouse(); + //} _timer.Start(); } private void OnMouseOrTouchUp(object sender, MouseOrTouchEventArgs e) { - this.ReleaseMouseCapture(); - - if (e.TouchDevice != null) - { - techPressElement.ReleaseTouchCapture(e.TouchDevice); - } + //if (e.TouchDevice != null) + //{ + // techPressElement.ReleaseTouchCapture(e.TouchDevice); + //} + //else + //{ + // techPressElement.ReleaseMouseCapture(); + //} _timer.Stop(); } diff --git a/Software/Visual_Studio/Tango.AnimatedGif/ImageBehavior.cs b/Software/Visual_Studio/Tango.AnimatedGif/ImageBehavior.cs index a159106e6..cc13688ff 100644 --- a/Software/Visual_Studio/Tango.AnimatedGif/ImageBehavior.cs +++ b/Software/Visual_Studio/Tango.AnimatedGif/ImageBehavior.cs @@ -573,10 +573,8 @@ namespace Tango.AnimatedGif animation.RepeatBehavior = GetActualRepeatBehavior(imageControl, decoder, gifMetadata); - //Removed animation cache for PPC AsyncAdornerControl! - - //AnimationCache.AddAnimation(source, GetRepeatBehavior(imageControl), animation); - //AnimationCache.IncrementReferenceCount(source, GetRepeatBehavior(imageControl)); + AnimationCache.AddAnimation(source, GetRepeatBehavior(imageControl), animation); + AnimationCache.IncrementReferenceCount(source, GetRepeatBehavior(imageControl)); return animation; } return null; diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs index 08f3bb101..909366ffd 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs @@ -77,6 +77,7 @@ public static class FrameworkElementExtensions OriginalSource = e.OriginalSource, Handled = e.Handled, GetPositionAction = (s) => { return e.GetTouchPoint(s).Position; }, + TouchDevice = e.TouchDevice, }; handler(element, args); @@ -176,6 +177,7 @@ public static class FrameworkElementExtensions OriginalSource = e.OriginalSource, Handled = e.Handled, GetPositionAction = (s) => { return e.GetTouchPoint(s).Position; }, + TouchDevice = e.TouchDevice, }; handler(element, args); @@ -270,6 +272,7 @@ public static class FrameworkElementExtensions OriginalSource = e.OriginalSource, Handled = e.Handled, GetPositionAction = (s) => { return e.GetTouchPoint(s).Position; }, + TouchDevice = e.TouchDevice, }; handler(element, args); @@ -369,6 +372,7 @@ public static class FrameworkElementExtensions OriginalSource = e.OriginalSource, Handled = e.Handled, GetPositionAction = (s) => { return e.GetTouchPoint(s).Position; }, + TouchDevice = e.TouchDevice, }; handler(element, args); diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNativeListBox.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchNativeListBox.xaml index 7d04c902a..456e82750 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNativeListBox.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNativeListBox.xaml @@ -7,37 +7,35 @@ <ResourceDictionary Source="../Resources/Colors.xaml" /> </ResourceDictionary.MergedDictionaries> - <Style TargetType="{x:Type local:TouchNativeListBox}"> - <Setter Property="ItemContainerStyle"> + <Style x:Key="TangoTouchNativeListBoxItem" TargetType="ListBoxItem"> + <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter> + <Setter Property="VerticalContentAlignment" Value="Stretch"></Setter> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="Template"> <Setter.Value> - <Style TargetType="ListBoxItem"> - <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter> - <Setter Property="VerticalContentAlignment" Value="Stretch"></Setter> - <Setter Property="Background" Value="Transparent"></Setter> - <Setter Property="Template"> - <Setter.Value> - <ControlTemplate TargetType="ListBoxItem"> - <components:Ripple RippleBrush="{StaticResource TangoRippleDarkBrush}" RippleFactor="{Binding RelativeSource={RelativeSource AncestorType=local:TouchNativeListBox},Path=RippleFactor}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"> - <components:Ripple.Style> - <Style TargetType="components:Ripple"> - <Setter Property="Disabled" Value="False"></Setter> - <Style.Triggers> - <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:LightTouchScrollViewer},Path=IsScrolling}" Value="True"> - <Setter Property="Disabled" Value="True"></Setter> - </DataTrigger> - </Style.Triggers> - </Style> - </components:Ripple.Style> - <Border Background="{TemplateBinding Background}"> - <ContentControl Content="{Binding}" ContentTemplate="{Binding RelativeSource={RelativeSource AncestorType=local:TouchNativeListBox},Path=ItemTemplate}" /> - </Border> - </components:Ripple> - </ControlTemplate> - </Setter.Value> - </Setter> - </Style> + <ControlTemplate TargetType="ListBoxItem"> + <components:Ripple RippleBrush="{StaticResource TangoRippleDarkBrush}" RippleFactor="{Binding RelativeSource={RelativeSource AncestorType=local:TouchNativeListBox},Path=RippleFactor}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"> + <components:Ripple.Style> + <Style TargetType="components:Ripple"> + <Setter Property="Disabled" Value="False"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:LightTouchScrollViewer},Path=IsScrolling}" Value="True"> + <Setter Property="Disabled" Value="True"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </components:Ripple.Style> + <Border Background="{TemplateBinding Background}"> + <ContentControl Content="{Binding}" ContentTemplate="{Binding RelativeSource={RelativeSource AncestorType=local:TouchNativeListBox},Path=ItemTemplate}" /> + </Border> + </components:Ripple> + </ControlTemplate> </Setter.Value> </Setter> + </Style> + + <Style TargetType="{x:Type local:TouchNativeListBox}"> + <Setter Property="ItemContainerStyle" Value="{StaticResource TangoTouchNativeListBoxItem}"></Setter> <Setter Property="Background" Value="Transparent"/> <Setter Property="BorderThickness" Value="0"/> <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter> diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml index a36dc5069..e80bd7daa 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml @@ -154,7 +154,7 @@ <Grid Background="#9E000000"> <i:Interaction.Triggers> - <i:EventTrigger EventName="MouseUp"> + <i:EventTrigger EventName="MouseDown"> <i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource TemplatedParent},Path=CurrentDialog.DataContext.CloseCommand}" /> </i:EventTrigger> </i:Interaction.Triggers> |
