diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-11-26 13:12:10 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-11-26 13:12:10 +0200 |
| commit | c338e69e9b60ddb71102a6b11058912dd06d5018 (patch) | |
| tree | 16d1445dd6028a4419eb1769affd757a5c1a05fc /Software/Visual_Studio/PPC | |
| parent | 03180d26af65c24822cf5ffd44a347db7394d3b2 (diff) | |
| download | Tango-c338e69e9b60ddb71102a6b11058912dd06d5018.tar.gz Tango-c338e69e9b60ddb71102a6b11058912dd06d5018.zip | |
Import job & update completed with dialogs!
Diffstat (limited to 'Software/Visual_Studio/PPC')
33 files changed, 481 insertions, 25 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/ImportJobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/ImportJobView.xaml new file mode 100644 index 000000000..df524aafb --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/ImportJobView.xaml @@ -0,0 +1,25 @@ +<UserControl x:Class="Tango.PPC.Jobs.Dialogs.ImportJobView" + 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.Jobs.Dialogs" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + mc:Ignorable="d" + Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DesignHeight="555" d:DesignWidth="560" Width="550" Height="450" d:DataContext="{d:DesignInstance Type=local:ImportJobViewVM, IsDesignTimeCreatable=False}"> + <Grid Margin="20"> + <DockPanel> + <StackPanel DockPanel.Dock="Bottom" HorizontalAlignment="Right" Orientation="Horizontal"> + <touch:TouchButton Command="{Binding CloseCommand}" CornerRadius="25" Style="{StaticResource TangoMessageBoxButton}" HorizontalContentAlignment="Center" DockPanel.Dock="Right" Width="120" Height="50" VerticalAlignment="Bottom">CANCEL</touch:TouchButton> + <touch:TouchButton Command="{Binding OKCommand}" CornerRadius="25" Style="{StaticResource TangoMessageBoxButton}" Foreground="{StaticResource TangoPrimaryAccentBrush}" HorizontalContentAlignment="Center" DockPanel.Dock="Right" Width="120" Height="50" VerticalAlignment="Bottom">IMPORT</touch:TouchButton> + </StackPanel> + <StackPanel> + <Image Source="../Images/job.png" Stretch="Uniform" Height="120"></Image> + <TextBlock HorizontalAlignment="Center" Margin="0 20 0 0" FontSize="{StaticResource TangoHeaderFontSize}">IMPORT JOB</TextBlock> + <TextBlock Margin="20 10" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center">A job file has been selected from the storage device. press 'IMPORT' to add the job to your job list.</TextBlock> + + <touch:TouchCheckBox IsChecked="{Binding ImportAndEdit}" Margin="40 50 0 0">Edit this job after import</touch:TouchCheckBox> + </StackPanel> + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/ImportJobView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/ImportJobView.xaml.cs new file mode 100644 index 000000000..2d17483f5 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/ImportJobView.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.Jobs.Dialogs +{ + /// <summary> + /// Interaction logic for ImportJobView.xaml + /// </summary> + public partial class ImportJobView : UserControl + { + public ImportJobView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/ImportJobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/ImportJobViewVM.cs new file mode 100644 index 000000000..0440d6a54 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/ImportJobViewVM.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Dialogs +{ + public class ImportJobViewVM : DialogViewVM + { + private bool _importAndEdit; + public bool ImportAndEdit + { + get { return _importAndEdit; } + set { _importAndEdit = value; RaisePropertyChangedAuto(); } + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Images/job.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Images/job.png Binary files differnew file mode 100644 index 000000000..a41bcf8f0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Images/job.png diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj index aa473ec02..c82512ef6 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj @@ -96,6 +96,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Dialogs\ImportJobView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Dialogs\JobTypePickerView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -162,6 +166,10 @@ <DependentUpon>FineTuningPaletteView.xaml</DependentUpon> </Compile> <Compile Include="Dialogs\FineTuningPaletteViewVM.cs" /> + <Compile Include="Dialogs\ImportJobView.xaml.cs"> + <DependentUpon>ImportJobView.xaml</DependentUpon> + </Compile> + <Compile Include="Dialogs\ImportJobViewVM.cs" /> <Compile Include="Dialogs\JobTypePickerView.xaml.cs"> <DependentUpon>JobTypePickerView.xaml</DependentUpon> </Compile> @@ -356,10 +364,13 @@ <ItemGroup> <Resource Include="Images\Knitting.png" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\job.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <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/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index 2f22e2f2d..8c1466c26 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -218,17 +218,25 @@ namespace Tango.PPC.Jobs.ViewModels /// Selects the job. /// </summary> /// <param name="job">The job.</param> - public async void SelectJob(Job job) + public async void SelectJob(Job job, bool directlyToEdit = false) { LogManager.Log($"Job '{job.Name}' selected."); - await NavigationManager.NavigateTo<JobsModule>(nameof(JobSummeryView)); + + if (!directlyToEdit) + { + await NavigationManager.NavigateTo<JobsModule>(nameof(JobSummeryView)); + } + else + { + await NavigationManager.NavigateTo<JobsModule>(nameof(JobView)); + } RaiseMessage(new JobSelectedMessage() { Job = job, Context = _db }); } /// <summary> /// Loads the jobs from database. /// </summary> - public void LoadJobs() + public void LoadJobs(Action onCompleted = null) { try { @@ -252,6 +260,7 @@ namespace Tango.PPC.Jobs.ViewModels FilterJobCategory(FilterCategory); IsLoadingJobs = false; LogManager.Log("Machine jobs loaded!"); + onCompleted?.Invoke(); }); }); } @@ -481,20 +490,29 @@ namespace Tango.PPC.Jobs.ViewModels new Storage.Models.StorageNavigationRequest() { Intent = Storage.Models.StorageNavigationIntent.SaveFile, - DefaultFileName = selected_job.Name + ExplorerFileDefinition.Job.Extension, - Filter = ExplorerFileDefinition.Job.Extension + DefaultFileName = selected_job.Name, + Filter = ExplorerFileDefinition.Job.Extension, + Title = "Save Job File", }); if (result != null) { - var jobFile = await selected_job.ToJobFile(); + try + { + var jobFile = await selected_job.ToJobFile(); + + using (FileStream fs = new FileStream(result.Path + ExplorerFileDefinition.Job.Extension, FileMode.Create)) + { + jobFile.WriteTo(fs); + } - using (FileStream fs = new FileStream(result.Path, FileMode.Create)) + await NotificationProvider.ShowSuccess("Job saved successfully."); + } + catch (Exception ex) { - jobFile.WriteTo(fs); + LogManager.Log(ex, $"Error saving job {selected_job.Name} to file."); + await NotificationProvider.ShowError($"An error occurred while trying to save the job.\n{ex.Message}"); } - - await NotificationProvider.ShowInfo("Job saved."); } } @@ -504,13 +522,36 @@ namespace Tango.PPC.Jobs.ViewModels private async void HandleJobFileLoaded(ExplorerFileItem jobFile) { - using (ObservablesContext jobContext = ObservablesContext.CreateDefault()) + var vm = await NotificationProvider.ShowDialog<ImportJobViewVM>(); + + if (vm.DialogResult) { - JobFile jFile = JobFile.Parser.ParseFrom(File.ReadAllBytes(jobFile.Path)); - var job = await Job.FromJobFile(jFile, MachineProvider.Machine.Guid, AuthenticationProvider.CurrentUser.Guid); - jobContext.Jobs.Add(job); - await jobContext.SaveChangesAsync(); - LoadJobs(); + using (ObservablesContext jobContext = ObservablesContext.CreateDefault()) + { + try + { + JobFile jFile = JobFile.Parser.ParseFrom(File.ReadAllBytes(jobFile.Path)); + var job = await Job.FromJobFile(jFile, MachineProvider.Machine.Guid, AuthenticationProvider.CurrentUser.Guid); + jobContext.Jobs.Add(job); + await jobContext.SaveChangesAsync(); + LoadJobs(() => + { + if (vm.ImportAndEdit) + { + var postJob = Jobs.SingleOrDefault(x => x.Guid == job.Guid); + if (postJob != null) + { + SelectJob(postJob, true); + } + } + }); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error occurred while trying to import job from file {jobFile.Path}."); + await NotificationProvider.ShowError($"An error occurred while trying to import the selected job file.\n{ex.Message}"); + } + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/app.config b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/app.config index 0e58ccf54..1793e5c84 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/app.config +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/app.config @@ -54,6 +54,10 @@ <assemblyIdentity name="System.Xml.ReaderWriter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /> </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" /> + </dependentAssembly> </assemblyBinding> </runtime> <entityFramework> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/app.config b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/app.config index 0e58ccf54..1793e5c84 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/app.config +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/app.config @@ -54,6 +54,10 @@ <assemblyIdentity name="System.Xml.ReaderWriter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /> </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" /> + </dependentAssembly> </assemblyBinding> </runtime> <entityFramework> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Models/StorageNavigationRequest.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Models/StorageNavigationRequest.cs index 32a546f4f..ef991a7f2 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Models/StorageNavigationRequest.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Models/StorageNavigationRequest.cs @@ -22,5 +22,10 @@ namespace Tango.PPC.Storage.Models /// Gets or sets the default file name when saving a file. /// </summary> public String DefaultFileName { get; set; } + + /// <summary> + /// Gets or sets the title. + /// </summary> + public String Title { get; set; } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Tango.PPC.Storage.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Tango.PPC.Storage.csproj index 83f23e6b9..0a2f65711 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Tango.PPC.Storage.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Tango.PPC.Storage.csproj @@ -80,6 +80,7 @@ <Generator>ResXFileCodeGenerator</Generator> <LastGenOutput>Resources.Designer.cs</LastGenOutput> </EmbeddedResource> + <None Include="app.config" /> <None Include="Properties\Settings.settings"> <Generator>SettingsSingleFileGenerator</Generator> <LastGenOutput>Settings.Designer.cs</LastGenOutput> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewContracts/IMainView.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewContracts/IMainView.cs index 8c08f5a28..1dea82c4f 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewContracts/IMainView.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewContracts/IMainView.cs @@ -11,5 +11,6 @@ namespace Tango.PPC.Storage.ViewContracts public interface IMainView : IPPCView { void NavigateBack(); + void EditFileName(); } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewModels/MainViewVM.cs index 05316d1f6..3882fb486 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/ViewModels/MainViewVM.cs @@ -72,6 +72,11 @@ namespace Tango.PPC.Storage.ViewModels { CurrentPath = null; CurrentPath = StorageProvider.Drive.RootDirectory.FullName; + + if (Request.Intent == StorageNavigationIntent.SaveFile) + { + View.EditFileName(); + } } else { diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Views/MainView.xaml index d7817fe6f..840149c98 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Views/MainView.xaml @@ -17,10 +17,13 @@ <Grid DockPanel.Dock="Top" Visibility="{Binding Request.Intent,Converter={StaticResource EnumToVisibilityConverter},ConverterParameter=SaveFile,TargetNullValue=Visibility.Collapsed,FallbackValue=Visibility.Collapsed}"> <Border BorderThickness="0 0 0 1" BorderBrush="{StaticResource TangoDividerBrush}" Padding="20"> - <DockPanel> - <touch:TouchButton Command="{Binding SaveCommand}" Margin="20 0 0 0" Height="50" Width="200" Style="{StaticResource TangoHollowButton}" CornerRadius="0" DockPanel.Dock="Right">SAVE</touch:TouchButton> - <touch:TouchTextBox VerticalAlignment="Bottom" Text="{Binding Request.DefaultFileName}" /> - </DockPanel> + <StackPanel> + <TextBlock Text="{Binding Request.Title}" FontSize="{StaticResource TangoHeaderFontSize}"></TextBlock> + <DockPanel Margin="0 10 0 0"> + <touch:TouchButton Command="{Binding SaveCommand}" Margin="20 0 0 0" Height="50" Width="200" Style="{StaticResource TangoHollowButton}" CornerRadius="0" DockPanel.Dock="Right">SAVE</touch:TouchButton> + <touch:TouchTextBox x:Name="txtFileName" FocusSelectionMode="SelectAll" VerticalAlignment="Bottom" Text="{Binding Request.DefaultFileName}" /> + </DockPanel> + </StackPanel> </Border> </Grid> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Views/MainView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Views/MainView.xaml.cs index f77eaa401..96090e870 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Views/MainView.xaml.cs @@ -14,6 +14,7 @@ using System.Windows.Navigation; using System.Windows.Shapes; using Tango.Core.DI; using Tango.PPC.Storage.ViewContracts; +using static Tango.SharedUI.Controls.NavigationControl; namespace Tango.PPC.Storage.Views { @@ -25,7 +26,6 @@ namespace Tango.PPC.Storage.Views public MainView() { InitializeComponent(); - TangoIOC.Default.Register<IMainView>(this); } @@ -33,5 +33,10 @@ namespace Tango.PPC.Storage.Views { explorer.NavigateBack(); } + + public void EditFileName() + { + txtFileName.Focus(); + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/app.config b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/app.config new file mode 100644 index 000000000..7b19296d1 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/app.config @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.2.2.0" newVersion="1.2.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.4.2.0" newVersion="1.4.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Console" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reactive.Core" publicKeyToken="94bc3704cddfc263" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/app.config b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/app.config index 0e58ccf54..1793e5c84 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/app.config +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Synchronization/app.config @@ -54,6 +54,10 @@ <assemblyIdentity name="System.Xml.ReaderWriter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /> </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" /> + </dependentAssembly> </assemblyBinding> </runtime> <entityFramework> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs index 13752b931..21fce7261 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/IMachineUpdateManager.cs @@ -70,5 +70,12 @@ namespace Tango.PPC.Common.MachineUpdate /// </summary> /// <returns></returns> Task UpdateDB(DbCompareResult dbCompareResult); + + /// <summary> + /// Gets the update package file information. + /// </summary> + /// <param name="filePath">The file path.</param> + /// <returns></returns> + Task<UpdatePackageFile> GetUpdatePackageFileInfo(String filePath); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs index d3757e50d..b4780887b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -2,6 +2,7 @@ using Microsoft.WindowsAzure.Storage.Blob; using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Linq; @@ -479,6 +480,33 @@ namespace Tango.PPC.Common.MachineUpdate }); } + /// <summary> + /// Gets the update package file information. + /// </summary> + /// <param name="filePath">The file path.</param> + /// <returns></returns> + public Task<UpdatePackageFile> GetUpdatePackageFileInfo(string filePath) + { + return Task.Factory.StartNew<UpdatePackageFile>(() => + { + UpdatePackageFile file = new UpdatePackageFile(); + var tempFolder = TemporaryManager.CreateFolder(); + + using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile(filePath)) + { + var appEntry = zip.Entries.SingleOrDefault(x => x.FileName == "Tango.PPC.UI.exe"); + appEntry.Extract(tempFolder); + } + + FileVersionInfo info = FileVersionInfo.GetVersionInfo(Path.Combine(tempFolder, "Tango.PPC.UI.exe")); + file.Version = Version.Parse(info.ProductVersion); + + tempFolder.Delete(); + + return file; + }); + } + #endregion } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdatePackageFile.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdatePackageFile.cs new file mode 100644 index 000000000..df496c3be --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/UpdatePackageFile.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.MachineUpdate +{ + public class UpdatePackageFile + { + public Version Version { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs index dc693e305..c9d66e0b3 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs @@ -81,6 +81,12 @@ namespace Tango.PPC.Common.Notifications Task ShowError(String message); /// <summary> + /// Shows a success message box. + /// </summary> + /// <param name="message">The message.</param> + Task ShowSuccess(String message); + + /// <summary> /// Shows a question message box. /// </summary> /// <param name="message">The message.</param> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index d09acd30a..67e5a4548 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -63,6 +63,9 @@ <Reference Include="Google.Protobuf, Version=3.4.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL"> <HintPath>..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll</HintPath> </Reference> + <Reference Include="Ionic.Zip, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Ionic.Zip.1.9.1.8\lib\Ionic.Zip.dll</HintPath> + </Reference> <Reference Include="Microsoft.Azure.Common.NetFramework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> <Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> <Reference Include="Microsoft.SqlServer.AzureStorageEnum, Version=14.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL" /> @@ -135,6 +138,7 @@ <Compile Include="MachineUpdate\MachineUpdateManager.cs" /> <Compile Include="MachineUpdate\MachineUpdateResult.cs" /> <Compile Include="MachineUpdate\MachineUpdateSteps.cs" /> + <Compile Include="MachineUpdate\UpdatePackageFile.cs" /> <Compile Include="Messages\JobRemovedMessage.cs" /> <Compile Include="Messages\JobSavedMessage.cs" /> <Compile Include="Messages\MachineSettingsSavedMessage.cs" /> @@ -321,7 +325,7 @@ </Target> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/app.config b/Software/Visual_Studio/PPC/Tango.PPC.Common/app.config index adc229d39..3e0fcee4b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/app.config +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/app.config @@ -54,6 +54,10 @@ <assemblyIdentity name="System.Xml.ReaderWriter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /> </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" /> + </dependentAssembly> </assemblyBinding> </runtime> <entityFramework> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/packages.config b/Software/Visual_Studio/PPC/Tango.PPC.Common/packages.config index c90a10a58..92f0d706c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/packages.config +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/packages.config @@ -4,6 +4,7 @@ <package id="FluentFTP" version="19.1.2" targetFramework="net46" /> <package id="FontAwesome.WPF" version="4.7.0.9" targetFramework="net46" /> <package id="Google.Protobuf" version="3.4.1" targetFramework="net46" /> + <package id="Ionic.Zip" version="1.9.1.8" targetFramework="net461" /> <package id="System.Data.SQLite" version="1.0.108.0" targetFramework="net46" /> <package id="System.Data.SQLite.Core" version="1.0.108.0" targetFramework="net46" /> <package id="System.Data.SQLite.EF6" version="1.0.108.0" targetFramework="net46" /> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.config b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.config index b9930d796..d1b1a6a00 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.config +++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/App.config @@ -63,6 +63,10 @@ <assemblyIdentity name="System.Xml.ReaderWriter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /> </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" /> + </dependentAssembly> </assemblyBinding> </runtime> </configuration>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config index b2738c8cf..ca5f29fc1 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config @@ -10,6 +10,62 @@ <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.2.2.0" newVersion="1.2.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.4.2.0" newVersion="1.4.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Console" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reactive.Core" publicKeyToken="94bc3704cddfc263" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.19.8.16603" newVersion="3.19.8.16603" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.19.8.16603" newVersion="3.19.8.16603" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" /> + </dependentAssembly> </assemblyBinding> </runtime> <entityFramework> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/UpdateFromFileView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/UpdateFromFileView.xaml new file mode 100644 index 000000000..231f5dabb --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/UpdateFromFileView.xaml @@ -0,0 +1,28 @@ +<UserControl x:Class="Tango.PPC.UI.Dialogs.UpdateFromFileView" + 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.Dialogs" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + mc:Ignorable="d" + Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DesignHeight="555" d:DesignWidth="560" Width="550" Height="450" d:DataContext="{d:DesignInstance Type=local:UpdateFromFileViewVM, IsDesignTimeCreatable=False}"> + <Grid Margin="20"> + <DockPanel> + <StackPanel DockPanel.Dock="Bottom" HorizontalAlignment="Right" Orientation="Horizontal"> + <touch:TouchButton Command="{Binding CloseCommand}" CornerRadius="25" Style="{StaticResource TangoMessageBoxButton}" HorizontalContentAlignment="Center" DockPanel.Dock="Right" Width="120" Height="50" VerticalAlignment="Bottom">CANCEL</touch:TouchButton> + <touch:TouchButton Command="{Binding OKCommand}" CornerRadius="25" Style="{StaticResource TangoMessageBoxButton}" Foreground="{StaticResource TangoPrimaryAccentBrush}" HorizontalContentAlignment="Center" DockPanel.Dock="Right" Width="120" Height="50" VerticalAlignment="Bottom">UPDATE</touch:TouchButton> + </StackPanel> + <StackPanel> + <Image Source="../Images/update.png" Stretch="Uniform" Height="120"></Image> + <TextBlock HorizontalAlignment="Center" Margin="0 20 0 0" FontSize="{StaticResource TangoHeaderFontSize}">UPDATE PACKAGE</TextBlock> + <TextBlock Margin="20 10" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center">The selected file contains a software update package. Press 'UPDATE' to start updating your system.</TextBlock> + + <TextBlock HorizontalAlignment="Center" Margin="0 40 0 0" FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoGrayTextBrush}"> + <Run>Version</Run> + <Run Text="{Binding Version}"></Run> + </TextBlock> + </StackPanel> + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/UpdateFromFileView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/UpdateFromFileView.xaml.cs new file mode 100644 index 000000000..4c5d14a6e --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/UpdateFromFileView.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.Dialogs +{ + /// <summary> + /// Interaction logic for UpdateFromFileView.xaml + /// </summary> + public partial class UpdateFromFileView : UserControl + { + public UpdateFromFileView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/UpdateFromFileViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/UpdateFromFileViewVM.cs new file mode 100644 index 000000000..b9e876809 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/UpdateFromFileViewVM.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; + +namespace Tango.PPC.UI.Dialogs +{ + public class UpdateFromFileViewVM : DialogViewVM + { + public String Version { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/update.png b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/update.png Binary files differnew file mode 100644 index 000000000..3e2475359 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/update.png diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs index f68d57805..27df6ae1d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs @@ -173,6 +173,22 @@ namespace Tango.PPC.UI.Notifications } /// <summary> + /// Shows a success message box. + /// </summary> + /// <param name="message">The message.</param> + /// <returns></returns> + public Task ShowSuccess(string message) + { + return ShowMessageBox(new MessageBoxVM() + { + Message = message, + Icon = TouchIconKind.Check, + Title = "Success", + Brush = Application.Current.Resources["TangoMessageBoxSuccessBrush"] as Brush, + }); + } + + /// <summary> /// Shows the message box. /// </summary> /// <param name="vm">The view model.</param> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Colors.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Colors.xaml index ae46563eb..2b89aac82 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Colors.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Resources/Colors.xaml @@ -5,6 +5,7 @@ <SolidColorBrush x:Key="TangoMessageBoxInfoBrush" Color="{StaticResource TangoPrimaryAccentColor}" /> <SolidColorBrush x:Key="TangoMessageBoxWarningBrush" Color="#FF9629" /> <SolidColorBrush x:Key="TangoMessageBoxErrorBrush" Color="#FF6262" /> + <SolidColorBrush x:Key="TangoMessageBoxSuccessBrush" Color="#56da6c" /> <SolidColorBrush x:Key="TangoMessageBoxQuestionBrush" Color="{StaticResource TangoPrimaryAccentColor}" /> </ResourceDictionary>
\ No newline at end of file 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 f615f25e0..2ff219906 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 @@ -119,6 +119,10 @@ <Compile Include="Connectivity\WiFiAuthenticationViewVM.cs" /> <Compile Include="Converters\AppBarItemConverter.cs" /> <Compile Include="Converters\ItemBaseConverter.cs" /> + <Compile Include="Dialogs\UpdateFromFileView.xaml.cs"> + <DependentUpon>UpdateFromFileView.xaml</DependentUpon> + </Compile> + <Compile Include="Dialogs\UpdateFromFileViewVM.cs" /> <Compile Include="Modules\DefaultStudioModuleLoader.cs" /> <Compile Include="Navigation\DefaultNavigationManager.cs" /> <Compile Include="Notifications\DefaultNotificationProvider.cs" /> @@ -163,6 +167,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Dialogs\UpdateFromFileView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="MainWindow.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -373,6 +381,7 @@ <Link>Tango.ColorLib.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> + <Resource Include="Images\update.png" /> <Resource Include="Images\flash-drive.png" /> <Resource Include="Images\right-arrow-64.png" /> <Resource Include="Images\machine-update.png" /> @@ -441,7 +450,7 @@ copy /Y "$(SolutionDir)Referenced Assemblies\vcruntime140d.dll" "$(TargetDir)"</ </PropertyGroup> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs index f582d0bb0..fc1de5de1 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs @@ -10,6 +10,7 @@ using Tango.Core.Helpers; using Tango.Explorer; using Tango.PPC.Common; using Tango.PPC.Common.MachineUpdate; +using Tango.PPC.UI.Dialogs; using Tango.PPC.UI.ViewsContracts; namespace Tango.PPC.UI.ViewModels @@ -246,7 +247,31 @@ namespace Tango.PPC.UI.ViewModels private async void HandleSoftwareUpdatePackageLoaded(ExplorerFileItem fileItem) { - if (await NotificationProvider.ShowQuestion("Do you with to install the selected software package?")) + UpdatePackageFile packageFile = null; + + try + { + packageFile = await MachineUpdateManager.GetUpdatePackageFileInfo(fileItem.Path); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error loading update package file from {fileItem.Path}."); + await NotificationProvider.ShowError("An error occurred while trying to load the selected software update package. Please make sure the package is valid."); + return; + } + + if (ApplicationManager.Version <= packageFile.Version) + { + await NotificationProvider.ShowError($"The selected update package (v{packageFile.Version.ToString()}) contains an older software version."); + return; + } + + UpdateFromFileViewVM vm = new UpdateFromFileViewVM(); + vm.Version = packageFile.Version.ToString(); + + await NotificationProvider.ShowDialog(vm); + + if (vm.DialogResult) { await NavigationManager.NavigateTo(Common.Navigation.NavigationView.MachineUpdateView); await NavigateTo(MachineUpdateView.UpdateFromPackageView); |
