mirror of
https://github.com/openziti/desktop-edge-win.git
synced 2026-10-14 08:39:55 +00:00
Notify Area Show and Timer
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
|
||||
@@ -1,15 +1,35 @@
|
||||
<Window x:Name="MainWindow1" x:Class="ZitiTunneler.MainWindow"
|
||||
<Window x:Class="ZitiTunneler.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:ZitiTunneler"
|
||||
mc:Ignorable="d"
|
||||
ShowInTaskbar="True"
|
||||
ShowInTaskbar="False"
|
||||
x:Name="MainUI"
|
||||
Title="MainWindow" Height="510"
|
||||
Width="375" ResizeMode="NoResize"
|
||||
Icon="Assets/Images/icon.png" AllowsTransparency="True"
|
||||
Closing="Window_Closing"
|
||||
WindowStyle="None" Loaded="MainWindow1_Loaded" Background="#000F0F23">
|
||||
<Window.Triggers>
|
||||
<EventTrigger RoutedEvent="Window.Loaded">
|
||||
<BeginStoryboard>
|
||||
<Storyboard Name="FormFade">
|
||||
<DoubleAnimation Name="FormFadeAnimation" Storyboard.TargetName="MainUI" Storyboard.TargetProperty="(Window.Opacity)" From="0.0" To="1.0" Duration="0:0:.5" AutoReverse="False" RepeatBehavior="1x" />
|
||||
<DoubleAnimation Name="FormGrowAnimation" Storyboard.TargetName="MainUI" Storyboard.TargetProperty="(Window.Height)" From="300" To="575" Duration="0:0:.5" AutoReverse="False" RepeatBehavior="1x" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
<EventTrigger RoutedEvent="Window.Unloaded">
|
||||
<BeginStoryboard>
|
||||
<Storyboard Name="FormFadeOut" Completed="FormFadeOut_Completed">
|
||||
<DoubleAnimation Name="FormGrowOutAnimation" Storyboard.TargetName="MainUI" Storyboard.TargetProperty="(Window.Height)" From="575" To="200" Duration="0:0:.5" AutoReverse="False" RepeatBehavior="1x" />
|
||||
<DoubleAnimation Name="FormFadeOutAnimation" Storyboard.TargetName="MainUI" Storyboard.TargetProperty="(Window.Opacity)" From="1.0" To="0.0" Duration="0:0:.5" AutoReverse="False" RepeatBehavior="1x" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
</Window.Triggers>
|
||||
<Window.Resources>
|
||||
<Storyboard x:Key="gridFadeInStoryBoard">
|
||||
<DoubleAnimation Storyboard.TargetName="UIMain" BeginTime="0:0:0.1" Storyboard.TargetProperty="Opacity" From="0.00" To="1.00" AutoReverse="False" Duration="0:0:0.3" />
|
||||
@@ -26,7 +46,7 @@
|
||||
</Rectangle>
|
||||
<Border Name="UIBorder" Width="375" Height="510" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderBrush="Black" BorderThickness="3" CornerRadius="10">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect />
|
||||
<DropShadowEffect BlurRadius="15" Direction="0" RenderingBias="Quality" ShadowDepth="2" Opacity="0.2"/>
|
||||
</Border.Effect>
|
||||
</Border>
|
||||
<Rectangle Name="BgColor" Width="375" Height="510" Stroke="Black" RadiusY="10" RadiusX="10" ClipToBounds="True">
|
||||
@@ -56,20 +76,22 @@
|
||||
<Label Content="IDENTITY" FontFamily="pack://application:,,,/Assets/Fonts/#Open Sans" Foreground="White" Height="25" Margin="0,-14,0,0" FontSize="12" HorizontalAlignment="Right"></Label>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Button Name="ConnectButton" Height="160" Click="Connect">
|
||||
<Button.Template>
|
||||
<ControlTemplate>
|
||||
<Image Source="/Assets/Images/connect.png" />
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
<Button Name="DisconnectButton" Height="160" Click="Disconnect" Visibility="Collapsed">
|
||||
<Button.Template>
|
||||
<ControlTemplate>
|
||||
<Image Source="/Assets/Images/connected.png" />
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
<Canvas Name="ConnectButton" Width="375" Height="160" MouseDown="Connect" Visibility="Visible">
|
||||
<Grid Width="{Binding ActualWidth, ElementName=ConnectButton}" Height="180">
|
||||
<Image Source="/Assets/Images/connect.png" Height="180" HorizontalAlignment="Center" />
|
||||
</Grid>
|
||||
</Canvas>
|
||||
<Canvas Name="DisconnectButton" Width="375" Height="160" MouseDown="Disconnect" Visibility="Collapsed">
|
||||
<Grid Width="{Binding ActualWidth, ElementName=DisconnectButton}" Height="180">
|
||||
<Image Source="/Assets/Images/connected.png" Height="180" HorizontalAlignment="Center" />
|
||||
</Grid>
|
||||
<Grid Width="{Binding ActualWidth, ElementName=DisconnectButton}" Height="180">
|
||||
<Label Name="ConnectedTime" HorizontalAlignment="Center" Content="00:00:00" Foreground="White" Padding="0,115,0,0"/>
|
||||
</Grid>
|
||||
<Grid Width="{Binding ActualWidth, ElementName=DisconnectButton}" Height="180">
|
||||
<Label HorizontalAlignment="Center" Content="STOP" Foreground="White" Padding="0,130,0,0"/>
|
||||
</Grid>
|
||||
</Canvas>
|
||||
<Grid HorizontalAlignment="Stretch" Width="Auto" Margin="0,30,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace ZitiTunneler {
|
||||
public partial class MainWindow:Window {
|
||||
|
||||
public NotifyIcon notifyIcon;
|
||||
private DateTime _startDate;
|
||||
private Timer _timer;
|
||||
|
||||
private List<ZitiIdentity> identities = new List<ZitiIdentity>();
|
||||
private List<ZitiService> services = new List<ZitiService>();
|
||||
@@ -36,6 +38,7 @@ namespace ZitiTunneler {
|
||||
notifyIcon = new NotifyIcon();
|
||||
notifyIcon.Visible = true;
|
||||
notifyIcon.Click += TargetNotifyIcon_Click;
|
||||
notifyIcon.Visible = true;
|
||||
|
||||
SetNotifyIcon("white");
|
||||
|
||||
@@ -43,14 +46,22 @@ namespace ZitiTunneler {
|
||||
}
|
||||
|
||||
private void TargetNotifyIcon_Click(object sender, EventArgs e) {
|
||||
this.Show();
|
||||
this.Activate();
|
||||
/*
|
||||
if (App.Current.MainWindow.WindowState==WindowState.Minimized) {
|
||||
App.Current.MainWindow.WindowState = WindowState.Normal;
|
||||
App.Current.MainWindow.BringIntoView();
|
||||
//App.Current.MainWindow.BringIntoView();
|
||||
App.Current.MainWindow.Show();
|
||||
App.Current.MainWindow.Activate();
|
||||
//this.Opacity = 1;
|
||||
//this.Activate();
|
||||
} else {
|
||||
App.Current.MainWindow.WindowState = WindowState.Minimized;
|
||||
this.Close();
|
||||
//this.Opacity = 0;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private void MainWindow1_Loaded(object sender, RoutedEventArgs e) {
|
||||
@@ -87,6 +98,8 @@ namespace ZitiTunneler {
|
||||
}
|
||||
UIMain.Height = 480+(identities.Count*60);
|
||||
BgColor.Height = 480+(identities.Count*60);
|
||||
FormGrowAnimation.To = UIMain.Height;
|
||||
FormGrowOutAnimation.From = BgColor.Height;
|
||||
App.Current.MainWindow.Height = 490+(identities.Count*60);
|
||||
var desktopWorkingArea = System.Windows.SystemParameters.WorkArea;
|
||||
this.Left = desktopWorkingArea.Right-this.Width-25;
|
||||
@@ -114,13 +127,46 @@ namespace ZitiTunneler {
|
||||
|
||||
private void Connect(object sender, RoutedEventArgs e) {
|
||||
SetNotifyIcon("green");
|
||||
_startDate = DateTime.Now;
|
||||
_timer = new Timer();
|
||||
_timer.Interval = 1000;
|
||||
_timer.Tick += OnTimedEvent;
|
||||
_timer.Enabled = true;
|
||||
_timer.Start();
|
||||
ConnectButton.Visibility = Visibility.Collapsed;
|
||||
DisconnectButton.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void OnTimedEvent(object sender, EventArgs e) {
|
||||
TimeSpan span = (DateTime.Now - _startDate);
|
||||
int hours = span.Hours;
|
||||
int minutes = span.Minutes;
|
||||
int seconds = span.Seconds;
|
||||
var hoursString = (hours>9)?hours.ToString():"0"+hours;
|
||||
var minutesString = (minutes>9)? minutes.ToString():"0"+minutes;
|
||||
var secondsString = (seconds>9) ? seconds.ToString() : "0"+seconds;
|
||||
ConnectedTime.Content = hoursString+":"+minutesString+":"+secondsString;
|
||||
}
|
||||
|
||||
private void Disconnect(object sender, RoutedEventArgs e) {
|
||||
_timer.Stop();
|
||||
SetNotifyIcon("white");
|
||||
ConnectButton.Visibility = Visibility.Visible;
|
||||
DisconnectButton.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void FormFadeOut_Completed(object sender, EventArgs e) {
|
||||
closeCompleted = true;
|
||||
//this.Close();
|
||||
}
|
||||
private bool closeCompleted = false;
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
|
||||
if (!closeCompleted) {
|
||||
FormFadeOut.Begin();
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>ZitiTunneler</RootNamespace>
|
||||
<AssemblyName>ZitiTunneler</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
||||
Reference in New Issue
Block a user