diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-04-12 04:37:11 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-04-12 04:37:11 +0300 |
| commit | e1802508c00e0cede200d3914c5b6e4587cb6963 (patch) | |
| tree | ec6d74dc182ec77cf4e94c58cdcb983d12a921bf /Software/Visual_Studio | |
| parent | 2c68ed841941d4e1b27815a52ca841d6abc4e806 (diff) | |
| download | Tango-e1802508c00e0cede200d3914c5b6e4587cb6963.tar.gz Tango-e1802508c00e0cede200d3914c5b6e4587cb6963.zip | |
Working on FSE TUP.
Diffstat (limited to 'Software/Visual_Studio')
24 files changed, 747 insertions, 213 deletions
diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Images/application.png b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Images/application.png Binary files differnew file mode 100644 index 000000000..54b78078d --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Images/application.png diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Images/firmware.png b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Images/firmware.png Binary files differnew file mode 100644 index 000000000..2ec10ffc3 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Images/firmware.png diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Images/machine-update.png b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Images/machine-update.png Binary files differnew file mode 100644 index 000000000..d8db51337 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Images/machine-update.png diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Images/machine-update2.png b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Images/machine-update2.png Binary files differnew file mode 100644 index 000000000..db513c76f --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Images/machine-update2.png diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Images/remote_upgrade_large.png b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Images/remote_upgrade_large.png Binary files differnew file mode 100644 index 000000000..e09579bb3 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Images/remote_upgrade_large.png diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Tango.FSE.Upgrade.csproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Tango.FSE.Upgrade.csproj index c4fdd5c22..bae2811ac 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Tango.FSE.Upgrade.csproj +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Tango.FSE.Upgrade.csproj @@ -193,6 +193,19 @@ <ItemGroup> <Resource Include="Images\remote_upgrade.png" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\remote_upgrade_large.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\application.png" /> + <Resource Include="Images\firmware.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\machine-update.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\machine-update2.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="..\..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets" Condition="Exists('..\..\..\packages\MaterialDesignThemes.3.0.1\build\MaterialDesignThemes.targets')" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/ApplicationUpgradeViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/ApplicationUpgradeViewVM.cs index 171a461cc..cfe2e212c 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/ApplicationUpgradeViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/ApplicationUpgradeViewVM.cs @@ -3,11 +3,129 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.Core.Commands; using Tango.FSE.Common; +using Tango.FSE.Common.Navigation; +using Tango.FSE.Common.RemoteUpgrade; namespace Tango.FSE.Upgrade.ViewModels { - public class ApplicationUpgradeViewVM : FSEViewModel + public class ApplicationUpgradeViewVM : FSEViewModel, INavigationObjectReceiver<ApplicationUpgradeViewVM.NavigationObject> { + public enum ApplicationUpgradeMode + { + ConnectedMachine, + OtherMachine + } + + public class NavigationObject + { + public ApplicationUpgradeMode ApplicationUpgradeMode { get; set; } + public Machine SelectedMachine { get; set; } + } + + private List<TangoVersion> _tangoVersions; + public List<TangoVersion> TangoVersions + { + get { return _tangoVersions; } + set { _tangoVersions = value; RaisePropertyChangedAuto(); } + } + + private TangoVersion _selectedVersion; + public TangoVersion SelectedVersion + { + get { return _selectedVersion; } + set { _selectedVersion = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + private String _tupFileLocation; + public String TupFileLocation + { + get { return _tupFileLocation; } + set { _tupFileLocation = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + private Machine _selectedMachine; + public Machine SelectedMachine + { + get { return _selectedMachine; } + set { _selectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + private RemoteUpgradeHandler _handler; + public RemoteUpgradeHandler Handler + { + get { return _handler; } + set { _handler = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand SelectTupFileLocationCommand { get; set; } + + public RelayCommand GeneratePackageCommand { get; set; } + + public ApplicationUpgradeViewVM() + { + SelectTupFileLocationCommand = new RelayCommand(SelectTupFileLocation, () => SelectedVersion != null && SelectedMachine != null); + GeneratePackageCommand = new RelayCommand(GeneratePackage, () => SelectedVersion != null && SelectedMachine != null && TupFileLocation != null); + Handler = new RemoteUpgradeHandler(null) { Message = "Ready" }; + } + + private async void SelectTupFileLocation() + { + String fileName = $"{SelectedMachine.SerialNumber}_Update_{DateTime.Now.Date.ToFileName()}_v{SelectedVersion.Version}.tup"; + var result = await StorageProvider.SaveFile("Select update package location", "Tango Update Package|*.tup", fileName, ".tup"); + if (result) + { + TupFileLocation = result.SelectedItem; + } + } + + private async void GeneratePackage() + { + try + { + IsFree = false; + Handler = await RemoteUpgradeManager.CreateTupFile(SelectedVersion, SelectedMachine.SerialNumber, TupFileLocation); + await Handler.WaitForCompletion(); + } + catch (OperationCanceledException) + { + //Aborted... + } + catch (Exception ex) + { + LogManager.Log("Error generating remote upgrade package."); + await NotificationProvider.ShowError($"Error occurred while trying to generate the update package.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + + public async override void OnNavigatedTo() + { + base.OnNavigatedTo(); + + if (TangoVersions == null) + { + try + { + TangoVersions = (await Services.TangoVersionsService.GetAllTangoVersions()).Take(10).ToList(); + SelectedVersion = TangoVersions.FirstOrDefault(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error retrieving tango versions."); + await NotificationProvider.ShowError($"Error retrieving Tango version.\n{ex.FlattenMessage()}"); + } + } + } + + public void OnNavigatedToWithObject(NavigationObject obj) + { + SelectedMachine = obj.SelectedMachine; + } } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/WelcomeViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/WelcomeViewVM.cs index a49c9972a..b6e719667 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/WelcomeViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/ViewModels/WelcomeViewVM.cs @@ -3,24 +3,92 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL.Entities; using Tango.Core.Commands; using Tango.FSE.Common; +using Tango.FSE.Common.AutoComplete; using Tango.FSE.Upgrade.Views; namespace Tango.FSE.Upgrade.ViewModels { public class WelcomeViewVM : FSEViewModel { - public RelayCommand NavigateToApplicationUpgradeCommand { get; set; } + private Machine _selectedMachine; + /// <summary> + /// Gets or sets the selected machine. + /// </summary> + public Machine SelectedMachine + { + get { return _selectedMachine; } + set { _selectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + private bool _isApplicationUpdate; + /// <summary> + /// Gets or sets a value indicating whether to update application and firmware, otherwise only firmware. + /// </summary> + public bool IsApplicationUpdate + { + get { return _isApplicationUpdate; } + set { _isApplicationUpdate = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + private bool _isUpdateConnectedMachine; + /// <summary> + /// Gets or sets a value indicating whether to update the currently connected machine (relevant only on application update). + /// </summary> + public bool IsUpdateConnectedMachine + { + get { return _isUpdateConnectedMachine; } + set { _isUpdateConnectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + /// <summary> + /// Gets or sets the start upgrade command. + /// </summary> + public RelayCommand StartUpgradeCommand { get; set; } + + /// <summary> + /// Initializes a new instance of the <see cref="WelcomeViewVM"/> class. + /// </summary> public WelcomeViewVM() { - NavigateToApplicationUpgradeCommand = new RelayCommand(NavigateToApplicationUpgrade); + IsApplicationUpdate = true; + IsUpdateConnectedMachine = false; + StartUpgradeCommand = new RelayCommand(StartUpgrade, () => !IsApplicationUpdate || IsUpdateConnectedMachine || SelectedMachine != null); + } + + /// <summary> + /// Called before the navigation system has navigated to this VM view. + /// </summary> + public override void OnBeforeNavigatedTo() + { + base.OnBeforeNavigatedTo(); + + if (IsUpdateConnectedMachine && !MachineProvider.IsConnected) + { + IsUpdateConnectedMachine = false; + } } - private void NavigateToApplicationUpgrade() + private void StartUpgrade() { - NavigationManager.NavigateTo<UpgradeModule>(nameof(ApplicationUpgradeView)); + if (IsApplicationUpdate) + { + NavigationManager.NavigateWithObject< + UpgradeModule, + ApplicationUpgradeView, + ApplicationUpgradeViewVM.NavigationObject> + (new ApplicationUpgradeViewVM.NavigationObject() + { + ApplicationUpgradeMode = IsUpdateConnectedMachine ? ApplicationUpgradeViewVM.ApplicationUpgradeMode.ConnectedMachine : ApplicationUpgradeViewVM.ApplicationUpgradeMode.OtherMachine, + SelectedMachine = IsUpdateConnectedMachine ? MachineProvider.Machine : SelectedMachine + }); + } + else + { + //Navigate to firmware view. + } } } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/ApplicationUpgradeView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/ApplicationUpgradeView.xaml index 4c8aa32a7..349fa45e4 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/ApplicationUpgradeView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/ApplicationUpgradeView.xaml @@ -4,12 +4,97 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:global="clr-namespace:Tango.FSE.Upgrade" + xmlns:controls="clr-namespace:Tango.FSE.Common.Controls;assembly=Tango.FSE.Common" xmlns:vm="clr-namespace:Tango.FSE.Upgrade.ViewModels" xmlns:material="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:local="clr-namespace:Tango.FSE.Upgrade.Views" mc:Ignorable="d" - d:DesignHeight="720" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:ApplicationUpgradeViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.ApplicationUpgradeViewVM}" Background="{StaticResource FSE_PrimaryBackgroundBrush}" Foreground="{StaticResource FSE_PrimaryForegroundBrush}"> - <Grid> - <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="60">Application Upgrade View</TextBlock> + d:DesignHeight="720" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:ApplicationUpgradeViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.ApplicationUpgradeViewVM}" Foreground="{StaticResource FSE_PrimaryForegroundBrush}"> + <Grid IsEnabled="{Binding IsFree}" Background="Transparent"> + <Grid.Style> + <Style TargetType="Grid"> + <Setter Property="Cursor" Value="Arrow"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding IsFree}" Value="False"> + <Setter Property="Cursor" Value="AppStarting"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Grid.Style> + <StackPanel> + <TextBlock FontSize="{StaticResource FSE_LargeFontSize}">Application Upgrade</TextBlock> + + <TextBlock Margin="0 10 0 0" Foreground="{StaticResource FSE_GrayBrush}" LineHeight="20" Visibility="{Binding ResolutionService.IsHighResolution,Converter={StaticResource BooleanToVisibilityConverter}}"> + <Run>You chose to perform a machine application and firmware upgrade.</Run> + <LineBreak/> + <Run>The upgrade is done by downloading the specified Tango system version below and composing a .tup file (Tango Update Package).</Run> + <LineBreak/> + <Run>This .tup file will contains all the relevant information required to update the selected machine.</Run> + <LineBreak/> + <Run>.tup files encapsulates update information relevant to a machine at the moment of generation.</Run> + <LineBreak/> + <Run FontWeight="SemiBold">Too much time between generation and update can result in irrelevant information.</Run> + </TextBlock> + + <TextBlock Margin="0 20 0 0" Foreground="{StaticResource FSE_GrayBrush}" LineHeight="20"> + <Run>Once the .tup file has been generated, you will be able to store that file on a removable storage which can be later inserted into a machine.</Run> + <LineBreak/> + <Run>In case you chose to upgrade the currently connected machine, you will be able to perform the upgrade remotely.</Run> + </TextBlock> + + <StackPanel Margin="0 20 0 0" Width="360" HorizontalAlignment="Left"> + <TextBlock>Select the desired Tango system software version</TextBlock> + + <ComboBox Margin="0 5 0 0" HorizontalContentAlignment="Stretch" FontSize="{StaticResource FSE_SmallFontSize}" material:ComboBoxAssist.ClassicMode="True" material:ComboBoxAssist.ShowSelectedItem="False" ItemsSource="{Binding TangoVersions}" SelectedItem="{Binding SelectedVersion}" Foreground="{StaticResource FSE_PrimaryAccentBrush}"> + <ComboBox.ItemTemplate> + <DataTemplate> + <DockPanel> + <TextBlock DockPanel.Dock="Right" VerticalAlignment="Center" Margin="10 1 0 0" Foreground="{StaticResource FSE_GrayBrush}" FontSize="{StaticResource FSE_SmallFontSize}"> + <Run>(</Run><Run Text="{Binding LastUpdated,Converter={StaticResource DateTimeUTCToShortDateConverter}}"></Run><Run>)</Run> + </TextBlock> + <StackPanel> + <TextBlock> + <Run Foreground="{StaticResource FSE_GrayBrush}">Application:</Run> + <Run>v</Run><Run Text="{Binding Version}"></Run> + </TextBlock> + <TextBlock Margin="0 5 0 0"> + <Run Foreground="{StaticResource FSE_GrayBrush}">Firmware:</Run> + <Run>v</Run><Run Text="{Binding FirmwareVersion}"></Run> + </TextBlock> + </StackPanel> + </DockPanel> + </DataTemplate> + </ComboBox.ItemTemplate> + </ComboBox> + </StackPanel> + + <StackPanel Margin="0 30 0 0" Width="400" HorizontalAlignment="Left"> + <TextBlock>Select where to save the upgrade package (.tup file)</TextBlock> + + <DockPanel Margin="0 0 0 0"> + <controls:IconButton ToolTip="Browse for .tup file location" Margin="5 0 0 0" DockPanel.Dock="Right" Icon="FolderOpenOutline" Width="38" Height="38" Command="{Binding SelectTupFileLocationCommand}" /> + <TextBox FontSize="{StaticResource FSE_SmallFontSize}" Foreground="{StaticResource FSE_PrimaryAccentBrush}" IsReadOnly="True" Text="{Binding TupFileLocation}" FlowDirection="RightToLeft" VerticalContentAlignment="Bottom"></TextBox> + </DockPanel> + </StackPanel> + + <StackPanel Margin="0 80 0 0" HorizontalAlignment="Left" Width="1000"> + + <DockPanel> + <Button Command="{Binding GeneratePackageCommand}" DockPanel.Dock="Right" HorizontalAlignment="Right" Width="250" Height="50" Style="{StaticResource FSE_RaisedButton_Dark_Hover}"> + <StackPanel Orientation="Horizontal"> + <material:PackIcon Width="32" Height="28" Kind="ClockFast" /> + <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" FontSize="{StaticResource FSE_LargeFontSize}">GENERATE PACKAGE</TextBlock> + </StackPanel> + </Button> + + <StackPanel VerticalAlignment="Bottom" Margin="0 0 40 0"> + <TextBlock Text="{Binding Handler.Message}"></TextBlock> + <ProgressBar Margin="0 5 0 0" Minimum="0" Maximum="{Binding Handler.Maximum}" Value="{Binding Handler.Progress}" IsIndeterminate="{Binding Handler.IsIndeterminate}"></ProgressBar> + </StackPanel> + </DockPanel> + + <Rectangle StrokeThickness="1" Stroke="{StaticResource FSE_GrayBrush}" StrokeDashArray="4" Margin="0 10 0 0"></Rectangle> + </StackPanel> + </StackPanel> </Grid> </UserControl> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/MainView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/MainView.xaml index dc724117e..f06753409 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/MainView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/MainView.xaml @@ -9,11 +9,51 @@ xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}" Background="{StaticResource FSE_PrimaryBackgroundBrush}" Foreground="{StaticResource FSE_PrimaryForegroundBrush}"> + <Grid> - <controls:NavigationControl TransitionAlwaysFades="False" TransitionDuration="00:00:0.2" TransitionType="Slide"> - <local:WelcomeView/> - <local:ApplicationUpgradeView/> - <local:FirmwareUpgradeView/> - </controls:NavigationControl> + <Image Source="../Images/machine-update2.png" HorizontalAlignment="Right" VerticalAlignment="Top" Stretch="Uniform" Width="800" Margin="80" Opacity="0.6" Visibility="{Binding ResolutionService.IsHighResolution,Converter={StaticResource BooleanToVisibilityConverter}}"></Image> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="0.5*" /> + <ColumnDefinition Width="10*" /> + <ColumnDefinition Width="1*" /> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="0.5*" /> + <RowDefinition Height="7*" /> + <RowDefinition Height="0*" /> + </Grid.RowDefinitions> + + <Grid Grid.Column="1" Grid.Row="1"> + <Grid.Style> + <Style TargetType="Grid"> + <Setter Property="Margin" Value="30 30 0 0"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding ResolutionService.IsLowResolution}" Value="True"> + <Setter Property="Margin" Value="0"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Grid.Style> + <DockPanel> + <DockPanel DockPanel.Dock="Top"> + <Image Source="../Images/remote_upgrade_large.png" Stretch="Uniform" Width="90" RenderOptions.BitmapScalingMode="Fant" /> + <StackPanel Margin="20 0 0 0"> + <TextBlock FontSize="{StaticResource FSE_ModuleHeaderFontSize}" Foreground="{StaticResource FSE_PrimaryAccentBrush}">Remote Upgrade Wizard</TextBlock> + <TextBlock Margin="0 10 0 0" Foreground="{StaticResource FSE_GrayBrush}"> + <Run>Welcome to the remote upgrade wizard.</Run> + <LineBreak/> + <Run>This wizard will help you perform various application and firmware version upgrade operations.</Run> + </TextBlock> + </StackPanel> + </DockPanel> + <controls:NavigationControl Margin="0 60 0 0" TransitionAlwaysFades="False" TransitionDuration="00:00:0.2" TransitionType="Slide"> + <local:WelcomeView/> + <local:ApplicationUpgradeView/> + <local:FirmwareUpgradeView/> + </controls:NavigationControl> + </DockPanel> + </Grid> + </Grid> </Grid> </UserControl> diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/WelcomeView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/WelcomeView.xaml index fec8c87e3..111d19b29 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/WelcomeView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Upgrade/Views/WelcomeView.xaml @@ -4,15 +4,62 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:global="clr-namespace:Tango.FSE.Upgrade" + xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete" xmlns:vm="clr-namespace:Tango.FSE.Upgrade.ViewModels" xmlns:material="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:local="clr-namespace:Tango.FSE.Upgrade.Views" mc:Ignorable="d" - d:DesignHeight="720" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:WelcomeViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.WelcomeViewVM}" Background="{StaticResource FSE_PrimaryBackgroundBrush}" Foreground="{StaticResource FSE_PrimaryForegroundBrush}"> - <Grid> - <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> - <TextBlock FontSize="60">Welcome View</TextBlock> - <Button Margin="0 20 0 0" Height="40" Command="{Binding NavigateToApplicationUpgradeCommand}">Navigate To Application</Button> + d:DesignHeight="720" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:WelcomeViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.WelcomeViewVM}" Foreground="{StaticResource FSE_PrimaryForegroundBrush}"> + + <StackPanel> + <StackPanel> + <TextBlock Foreground="{StaticResource FSE_GrayBrush}" FontSize="{StaticResource FSE_LargeFontSize}">Please select the desired upgrade operation and press 'continue'.</TextBlock> + + <StackPanel Margin="0 40 0 0"> + <RadioButton x:Name="chkApplication" VerticalContentAlignment="Center" Cursor="Hand" Padding="30 0 0 0" IsChecked="{Binding IsApplicationUpdate,Mode=TwoWay}"> + <DockPanel> + <Image Source="../Images/application.png" Width="64" Height="64" /> + <TextBlock Margin="20 0 0 0" VerticalAlignment="Center">I want to upgrade a machine's application and firmware version.</TextBlock> + </DockPanel> + </RadioButton> + + <StackPanel Margin="80 10 0 0" IsEnabled="{Binding ElementName=chkApplication,Path=IsChecked}"> + <TextBlock>Please specify the target machine for this upgrade.</TextBlock> + <RadioButton x:Name="chkCurrentMachine" IsEnabled="{Binding MachineProvider.IsConnected}" Margin="10 20 0 0" IsChecked="{Binding IsUpdateConnectedMachine,Mode=TwoWay}">Upgrade the currently connected machine.</RadioButton> + <RadioButton x:Name="chkDifferentMachine" Margin="10 10 0 0" IsChecked="{Binding ElementName=chkCurrentMachine,Path=IsChecked,Converter={StaticResource BooleanInverseConverter},Mode=TwoWay}">Upgrade a different machine.</RadioButton> + <DockPanel Margin="20 10 0 0" IsEnabled="{Binding ElementName=chkDifferentMachine,Path=IsChecked}"> + <autoComplete:AutoCompleteTextBox HorizontalAlignment="Left" Width="440" Margin="5 0 0 0" MaxPopupHeight="300" Provider="{Binding MachinesAutoCompleteProvider}" SelectedItem="{Binding SelectedMachine,Mode=TwoWay}" Style="{StaticResource FSE_AutoComplete_Machines}"></autoComplete:AutoCompleteTextBox> + </DockPanel> + </StackPanel> + + <RadioButton IsChecked="{Binding ElementName=chkApplication,Path=IsChecked,Converter={StaticResource BooleanInverseConverter},Mode=TwoWay}" Margin="0 40 0 0" VerticalContentAlignment="Center" Cursor="Hand" Padding="25 0 0 0"> + <DockPanel> + <Image Source="../Images/firmware.png" Width="64" Height="64" /> + <TextBlock Margin="20 0 0 0" VerticalAlignment="Center">I want to upgrade a machine's firmware version.</TextBlock> + </DockPanel> + </RadioButton> + </StackPanel> + + <StackPanel HorizontalAlignment="Left"> + <StackPanel.Style> + <Style TargetType="StackPanel"> + <Setter Property="Margin" Value="0 100 0 0"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding ResolutionService.IsLowResolution}" Value="True"> + <Setter Property="Margin" Value="0 -40 0 0"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </StackPanel.Style> + <Button Command="{Binding StartUpgradeCommand}" DockPanel.Dock="Right" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="200" Height="50" Style="{StaticResource FSE_RaisedButton_Dark_Hover}"> + <StackPanel Orientation="Horizontal"> + <TextBlock VerticalAlignment="Center" FontSize="{StaticResource FSE_LargeFontSize}">CONTINUE</TextBlock> + <material:PackIcon Margin="10 -5 0 0" Width="32" Height="28" Kind="ArrowRight" /> + </StackPanel> + </Button> + + <Rectangle StrokeThickness="1" Stroke="{StaticResource FSE_GrayBrush}" StrokeDashArray="4" Width="1000" Margin="0 10 0 0"></Rectangle> + </StackPanel> </StackPanel> - </Grid> + </StackPanel> </UserControl> diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/MachinesService.cs b/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/MachinesService.cs index ea12f0021..03d17e5ed 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/MachinesService.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/MachinesService.cs @@ -276,11 +276,16 @@ namespace Tango.FSE.BL.Services { var collection = cache.GetCollection<CachedMachine>(MACHINES_COLLECTION); - return collection + var cachedMachines = collection .Find(x => x.OrganizationGuid == CurrentUser.OrganizationGuid) - .ToList() - .Select(x => x.ToObservable()) .ToList(); + + foreach (var cachedMachine in cachedMachines) + { + _machinesCache[cachedMachine.SerialNumber] = cachedMachine; + } + + return cachedMachines.Select(x => x.ToObservable()).ToList(); } }) .BuildExecuteAsync(); diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs index d790a54a1..d53c0483c 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs @@ -34,6 +34,8 @@ using static Tango.SharedUI.Controls.NavigationControl; using Tango.FSE.BL.Connectivity; using Tango.FSE.Common.BugReporting; using Tango.FSE.Common.RemoteUpgrade; +using Tango.FSE.Common.AutoComplete; +using Tango.BL.Entities; namespace Tango.FSE.Common { @@ -159,6 +161,11 @@ namespace Tango.FSE.Common [TangoInject] public FSEServicesContainer Services { get; set; } + /// <summary> + /// Gets or sets the machines automatic complete provider. + /// </summary> + public AutoCompleteSource<Machine> MachinesAutoCompleteProvider { get; set; } + private FSESettings _settings; /// <summary> /// Gets the main PPC settings. @@ -188,6 +195,29 @@ namespace Tango.FSE.Common } /// <summary> + /// Initializes a new instance of the <see cref="FSEViewModel"/> class. + /// </summary> + public FSEViewModel() + { + MachinesAutoCompleteProvider = new AutoCompleteSource<Machine>(AutoCompleteMachines); + } + + private List<Machine> AutoCompleteMachines(string key) + { + key = key ?? String.Empty; + + try + { + return Services.MachinesService.GetAllMachines().Result.Where(x => x.SerialNumber.ToLower().StartsWith(key.ToLower())).Take(8).ToList(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error on auto complete machine filter."); + return new List<Machine>(); + } + } + + /// <summary> /// Called when the application has been started. /// </summary> public virtual void OnApplicationStarted() diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/RemoteUpgrade/IRemoteUpgradeManager.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/RemoteUpgrade/IRemoteUpgradeManager.cs index 9bbfb83f9..98378585f 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/RemoteUpgrade/IRemoteUpgradeManager.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/RemoteUpgrade/IRemoteUpgradeManager.cs @@ -11,17 +11,12 @@ namespace Tango.FSE.Common.RemoteUpgrade public interface IRemoteUpgradeManager { /// <summary> - /// Occurs when a TUP creation has made progress. - /// </summary> - event EventHandler<RemoteUpgradeProgressEventArgs> Progress; - - /// <summary> /// Creates a Tango Update Package for the current connected machine. /// </summary> /// <param name="tangoVersion">The tango version.</param> /// <param name="filePath">The file path.</param> /// <returns></returns> - Task CreateTupFile(TangoVersion tangoVersion, String filePath); + Task<RemoteUpgradeHandler> CreateTupFile(TangoVersion tangoVersion, String filePath); /// <summary> /// Creates a Tango Update Package for specified machine. @@ -30,6 +25,6 @@ namespace Tango.FSE.Common.RemoteUpgrade /// <param name="serialNumber">The machine serial number.</param> /// <param name="filePath">The file path.</param> /// <returns></returns> - Task CreateTupFile(TangoVersion tangoVersion, String serialNumber, String filePath); + Task<RemoteUpgradeHandler> CreateTupFile(TangoVersion tangoVersion, String serialNumber, String filePath); } } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/RemoteUpgrade/RemoteUpgradeHandler.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/RemoteUpgrade/RemoteUpgradeHandler.cs new file mode 100644 index 000000000..8ba757edc --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/RemoteUpgrade/RemoteUpgradeHandler.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; + +namespace Tango.FSE.Common.RemoteUpgrade +{ + public class RemoteUpgradeHandler : ExtendedObject + { + private Action _abortAction; + private TaskCompletionSource<RemoteUpgradeHandlerStatus> _completionSource; + + public event EventHandler<RemoteUpgradeHandlerStatus> StatusChanged; + + private double _progress; + public double Progress + { + get { return _progress; } + set { _progress = value; RaisePropertyChangedAuto(); } + } + + private double _maximum; + public double Maximum + { + get { return _maximum; } + set { _maximum = value; RaisePropertyChangedAuto(); } + } + + private bool _isIndeterminate; + public bool IsIndeterminate + { + get { return _isIndeterminate; } + set { _isIndeterminate = value; RaisePropertyChangedAuto(); } + } + + private String _message; + public String Message + { + get { return _message; } + set { _message = value; RaisePropertyChangedAuto(); } + } + + private RemoteUpgradeHandlerStatus _status; + public RemoteUpgradeHandlerStatus Status + { + get { return _status; } + set + { + if (_status != value) + { + _status = value; + RaisePropertyChangedAuto(); + StatusChanged?.Invoke(this, value); + } + } + } + + private Exception _failedException; + public Exception FailedException + { + get { return _failedException; } + set { _failedException = value; RaisePropertyChangedAuto(); } + } + + + public RemoteUpgradeHandler(Action abortAction) + { + Message = "Initializing..."; + Maximum = 100; + _abortAction = abortAction; + _completionSource = new TaskCompletionSource<RemoteUpgradeHandlerStatus>(); + } + + internal void UpdateProgress(String message, bool isIndeterminate = true, double progress = 0, double maximum = 100) + { + Progress = progress; + Maximum = maximum; + IsIndeterminate = isIndeterminate; + Message = message; + } + + public void Abort() + { + _abortAction?.Invoke(); + } + + public Task WaitForCompletion() + { + return _completionSource.Task; + } + + internal void RaiseFailed(Exception exception) + { + FailedException = exception; + Status = RemoteUpgradeHandlerStatus.Failed; + _completionSource.SetException(exception); + } + + internal void RaiseCompleted() + { + Status = RemoteUpgradeHandlerStatus.Completed; + _completionSource.SetResult(Status); + } + + internal void RaiseAborted() + { + Status = RemoteUpgradeHandlerStatus.Aborted; + _completionSource.SetException(new OperationCanceledException("Remote upgrade operation aborted.")); + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/RemoteUpgrade/RemoteUpgradeHandlerStatus.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/RemoteUpgrade/RemoteUpgradeHandlerStatus.cs new file mode 100644 index 000000000..b1f2b6a2c --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/RemoteUpgrade/RemoteUpgradeHandlerStatus.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FSE.Common.RemoteUpgrade +{ + public enum RemoteUpgradeHandlerStatus + { + Started, + Completed, + Aborted, + Failed + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/RemoteUpgrade/RemoteUpgradeProgressEventArgs.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/RemoteUpgrade/RemoteUpgradeProgressEventArgs.cs deleted file mode 100644 index 31f79d682..000000000 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/RemoteUpgrade/RemoteUpgradeProgressEventArgs.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.FSE.Common.RemoteUpgrade -{ - public class RemoteUpgradeProgressEventArgs - { - public double Progress { get; set; } - public double Total { get; set; } - public bool IsIntermediate { get; set; } - public String Message { get; set; } - } -} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml index bb3d6ebe8..6aaffbd8a 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml @@ -585,4 +585,35 @@ <Setter Property="CellStyle" Value="{StaticResource LogsGridCellStyle}" /> </Style> + <Style x:Key="FSE_AutoComplete_Machines" TargetType="{x:Type editors:AutoCompleteTextBox}" BasedOn="{StaticResource {x:Type editors:AutoCompleteTextBox}}"> + <Setter Property="material:HintAssist.Hint" Value="Serial Number"></Setter> + <Setter Property="DisplayMember" Value="SerialNumber"></Setter> + <Setter Property="SelectedItemTemplate"> + <Setter.Value> + <DataTemplate> + <DockPanel VerticalAlignment="Center"> + <Image RenderOptions.BitmapScalingMode="Fant" Source="{StaticResource FSE_Machine_Small}" Width="24" /> + <StackPanel VerticalAlignment="Center" Margin="10 0 0 0" Orientation="Horizontal"> + <TextBlock Text="{Binding SerialNumber}" FontSize="{StaticResource FSE_SmallFontSize}"></TextBlock> + <TextBlock Margin="10 0 0 0" FontSize="{StaticResource FSE_SmallFontSize}" Foreground="{StaticResource FSE_GrayBrush}" Text="{Binding Name}"></TextBlock> + </StackPanel> + </DockPanel> + </DataTemplate> + </Setter.Value> + </Setter> + <Setter Property="ItemTemplate"> + <Setter.Value> + <DataTemplate> + <DockPanel VerticalAlignment="Center"> + <Image RenderOptions.BitmapScalingMode="Fant" Source="{StaticResource FSE_Machine_Small}" Width="32" /> + <StackPanel Margin="5 0 0 0"> + <TextBlock Text="{Binding SerialNumber}"></TextBlock> + <TextBlock Margin="0 5 0 0" FontSize="{StaticResource FSE_SmallerFontSize}" Foreground="{StaticResource FSE_GrayBrush}" Text="{Binding Name}"></TextBlock> + </StackPanel> + </DockPanel> + </DataTemplate> + </Setter.Value> + </Setter> + </Style> + </ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj index a1a4c84e4..cbe18efc5 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj @@ -162,6 +162,8 @@ <Compile Include="RemoteDesktop\DesktopFrameReceivedEventArgs.cs" /> <Compile Include="RemoteDesktop\IRemoteDesktopProvider.cs" /> <Compile Include="RemoteUpgrade\IRemoteUpgradeManager.cs" /> + <Compile Include="RemoteUpgrade\RemoteUpgradeHandler.cs" /> + <Compile Include="RemoteUpgrade\RemoteUpgradeHandlerStatus.cs" /> <Compile Include="Resolution\IResolutionService.cs" /> <Compile Include="Resolution\ResolutionHelper.cs" /> <Compile Include="Resolution\ResolutionMode.cs" /> @@ -172,7 +174,6 @@ <Compile Include="Storage\StorageMode.cs" /> <Compile Include="SystemInfo\ISystemInfoProvider.cs" /> <Compile Include="Threading\IDispatcherProvider.cs" /> - <Compile Include="RemoteUpgrade\RemoteUpgradeProgressEventArgs.cs" /> <Page Include="App.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/RemoteUpgrade/DefaultRemoteUpgradeManager.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/RemoteUpgrade/DefaultRemoteUpgradeManager.cs index bb808e685..13ea597e1 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/RemoteUpgrade/DefaultRemoteUpgradeManager.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/RemoteUpgrade/DefaultRemoteUpgradeManager.cs @@ -13,6 +13,7 @@ using Tango.Core.Components; using Tango.Core.DB; using Tango.Core.DI; using Tango.Core.ExtensionMethods; +using Tango.Core.Threading; using Tango.FSE.BL.Web; using Tango.FSE.Common; using Tango.FSE.Common.Authentication; @@ -35,17 +36,11 @@ namespace Tango.FSE.UI.RemoteUpgrade /// <seealso cref="Tango.FSE.Common.MachineUpdates.IMachineUpdatesProvider" /> public class DefaultRemoteUpgradeManager : FSEExtendedObject, IRemoteUpgradeManager { - private bool _isGeneratingTup; private IMachineProvider MachineProvider { get; set; } private FSEWebClient WebClient { get; set; } private IAuthenticationProvider AuthenticationProvider { get; set; } /// <summary> - /// Occurs when a TUP creation has made progress. - /// </summary> - public event EventHandler<RemoteUpgradeProgressEventArgs> Progress; - - /// <summary> /// Initializes a new instance of the <see cref="DefaultRemoteUpgradeManager"/> class. /// </summary> /// <param name="authenticationProvider">The authentication provider.</param> @@ -64,7 +59,7 @@ namespace Tango.FSE.UI.RemoteUpgrade /// <param name="tangoVersion">The tango version.</param> /// <param name="filePath">The file path.</param> /// <returns></returns> - public Task CreateTupFile(TangoVersion tangoVersion, string filePath) + public Task<RemoteUpgradeHandler> CreateTupFile(TangoVersion tangoVersion, string filePath) { if (MachineProvider.Machine == null) { @@ -81,17 +76,14 @@ namespace Tango.FSE.UI.RemoteUpgrade /// <param name="serialNumber">The machine serial number.</param> /// <param name="targetFilePath">The file path.</param> /// <returns></returns> - public Task CreateTupFile(TangoVersion tangoVersion, string serialNumber, string targetFilePath) + public Task<RemoteUpgradeHandler> CreateTupFile(TangoVersion tangoVersion, string serialNumber, string targetFilePath) { - if (_isGeneratingTup) - { - throw new InvalidOperationException("Only one TUP file can be created at a time."); - } - - _isGeneratingTup = true; + RemoteUpgradeHandler handler = new RemoteUpgradeHandler(() => { }); //Abort Action ? - return Task.Factory.StartNew(() => + ThreadFactory.StartNew(() => { + Thread.Sleep(100); + String tempDbName = "Tango_TUP"; var tempPackageFolder = TemporaryManager.CreateFolder(); String tempBackupFolder = "C:\\FSE_TUP"; @@ -111,7 +103,7 @@ namespace Tango.FSE.UI.RemoteUpgrade { LogManager.Log("Initializing..."); - OnProgress("Initializing..."); + handler.UpdateProgress("Initializing..."); Tango.Core.DataSource localDataSource = new Tango.Core.DataSource() { @@ -164,7 +156,7 @@ namespace Tango.FSE.UI.RemoteUpgrade - OnProgress($"Downloading Tango version '{tangoVersion.Version}'..."); + handler.UpdateProgress($"Downloading Tango version '{tangoVersion.Version}'..."); LogManager.Log("Connecting to machine service..."); @@ -179,7 +171,7 @@ namespace Tango.FSE.UI.RemoteUpgrade { downloader.Progress += (x, e) => { - OnProgress($"Downloading Tango version '{response.Version}'...", false, e.Current, e.Total); + handler.UpdateProgress($"Downloading Tango version '{response.Version}'...", false, e.Current, e.Total); }; downloader.ResolveMode().GetAwaiter().GetResult(); @@ -191,7 +183,7 @@ namespace Tango.FSE.UI.RemoteUpgrade LogManager.Log("Extracting version package..."); - OnProgress("Extracting package..."); + handler.UpdateProgress("Extracting package..."); using (ZipFile zip = new ZipFile(tempZipFile)) { @@ -201,14 +193,14 @@ namespace Tango.FSE.UI.RemoteUpgrade { if (args.EventType == ZipProgressEventType.Extracting_AfterExtractEntry) { - OnProgress("Extracting package...", false, currentEntry++, zip.Entries.Count); + handler.UpdateProgress("Extracting package...", false, currentEntry++, zip.Entries.Count); } }; zip.ExtractAll(tempPackageFolder); } - OnProgress("Extracting version information..."); + handler.UpdateProgress("Extracting version information..."); LogManager.Log("Extracting publish information..."); PublishInfo publishInfo = PublishInfo.FromJson(File.ReadAllText(Path.Combine(tempPackageFolder, "version.json"))); LogManager.Log($"Publish Information:\n{publishInfo}"); @@ -218,7 +210,7 @@ namespace Tango.FSE.UI.RemoteUpgrade publishInfo.MachineSerialNumber = serialNumber; publishInfo.MachineDeploymentSlot = (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), AuthenticationProvider.CurrentEnvironment.Name); - OnProgress("Creating temporary database..."); + handler.UpdateProgress("Creating temporary database..."); LogManager.Log($"Creating temporary db backup directory '{tempBackupFolder}'"); @@ -229,7 +221,7 @@ namespace Tango.FSE.UI.RemoteUpgrade //Create temp db dbManager.Create(tempDbName, Path.Combine(tempBackupFolder, tempDbName + ".mdf")); - OnProgress("Generating database snapshot..."); + handler.UpdateProgress("Generating database snapshot..."); LogManager.Log("Starting database synchronization..."); @@ -247,7 +239,7 @@ namespace Tango.FSE.UI.RemoteUpgrade runner.ScriptExecuting += (x, item) => { LogManager.Log($"Executing script '{item.FileName}'..."); - OnProgress($"{item.Name}..."); + handler.UpdateProgress($"{item.Name}..."); }; runner.Log += (x, log) => @@ -257,7 +249,7 @@ namespace Tango.FSE.UI.RemoteUpgrade runner.Run().GetAwaiter().GetResult(); - OnProgress("Generating database snapshot..."); + handler.UpdateProgress("Generating database snapshot..."); if (File.Exists(tempBackupFile)) { @@ -269,7 +261,7 @@ namespace Tango.FSE.UI.RemoteUpgrade dbManager.Backup(tempDbName, tempBackupFile); - OnProgress("Injecting database snapshot to PPC package..."); + handler.UpdateProgress("Injecting database snapshot to PPC package..."); using (ZipFile zip = new ZipFile(tempZipFile)) { @@ -286,19 +278,19 @@ namespace Tango.FSE.UI.RemoteUpgrade File.Copy(tempZipFile, targetFilePath, true); - OnProgress("Completed", false, 100, 100); - + handler.UpdateProgress("Completed", false, 100, 100); LogManager.Log("TUP file generation completed successfully."); + + handler.RaiseCompleted(); } catch (Exception ex) { LogManager.Log(ex, "TUP file generation failed."); - OnProgress("Failed", false, 0, 100); - throw ex; + handler.UpdateProgress("Failed", false, 0, 100); + handler.RaiseFailed(ex); } finally { - _isGeneratingTup = false; LogManager.Log($"Removing '{tempZipFile}'."); tempZipFile.Delete(); LogManager.Log($"Removing '{tempPackageFolder}'."); @@ -328,24 +320,8 @@ namespace Tango.FSE.UI.RemoteUpgrade } } }); - } - /// <summary> - /// Called when the TUP creation has made some progress. - /// </summary> - /// <param name="message">The message.</param> - /// <param name="isIntermediate">if set to <c>true</c> [is intermediate].</param> - /// <param name="progress">The progress.</param> - /// <param name="total">The total.</param> - protected virtual void OnProgress(String message, bool isIntermediate = true, double progress = 0, double total = 100) - { - Progress?.Invoke(this, new RemoteUpgradeProgressEventArgs() - { - Message = message, - IsIntermediate = isIntermediate, - Progress = progress, - Total = total, - }); + return Task.FromResult(handler); } } } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Resolution/DefaultResolutionService.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Resolution/DefaultResolutionService.cs index 33f15b066..21e1ec9af 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Resolution/DefaultResolutionService.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Resolution/DefaultResolutionService.cs @@ -137,7 +137,7 @@ namespace Tango.FSE.UI.Resolution ResolutionWidth = size.Width; ResolutionHeight = size.Height; - IsHighResolution = ResolutionWidth > 1280 && ResolutionHeight > 800; + IsHighResolution = ResolutionWidth > 1599 && ResolutionHeight > 800; IsLowResolution = !isHighResolution; ResolutionMode previousMode = Resolution; diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/LayoutView.xaml b/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/LayoutView.xaml index c75579215..a7e87d8ad 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/LayoutView.xaml @@ -59,7 +59,7 @@ <GradientStop Offset="1" Color="#A32323" /> </RadialGradientBrush> </StackPanel.Resources> - <Grid Width="14" Height="14" ToolTip="Communication In"> + <Grid Width="14" Height="14" ToolTip="Communication In" ToolTipService.Placement="Top"> <Ellipse Stroke="#353535" Fill="{StaticResource FSE_LED_GrayBrush}" /> <Ellipse Stroke="#353535"> <Ellipse.Style> @@ -76,7 +76,7 @@ </Ellipse> </Grid> - <Grid Margin="5 0 0 0" Width="14" Height="14" ToolTip="Communication Out"> + <Grid Margin="5 0 0 0" Width="14" Height="14" ToolTip="Communication Out" ToolTipService.Placement="Top"> <Ellipse Stroke="#353535" Fill="{StaticResource FSE_LED_GrayBrush}" /> <Ellipse Stroke="#353535"> <Ellipse.Style> @@ -95,7 +95,7 @@ <Rectangle Margin="10 6" Stroke="{StaticResource FSE_BorderBrush}" /> - <material:PackIcon Kind="Wan" VerticalAlignment="Center"> + <material:PackIcon Kind="Wan" VerticalAlignment="Center" ToolTipService.Placement="Top"> <material:PackIcon.Style> <Style TargetType="material:PackIcon"> <Setter Property="Foreground" Value="{StaticResource FSE_WarningBrush}"></Setter> diff --git a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs index cb27351f8..ef9ed4959 100644 --- a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs +++ b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs @@ -275,6 +275,11 @@ namespace Tango.Core.DI /// <param name="instance">The instance.</param> protected virtual void RegisterInternal(Type interfaceType, Type implementationType, Object instance) { + if (DesignMode) + { + return; + } + if (!interfaceType.IsAssignableFrom(implementationType)) { throw new InvalidOperationException(String.Format("Interface type '{0}' cannot be assigned from implementation type '{1}'.", interfaceType.Name, implementationType.Name)); diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs index c2d544042..879401c1b 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Controls/NavigationControl.cs @@ -457,165 +457,172 @@ namespace Tango.SharedUI.Controls private void NavigationThread() { - while (true) + try { - var item = _navigationQueue.BlockDequeue(); + while (true) + { + var item = _navigationQueue.BlockDequeue(); - var navigationCompleted = false; + var navigationCompleted = false; - NavigationElement fromElement = item.FromElement; - NavigationElement toElement = item.ToElement; + NavigationElement fromElement = item.FromElement; + NavigationElement toElement = item.ToElement; - Dispatcher.BeginInvoke(new Action(() => - { - if (toElement == null || toElement == fromElement) + Dispatcher.BeginInvoke(new Action(() => { + if (toElement == null || toElement == fromElement) + { //navigationCompleted = true; Debug.WriteLine("NavigationControl: THIS MIGHT CAUSE PROBLEMS !!"); - } + } - if (fromElement != null) - { - DoubleAnimation toAnimation = new DoubleAnimation(); - toAnimation.Duration = TransitionDuration; + if (fromElement != null) + { + DoubleAnimation toAnimation = new DoubleAnimation(); + toAnimation.Duration = TransitionDuration; - DoubleAnimation fromAnimation = new DoubleAnimation(); - fromAnimation.Duration = TransitionDuration; + DoubleAnimation fromAnimation = new DoubleAnimation(); + fromAnimation.Duration = TransitionDuration; - int fromIndex = Elements.IndexOf(fromElement.Element); - int toIndex = Elements.IndexOf(toElement.Element); + int fromIndex = Elements.IndexOf(fromElement.Element); + int toIndex = Elements.IndexOf(toElement.Element); - fromElement.Reset(); - toElement.Reset(); + fromElement.Reset(); + toElement.Reset(); - fromAnimation.Completed += (_, __) => - { - fromElement.Deactivate(!KeepElementsAttached); - }; + fromAnimation.Completed += (_, __) => + { + fromElement.Deactivate(!KeepElementsAttached); + }; - bool completed = false; + bool completed = false; - toAnimation.Completed += (_, __) => - { - if (!completed) + toAnimation.Completed += (_, __) => { - completed = true; + if (!completed) + { + completed = true; - INavigationView fromNavigationView = fromElement.Element as INavigationView; - INavigationView toNavigationView = toElement.Element as INavigationView; + INavigationView fromNavigationView = fromElement.Element as INavigationView; + INavigationView toNavigationView = toElement.Element as INavigationView; - if (fromNavigationView != null) - { - fromNavigationView.OnNavigatedFrom(); - } - if (toNavigationView != null) - { - toNavigationView.OnNavigatedTo(); + if (fromNavigationView != null) + { + fromNavigationView.OnNavigatedFrom(); + } + if (toNavigationView != null) + { + toNavigationView.OnNavigatedTo(); + } + + INavigationViewModel fromVM = fromElement.Element.DataContext as INavigationViewModel; + INavigationViewModel toVM = toElement.Element.DataContext as INavigationViewModel; + + if (fromVM != null && fromVM != toVM) fromVM.OnNavigatedFrom(); + if (toVM != null) toVM.OnNavigatedTo(); + + navigationCompleted = true; } + }; - INavigationViewModel fromVM = fromElement.Element.DataContext as INavigationViewModel; - INavigationViewModel toVM = toElement.Element.DataContext as INavigationViewModel; + switch (TransitionType) + { + case TransitionTypes.Fade: + fromAnimation.From = 1; + fromAnimation.To = 0; - if (fromVM != null && fromVM != toVM) fromVM.OnNavigatedFrom(); - if (toVM != null) toVM.OnNavigatedTo(); + toAnimation.From = 0; + toAnimation.To = 1; - navigationCompleted = true; - } - }; + fromElement.AnimateOpacity(fromAnimation); + toElement.AnimateOpacity(toAnimation); - switch (TransitionType) - { - case TransitionTypes.Fade: - fromAnimation.From = 1; - fromAnimation.To = 0; + break; + case TransitionTypes.Zoom: + fromAnimation.From = 1; + fromAnimation.To = 0; - toAnimation.From = 0; - toAnimation.To = 1; + toAnimation.From = 0; + toAnimation.To = 1; - fromElement.AnimateOpacity(fromAnimation); - toElement.AnimateOpacity(toAnimation); + fromElement.AnimateScale(fromAnimation); + toElement.AnimateScale(toAnimation); - break; - case TransitionTypes.Zoom: - fromAnimation.From = 1; - fromAnimation.To = 0; + break; + case TransitionTypes.Slide: - toAnimation.From = 0; - toAnimation.To = 1; + if (toIndex > fromIndex) + { + fromAnimation.From = 0; + fromAnimation.To = -ActualWidth; - fromElement.AnimateScale(fromAnimation); - toElement.AnimateScale(toAnimation); + toAnimation.From = ActualWidth; + toAnimation.To = 0; + } + else + { + fromAnimation.From = 0; + fromAnimation.To = ActualWidth; - break; - case TransitionTypes.Slide: + toAnimation.From = -ActualWidth; + toAnimation.To = 0; + } - if (toIndex > fromIndex) - { - fromAnimation.From = 0; - fromAnimation.To = -ActualWidth; + fromElement.AnimateTranslateX(fromAnimation); + toElement.AnimateTranslateX(toAnimation); - toAnimation.From = ActualWidth; - toAnimation.To = 0; - } - else - { - fromAnimation.From = 0; - fromAnimation.To = ActualWidth; + break; + } - toAnimation.From = -ActualWidth; - toAnimation.To = 0; - } + if (TransitionAlwaysFades && TransitionType != TransitionTypes.Fade) + { + DoubleAnimation fromFadeAnimation = new DoubleAnimation(); + fromFadeAnimation.From = 1; + fromFadeAnimation.To = 0; + fromFadeAnimation.Duration = TransitionDuration; - fromElement.AnimateTranslateX(fromAnimation); - toElement.AnimateTranslateX(toAnimation); + DoubleAnimation toFadeAnimation = new DoubleAnimation(); + toFadeAnimation.From = 0; + toFadeAnimation.To = 1; + toFadeAnimation.Duration = TransitionDuration; - break; - } + fromElement.AnimateOpacity(fromFadeAnimation); + toElement.AnimateOpacity(toFadeAnimation); + } - if (TransitionAlwaysFades && TransitionType != TransitionTypes.Fade) + fromElement.Activate(); + toElement.Activate(); + } + else { - DoubleAnimation fromFadeAnimation = new DoubleAnimation(); - fromFadeAnimation.From = 1; - fromFadeAnimation.To = 0; - fromFadeAnimation.Duration = TransitionDuration; + toElement.Activate(); + toElement.Reset(); - DoubleAnimation toFadeAnimation = new DoubleAnimation(); - toFadeAnimation.From = 0; - toFadeAnimation.To = 1; - toFadeAnimation.Duration = TransitionDuration; + INavigationViewModel toVM = toElement.Element.DataContext as INavigationViewModel; + if (toVM != null) toVM.OnNavigatedTo(); - fromElement.AnimateOpacity(fromFadeAnimation); - toElement.AnimateOpacity(toFadeAnimation); + navigationCompleted = true; } + })); - fromElement.Activate(); - toElement.Activate(); - } - else + for (int i = 0; i < 30; i++) { - toElement.Activate(); - toElement.Reset(); - - INavigationViewModel toVM = toElement.Element.DataContext as INavigationViewModel; - if (toVM != null) toVM.OnNavigatedTo(); - - navigationCompleted = true; + if (navigationCompleted) + { + break; + } + Thread.Sleep(100); } - })); - for (int i = 0; i < 30; i++) - { - if (navigationCompleted) + Dispatcher.BeginInvoke(new Action(() => { - break; - } - Thread.Sleep(100); + NavigationCompleted?.Invoke(); + })); } - - Dispatcher.BeginInvoke(new Action(() => - { - NavigationCompleted?.Invoke(); - })); + } + catch + { + } } |
