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);
|
||||
Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(StatusBarViewModel));
|
||||
this.DataContext = ViewModel;
|
||||
DataContext = ViewModel;
|
||||
}
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
|
@ -65,16 +65,20 @@ public partial class App : Application
|
|||
var clipboardData = await AvaUtils.GetClipboardData(desktop.MainWindow);
|
||||
var service = Locator.Current.GetService<MainWindowViewModel>();
|
||||
if (service != null)
|
||||
{
|
||||
_ = service.AddServerViaClipboardAsync(clipboardData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void MenuExit_Click(object? sender, EventArgs e)
|
||||
{
|
||||
var service = Locator.Current.GetService<MainWindowViewModel>();
|
||||
if (service != null)
|
||||
{
|
||||
await service.MyAppExitAsync(true);
|
||||
}
|
||||
service?.Shutdown(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,9 @@ namespace v2rayN.Desktop.Common
|
|||
{
|
||||
var sp = GetStorageProvider(owner);
|
||||
if (sp is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Start async operation to open the dialog.
|
||||
var files = await sp.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
|
@ -35,7 +37,9 @@ namespace v2rayN.Desktop.Common
|
|||
{
|
||||
var sp = GetStorageProvider(owner);
|
||||
if (sp is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Start async operation to open the dialog.
|
||||
var files = await sp.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
|
|
|
@ -27,7 +27,9 @@ public class AutoCompleteBox : Avalonia.Controls.AutoCompleteBox
|
|||
{
|
||||
base.OnGotFocus(e);
|
||||
if (IsDropDownOpen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SetCurrentValue(IsDropDownOpenProperty, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,14 +8,14 @@ namespace v2rayN.Desktop.Converters
|
|||
{
|
||||
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 new SolidColorBrush(Colors.Red);
|
||||
if (delay <= 500)
|
||||
return new SolidColorBrush(Colors.Green);
|
||||
else
|
||||
return new SolidColorBrush(Colors.IndianRed);
|
||||
return delay switch
|
||||
{
|
||||
<= 0 => new SolidColorBrush(Colors.Red),
|
||||
<= 500 => new SolidColorBrush(Colors.Green),
|
||||
_ => new SolidColorBrush(Colors.IndianRed)
|
||||
};
|
||||
}
|
||||
|
||||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
|
|
|
@ -25,8 +25,8 @@ internal class Program
|
|||
if (Utils.IsWindows())
|
||||
{
|
||||
var exePathKey = Utils.GetMd5(Utils.GetExePath());
|
||||
var rebootas = (Args ?? Array.Empty<string>()).Any(t => t == Global.RebootAs);
|
||||
ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, exePathKey, out bool bCreatedNew);
|
||||
var rebootas = (Args ?? []).Any(t => t == Global.RebootAs);
|
||||
ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, exePathKey, out var bCreatedNew);
|
||||
if (!rebootas && !bCreatedNew)
|
||||
{
|
||||
ProgramStarted.Set();
|
||||
|
|
Loading…
Reference in a new issue