Widen Interface

This commit is contained in:
Jeremy Tellier - ROG
2020-10-27 20:09:39 +01:00
parent 41e73a5c7c
commit 53e512c8a5
5 changed files with 75 additions and 40 deletions
+2 -2
View File
@@ -7,9 +7,9 @@
mc:Ignorable="d"
x:Name="IdentityArea"
d:DesignHeight="500" d:DesignWidth="350">
<Grid MaxWidth="350">
<Grid MaxWidth="400">
<Canvas>
<Rectangle Name="Arrow" HorizontalAlignment="Center" Height="20" Fill="White" Width="20" Canvas.Left="165" ClipToBounds="True" Canvas.Bottom="-10">
<Rectangle Name="Arrow" HorizontalAlignment="Center" Height="20" Fill="White" Width="20" Canvas.Left="185" ClipToBounds="True" Canvas.Bottom="-10">
<Rectangle.LayoutTransform>
<RotateTransform Angle="-45"/>
</Rectangle.LayoutTransform>
+2 -2
View File
@@ -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">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
@@ -15,7 +15,7 @@
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Canvas>
<Rectangle Name="Arrow" HorizontalAlignment="Center" Height="20" Fill="White" VerticalAlignment="Bottom" Width="20" Canvas.Bottom="-10" Canvas.Left="165">
<Rectangle Name="Arrow" HorizontalAlignment="Center" Height="20" Fill="White" VerticalAlignment="Bottom" Width="20" Canvas.Bottom="-10" Canvas.Left="185">
<Rectangle.LayoutTransform>
<RotateTransform Angle="-45"/>
</Rectangle.LayoutTransform>
+11 -9
View File
@@ -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 @@
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Canvas ClipToBounds="False">
<Rectangle Name="Arrow" HorizontalAlignment="Center" Height="20" Fill="#070826" Width="20" ClipToBounds="True" Canvas.Left="165" Canvas.Bottom="-10">
<Rectangle Name="Arrow" HorizontalAlignment="Center" Height="20" Fill="#070826" Width="20" ClipToBounds="True" Canvas.Left="185" Canvas.Bottom="-10">
<Rectangle.LayoutTransform>
<RotateTransform Angle="-45"/>
</Rectangle.LayoutTransform>
@@ -137,13 +137,13 @@
<Image Source="/Assets/Images/z.png" Height="40" RenderOptions.BitmapScalingMode="Fant"></Image>
<Label Content="Tap to Connect" MouseDoubleClick="Label_MouseDoubleClick" Margin="0,-3,0,0" FontFamily="pack://application:,,,/Assets/Fonts/#Russo One" FontSize="14" Foreground="White" HorizontalAlignment="Center"></Label>
</StackPanel>
<StackPanel Grid.Column="2" Cursor="Hand" Orientation="Vertical" Margin="14,16,14,14" MouseLeftButtonDown="AddIdentity">
<StackPanel x:Name="AddIdAreaButton" Grid.Column="2" Cursor="Hand" Orientation="Vertical" Margin="14,16,14,14" MouseLeftButtonDown="AddIdentity">
<Image Source="/Assets/Images/identity.png" Margin="0,0,5,-4" Width="26" Height="26" HorizontalAlignment="Right"></Image>
<Label Content="ADD" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" Foreground="White" Height="25" FontSize="10" HorizontalAlignment="Right"></Label>
<Label Content="IDENTITY" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" Foreground="White" Height="25" Margin="0,-14,0,0" FontSize="10" HorizontalAlignment="Right"></Label>
</StackPanel>
</Grid>
<Canvas Name="ConnectButton" Width="350" Height="160" MouseDown="Connect" Visibility="Visible">
<Canvas Name="ConnectButton" Width="400" Height="160" MouseDown="Connect" Visibility="Visible">
<Grid Width="{Binding ActualWidth, ElementName=ConnectButton}" Height="140">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="221*"/>
@@ -152,7 +152,7 @@
<Image Source="/Assets/Images/connect.png" Height="140" HorizontalAlignment="Center" Grid.ColumnSpan="2" Margin="105,0" />
</Grid>
</Canvas>
<Canvas Name="DisconnectButton" Width="350" Height="160" MouseDown="Disconnect" Visibility="Collapsed">
<Canvas Name="DisconnectButton" Width="400" Height="160" MouseDown="Disconnect" Visibility="Collapsed">
<Grid Width="{Binding ActualWidth, ElementName=DisconnectButton}" Height="140">
<Image Source="/Assets/Images/connected.png" Height="140" HorizontalAlignment="Center" />
</Grid>
@@ -163,7 +163,7 @@
<Label HorizontalAlignment="Center" Content="STOP" Foreground="White" Padding="0,105,0,0"/>
</Grid>
</Canvas>
<Grid HorizontalAlignment="Stretch" Width="Auto" Margin="0,30,0,0">
<Grid x:Name="StatArea" HorizontalAlignment="Stretch" Width="Auto" Margin="0,30,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
@@ -217,14 +217,16 @@
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Label x:Name="ErrorMsg" Foreground="White" Content="Service Not Started" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="24" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans"/>
<Label x:Name="ErrorMsgDetail" Foreground="LightGray" Content="Start the Ziti Tunnel Service to get started" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans"/>
<Label Name="QuitButton" Grid.Row="3" Foreground="#F4044D" FontWeight="SemiBold" Content="Quit Ziti Desktop Edge" Cursor="Hand" MouseDown="CloseApp" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" HorizontalAlignment="Center"></Label>
<Label Name="CloseServiceErrorButton" Grid.Row="3" Foreground="#F4044D" FontWeight="SemiBold" Content="Close" Cursor="Hand" MouseDown="CloseError" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" HorizontalAlignment="Center"></Label>
<Label Name="QuitButton" Grid.Row="4" Foreground="#F4044D" FontWeight="SemiBold" Content="Quit Ziti Desktop Edge" Cursor="Hand" MouseDown="CloseApp" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" HorizontalAlignment="Center"></Label>
</Grid>
</Grid>
<Grid x:Name="LoadingScreen" Visibility="Collapsed" Width="350">
<Grid x:Name="LoadingScreen" Visibility="Collapsed" Width="400">
<Rectangle RadiusX="10" RadiusY="10">
<Rectangle.Fill>
<SolidColorBrush Color="Black" Opacity="0.9"/>
@@ -248,7 +250,7 @@
<ProgressBar x:Name="LoadProgress" Width="100" Grid.Row="3" IsEnabled="True" />
</Grid>
</Grid>
<Grid x:Name="ErrorView" Visibility="Collapsed" Width="350">
<Grid x:Name="ErrorView" Visibility="Collapsed" Width="400">
<Rectangle RadiusX="10" RadiusY="10">
<Rectangle.Fill>
<SolidColorBrush Color="Black" Opacity="0.9"/>
+59 -26
View File
@@ -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) {
@@ -8,7 +8,7 @@
d:DesignHeight="64" d:DesignWidth="375" Height="64">
<Canvas MouseEnter="Canvas_MouseEnter" MouseLeave="Canvas_MouseLeave">
<Rectangle Fill="#0F0C28" HorizontalAlignment="Left" Stroke="Black" VerticalAlignment="Top" ClipToBounds="True"></Rectangle>
<Rectangle Name="OverState" Fill="#FFFFFF" Height="64" Width="375" Opacity="0" ClipToBounds="True" Cursor="Hand"></Rectangle>
<Rectangle Name="OverState" Fill="#FFFFFF" Height="64" Width="400" Opacity="0" ClipToBounds="True" Cursor="Hand"></Rectangle>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>