diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-12-18 07:09:51 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-12-18 07:09:51 +0200 |
| commit | dcf222f6811d4a4dcda7f517f61e22e3c5ac0e7e (patch) | |
| tree | d492cbde97b4d4c6893f4217b07336edc077dec5 /Software/Visual_Studio/StubsUtils/Tango.StubsUtils.Service.UI | |
| parent | 3cdb90407e360a8b820058d8b10651b24bf70599 (diff) | |
| download | Tango-dcf222f6811d4a4dcda7f517f61e22e3c5ac0e7e.tar.gz Tango-dcf222f6811d4a4dcda7f517f61e22e3c5ac0e7e.zip | |
Stubs Utils.
Diffstat (limited to 'Software/Visual_Studio/StubsUtils/Tango.StubsUtils.Service.UI')
4 files changed, 44 insertions, 0 deletions
diff --git a/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.Service.UI/App.xaml.cs b/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.Service.UI/App.xaml.cs index 2f7861a97..d223c6067 100644 --- a/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.Service.UI/App.xaml.cs +++ b/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.Service.UI/App.xaml.cs @@ -77,6 +77,13 @@ namespace Tango.StubsUtils.Service.UI "The calling thread must be STA, because many UI components require this." }; + String exceptionString = e.Exception.ToStringSafe(); + + if (ignoredExceptions.Exists(x => exceptionString.Contains(x))) + { + return; + } + LogManager.Log(e.Exception, LogCategory.Critical, "Unexpected Application Error."); Application.Current.Dispatcher.Invoke(() => diff --git a/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.Service.UI/Resources/Styles.xaml b/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.Service.UI/Resources/Styles.xaml index e47e4594c..2698c7bc7 100644 --- a/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.Service.UI/Resources/Styles.xaml +++ b/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.Service.UI/Resources/Styles.xaml @@ -13,4 +13,14 @@ </Style.Triggers> </Style> + <Style x:Key="FSE_FlatButton_OpacityHover" TargetType="Button" BasedOn="{StaticResource MaterialDesignToolForegroundButton}"> + <Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter> + <Setter Property="Foreground" Value="{StaticResource FSE_PrimaryAccentBrush}"></Setter> + <Style.Triggers> + <Trigger Property="IsMouseOver" Value="True"> + <Setter Property="Opacity" Value="0.6"></Setter> + </Trigger> + </Style.Triggers> + </Style> + </ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.Service.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.Service.UI/ViewModels/MainViewVM.cs index 16078fc47..361f85e41 100644 --- a/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.Service.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.Service.UI/ViewModels/MainViewVM.cs @@ -1,6 +1,7 @@ using Notifications.Wpf; using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO.Ports; using System.Linq; using System.Text; @@ -73,6 +74,7 @@ namespace Tango.StubsUtils.Service.UI.ViewModels public RelayCommand RefreshPortsCommand { get; set; } public RelayCommand ToggleConnectionCommand { get; set; } public RelayCommand ClearLogCommand { get; set; } + public RelayCommand StartPerformanceTesterCommand { get; set; } public MainViewVM() { @@ -82,6 +84,7 @@ namespace Tango.StubsUtils.Service.UI.ViewModels AvailablePorts = new List<string>(); RefreshPortsCommand = new RelayCommand(RefreshPorts); ToggleConnectionCommand = new RelayCommand(ToggleConnection); + StartPerformanceTesterCommand = new RelayCommand(StartPerformanceTester); ClearLogCommand = new RelayCommand(ClearLog); _logsQueue = new ProducerConsumerQueue<string>(); @@ -110,6 +113,7 @@ namespace Tango.StubsUtils.Service.UI.ViewModels RefreshPorts(); Service = new StubsService(); + Service.CommunicationFailed += Service_CommunicationFailed; await Service.Start(); if (Settings.AutoConnect) @@ -124,6 +128,22 @@ namespace Tango.StubsUtils.Service.UI.ViewModels } } + private void Service_CommunicationFailed(object sender, EventArgs e) + { + if (IsTrayIconVisible) + { + InvokeUI(() => + { + _notification.Show(new NotificationContent() + { + Title = "Tango Stubs Service", + Message = $"Communication Error", + Type = NotificationType.Error + }); + }); + } + } + private void Logger_LogReceived(object sender, LogItemBase e) { String message = e.TimeStamp.ToString("HH:mm:ss.ff") + ": " + e.Message; @@ -269,5 +289,10 @@ namespace Tango.StubsUtils.Service.UI.ViewModels Settings.USBPort = SelectedPort; Settings.Save(); } + + private void StartPerformanceTester() + { + Process.Start("tangostub_perf.exe"); + } } } diff --git a/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.Service.UI/Views/MainView.xaml b/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.Service.UI/Views/MainView.xaml index 667a25502..6eaf8d3a7 100644 --- a/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.Service.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.Service.UI/Views/MainView.xaml @@ -111,6 +111,8 @@ Auto Connect on Startup </TextBlock> </CheckBox> + + <Button Margin="20 -1 0 0" IsEnabled="{Binding Service.IsConnected}" Command="{Binding StartPerformanceTesterCommand}" Height="Auto" Style="{StaticResource FSE_FlatButton_OpacityHover}" FontSize="{StaticResource FSE_SmallFontSize}">Start Performance Tester</Button> </StackPanel> <DockPanel Margin="0 10 0 0" > |
