diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2018-08-30 19:38:41 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2018-08-30 19:38:41 +0300 |
| commit | dd6bc91bb43b70fcae954834cd03c6028f3eefa5 (patch) | |
| tree | 08710978223e7bc2eedae6c7515a241e6b1c64a8 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI | |
| parent | 5c9bca9cb0bbbb1c448228ef5ac5f898f17e9827 (diff) | |
| parent | a4a0d4973c8eff2bbfe2c8e753f30626c9e9076d (diff) | |
| download | Tango-dd6bc91bb43b70fcae954834cd03c6028f3eefa5.tar.gz Tango-dd6bc91bb43b70fcae954834cd03c6028f3eefa5.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI')
12 files changed, 356 insertions, 19 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/external-bridge-emulator.png b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/external-bridge-emulator.png Binary files differnew file mode 100644 index 000000000..cb159d4a6 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/external-bridge-emulator.png diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs index 2c31c002f..1865bfb2f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Properties/AssemblyInfo.cs @@ -4,5 +4,5 @@ using System.Runtime.InteropServices; [assembly: System.Windows.ThemeInfo(System.Windows.ResourceDictionaryLocation.None, System.Windows.ResourceDictionaryLocation.SourceAssembly)] [assembly: AssemblyTitle("Tango - Machine Studio")] -[assembly: AssemblyVersion("3.3.38.18238")] +[assembly: AssemblyVersion("3.3.40.18238")] [assembly: ComVisible(false)]
\ No newline at end of file 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 17bf57f56..29bb459ee 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -19,6 +19,8 @@ using Tango.Integration.ExternalBridge; using Tango.MachineStudio.Common.EventLogging; using Tango.BL.Enumerations; using Tango.Core.DI; +using Tango.BL.Entities; +using Tango.BL; namespace Tango.MachineStudio.UI.StudioApplication { @@ -55,22 +57,23 @@ namespace Tango.MachineStudio.UI.StudioApplication public bool IsShuttingDown { get; private set; } /// <summary> - /// The connected machine + /// Occurs when the connected machine property has changed. /// </summary> - private IExternalBridgeClient _connectedMachine; + public event EventHandler<IExternalBridgeClient> ConnectedMachineChanged; /// <summary> - /// Occurs when the connected machine property has changed. + /// Gets or sets the machine. /// </summary> - public event EventHandler<IExternalBridgeClient> ConnectedMachineChanged; + public Machine Machine { get; private set; } + private IExternalBridgeClient _connectedMachine; /// <summary> /// Gets or sets the currently connected machine if any. /// </summary> public IExternalBridgeClient ConnectedMachine { get { return _connectedMachine; } - set + private set { _connectedMachine = value; RaisePropertyChangedAuto(); @@ -270,9 +273,31 @@ namespace Tango.MachineStudio.UI.StudioApplication } } + /// <summary> + /// Raises the application ready event. + /// </summary> public void NotifyApplicationReady() { TangoIOC.Default.GetAllInstancesByBase<IStudioViewModel>().ToList().ForEach(x => x.OnApplicationReady()); } + + /// <summary> + /// Sets the connected machine. + /// </summary> + /// <param name="connectedMachine">The connected machine.</param> + public void SetConnectedMachine(IExternalBridgeClient connectedMachine) + { + if (connectedMachine != null) + { + Machine = ObservablesStaticCollections.Instance.Machines.SingleOrDefault(x => x.SerialNumber == connectedMachine.SerialNumber); + ConnectedMachine = connectedMachine; + ConnectedMachine.SetMachine(Machine); + } + else + { + Machine = null; + ConnectedMachine = null; + } + } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs index 6225e1480..8f67a21c2 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs @@ -196,7 +196,7 @@ namespace Tango.MachineStudio.UI.TFS if (app.ConnectedMachine != null) { - Machine machine = app.ConnectedMachine.Machine; + Machine machine = app.Machine; sysModel.Machine = machine; sysModel.EmbeddedVersion = app.ConnectedMachine.DeviceInformation.Version; 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 ed3d0e5fc..3cab71602 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 @@ -369,6 +369,10 @@ <Project>{38197109-8610-4d3f-92b9-16d48df94d7c}</Project> <Name>Tango.DAL.Remote</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.Emulations\Tango.Emulations.csproj"> + <Project>{63561e19-ff5a-414b-a5ef-e30711543e1d}</Project> + <Name>Tango.Emulations</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.Integration\Tango.Integration.csproj"> <Project>{4206ac58-3b57-4699-8835-90bf6db01a61}</Project> <Name>Tango.Integration</Name> @@ -481,6 +485,7 @@ <Resource Include="Images\settings.png" /> </ItemGroup> <ItemGroup> + <Resource Include="Images\external-bridge-emulator.png" /> <EmbeddedResource Include="..\..\Versioning\ChangeLog.txt"> <Link>ChangeLog.txt</Link> </EmbeddedResource> @@ -571,7 +576,7 @@ copy /Y "$(SolutionDir)Referenced Assemblies\Microsoft.WITDataStore32.dll" "$(Ta </Target> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_BuildVersioningStyle="None.None.Increment.DeltaBaseYearDayOfYear" BuildVersion_UpdateFileVersion="True" BuildVersion_DetectChanges="True" BuildVersion_UseGlobalSettings="False" /> + <UserProperties BuildVersion_UseGlobalSettings="False" BuildVersion_DetectChanges="True" BuildVersion_UpdateFileVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.DeltaBaseYearDayOfYear" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs index 60447f37a..51b7168ed 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineConnectionViewVM.cs @@ -4,8 +4,11 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Core.Commands; +using Tango.Emulations.ExternalBridge; using Tango.Integration.ExternalBridge; +using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Notifications; +using Tango.Settings; using Tango.SharedUI; namespace Tango.MachineStudio.UI.ViewModels @@ -16,6 +19,8 @@ namespace Tango.MachineStudio.UI.ViewModels /// <seealso cref="Tango.MachineStudio.Common.Notifications.DialogViewVM" /> public class MachineConnectionViewVM : DialogViewVM { + private EmulatorExternalBridge _emulator; + private ExternalBridgeScanner _scanner; /// <summary> /// Gets or sets the machine scanner. @@ -63,6 +68,9 @@ namespace Tango.MachineStudio.UI.ViewModels } } + /// <summary> + /// Invokes the <see cref="E:Tango.SharedUI.DialogViewVM.Canceled" /> event. + /// </summary> protected override void Cancel() { Scanner.Stop(); @@ -76,6 +84,17 @@ namespace Tango.MachineStudio.UI.ViewModels { base.OnShow(); Scanner.AvailableMachines.Clear(); + + if (SettingsManager.Default.GetOrCreate<MachineStudioSettings>().UseExternalBridgeEmulator) + { + if (_emulator != null) + { + _emulator.Disconnect(); + } + _emulator = new EmulatorExternalBridge(); + } + + Scanner.AvailableMachines.Add(_emulator); Scanner.Start(); } } 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 ee4435832..31b2181ea 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -388,7 +388,7 @@ namespace Tango.MachineStudio.UI.ViewModels InvalidateRelayCommands(); String serial = ApplicationManager.ConnectedMachine.SerialNumber; await ApplicationManager.ConnectedMachine.Disconnect(); - ApplicationManager.ConnectedMachine = null; + ApplicationManager.SetConnectedMachine(null); _eventLogger.Log("Disconnected from machine " + serial); PostMessage(new MachineConnectionChangedMessage() { Machine = null }); @@ -459,13 +459,13 @@ namespace Tango.MachineStudio.UI.ViewModels Intent = PMR.Integration.ExternalBridgeLoginIntent.Override, }); - ApplicationManager.ConnectedMachine = x.SelectedMachine; + ApplicationManager.SetConnectedMachine(x.SelectedMachine); (x.SelectedMachine as IExternalBridgeSecureClient).SessionClosed += (_, __) => { InvokeUI(() => { _notificationProvider.ShowError("The remote machine has closed the current session. Machine disconnected."); - ApplicationManager.ConnectedMachine = null; + ApplicationManager.SetConnectedMachine(null); }); }; PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine }); @@ -506,7 +506,7 @@ namespace Tango.MachineStudio.UI.ViewModels await x.SelectedMachine.Connect(); x.SelectedMachine.SerialNumber = vm.SelectedMachine.SerialNumber; - ApplicationManager.ConnectedMachine = x.SelectedMachine; + ApplicationManager.SetConnectedMachine(x.SelectedMachine); PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine }); _eventLogger.Log(String.Format("Successfully connected to machine {0} via USB", x.SelectedMachine.SerialNumber)); @@ -556,8 +556,8 @@ namespace Tango.MachineStudio.UI.ViewModels { using (ObservablesContext db = ObservablesContext.CreateDefault()) { - var config = db.Adapter.GetConfiguration(s => s.Guid == ApplicationManager.ConnectedMachine.Machine.ConfigurationGuid); - var hw = db.Adapter.GetHardwareVersionByMachine(ApplicationManager.ConnectedMachine.Machine.Guid); + var config = db.Adapter.GetConfiguration(s => s.Guid == ApplicationManager.Machine.ConfigurationGuid); + var hw = db.Adapter.GetHardwareVersionByMachine(ApplicationManager.Machine.Guid); await ApplicationManager.ConnectedMachine.UploadHardwareConfiguration(hw, config); } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs index c5831f701..55f585626 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs @@ -35,6 +35,9 @@ namespace Tango.MachineStudio.UI.ViewModels Updating, UpdateCompleted, Error, + RollingBack, + RollbackCompleted, + RollbackError, } public class UpdateViewVM : ViewModel @@ -48,6 +51,7 @@ namespace Tango.MachineStudio.UI.ViewModels private IAuthenticationProvider _authentication; private CheckForUpdatesResponse _updateInfo; private TemporaryFolder _newPackageTempFolder; + private TemporaryFolder _previousPackageTempFolder; private bool _forcedUpdate; public bool ForcedUpdate @@ -88,6 +92,14 @@ namespace Tango.MachineStudio.UI.ViewModels set { _downloadProgress = value; RaisePropertyChangedAuto(); } } + private double _rollbackProgress; + + public double RollbackProgress + { + get { return _rollbackProgress; } + set { _rollbackProgress = value; RaisePropertyChangedAuto(); } + } + private double _updateProgress; public double UpdateProgress @@ -104,6 +116,14 @@ namespace Tango.MachineStudio.UI.ViewModels set { _currentUpdateFile = value; RaisePropertyChanged(nameof(CurrentUpdateFile)); } } + private bool _isRollbackAvailable; + + public bool IsRollbackAvailable + { + get { return _isRollbackAvailable; } + set { _isRollbackAvailable = value; RaisePropertyChangedAuto(); } + } + public RelayCommand UpdateCommand { get; set; } public RelayCommand BackCommand { get; set; } @@ -112,6 +132,10 @@ namespace Tango.MachineStudio.UI.ViewModels public RelayCommand TryAgainCommand { get; set; } + public RelayCommand RollbackCommand { get; set; } + + public RelayCommand TryRollbackAgainCommand { get; set; } + public UpdateViewVM(INotificationProvider notification, IAuthenticationProvider authentication, INavigationManager navigation, IStudioApplicationManager application) { _notification = notification; @@ -123,8 +147,12 @@ namespace Tango.MachineStudio.UI.ViewModels Status = UpdateStatus.CheckingForUpdate; UpdateCommand = new RelayCommand(StartUpdate, () => Status == UpdateStatus.UpdateAvailable); BackCommand = new RelayCommand(BackToApplication, () => Status != UpdateStatus.Updating && !ForcedUpdate); - RestartCommand = new RelayCommand(RestartApplication, () => Status == UpdateStatus.UpdateCompleted); + RestartCommand = new RelayCommand(RestartApplication, () => Status == UpdateStatus.UpdateCompleted || Status == UpdateStatus.RollbackCompleted); TryAgainCommand = new RelayCommand(TryAgain, () => Status == UpdateStatus.Error); + RollbackCommand = new RelayCommand(Rollback, () => Status != UpdateStatus.RollingBack && !ForcedUpdate); + TryRollbackAgainCommand = new RelayCommand(TryRollbackAgain, () => Status == UpdateStatus.RollbackError); + + IsRollbackAvailable = File.Exists(GetRollbackFile()); TangoMessenger.Default.Register<Messages.ForcedUpdateMessage>(HandleForcedUpdateMessage); } @@ -294,6 +322,41 @@ namespace Tango.MachineStudio.UI.ViewModels } } + try + { + LogManager.Log("Backing up current version..."); + CurrentUpdateFile = "Backing up current version..."; + + String rollbackFolder = GetRollbackFolder(); + Directory.CreateDirectory(rollbackFolder); + + String backFile = GetRollbackFile(); + + if (File.Exists(backFile)) + { + File.Delete(backFile); + } + + using (ZipFile backZip = new ZipFile(backFile)) + { + int currentEntry = 0; + + backZip.SaveProgress += (_, e) => + { + UpdateProgress = ((double)(currentEntry++) / (double)backZip.Entries.Count) * 100d; + }; + + backZip.Password = "Aa123456"; + backZip.AddDirectory(_appPath); + backZip.Save(); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Could not construct rollback."); + _notification.ShowWarning("Update center has failed to construct a rollback point for the current version. Version rollback will not be available."); + } + TangoIOC.Default.GetInstance<MainViewVM>().DisableCheckForUpdates = true; Status = UpdateStatus.UpdateCompleted; } @@ -319,7 +382,16 @@ namespace Tango.MachineStudio.UI.ViewModels try { Process p = new Process(); - p.StartInfo.FileName = _newPackageTempFolder + "\\Tango.MachineStudio.Updater.exe"; + + if (Status == UpdateStatus.UpdateCompleted) + { + p.StartInfo.FileName = _newPackageTempFolder + "\\Tango.MachineStudio.Updater.exe"; + } + else if (Status == UpdateStatus.RollbackCompleted) + { + p.StartInfo.FileName = _previousPackageTempFolder + "\\Tango.MachineStudio.Updater.exe"; + } + p.StartInfo.UseShellExecute = true; p.StartInfo.Arguments = _appPath; p.Start(); @@ -335,6 +407,90 @@ namespace Tango.MachineStudio.UI.ViewModels Environment.Exit(0); } + private void Rollback() + { + if (_notification.ShowQuestion("Are you sure you want to restore the previous version?")) + { + Status = UpdateStatus.RollingBack; + + try + { + Task.Factory.StartNew(() => + { + _previousPackageTempFolder = TemporaryManager.CreateFolder(); + _previousPackageTempFolder.Persist = true; + + using (ZipFile zip = new ZipFile(GetRollbackFile())) + { + zip.Password = "Aa123456"; + + int currentEntry = 0; + + zip.ExtractProgress += (x, args) => + { + if (args.EventType == ZipProgressEventType.Extracting_AfterExtractEntry) + { + logManager.Log("Extracting " + Path.GetFileName(args.CurrentEntry.FileName)); + RollbackProgress = ((double)(currentEntry++) / (double)zip.Entries.Count) * 100d; + } + }; + + foreach (ZipEntry entry in zip) + { + Thread.Sleep(10); + + string newPath = Path.Combine(_previousPackageTempFolder.Path, entry.FileName); + + try + { + if (entry.IsDirectory) + { + Directory.CreateDirectory(newPath); + } + else + { + entry.Extract(_previousPackageTempFolder.Path, ExtractExistingFileAction.OverwriteSilently); + } + } + catch + { + logManager.Log("Could not extract file " + entry.FileName); + } + } + + } + + File.Delete(GetRollbackFile()); + + Status = UpdateStatus.RollbackCompleted; + }); + } + catch (Exception ex) + { + Status = UpdateStatus.Error; + LogManager.Log(ex, "Error while trying to restore version."); + _notification.ShowError("An error occurred while trying to restore the previous version."); + } + } + } + + private void TryRollbackAgain() + { + CheckForUpdates(); + } + + private String GetRollbackFolder() + { + String rollbackFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "Rollback"); + return rollbackFolder; + } + + private String GetRollbackFile() + { + String backFile = Path.Combine(GetRollbackFolder(), Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName) + ".rollback"); + return backFile; + } + protected override void RaisePropertyChangedAuto([CallerMemberName] string caller = null) { base.RaisePropertyChangedAuto(caller); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml index 319fa3596..26790c67d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml @@ -6,6 +6,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:integration="clr-namespace:Tango.Integration.ExternalBridge;assembly=Tango.Integration" xmlns:integ="clr-namespace:Tango.Integration.Operation;assembly=Tango.Integration" + xmlns:emulations="clr-namespace:Tango.Emulations.ExternalBridge;assembly=Tango.Emulations" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" @@ -38,6 +39,10 @@ <DataTemplate DataType="{x:Type integration:ExternalBridgeUsbClient}"> <Image Source="/Images/external-bridge-usb.png" Width="48" Height="48" RenderOptions.BitmapScalingMode="Fant"></Image> </DataTemplate> + + <DataTemplate DataType="{x:Type emulations:EmulatorExternalBridge}"> + <Image Source="/Images/external-bridge-emulator.png" Width="48" Height="48" RenderOptions.BitmapScalingMode="Fant"></Image> + </DataTemplate> </ContentControl.Resources> </ContentControl> @@ -131,6 +136,39 @@ <ToggleButton IsChecked="{Binding EnableEventsNotification}" HorizontalAlignment="Left"></ToggleButton> </controls:TableGrid> </DataTemplate> + + <DataTemplate DataType="{x:Type emulations:EmulatorExternalBridge}"> + <controls:TableGrid RowHeight="22"> + <TextBlock FontWeight="SemiBold" Text="Address:" /> + <TextBlock Text="{Binding Adapter.Address}" /> + <TextBlock FontWeight="SemiBold" Text="Serial Number:" /> + <TextBlock Text="{Binding SerialNumber}" /> + <TextBlock FontWeight="SemiBold" Text="Name:" /> + <TextBlock Text="{Binding Machine.Name}" /> + <TextBlock FontWeight="SemiBold" Text="Organization:" /> + <TextBlock Text="{Binding Machine.Organization.Name}" /> + <TextBlock FontWeight="SemiBold" Text="Total Bytes Sent:" /> + <TextBlock Text="{Binding Adapter.TotalBytesSent,Converter={StaticResource ByteArrayToFileSizeConverter},Mode=OneWay}" /> + <TextBlock FontWeight="SemiBold" Text="Total Bytes Received:" /> + <TextBlock Text="{Binding Adapter.TotalBytesReceived,Converter={StaticResource ByteArrayToFileSizeConverter},Mode=OneWay}" /> + <TextBlock FontWeight="SemiBold" Text="Transfer Rate:" /> + <TextBlock> + <Run Text="{Binding Adapter.TransferRate,Converter={StaticResource ByteArrayToFileSizeConverter},Mode=OneWay}"></Run> + <Run Text="/ sec"></Run> + </TextBlock> + <TextBlock FontWeight="SemiBold" Text="Diagnostics Frame Rate:" /> + <TextBlock> + <Run Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.DiagnosticsFrameProvider.FrameRate,Mode=OneWay,IsAsync=True}"></Run> + <Run Text="/ sec"></Run> + </TextBlock> + <TextBlock FontWeight="SemiBold" Text="Enable Diagnostics:" /> + <ToggleButton IsChecked="{Binding EnableDiagnostics}" HorizontalAlignment="Left"></ToggleButton> + <TextBlock FontWeight="SemiBold" Text="Enable Embedded Debug Logs:" /> + <ToggleButton IsChecked="{Binding EnableEmbeddedDebugging}" HorizontalAlignment="Left"></ToggleButton> + <TextBlock FontWeight="SemiBold" Text="Enable Events:" /> + <ToggleButton IsChecked="{Binding EnableEventsNotification}" HorizontalAlignment="Left"></ToggleButton> + </controls:TableGrid> + </DataTemplate> </ContentControl.Resources> </ContentControl> </Grid> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml index 5f8cca8fe..180a2a8e0 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml @@ -7,6 +7,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:integration="clr-namespace:Tango.Integration.ExternalBridge;assembly=Tango.Integration" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:emulations="clr-namespace:Tango.Emulations.ExternalBridge;assembly=Tango.Emulations" xmlns:local="clr-namespace:Tango.MachineStudio.UI.Views" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300" Width="600" Height="400" Background="White" DataContext="{Binding MachineConnectionViewVM, Source={StaticResource Locator}}"> @@ -95,6 +96,25 @@ </StackPanel> </DockPanel> </DataTemplate> + <DataTemplate DataType="{x:Type emulations:EmulatorExternalBridge}"> + <DockPanel> + <StackPanel Orientation="Vertical" VerticalAlignment="Center" DockPanel.Dock="Right" ToolTip="Allow incoming diagnostics data"> + <ToggleButton IsChecked="{Binding EnableDiagnostics}" VerticalAlignment="Center"></ToggleButton> + <TextBlock VerticalAlignment="Center" FontSize="10">Diagnostics</TextBlock> + </StackPanel> + <StackPanel Orientation="Horizontal"> + <Image Source="/Images/external-bridge-emulator.png" Width="38" Height="38" RenderOptions.BitmapScalingMode="Fant"></Image> + <StackPanel Margin="10 0 0 0"> + <TextBlock FontSize="11"> + <Run Text="External Bridge Emulator"></Run> + </TextBlock> + <TextBlock FontSize="11"> + <Run FontWeight="Bold">Address:</Run> <Run Text="{Binding Adapter.Address,Mode=OneWay}"></Run> + </TextBlock> + </StackPanel> + </StackPanel> + </DockPanel> + </DataTemplate> </ListBox.Resources> </ListBox> 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 9a494f862..67bdf81ed 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml @@ -15,7 +15,7 @@ xmlns:local="clr-namespace:Tango.MachineStudio.UI.Views" xmlns:commonConverters="clr-namespace:Tango.MachineStudio.Common.Converters;assembly=Tango.MachineStudio.Common" mc:Ignorable="d" - d:DesignHeight="720" d:DesignWidth="1270" Background="Transparent" DataContext="{Binding MainViewVM, Source={StaticResource Locator}}"> + d:DesignHeight="720" d:DesignWidth="1270" Background="Transparent" DataContext="{Binding MainViewVM, Source={StaticResource Locator}}" x:Name="control"> <UserControl.Resources> <converters:StringEllipsisConverter x:Key="StringEllipsisConverter" /> @@ -161,7 +161,7 @@ </StackPanel> </Button> <Separator/> - <Button IsEnabled="{Binding IsModuleLoaded}" Command="{Binding OpenModuleInWindowCommand}" CommandParameter="{Binding CurrentModule}"> + <Button IsEnabled="{Binding IsModuleLoaded}" Command="{Binding OpenModuleInWindowCommand,Mode=TwoWay}" CommandParameter="{Binding CurrentModule}"> <StackPanel Orientation="Horizontal"> <materialDesign:PackIcon Kind="ArrowTopRight" Width="24" Height="24" /> <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">Open Module In New Window</TextBlock> @@ -440,7 +440,7 @@ <StackPanel Grid.Row="2" Margin="8" HorizontalAlignment="Right" Orientation="Horizontal"> <materialDesign:PopupBox Padding="2,0,2,0" Style="{StaticResource MaterialDesignToolPopupBox}"> <StackPanel> - <Button Command="{Binding RelativeSource={RelativeSource AncestorType=local:MainView},Path=DataContext.OpenModuleInWindowCommand}" CommandParameter="{Binding}"> + <Button Command="{Binding Source={x:Reference control},Path=DataContext.OpenModuleInWindowCommand}" CommandParameter="{Binding}"> <StackPanel Orientation="Horizontal"> <materialDesign:PackIcon Kind="ArrowTopRight" Width="24" Height="24" /> <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">Start in new window</TextBlock> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml index 52ba9ee18..6818d13cc 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/UpdateView.xaml @@ -108,6 +108,13 @@ <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">UPDATE</TextBlock> </StackPanel> </Button> + + <Button Visibility="{Binding IsRollbackAvailable,Converter={StaticResource BoolToVisConverter}}" MinWidth="140" Height="40" Style="{StaticResource MaterialDesignFlatButton}" ToolTip="Restore Machine Studio to the previous version." Margin="0 40 0 0" Command="{Binding RollbackCommand}" Foreground="#FF5F5F"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="BackupRestore" Width="24" Height="24" /> + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">Restore previous version</TextBlock> + </StackPanel> + </Button> </StackPanel> </Grid> </Setter.Value> @@ -177,6 +184,13 @@ <StackPanel Orientation="Horizontal"> <TextBlock VerticalAlignment="Center" Margin="0 20 0 0">Your version of Machine Studio is up to date!</TextBlock> </StackPanel> + + <Button Visibility="{Binding IsRollbackAvailable,Converter={StaticResource BoolToVisConverter}}" MinWidth="140" Height="40" Style="{StaticResource MaterialDesignFlatButton}" ToolTip="Restore Machine Studio to the previous version." Margin="0 40 0 0" Command="{Binding RollbackCommand}" Foreground="#FF5F5F"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="BackupRestore" Width="24" Height="24" /> + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">Restore previous version</TextBlock> + </StackPanel> + </Button> </StackPanel> </Grid> </Setter.Value> @@ -205,6 +219,66 @@ </Setter.Value> </Setter> </DataTrigger> + <DataTrigger Binding="{Binding Status}" Value="{x:Static vm:UpdateStatus.RollingBack}"> + <Setter Property="Content"> + <Setter.Value> + <Grid> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> + <TextBlock HorizontalAlignment="Center"> + <Run>Restoring previous version, please wait...</Run> + </TextBlock> + <ProgressBar Height="10" Foreground="DimGray" Margin="0 20 0 0" Maximum="100" Value="{Binding RollbackProgress}"></ProgressBar> + </StackPanel> + </Grid> + </Setter.Value> + </Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Status}" Value="{x:Static vm:UpdateStatus.RollbackError}"> + <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 restoring previous version</TextBlock> + <TextBlock HorizontalAlignment="Center" Margin="0 10 0 0" FontSize="12" TextAlignment="Center"> + <Run>An error occurred while restore the last version.</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 TryRollbackAgainCommand}"> + <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> + <DataTrigger Binding="{Binding Status}" Value="{x:Static vm:UpdateStatus.RollbackCompleted}"> + <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">Machine studio has been restored to the previous version!</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> </Style.Triggers> </Style> </ContentControl.Style> |
