diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-21 20:21:57 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-21 20:21:57 +0200 |
| commit | 956f9ea033553136ebf199fff30f288dc26fbeb0 (patch) | |
| tree | 3780e906d8d4f12c5be3836e1704d93d8d4966bd /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI | |
| parent | 808ce20dbd74862a75499ee0d4e87247ee4479b4 (diff) | |
| download | Tango-956f9ea033553136ebf199fff30f288dc26fbeb0.tar.gz Tango-956f9ea033553136ebf199fff30f288dc26fbeb0.zip | |
Working on machine studio update center..
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI')
14 files changed, 490 insertions, 3 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config index 9d1c60022..0bd51a469 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.config @@ -6,8 +6,10 @@ <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" /> </startup> + + <entityFramework> - <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> + <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> <providers> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/new-version.png b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/new-version.png Binary files differnew file mode 100644 index 000000000..eab60ef03 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/new-version.png diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/update.png b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/update.png Binary files differnew file mode 100644 index 000000000..a82777414 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/update.png diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml index e0f0b1f4f..63b2b3f6a 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/MainWindow.xaml @@ -31,6 +31,9 @@ <ContentControl Tag="ShutdownView"> <views:ShutdownView></views:ShutdownView> </ContentControl> + <ContentControl Tag="UpdateView"> + <views:UpdateView></views:UpdateView> + </ContentControl> </sharedControls:MultiTransitionControl.Controls> </sharedControls:MultiTransitionControl> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs index ee1724435..9538c59af 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -112,6 +112,17 @@ namespace Tango.MachineStudio.UI.StudioApplication } /// <summary> + /// Gets the machine studio application version. + /// </summary> + public string Version + { + get + { + return typeof(DefaultStudioApplicationManager).Assembly.GetName().Version.ToString(); + } + } + + /// <summary> /// Shutdown the application. /// </summary> public async void ShutDown() diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index 7c8600594..0ad97907b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -110,6 +110,7 @@ <Reference Include="System.Reactive.Windows.Threading, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL"> <HintPath>..\..\packages\System.Reactive.Windows.Threading.3.1.1\lib\net45\System.Reactive.Windows.Threading.dll</HintPath> </Reference> + <Reference Include="System.ServiceModel" /> <Reference Include="System.Windows" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> @@ -153,6 +154,7 @@ <Compile Include="ViewModelLocator.cs" /> <Compile Include="ViewModels\ModuleWindowVM.cs" /> <Compile Include="ViewModels\ShutdownViewVM.cs" /> + <Compile Include="ViewModels\UpdateViewVM.cs" /> <Compile Include="Views\LoadingView.xaml.cs"> <DependentUpon>LoadingView.xaml</DependentUpon> </Compile> @@ -174,6 +176,9 @@ <Compile Include="Views\ShutdownView.xaml.cs"> <DependentUpon>ShutdownView.xaml</DependentUpon> </Compile> + <Compile Include="Views\UpdateView.xaml.cs"> + <DependentUpon>UpdateView.xaml</DependentUpon> + </Compile> <Compile Include="Windows\ExceptionResolutions.cs" /> <Compile Include="Windows\ExceptionWindow.xaml.cs"> <DependentUpon>ExceptionWindow.xaml</DependentUpon> @@ -236,6 +241,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\UpdateView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Windows\ExceptionWindow.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -365,6 +374,12 @@ <ItemGroup> <Resource Include="Images\exception.png" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\update.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\new-version.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <PropertyGroup> <PostBuildEvent>$(TargetDir)linkgen.exe -s "$(TargetPath)" -d "$(TargetDir)Utilities\Machine Studio.lnk" diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs index 1907074c0..330bcd6eb 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs @@ -71,6 +71,7 @@ namespace Tango.MachineStudio.UI SimpleIoc.Default.Register<LoginViewVM>(); SimpleIoc.Default.Register<MachineConnectionViewVM>(); SimpleIoc.Default.Register<MachineLoginViewVM>(); + SimpleIoc.Default.Register<UpdateViewVM>(); //Register View (Supervising Controller Pattern). if (!ViewModelBase.IsInDesignModeStatic) @@ -127,5 +128,13 @@ namespace Tango.MachineStudio.UI return ServiceLocator.Current.GetInstance<MachineLoginViewVM>(); } } + + public UpdateViewVM UpdateViewVM + { + get + { + return ServiceLocator.Current.GetInstance<UpdateViewVM>(); + } + } } }
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs index 7ea7c6fa9..9acf26afd 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -10,6 +10,7 @@ using Tango.Logging; using Tango.MachineStudio.Common.Modules; using Tango.MachineStudio.Common.Navigation; using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.Common.StudioApplication; using Tango.SharedUI; namespace Tango.MachineStudio.UI.ViewModels @@ -24,14 +25,17 @@ namespace Tango.MachineStudio.UI.ViewModels private INavigationManager _navigationManager; private IStudioModuleLoader _studioModuleLoader; + public IStudioApplicationManager ApplicationManager { get; set; } + /// <summary> /// Initializes a new instance of the <see cref="LoadingViewVM"/> class. /// </summary> /// <param name="navigationManager">The navigation manager.</param> /// <param name="studioModuleLoader">The studio module loader.</param> /// <param name="notificationProvider">The notification provider.</param> - public LoadingViewVM(INavigationManager navigationManager, IStudioModuleLoader studioModuleLoader, INotificationProvider notificationProvider) + public LoadingViewVM(IStudioApplicationManager applicationManager, INavigationManager navigationManager, IStudioModuleLoader studioModuleLoader, INotificationProvider notificationProvider) { + ApplicationManager = applicationManager; _navigationManager = navigationManager; _studioModuleLoader = studioModuleLoader; _notificationProvider = notificationProvider; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index da73e8eae..acd9e7925 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -99,6 +99,16 @@ namespace Tango.MachineStudio.UI.ViewModels /// </summary> public RelayCommand SignoutCommand { get; set; } + /// <summary> + /// Gets or sets the exit command. + /// </summary> + public RelayCommand ExitCommand { get; set; } + + /// <summary> + /// Gets or sets the update center command. + /// </summary> + public RelayCommand UpdateCenterCommand { get; set; } + private IAuthenticationProvider _authenticationProvider; /// <summary> /// Gets or sets the authentication provider. @@ -169,6 +179,8 @@ namespace Tango.MachineStudio.UI.ViewModels SignoutCommand = new RelayCommand(SignOut); DisconnectCommand = new RelayCommand(DisconnectFromMachine, (x) => ApplicationManager.IsMachineConnected && !_isDisconnecting); OpenModuleInWindowCommand = new RelayCommand<IStudioModule>(OpenModuleInWindow); + ExitCommand = new RelayCommand(ExitApplication); + UpdateCenterCommand = new RelayCommand(NavigateToUpdateCenter); } /// <summary> @@ -315,6 +327,10 @@ namespace Tango.MachineStudio.UI.ViewModels base.OnViewAttached(); } + /// <summary> + /// Opens the module in a new window. + /// </summary> + /// <param name="module">The module.</param> private void OpenModuleInWindow(IStudioModule module) { if (module == null) return; @@ -351,5 +367,21 @@ namespace Tango.MachineStudio.UI.ViewModels _notificationProvider.ShowError("Error popping out module " + module.Name); } } + + /// <summary> + /// Navigates to update center. + /// </summary> + private void NavigateToUpdateCenter() + { + _navigation.NavigateTo(NavigationView.UpdateView); + } + + /// <summary> + /// Exits the application. + /// </summary> + private void ExitApplication() + { + _applicationManager.ShutDown(); + } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs new file mode 100644 index 000000000..014aecdb6 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs @@ -0,0 +1,175 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.MachineStudio.Common.Authentication; +using Tango.MachineStudio.Common.Navigation; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.Common.StudioApplication; +using Tango.MachineStudio.Common.Update; +using Tango.SharedUI; + +namespace Tango.MachineStudio.UI.ViewModels +{ + public enum UpdateStatus + { + None, + CheckingForUpdate, + UpToDate, + UpdateAvailable, + Downloading, + Updating, + UpdateCompleted, + Error, + } + + public class UpdateViewVM : ViewModel + { + private INotificationProvider _notification; + private INavigationManager _navigation; + private IStudioApplicationManager _application; + private IAuthenticationProvider _authentication; + + private UpdateStatus _status; + public UpdateStatus Status + { + get { return _status; } + set { _status = value; RaisePropertyChangedAuto(); } + } + + private String _latestVersion; + public String LatestVersion + { + get { return _latestVersion; } + set { _latestVersion = value; RaisePropertyChangedAuto(); } + } + + private double _downloadProgress; + + public double DownloadProgress + { + get { return _downloadProgress; } + set { _downloadProgress = value; RaisePropertyChangedAuto(); } + } + + private double _updateProgress; + + public double UpdateProgress + { + get { return _updateProgress; } + set { _updateProgress = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand UpdateCommand { get; set; } + + public RelayCommand BackCommand { get; set; } + + public RelayCommand RestartCommand { get; set; } + + public RelayCommand TryAgainCommand { get; set; } + + public UpdateViewVM(INotificationProvider notification, IAuthenticationProvider authentication, INavigationManager navigation, IStudioApplicationManager application) + { + _notification = notification; + _navigation = navigation; + _application = application; + _authentication = authentication; + + LatestVersion = "1.0.0.2"; + Status = UpdateStatus.CheckingForUpdate; + UpdateCommand = new RelayCommand(StartUpdate, () => Status == UpdateStatus.UpdateAvailable); + BackCommand = new RelayCommand(BackToApplication, () => Status != UpdateStatus.Updating); + RestartCommand = new RelayCommand(RestartApplication, () => Status == UpdateStatus.UpdateCompleted); + TryAgainCommand = new RelayCommand(TryAgain, () => Status == UpdateStatus.CheckingForUpdate); + } + + public void OnNavigatedInto() + { + CheckForUpdates(); + } + + private void CheckForUpdates() + { + Status = UpdateStatus.CheckingForUpdate; + + Task.Factory.StartNew(() => + { + var service = UpdateServiceHelper.GetUpdateServiceChannel(); + var client = service.CreateChannel(); + + CheckForUpdatesResponse response = client.CheckForUpdates(new CheckForUpdatesRequest() + { + Email = _authentication.CurrentUser.Email, + Password = _authentication.CurrentUser.Password, + Version = _application.Version, + }); + + var a = response; + + Thread.Sleep(5000); + Status = UpdateStatus.UpdateAvailable; + }); + } + + private void BackToApplication() + { + if (Status == UpdateStatus.Downloading) + { + if (!_notification.ShowQuestion("This will abort all update operations. Are you sure?")) + { + return; + } + } + + _navigation.NavigateTo(NavigationView.MainView); + Status = UpdateStatus.None; + } + + private void StartUpdate() + { + DownloadProgress = 0; + UpdateProgress = 0; + + Status = UpdateStatus.Downloading; + + Task.Factory.StartNew(() => + { + for (int i = 0; i < 100; i++) + { + DownloadProgress++; + Thread.Sleep(30); + } + + Status = UpdateStatus.Updating; + + for (int i = 0; i < 100; i++) + { + UpdateProgress++; + Thread.Sleep(30); + } + + Status = UpdateStatus.UpdateCompleted; + }); + } + + private void TryAgain() + { + CheckForUpdates(); + } + + private void RestartApplication() + { + _application.ShutDown(); + } + + protected override void RaisePropertyChangedAuto([CallerMemberName] string caller = null) + { + base.RaisePropertyChangedAuto(caller); + InvalidateRelayCommands(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoadingView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoadingView.xaml index 2478c1155..aaf4accd4 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoadingView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoadingView.xaml @@ -13,6 +13,10 @@ <Image Source="/Images/machine-trans.png" RenderOptions.BitmapScalingMode="Fant" Width="100"></Image> <StackPanel Orientation="Horizontal"> <TextBlock FontSize="70" Foreground="{StaticResource AccentColorBrush}">Machine Studio</TextBlock> + <TextBlock Foreground="Gray" VerticalAlignment="Bottom" Margin="10 0 0 5" FontSize="16" FontWeight="SemiBold" FontStyle="Italic"> + <Run>v</Run> + <Run Text="{Binding ApplicationManager.Version,Mode=OneWay}"></Run> + </TextBlock> </StackPanel> <TextBlock HorizontalAlignment="Right" FontSize="18" Margin="0 0 -50 0" Foreground="{StaticResource AccentColorBrush}">Twine Solutions</TextBlock> <mahapps:ProgressRing Margin="20 60 20 40" Width="80" Height="80"></mahapps:ProgressRing> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml index 9a2cc37a4..355bdc1fd 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml @@ -126,7 +126,9 @@ <Separator/> <Button Content="Open Module In New Window" IsEnabled="{Binding IsModuleLoaded}" Command="{Binding OpenModuleInWindowCommand}" CommandParameter="{Binding CurrentModule}" /> <Separator/> - <Button Content="Exit" /> + <Button Content="Update Center" Command="{Binding UpdateCenterCommand}" /> + <Separator/> + <Button Content="Exit" Command="{Binding ExitCommand}" /> </StackPanel> </materialDesign:PopupBox> <Grid> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml new file mode 100644 index 000000000..5b09d3381 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml @@ -0,0 +1,188 @@ +<UserControl x:Class="Tango.MachineStudio.UI.Views.UpdateView" + 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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:vm="clr-namespace:Tango.MachineStudio.UI.ViewModels" + xmlns:mahApps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:local="clr-namespace:Tango.MachineStudio.UI.Views" + mc:Ignorable="d" + d:DesignHeight="1080" d:DesignWidth="1920" DataContext="{Binding UpdateViewVM, Source={StaticResource Locator}}" Background="White" FontSize="20"> + <Grid> + <Grid.Background> + <ImageBrush ImageSource="/Images/White-Abstract.png" /> + </Grid.Background> + <Grid MaxWidth="1200" MaxHeight="700"> + <DockPanel> + <Grid DockPanel.Dock="Top" HorizontalAlignment="Center"> + <Grid.Effect> + <DropShadowEffect BlurRadius="100" ShadowDepth="0" Opacity="0.7" /> + </Grid.Effect> + <StackPanel Orientation="Horizontal"> + <Image Source="/Images/update.png" Width="100" /> + <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" FontSize="70">Update Center</TextBlock> + </StackPanel> + </Grid> + + <Grid DockPanel.Dock="Bottom"> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> + <Button MinWidth="140" Height="40" Style="{StaticResource MaterialDesignFlatButton}" Command="{Binding BackCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="KeyboardBackspace" Width="24" Height="24" /> + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">BACK TO APPLICATION</TextBlock> + </StackPanel> + </Button> + </StackPanel> + </Grid> + + <Grid> + <Border Margin="0 10 0 10" BorderThickness="0 0 0 2" BorderBrush="DimGray"> + <ContentControl> + <ContentControl.Style> + <Style TargetType="ContentControl"> + <Setter Property="Content"> + <Setter.Value> + <Grid> + + </Grid> + </Setter.Value> + </Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding Status}" Value="{x:Static vm:UpdateStatus.CheckingForUpdate}"> + <Setter Property="Content"> + <Setter.Value> + <Grid> + <StackPanel VerticalAlignment="Center"> + <mahApps:ProgressRing Width="120" Height="120" Foreground="DimGray" /> + <TextBlock HorizontalAlignment="Center" Margin="0 30 0 0">Checking for updates...</TextBlock> + </StackPanel> + </Grid> + </Setter.Value> + </Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Status}" Value="{x:Static vm:UpdateStatus.UpdateAvailable}"> + <Setter Property="Content"> + <Setter.Value> + <Grid> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> + <Image Source="/Images/new-version.png" Width="64"></Image> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> + <TextBlock VerticalAlignment="Center" Margin="0 20 0 0">New version is available!</TextBlock> + </StackPanel> + <TextBlock FontSize="12" TextAlignment="Center" Padding="20" Margin="0 0 0 40"> + <Run>A new version of Machine Studio is available to download</Run> + <LineBreak/> + <Run>Click 'Update' to start the update process.</Run> + </TextBlock> + <Button MinWidth="140" Height="40" Margin="0 0 0 0" Width="200" Command="{Binding UpdateCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="Download" Width="24" Height="24" /> + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">UPDATE</TextBlock> + </StackPanel> + </Button> + </StackPanel> + </Grid> + </Setter.Value> + </Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Status}" Value="{x:Static vm:UpdateStatus.Downloading}"> + <Setter Property="Content"> + <Setter.Value> + <Grid> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> + <TextBlock HorizontalAlignment="Center"> + <Run>Downloading version</Run> + <Run Text="{Binding LatestVersion,FallbackValue='0.0.0.0'}"></Run> + <Run>, please wait...</Run> + </TextBlock> + <ProgressBar Height="10" Foreground="DimGray" Margin="0 20 0 0" Maximum="100" Value="{Binding DownloadProgress}"></ProgressBar> + </StackPanel> + </Grid> + </Setter.Value> + </Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Status}" Value="{x:Static vm:UpdateStatus.Updating}"> + <Setter Property="Content"> + <Setter.Value> + <Grid> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> + <TextBlock HorizontalAlignment="Center"> + <Run>Updating Machine Studio, please wait...</Run> + </TextBlock> + <ProgressBar Height="10" Foreground="DimGray" Margin="0 20 0 0" Maximum="100" Value="{Binding DownloadProgress}"></ProgressBar> + </StackPanel> + </Grid> + </Setter.Value> + </Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Status}" Value="{x:Static vm:UpdateStatus.UpdateCompleted}"> + <Setter Property="Content"> + <Setter.Value> + <Grid> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> + <materialDesign:PackIcon Kind="Check" Width="100" Height="100" Foreground="#1CBB1C" HorizontalAlignment="Center" /> + <StackPanel Orientation="Horizontal"> + <TextBlock VerticalAlignment="Center" Margin="0 20 0 0">Your version of Machine Studio is up to date!</TextBlock> + </StackPanel> + + <TextBlock HorizontalAlignment="Center" Margin="0 10 0 0" FontSize="12">Please restart Machine Studio in order to apply the changes.</TextBlock> + + <Button MinWidth="140" Height="40" Margin="0 50 0 0" Width="200" Command="{Binding RestartCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="BackupRestore" Width="24" Height="24" /> + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">RESTART</TextBlock> + </StackPanel> + </Button> + </StackPanel> + </Grid> + </Setter.Value> + </Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Status}" Value="{x:Static vm:UpdateStatus.UpToDate}"> + <Setter Property="Content"> + <Setter.Value> + <Grid> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> + <materialDesign:PackIcon Kind="Check" Width="100" Height="100" Foreground="#1CBB1C" HorizontalAlignment="Center" /> + <StackPanel Orientation="Horizontal"> + <TextBlock VerticalAlignment="Center" Margin="0 20 0 0">Your version of Machine Studio is up to date!</TextBlock> + </StackPanel> + </StackPanel> + </Grid> + </Setter.Value> + </Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Status}" Value="{x:Static vm:UpdateStatus.Error}"> + <Setter Property="Content"> + <Setter.Value> + <Grid> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> + <materialDesign:PackIcon Kind="Alert" Width="100" Height="100" Foreground="#FF5F5F" HorizontalAlignment="Center" /> + <TextBlock VerticalAlignment="Center" Margin="0 20 0 0" HorizontalAlignment="Center">Error updating machine studio</TextBlock> + <TextBlock HorizontalAlignment="Center" Margin="0 10 0 0" FontSize="12" TextAlignment="Center"> + <Run>An error occurred while updating your software.</Run> + <LineBreak/> + <Run>press 'Try Again' to give it another try.</Run> + </TextBlock> + <Button MinWidth="140" Height="40" Margin="0 50 0 0" Width="200" Command="{Binding TryAgainCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="BackupRestore" Width="24" Height="24" /> + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">TRY AGAIN</TextBlock> + </StackPanel> + </Button> + </StackPanel> + </Grid> + </Setter.Value> + </Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </ContentControl.Style> + </ContentControl> + </Border> + </Grid> + </DockPanel> + </Grid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml.cs new file mode 100644 index 000000000..75b74f65d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml.cs @@ -0,0 +1,42 @@ +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; +using Tango.MachineStudio.UI.ViewModels; +using static Tango.SharedUI.Controls.MultiTransitionControl; + +namespace Tango.MachineStudio.UI.Views +{ + /// <summary> + /// Interaction logic for UpdateView.xaml + /// </summary> + public partial class UpdateView : UserControl, ITransitionView + { + private UpdateViewVM _vm; + + public UpdateView() + { + InitializeComponent(); + + this.Loaded += (x, y) => + { + _vm = DataContext as UpdateViewVM; + }; + } + + public void OnTransitionCompleted() + { + _vm.OnNavigatedInto(); + } + } +} |
