From 53e512c8a54355eb0a05d400fa94da387bef63ad Mon Sep 17 00:00:00 2001 From: Jeremy Tellier - ROG Date: Tue, 27 Oct 2020 20:09:39 +0100 Subject: [PATCH] Widen Interface --- DesktopEdge/IdentityDetails.xaml | 4 +- DesktopEdge/MainMenu.xaml | 4 +- DesktopEdge/MainWindow.xaml | 20 +++-- DesktopEdge/MainWindow.xaml.cs | 85 +++++++++++++------ .../Views/ItemRenderers/IdentityItem.xaml | 2 +- 5 files changed, 75 insertions(+), 40 deletions(-) diff --git a/DesktopEdge/IdentityDetails.xaml b/DesktopEdge/IdentityDetails.xaml index d179f761..95ccf5ed 100644 --- a/DesktopEdge/IdentityDetails.xaml +++ b/DesktopEdge/IdentityDetails.xaml @@ -7,9 +7,9 @@ mc:Ignorable="d" x:Name="IdentityArea" d:DesignHeight="500" d:DesignWidth="350"> - + - + diff --git a/DesktopEdge/MainMenu.xaml b/DesktopEdge/MainMenu.xaml index 36ba6a25..9a430579 100644 --- a/DesktopEdge/MainMenu.xaml +++ b/DesktopEdge/MainMenu.xaml @@ -6,7 +6,7 @@ xmlns:local="clr-namespace:ZitiDesktopEdge" mc:Ignorable="d" x:Name="MainMenuArea" - d:DesignHeight="400" d:DesignWidth="350" Margin="1,1,1,1"> + d:DesignHeight="400" d:DesignWidth="400" Margin="1,1,1,1"> @@ -15,7 +15,7 @@ - + diff --git a/DesktopEdge/MainWindow.xaml b/DesktopEdge/MainWindow.xaml index 58284dd2..f1f82a74 100644 --- a/DesktopEdge/MainWindow.xaml +++ b/DesktopEdge/MainWindow.xaml @@ -8,7 +8,7 @@ ShowInTaskbar="False" x:Name="MainUI" Title="Ziti Desktop Edge" Height="520" - Width="350" ResizeMode="NoResize" + Width="400" ResizeMode="NoResize" ClipToBounds="False" Icon="Assets/Images/icon.png" AllowsTransparency="True" Closing="Window_Closing" @@ -105,7 +105,7 @@ - + @@ -137,13 +137,13 @@ - + - + @@ -152,7 +152,7 @@ - + @@ -163,7 +163,7 @@ - + @@ -217,14 +217,16 @@ + - + @@ -248,7 +250,7 @@ - + diff --git a/DesktopEdge/MainWindow.xaml.cs b/DesktopEdge/MainWindow.xaml.cs index 7528db6c..be868b12 100644 --- a/DesktopEdge/MainWindow.xaml.cs +++ b/DesktopEdge/MainWindow.xaml.cs @@ -22,6 +22,7 @@ namespace ZitiDesktopEdge { private System.Windows.Forms.Timer _timer; private Client serviceClient = null; private bool _isAttached = true; + private bool _isServiceInError = false; private int _right = 75; private int _bottom = 0; private double _maxHeight = 800d; @@ -94,6 +95,8 @@ namespace ZitiDesktopEdge { ErrorMsg.Content = msg; ErrorMsgDetail.Content = detailMessage; SetNotifyIcon("red"); + _isServiceInError = true; + UpdateServiceView(); } private void SetCantDisplay() { SetCantDisplay("Service Not Started", "Start the Ziti Tunnel Service to get started"); @@ -114,6 +117,27 @@ namespace ZitiDesktopEdge { this.Activate(); } + private void UpdateServiceView() { + if (_isServiceInError) { + AddIdAreaButton.Opacity = 0.1; + AddIdAreaButton.IsEnabled = false; + AddIdButton.Opacity = 0.1; + AddIdButton.IsEnabled = false; + DisconnectButton.Visibility = Visibility.Collapsed; + ConnectButton.Visibility = Visibility.Visible; + ConnectButton.Opacity = 0.1; + StatArea.Opacity = 0.1; + } else { + AddIdAreaButton.Opacity = 1.0; + AddIdAreaButton.IsEnabled = true; + AddIdButton.Opacity = 1.0; + AddIdButton.IsEnabled = true; + ConnectButton.Visibility = Visibility.Collapsed; + DisconnectButton.Visibility = Visibility.Visible; + StatArea.Opacity = 1.0; + } + } + private void MainWindow_Loaded(object sender, RoutedEventArgs e) { Placement(); // add a new service client @@ -155,6 +179,8 @@ namespace ZitiDesktopEdge { this.Dispatcher.Invoke(() => { //e is _ALWAYS_ null at this time use this to display something if you want NoServiceView.Visibility = Visibility.Collapsed; + _isServiceInError = false; + UpdateServiceView(); SetNotifyIcon("white"); LoadIdentities(true); }); @@ -288,6 +314,8 @@ namespace ZitiDesktopEdge { this.identities.Clear(); if (status != null) { + _isServiceInError = false; + UpdateServiceView(); NoServiceView.Visibility = Visibility.Collapsed; SetNotifyIcon("white"); if (status.Active) { @@ -438,12 +466,14 @@ namespace ZitiDesktopEdge { _timer.Start(); } private void Connect(object sender, RoutedEventArgs e) { - ShowLoad(); - this.Dispatcher.Invoke(() => { - //Dispatcher.Invoke(new Action(() => { }), System.Windows.Threading.DispatcherPriority.ContextIdle); - DoConnect(); - HideLoad(); - }); + if (!_isServiceInError) { + ShowLoad(); + this.Dispatcher.Invoke(() => { + //Dispatcher.Invoke(new Action(() => { }), System.Windows.Threading.DispatcherPriority.ContextIdle); + DoConnect(); + HideLoad(); + }); + } } private void DoConnect() { @@ -468,28 +498,30 @@ namespace ZitiDesktopEdge { } } private void Disconnect(object sender, RoutedEventArgs e) { - ShowLoad(); - try { - ConnectedTime.Content = "00:00:00"; - _timer.Stop(); - serviceClient.SetTunnelState(false); - SetNotifyIcon("white"); - ConnectButton.Visibility = Visibility.Visible; - DisconnectButton.Visibility = Visibility.Collapsed; - for (int i = 0; i < identities.Count; i++) { - serviceClient.IdentityOnOff(identities[i].Fingerprint, false); + if (!_isServiceInError) { + ShowLoad(); + try { + ConnectedTime.Content = "00:00:00"; + _timer.Stop(); + serviceClient.SetTunnelState(false); + SetNotifyIcon("white"); + ConnectButton.Visibility = Visibility.Visible; + DisconnectButton.Visibility = Visibility.Collapsed; + for (int i = 0; i < identities.Count; i++) { + serviceClient.IdentityOnOff(identities[i].Fingerprint, false); + } + for (int i = 0; i < IdList.Children.Count; i++) { + IdentityItem item = IdList.Children[i] as IdentityItem; + item._identity.IsEnabled = false; + item.RefreshUI(); + } + } catch (ServiceException se) { + ShowError(se.AdditionalInfo, se.Message); + } catch (Exception ex) { + ShowError("Unexpected Error", "Code 4:" + ex.Message); } - for (int i = 0; i < IdList.Children.Count; i++) { - IdentityItem item = IdList.Children[i] as IdentityItem; - item._identity.IsEnabled = false; - item.RefreshUI(); - } - } catch (ServiceException se) { - ShowError(se.AdditionalInfo, se.Message); - } catch (Exception ex) { - ShowError("Unexpected Error", "Code 4:"+ex.Message); + HideLoad(); } - HideLoad(); } private void ShowLoad() { @@ -523,6 +555,7 @@ namespace ZitiDesktopEdge { private void CloseError(object sender, MouseButtonEventArgs e) { ErrorView.Visibility = Visibility.Collapsed; + NoServiceView.Visibility = Visibility.Collapsed; } private void CloseApp(object sender, MouseButtonEventArgs e) { diff --git a/DesktopEdge/Views/ItemRenderers/IdentityItem.xaml b/DesktopEdge/Views/ItemRenderers/IdentityItem.xaml index 611562ba..e8a4b9f1 100644 --- a/DesktopEdge/Views/ItemRenderers/IdentityItem.xaml +++ b/DesktopEdge/Views/ItemRenderers/IdentityItem.xaml @@ -8,7 +8,7 @@ d:DesignHeight="64" d:DesignWidth="375" Height="64"> - +