mirror of
https://github.com/2dust/v2rayN.git
synced 2025-04-19 13:42:24 +00:00
AI-optimized code
This commit is contained in:
parent
51e5885e76
commit
7e348c196e
5 changed files with 20 additions and 10 deletions
|
@ -23,7 +23,7 @@ public partial class App : Application
|
||||||
|
|
||||||
var ViewModel = new StatusBarViewModel(null);
|
var ViewModel = new StatusBarViewModel(null);
|
||||||
Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(StatusBarViewModel));
|
Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(StatusBarViewModel));
|
||||||
this.DataContext = ViewModel;
|
DataContext = ViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnFrameworkInitializationCompleted()
|
public override void OnFrameworkInitializationCompleted()
|
||||||
|
@ -65,7 +65,9 @@ public partial class App : Application
|
||||||
var clipboardData = await AvaUtils.GetClipboardData(desktop.MainWindow);
|
var clipboardData = await AvaUtils.GetClipboardData(desktop.MainWindow);
|
||||||
var service = Locator.Current.GetService<MainWindowViewModel>();
|
var service = Locator.Current.GetService<MainWindowViewModel>();
|
||||||
if (service != null)
|
if (service != null)
|
||||||
|
{
|
||||||
_ = service.AddServerViaClipboardAsync(clipboardData);
|
_ = service.AddServerViaClipboardAsync(clipboardData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +76,9 @@ public partial class App : Application
|
||||||
{
|
{
|
||||||
var service = Locator.Current.GetService<MainWindowViewModel>();
|
var service = Locator.Current.GetService<MainWindowViewModel>();
|
||||||
if (service != null)
|
if (service != null)
|
||||||
|
{
|
||||||
await service.MyAppExitAsync(true);
|
await service.MyAppExitAsync(true);
|
||||||
|
}
|
||||||
service?.Shutdown(true);
|
service?.Shutdown(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,9 @@ namespace v2rayN.Desktop.Common
|
||||||
{
|
{
|
||||||
var sp = GetStorageProvider(owner);
|
var sp = GetStorageProvider(owner);
|
||||||
if (sp is null)
|
if (sp is null)
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Start async operation to open the dialog.
|
// Start async operation to open the dialog.
|
||||||
var files = await sp.OpenFilePickerAsync(new FilePickerOpenOptions
|
var files = await sp.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||||
|
@ -35,7 +37,9 @@ namespace v2rayN.Desktop.Common
|
||||||
{
|
{
|
||||||
var sp = GetStorageProvider(owner);
|
var sp = GetStorageProvider(owner);
|
||||||
if (sp is null)
|
if (sp is null)
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Start async operation to open the dialog.
|
// Start async operation to open the dialog.
|
||||||
var files = await sp.SaveFilePickerAsync(new FilePickerSaveOptions
|
var files = await sp.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||||
|
|
|
@ -27,7 +27,9 @@ public class AutoCompleteBox : Avalonia.Controls.AutoCompleteBox
|
||||||
{
|
{
|
||||||
base.OnGotFocus(e);
|
base.OnGotFocus(e);
|
||||||
if (IsDropDownOpen)
|
if (IsDropDownOpen)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
SetCurrentValue(IsDropDownOpenProperty, true);
|
SetCurrentValue(IsDropDownOpenProperty, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,14 +8,14 @@ namespace v2rayN.Desktop.Converters
|
||||||
{
|
{
|
||||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
int.TryParse(value?.ToString(), out var delay);
|
_ = int.TryParse(value?.ToString(), out var delay);
|
||||||
|
|
||||||
if (delay <= 0)
|
return delay switch
|
||||||
return new SolidColorBrush(Colors.Red);
|
{
|
||||||
if (delay <= 500)
|
<= 0 => new SolidColorBrush(Colors.Red),
|
||||||
return new SolidColorBrush(Colors.Green);
|
<= 500 => new SolidColorBrush(Colors.Green),
|
||||||
else
|
_ => new SolidColorBrush(Colors.IndianRed)
|
||||||
return new SolidColorBrush(Colors.IndianRed);
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
|
|
|
@ -25,8 +25,8 @@ internal class Program
|
||||||
if (Utils.IsWindows())
|
if (Utils.IsWindows())
|
||||||
{
|
{
|
||||||
var exePathKey = Utils.GetMd5(Utils.GetExePath());
|
var exePathKey = Utils.GetMd5(Utils.GetExePath());
|
||||||
var rebootas = (Args ?? Array.Empty<string>()).Any(t => t == Global.RebootAs);
|
var rebootas = (Args ?? []).Any(t => t == Global.RebootAs);
|
||||||
ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, exePathKey, out bool bCreatedNew);
|
ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, exePathKey, out var bCreatedNew);
|
||||||
if (!rebootas && !bCreatedNew)
|
if (!rebootas && !bCreatedNew)
|
||||||
{
|
{
|
||||||
ProgramStarted.Set();
|
ProgramStarted.Set();
|
||||||
|
|
Loading…
Reference in a new issue