mirror of
https://github.com/2dust/v2rayN.git
synced 2025-04-20 06:02:23 +00:00
Fixed the issue of save window size when exit
https://github.com/2dust/v2rayN/issues/6251
This commit is contained in:
parent
78a28fbdb3
commit
a28cef5b98
8 changed files with 25 additions and 44 deletions
|
@ -6,6 +6,7 @@
|
||||||
SendMsgView,
|
SendMsgView,
|
||||||
SendSnackMsg,
|
SendSnackMsg,
|
||||||
RefreshProfiles,
|
RefreshProfiles,
|
||||||
StopSpeedtest
|
StopSpeedtest,
|
||||||
|
AppExit
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -160,9 +160,9 @@ namespace ServiceLib.ViewModels
|
||||||
var configDirZipTemp = Utils.GetTempPath($"v2rayN_{DateTime.Now:yyyyMMddHHmmss}");
|
var configDirZipTemp = Utils.GetTempPath($"v2rayN_{DateTime.Now:yyyyMMddHHmmss}");
|
||||||
var configDirTemp = Path.Combine(configDirZipTemp, _guiConfigs);
|
var configDirTemp = Path.Combine(configDirZipTemp, _guiConfigs);
|
||||||
|
|
||||||
await Task.Run(() => FileManager.CopyDirectory(configDir, configDirTemp, false, "cache.db"));
|
FileManager.CopyDirectory(configDir, configDirTemp, false, "cache.db");
|
||||||
var ret = await Task.Run(() => FileManager.CreateFromDirectory(configDirZipTemp, fileName));
|
var ret = FileManager.CreateFromDirectory(configDirZipTemp, fileName);
|
||||||
await Task.Run(() => Directory.Delete(configDirZipTemp, true));
|
Directory.Delete(configDirZipTemp, true);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,6 +283,7 @@ namespace ServiceLib.ViewModels
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Logging.SaveLog("MyAppExitAsync Begin");
|
Logging.SaveLog("MyAppExitAsync Begin");
|
||||||
|
MessageBus.Current.SendMessage("", EMsgCommand.AppExit.ToString());
|
||||||
|
|
||||||
await ConfigHandler.SaveConfig(_config);
|
await ConfigHandler.SaveConfig(_config);
|
||||||
await SysProxyHandler.UpdateSysProxy(_config, true);
|
await SysProxyHandler.UpdateSysProxy(_config, true);
|
||||||
|
|
|
@ -156,6 +156,7 @@ namespace v2rayN.Desktop.Views
|
||||||
RestoreUI();
|
RestoreUI();
|
||||||
AddHelpMenuItem();
|
AddHelpMenuItem();
|
||||||
//WindowsHandler.Instance.RegisterGlobalHotkey(_config, OnHotkeyHandler, null);
|
//WindowsHandler.Instance.RegisterGlobalHotkey(_config, OnHotkeyHandler, null);
|
||||||
|
MessageBus.Current.Listen<string>(EMsgCommand.AppExit.ToString()).Subscribe(StorageUI);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Event
|
#region Event
|
||||||
|
@ -441,7 +442,7 @@ namespace v2rayN.Desktop.Views
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StorageUI()
|
private void StorageUI(string? n = null)
|
||||||
{
|
{
|
||||||
_config.UiItem.MainWidth = Utils.ToInt(this.Width);
|
_config.UiItem.MainWidth = Utils.ToInt(this.Width);
|
||||||
_config.UiItem.MainHeight = Utils.ToInt(this.Height);
|
_config.UiItem.MainHeight = Utils.ToInt(this.Height);
|
||||||
|
@ -456,7 +457,6 @@ namespace v2rayN.Desktop.Views
|
||||||
_config.UiItem.MainGirdHeight1 = Math.Ceiling(gridMain1.RowDefinitions[0].ActualHeight + 0.1);
|
_config.UiItem.MainGirdHeight1 = Math.Ceiling(gridMain1.RowDefinitions[0].ActualHeight + 0.1);
|
||||||
_config.UiItem.MainGirdHeight2 = Math.Ceiling(gridMain1.RowDefinitions[2].ActualHeight + 0.1);
|
_config.UiItem.MainGirdHeight2 = Math.Ceiling(gridMain1.RowDefinitions[2].ActualHeight + 0.1);
|
||||||
}
|
}
|
||||||
ConfigHandler.SaveConfig(_config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddHelpMenuItem()
|
private void AddHelpMenuItem()
|
||||||
|
|
|
@ -56,28 +56,23 @@
|
||||||
Foreground="{DynamicResource ButtonDefaultTertiaryForeground}" />
|
Foreground="{DynamicResource ButtonDefaultTertiaryForeground}" />
|
||||||
</Button.Content>
|
</Button.Content>
|
||||||
</Button>
|
</Button>
|
||||||
<SplitButton
|
|
||||||
|
<Button
|
||||||
x:Name="btnAutofitColumnWidth"
|
x:Name="btnAutofitColumnWidth"
|
||||||
Width="54"
|
Width="30"
|
||||||
Height="30"
|
Height="30"
|
||||||
Margin="20,0"
|
Margin="4,0"
|
||||||
Padding="2"
|
Classes="Success"
|
||||||
Classes="Tertiary"
|
Theme="{DynamicResource BorderlessButton}"
|
||||||
Theme="{DynamicResource BorderlessSplitButton}"
|
|
||||||
ToolTip.Tip="{x:Static resx:ResUI.menuProfileAutofitColumnWidth}">
|
ToolTip.Tip="{x:Static resx:ResUI.menuProfileAutofitColumnWidth}">
|
||||||
<SplitButton.Content>
|
<Button.Content>
|
||||||
<PathIcon
|
<PathIcon
|
||||||
Width="24"
|
Width="24"
|
||||||
Height="24"
|
Height="24"
|
||||||
Data="{StaticResource building_fit}"
|
Data="{StaticResource building_fit}"
|
||||||
Foreground="{DynamicResource ButtonDefaultTertiaryForeground}" />
|
Foreground="{DynamicResource ButtonDefaultTertiaryForeground}" />
|
||||||
</SplitButton.Content>
|
</Button.Content>
|
||||||
<SplitButton.Flyout>
|
</Button>
|
||||||
<MenuFlyout>
|
|
||||||
<MenuItem Name="menuStorageUI" Header="{x:Static resx:ResUI.menuStorageUI}" />
|
|
||||||
</MenuFlyout>
|
|
||||||
</SplitButton.Flyout>
|
|
||||||
</SplitButton>
|
|
||||||
|
|
||||||
<TextBox
|
<TextBox
|
||||||
x:Name="txtServerFilter"
|
x:Name="txtServerFilter"
|
||||||
|
|
|
@ -27,7 +27,6 @@ namespace v2rayN.Desktop.Views
|
||||||
menuSelectAll.Click += menuSelectAll_Click;
|
menuSelectAll.Click += menuSelectAll_Click;
|
||||||
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
|
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
|
||||||
txtServerFilter.KeyDown += TxtServerFilter_KeyDown;
|
txtServerFilter.KeyDown += TxtServerFilter_KeyDown;
|
||||||
menuStorageUI.Click += MenuStorageUI_Click;
|
|
||||||
lstProfiles.KeyDown += LstProfiles_KeyDown;
|
lstProfiles.KeyDown += LstProfiles_KeyDown;
|
||||||
lstProfiles.SelectionChanged += lstProfiles_SelectionChanged;
|
lstProfiles.SelectionChanged += lstProfiles_SelectionChanged;
|
||||||
lstProfiles.DoubleTapped += LstProfiles_DoubleTapped;
|
lstProfiles.DoubleTapped += LstProfiles_DoubleTapped;
|
||||||
|
@ -91,6 +90,7 @@ namespace v2rayN.Desktop.Views
|
||||||
|
|
||||||
RestoreUI();
|
RestoreUI();
|
||||||
ViewModel?.RefreshServers();
|
ViewModel?.RefreshServers();
|
||||||
|
MessageBus.Current.Listen<string>(EMsgCommand.AppExit.ToString()).Subscribe(StorageUI);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void LstProfiles_Sorting(object? sender, DataGridColumnEventArgs e)
|
private async void LstProfiles_Sorting(object? sender, DataGridColumnEventArgs e)
|
||||||
|
@ -324,11 +324,6 @@ namespace v2rayN.Desktop.Views
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MenuStorageUI_Click(object? sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
StorageUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
//#endregion Event
|
//#endregion Event
|
||||||
|
|
||||||
//#region UI
|
//#region UI
|
||||||
|
@ -368,7 +363,7 @@ namespace v2rayN.Desktop.Views
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StorageUI()
|
private void StorageUI(string? n = null)
|
||||||
{
|
{
|
||||||
List<ColumnItem> lvColumnItem = new();
|
List<ColumnItem> lvColumnItem = new();
|
||||||
for (int k = 0; k < lstProfiles.Columns.Count; k++)
|
for (int k = 0; k < lstProfiles.Columns.Count; k++)
|
||||||
|
@ -386,7 +381,6 @@ namespace v2rayN.Desktop.Views
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
_config.UiItem.MainColumnItem = lvColumnItem;
|
_config.UiItem.MainColumnItem = lvColumnItem;
|
||||||
ConfigHandler.SaveConfig(_config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//#endregion UI
|
//#endregion UI
|
||||||
|
|
|
@ -26,7 +26,6 @@ namespace v2rayN.Views
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppHandler.Instance.Config;
|
||||||
ThreadPool.RegisterWaitForSingleObject(App.ProgramStarted, OnProgramStarted, null, -1, false);
|
ThreadPool.RegisterWaitForSingleObject(App.ProgramStarted, OnProgramStarted, null, -1, false);
|
||||||
|
|
||||||
Application.Current.Exit += Current_Exit;
|
|
||||||
App.Current.SessionEnding += Current_SessionEnding;
|
App.Current.SessionEnding += Current_SessionEnding;
|
||||||
this.Closing += MainWindow_Closing;
|
this.Closing += MainWindow_Closing;
|
||||||
this.PreviewKeyDown += MainWindow_PreviewKeyDown;
|
this.PreviewKeyDown += MainWindow_PreviewKeyDown;
|
||||||
|
@ -142,6 +141,7 @@ namespace v2rayN.Views
|
||||||
RestoreUI();
|
RestoreUI();
|
||||||
AddHelpMenuItem();
|
AddHelpMenuItem();
|
||||||
WindowsHandler.Instance.RegisterGlobalHotkey(_config, OnHotkeyHandler, null);
|
WindowsHandler.Instance.RegisterGlobalHotkey(_config, OnHotkeyHandler, null);
|
||||||
|
MessageBus.Current.Listen<string>(EMsgCommand.AppExit.ToString()).Subscribe(StorageUI);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Event
|
#region Event
|
||||||
|
@ -265,11 +265,6 @@ namespace v2rayN.Views
|
||||||
ShowHideWindow(false);
|
ShowHideWindow(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Current_Exit(object sender, ExitEventArgs e)
|
|
||||||
{
|
|
||||||
StorageUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void Current_SessionEnding(object sender, SessionEndingCancelEventArgs e)
|
private async void Current_SessionEnding(object sender, SessionEndingCancelEventArgs e)
|
||||||
{
|
{
|
||||||
Logging.SaveLog("Current_SessionEnding");
|
Logging.SaveLog("Current_SessionEnding");
|
||||||
|
@ -402,7 +397,7 @@ namespace v2rayN.Views
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StorageUI()
|
private void StorageUI(string? n = null)
|
||||||
{
|
{
|
||||||
_config.UiItem.MainWidth = Utils.ToInt(this.Width);
|
_config.UiItem.MainWidth = Utils.ToInt(this.Width);
|
||||||
_config.UiItem.MainHeight = Utils.ToInt(this.Height);
|
_config.UiItem.MainHeight = Utils.ToInt(this.Height);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using MaterialDesignThemes.Wpf;
|
using MaterialDesignThemes.Wpf;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Splat;
|
using Splat;
|
||||||
|
using System;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
@ -24,7 +25,6 @@ namespace v2rayN.Views
|
||||||
|
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppHandler.Instance.Config;
|
||||||
|
|
||||||
Application.Current.Exit += Current_Exit;
|
|
||||||
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
|
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
|
||||||
txtServerFilter.PreviewKeyDown += TxtServerFilter_PreviewKeyDown;
|
txtServerFilter.PreviewKeyDown += TxtServerFilter_PreviewKeyDown;
|
||||||
lstProfiles.PreviewKeyDown += LstProfiles_PreviewKeyDown;
|
lstProfiles.PreviewKeyDown += LstProfiles_PreviewKeyDown;
|
||||||
|
@ -90,15 +90,11 @@ namespace v2rayN.Views
|
||||||
|
|
||||||
RestoreUI();
|
RestoreUI();
|
||||||
ViewModel?.RefreshServers();
|
ViewModel?.RefreshServers();
|
||||||
|
MessageBus.Current.Listen<string>(EMsgCommand.AppExit.ToString()).Subscribe(StorageUI);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Event
|
#region Event
|
||||||
|
|
||||||
private void Current_Exit(object sender, ExitEventArgs e)
|
|
||||||
{
|
|
||||||
StorageUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
|
@ -356,7 +352,7 @@ namespace v2rayN.Views
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StorageUI()
|
private void StorageUI(string? n = null)
|
||||||
{
|
{
|
||||||
List<ColumnItem> lvColumnItem = new();
|
List<ColumnItem> lvColumnItem = new();
|
||||||
for (int k = 0; k < lstProfiles.Columns.Count; k++)
|
for (int k = 0; k < lstProfiles.Columns.Count; k++)
|
||||||
|
@ -370,7 +366,6 @@ namespace v2rayN.Views
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
_config.UiItem.MainColumnItem = lvColumnItem;
|
_config.UiItem.MainColumnItem = lvColumnItem;
|
||||||
ConfigHandler.SaveConfig(_config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion UI
|
#endregion UI
|
||||||
|
|
Loading…
Reference in a new issue