diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-12-15 01:09:46 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-12-15 01:09:46 +0200 |
| commit | 4cabb5aabc490156b50cd02592926539d48a7af8 (patch) | |
| tree | 0458fd87417eb06a89c1b15e65d1e0368518fd95 /Software/Visual_Studio | |
| parent | 51151796efb23162ca0b3d6701d90dfb6d3baeb9 (diff) | |
| download | Tango-4cabb5aabc490156b50cd02592926539d48a7af8.tar.gz Tango-4cabb5aabc490156b50cd02592926539d48a7af8.zip | |
Implmented InternalModule navigation for PPC.
Fixed issue with TangoIOC.GetAllInstancedByBase.
Implemented PowerOff Screen.
Diffstat (limited to 'Software/Visual_Studio')
14 files changed, 292 insertions, 3 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/power_off.gif b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/power_off.gif Binary files differnew file mode 100644 index 000000000..dd07593e2 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/power_off.gif diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/InternalModule.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/InternalModule.cs new file mode 100644 index 000000000..e960fa020 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/InternalModule.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media.Imaging; +using Tango.BL.Enumerations; +using Tango.PPC.Common; +using Tango.PPC.UI.Views; + +namespace Tango.PPC.UI +{ + [PPCModule(100)] + public class InternalModule : PPCModuleBase + { + public InternalModule() + { + IsVisibleInMenu = false; + } + + /// <summary> + /// Gets the module name. + /// </summary> + public override string Name + { + get + { + return "Internal"; + } + } + + /// <summary> + /// Gets the module description. + /// </summary> + public override string Description + { + get + { + return "Internal Module"; + } + } + + /// <summary> + /// Gets the module cover image. + /// </summary> + public override BitmapSource Image + { + get + { + return null; + } + } + + /// <summary> + /// Gets the module entry point view type. + /// </summary> + public override Type MainViewType + { + get + { + return typeof(InternalModuleView); + } + } + + /// <summary> + /// Gets the permission required to see and load this module. + /// </summary> + public override Permissions Permission + { + get + { + return Permissions.RunPPC; + } + } + + /// <summary> + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// </summary> + public override void Dispose() + { + //Dispose module here... + } + } +} 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 206aa112b..149fb549f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -328,6 +328,8 @@ namespace Tango.PPC.UI.PPCApplication } } + var internalModules = this.GetType().Assembly.GetTypes().Where(xx => typeof(PPCModuleBase).IsAssignableFrom(xx)).ToList(); + LogManager.Log("Waiting for IPPCModuleLoader instance injection..."); TangoIOC.Default.GetInstanceWhenAvailable<IPPCModuleLoader>((loader) => { @@ -355,6 +357,19 @@ namespace Tango.PPC.UI.PPCApplication } } } + + //Adding internal modules. + LogManager.Log("Loading internal modules..."); + foreach (var type in internalModules) + { + var module = Activator.CreateInstance(type) as IPPCModule; + LogManager.Log("Loading module view " + module.Name + "..."); + FrameworkElement view = Activator.CreateInstance(module.MainViewType) as FrameworkElement; + SharedUI.Controls.NavigationControl.SetNavigationName(view, module.Name); + Views.LayoutView.Instance.NavigationControl.Elements.Add(view); + _moduleLoader.AllModules.Add(module); + _moduleLoader.UserModules.Add(module); + } }); LogManager.Log($"{loader.UserModules.Count} modules loaded."); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index 893b1a02c..96891a8a9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -149,6 +149,7 @@ <DependentUpon>UpdateFromFileView.xaml</DependentUpon> </Compile> <Compile Include="Dialogs\UpdateFromFileViewVM.cs" /> + <Compile Include="InternalModule.cs" /> <Compile Include="Modules\DefaultStudioModuleLoader.cs" /> <Compile Include="Navigation\DefaultNavigationManager.cs" /> <Compile Include="Notifications\DefaultNotificationProvider.cs" /> @@ -164,6 +165,7 @@ <Compile Include="ViewModelLocator.cs" /> <Compile Include="ViewModels\EmergencyViewVM.cs" /> <Compile Include="ViewModels\ExternalBridgeViewVM.cs" /> + <Compile Include="ViewModels\InternalModuleViewVM.cs" /> <Compile Include="ViewModels\LayoutViewVM.cs" /> <Compile Include="ViewModels\LoadingErrorViewVM.cs" /> <Compile Include="ViewModels\LoadingViewVM.cs" /> @@ -172,6 +174,7 @@ <Compile Include="ViewModels\MainViewVM.cs" /> <Compile Include="ViewModels\MachineUpdateViewVM.cs" /> <Compile Include="ViewModels\NoPermissionsViewVM.cs" /> + <Compile Include="ViewModels\PowerOffViewVM.cs" /> <Compile Include="ViewModels\RestartingSystemViewVM.cs" /> <Compile Include="ViewModels\RestartingViewVM.cs" /> <Compile Include="ViewsContracts\ILayoutView.cs" /> @@ -180,6 +183,9 @@ <Compile Include="Views\ExternalBridgeView.xaml.cs"> <DependentUpon>ExternalBridgeView.xaml</DependentUpon> </Compile> + <Compile Include="Views\InternalModuleView.xaml.cs"> + <DependentUpon>InternalModuleView.xaml</DependentUpon> + </Compile> <Compile Include="Views\LayoutView.xaml.cs"> <DependentUpon>LayoutView.xaml</DependentUpon> </Compile> @@ -189,6 +195,9 @@ <Compile Include="Views\LoadingErrorView.xaml.cs"> <DependentUpon>LoadingErrorView.xaml</DependentUpon> </Compile> + <Compile Include="Views\PowerOffView.xaml.cs"> + <DependentUpon>PowerOffView.xaml</DependentUpon> + </Compile> <Compile Include="Views\RestartingView.xaml.cs"> <DependentUpon>RestartingView.xaml</DependentUpon> </Compile> @@ -277,6 +286,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\InternalModuleView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Views\LayoutView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -289,6 +302,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\PowerOffView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Views\RestartingView.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -383,6 +400,7 @@ <Resource Include="Images\GlobalStatus\service.png" /> <Resource Include="Images\update_available.png" /> <Resource Include="Images\powerup.gif" /> + <Resource Include="Images\power_off.gif" /> <Content Include="Manifests\release.xml" /> <Content Include="Manifests\debug.xml" /> <None Include="firmware_package.tfp"> @@ -645,7 +663,7 @@ if $(ConfigurationName) == Debug copy /Y "$(TargetDir)Packages" "$(TargetDir)"</ </PropertyGroup> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs index 49157a998..09ed7c6d0 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs @@ -124,6 +124,8 @@ namespace Tango.PPC.UI TangoIOC.Default.Register<RestartingSystemViewVM>(); TangoIOC.Default.Register<EmergencyViewVM>(); TangoIOC.Default.Register<RestartingViewVM>(); + TangoIOC.Default.Register<InternalModuleViewVM>(); + TangoIOC.Default.Register<PowerOffViewVM>(); TangoIOC.Default.GetInstance<IPPCApplicationManager>().ContentRendered += (_, __) => @@ -237,5 +239,21 @@ namespace Tango.PPC.UI return TangoIOC.Default.GetInstance<RestartingViewVM>(); } } + + public static InternalModuleViewVM InternalModuleViewVM + { + get + { + return TangoIOC.Default.GetInstance<InternalModuleViewVM>(); + } + } + + public static PowerOffViewVM PowerOffViewVM + { + get + { + return TangoIOC.Default.GetInstance<PowerOffViewVM>(); + } + } } }
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/InternalModuleViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/InternalModuleViewVM.cs new file mode 100644 index 000000000..29e6417f4 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/InternalModuleViewVM.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Common; + +namespace Tango.PPC.UI.ViewModels +{ + public class InternalModuleViewVM : PPCViewModel + { + public override void OnApplicationStarted() + { + + } + } +} 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 9e8a9fe34..e18354f89 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -10,6 +10,7 @@ using Tango.Integration.Operation; using Tango.PPC.Common; using Tango.PPC.Common.Modules; using Tango.PPC.Common.Navigation; +using Tango.PPC.UI.Views; using Tango.PPC.UI.ViewsContracts; using Tango.SharedUI; @@ -121,6 +122,11 @@ namespace Tango.PPC.UI.ViewModels /// </summary> public RelayCommand RestartApplicationCommand { get; set; } + /// <summary> + /// Gets or sets the power off command. + /// </summary> + public RelayCommand PowerOffCommand { get; set; } + #endregion #region Constructors @@ -146,6 +152,7 @@ namespace Tango.PPC.UI.ViewModels PowerCommand = new RelayCommand(() => IsPowerOpened = true); RestartApplicationCommand = new RelayCommand(RestartApplication); + PowerOffCommand = new RelayCommand(PowerOffMachine); } #endregion @@ -239,6 +246,12 @@ namespace Tango.PPC.UI.ViewModels } } + private async void PowerOffMachine() + { + IsMenuOpened = false; + await NavigationManager.NavigateTo<InternalModule>(nameof(PowerOffView)); + } + #endregion #region Override Methods diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/PowerOffViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/PowerOffViewVM.cs new file mode 100644 index 000000000..0d58b472f --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/PowerOffViewVM.cs @@ -0,0 +1,30 @@ +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.UI.ViewModels +{ + public class PowerOffViewVM : PPCViewModel + { + public RelayCommand AbortCommand { get; set; } + + public PowerOffViewVM() + { + AbortCommand = new RelayCommand(AbortPowerOff); + } + + public override void OnApplicationStarted() + { + + } + + private void AbortPowerOff() + { + NavigationManager.NavigateBack(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/InternalModuleView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/InternalModuleView.xaml new file mode 100644 index 000000000..88981a9fa --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/InternalModuleView.xaml @@ -0,0 +1,18 @@ +<UserControl x:Class="Tango.PPC.UI.Views.InternalModuleView" + 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.UI.Views" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:vm="clr-namespace:Tango.PPC.UI.ViewModels" + xmlns:global="clr-namespace:Tango.PPC.UI" + mc:Ignorable="d" + d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:InternalModuleViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.InternalModuleViewVM}"> + <Grid> + <controls:NavigationControl TransitionType="Zoom" KeepElementsAttached="True"> + <local:PowerOffView/> + </controls:NavigationControl> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/InternalModuleView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/InternalModuleView.xaml.cs new file mode 100644 index 000000000..f67d16dd9 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/InternalModuleView.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.UI.Views +{ + /// <summary> + /// Interaction logic for InternalModuleView.xaml + /// </summary> + public partial class InternalModuleView : UserControl + { + public InternalModuleView() + { + InitializeComponent(); + } + } +} 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 9315f9f0e..b4f93fd0a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -172,7 +172,7 @@ <Image Source="/Images/power-machine.png" Margin="30" /> <UniformGrid Grid.Column="1" Rows="2"> - <touch:TouchButton HorizontalAlignment="Left" VerticalAlignment="Center" Padding="50 20" Height="Auto" Style="{StaticResource TangoLinkButton}" FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoPrimaryBackgroundBrush}">Turn Off</touch:TouchButton> + <touch:TouchButton HorizontalAlignment="Left" VerticalAlignment="Center" Padding="50 20" Height="Auto" Style="{StaticResource TangoLinkButton}" FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoPrimaryBackgroundBrush}" Command="{Binding PowerOffCommand}" >Turn Off</touch:TouchButton> <touch:TouchButton HorizontalAlignment="Left" VerticalAlignment="Center" Padding="50 20" Height="Auto" Style="{StaticResource TangoLinkButton}" FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoPrimaryBackgroundBrush}">Stand By</touch:TouchButton> </UniformGrid> </Grid> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/PowerOffView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/PowerOffView.xaml new file mode 100644 index 000000000..9762ef621 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/PowerOffView.xaml @@ -0,0 +1,20 @@ +<UserControl x:Class="Tango.PPC.UI.Views.PowerOffView" + 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:vm="clr-namespace:Tango.PPC.UI.ViewModels" + xmlns:global="clr-namespace:Tango.PPC.UI" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:local="clr-namespace:Tango.PPC.UI.Views" + mc:Ignorable="d" + d:DesignHeight="1280" d:DesignWidth="800" Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DataContext="{d:DesignInstance Type=vm:PowerOffViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.PowerOffViewVM}"> + <Grid> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> + <touch:TouchGifAnimation Source="/Images/power_off.gif" EnableAnimation="{Binding IsVisible}" HorizontalAlignment="Center" /> + <TextBlock HorizontalAlignment="Center" Margin="0 60 0 0" FontSize="{StaticResource TangoHeaderFontSize}">Machine is turning Off</TextBlock> + <TextBlock HorizontalAlignment="Center" Margin="0 20 0 0" FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoGrayTextBrush}">Do not unplug machine while turning off</TextBlock> + <touch:TouchButton Command="{Binding AbortCommand}" Style="{StaticResource TangoHollowButton}" Margin="0 100 0 0" HorizontalAlignment="Center" Width="200" Height="50">ABORT</touch:TouchButton> + </StackPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/PowerOffView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/PowerOffView.xaml.cs new file mode 100644 index 000000000..ead34ae12 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/PowerOffView.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.UI.Views +{ + /// <summary> + /// Interaction logic for LoadingView.xaml + /// </summary> + public partial class PowerOffView : UserControl + { + public PowerOffView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs index de42ac6e7..0ab4f1969 100644 --- a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs +++ b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs @@ -347,7 +347,7 @@ namespace Tango.Core.DI /// <returns></returns> public virtual IEnumerable<object> GetAllInstancesByBase(Type baseType) { - return _registeredTypes.Where(x => baseType.IsAssignableFrom(x.Key)).Select(x => x.Value.Instance != null ? x.Value.Instance : CreateInstance(x.Value.ImplementationType)); + return _registeredTypes.Where(x => baseType.IsAssignableFrom(x.Key)).Select(x => x.Value.Instance != null ? x.Value.Instance : GetInstance(x.Value.ImplementationType)); } /// <summary> |
