mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-05-31 22:40:48 +00:00
cache window positions so we only have to move after open once.
This commit is contained in:
parent
3a3a23db34
commit
adb7a88836
@ -20,9 +20,7 @@
|
|||||||
<Grid>
|
<Grid>
|
||||||
<tb:TaskbarIcon x:Name="MyNotifyIcon"
|
<tb:TaskbarIcon x:Name="MyNotifyIcon"
|
||||||
IconSource="ZeroTierIcon.ico"
|
IconSource="ZeroTierIcon.ico"
|
||||||
ToolTipText="ZeroTier One"
|
ToolTipText="ZeroTier One">
|
||||||
TrayContextMenuOpen="ToolbarItem_TrayContextMenuOpen"
|
|
||||||
PreviewTrayContextMenuOpen="ToolbarItem_PreviewTrayContextMenuOpen">
|
|
||||||
<tb:TaskbarIcon.ContextMenu>
|
<tb:TaskbarIcon.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<ContextMenu.ItemsSource>
|
<ContextMenu.ItemsSource>
|
||||||
|
@ -29,6 +29,11 @@ namespace WinUI
|
|||||||
{
|
{
|
||||||
private APIHandler handler = APIHandler.Instance;
|
private APIHandler handler = APIHandler.Instance;
|
||||||
|
|
||||||
|
private Point netListLocation = new Point(0, 0);
|
||||||
|
private Point joinNetLocation = new Point(0, 0);
|
||||||
|
private Point aboutViewLocation = new Point(0, 0);
|
||||||
|
private Point prefsViewLocation = new Point(0, 0);
|
||||||
|
|
||||||
private NetworkListView netListView = new NetworkListView();
|
private NetworkListView netListView = new NetworkListView();
|
||||||
private JoinNetworkView joinNetView = null;
|
private JoinNetworkView joinNetView = null;
|
||||||
private AboutView aboutView = null;
|
private AboutView aboutView = null;
|
||||||
@ -101,16 +106,6 @@ namespace WinUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToolbarItem_TrayContextMenuOpen(object sender, System.Windows.RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
Console.WriteLine("TrayContextMenuOpen");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ToolbarItem_PreviewTrayContextMenuOpen(object sender, System.Windows.RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
Console.WriteLine("PreviewTrayContextMenuOpen");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ToolbarItem_NodeIDClicked(object sender, System.Windows.RoutedEventArgs e)
|
private void ToolbarItem_NodeIDClicked(object sender, System.Windows.RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Clipboard.SetText(nodeId);
|
Clipboard.SetText(nodeId);
|
||||||
@ -124,9 +119,22 @@ namespace WinUI
|
|||||||
netListView.Closed += ShowNetworksClosed;
|
netListView.Closed += ShowNetworksClosed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool netListNeedsMoving = true;
|
||||||
|
if (netListLocation.X > 0 && netListLocation.Y > 0)
|
||||||
|
{
|
||||||
|
netListView.Left = netListLocation.X;
|
||||||
|
netListView.Top = netListLocation.Y;
|
||||||
|
netListNeedsMoving = false;
|
||||||
|
}
|
||||||
|
|
||||||
netListView.Show();
|
netListView.Show();
|
||||||
|
|
||||||
setWindowPosition(netListView);
|
if (netListNeedsMoving)
|
||||||
|
{
|
||||||
|
setWindowPosition(netListView);
|
||||||
|
netListLocation.X = netListView.Left;
|
||||||
|
netListLocation.Y = netListView.Top;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowNetworksClosed(object sender, System.EventArgs e)
|
private void ShowNetworksClosed(object sender, System.EventArgs e)
|
||||||
@ -141,9 +149,22 @@ namespace WinUI
|
|||||||
joinNetView = new JoinNetworkView();
|
joinNetView = new JoinNetworkView();
|
||||||
joinNetView.Closed += JoinNetworkClosed;
|
joinNetView.Closed += JoinNetworkClosed;
|
||||||
|
|
||||||
|
bool needsMove = true;
|
||||||
|
if (joinNetLocation.X > 0 && joinNetLocation.Y > 0)
|
||||||
|
{
|
||||||
|
joinNetView.Left = joinNetLocation.X;
|
||||||
|
joinNetView.Top = joinNetLocation.Y;
|
||||||
|
needsMove = false;
|
||||||
|
}
|
||||||
|
|
||||||
joinNetView.Show();
|
joinNetView.Show();
|
||||||
|
|
||||||
setWindowPosition(joinNetView);
|
if (needsMove)
|
||||||
|
{
|
||||||
|
setWindowPosition(joinNetView);
|
||||||
|
joinNetLocation.X = joinNetView.Left;
|
||||||
|
joinNetLocation.Y = joinNetView.Top;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,8 +180,22 @@ namespace WinUI
|
|||||||
aboutView = new AboutView();
|
aboutView = new AboutView();
|
||||||
aboutView.Closed += AboutClosed;
|
aboutView.Closed += AboutClosed;
|
||||||
|
|
||||||
|
bool needsMove = true;
|
||||||
|
if (aboutViewLocation.X > 0 && aboutViewLocation.Y > 0)
|
||||||
|
{
|
||||||
|
aboutView.Left = aboutViewLocation.X;
|
||||||
|
aboutView.Top = aboutViewLocation.Y;
|
||||||
|
needsMove = false;
|
||||||
|
}
|
||||||
|
|
||||||
aboutView.Show();
|
aboutView.Show();
|
||||||
setWindowPosition(aboutView);
|
|
||||||
|
if (needsMove)
|
||||||
|
{
|
||||||
|
setWindowPosition(aboutView);
|
||||||
|
aboutViewLocation.X = aboutView.Left;
|
||||||
|
aboutViewLocation.Y = aboutView.Top;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,9 +211,22 @@ namespace WinUI
|
|||||||
prefsView = new PreferencesView();
|
prefsView = new PreferencesView();
|
||||||
prefsView.Closed += PreferencesClosed;
|
prefsView.Closed += PreferencesClosed;
|
||||||
|
|
||||||
|
bool needsMove = true;
|
||||||
|
if (prefsViewLocation.X > 0 && prefsViewLocation.Y > 0)
|
||||||
|
{
|
||||||
|
prefsView.Left = prefsViewLocation.X;
|
||||||
|
prefsView.Top = prefsViewLocation.Y;
|
||||||
|
needsMove = false;
|
||||||
|
}
|
||||||
|
|
||||||
prefsView.Show();
|
prefsView.Show();
|
||||||
|
|
||||||
setWindowPosition(prefsView);
|
if (needsMove)
|
||||||
|
{
|
||||||
|
setWindowPosition(prefsView);
|
||||||
|
prefsViewLocation.X = prefsView.Left;
|
||||||
|
prefsViewLocation.Y = prefsView.Top;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user