add start param #152

This commit is contained in:
huiyadanli 2024-02-08 15:44:50 +08:00
parent 1c345eae16
commit 3fc3935519
3 changed files with 22 additions and 5 deletions

View File

@ -0,0 +1,7 @@
{
"profiles": {
"BetterGenshinImpact": {
"commandName": "Project"
}
}
}

View File

@ -20,6 +20,7 @@ using Windows.System;
using BetterGenshinImpact.Core.Recognition.OCR;
using OpenCvSharp;
using Wpf.Ui.Controls;
using MessageBox = System.Windows.MessageBox;
namespace BetterGenshinImpact.ViewModel.Pages;
@ -33,12 +34,10 @@ public partial class HomePageViewModel : ObservableObject, INavigationAware
[ObservableProperty] private Visibility _startButtonVisibility = Visibility.Visible;
[ObservableProperty] private Visibility _stopButtonVisibility = Visibility.Collapsed;
[ObservableProperty]
[NotifyCanExecuteChangedFor(nameof(StartTriggerCommand))]
[ObservableProperty] [NotifyCanExecuteChangedFor(nameof(StartTriggerCommand))]
private bool _startButtonEnabled = true;
[ObservableProperty]
[NotifyCanExecuteChangedFor(nameof(StopTriggerCommand))]
[ObservableProperty] [NotifyCanExecuteChangedFor(nameof(StopTriggerCommand))]
private bool _stopButtonEnabled = true;
public AllConfig Config { get; set; }
@ -72,6 +71,15 @@ public partial class HomePageViewModel : ObservableObject, INavigationAware
}
}
});
var args = Environment.GetCommandLineArgs();
if (args.Length > 1)
{
if (args[1].Contains("start"))
{
_ = OnStartTriggerAsync();
}
}
}
[RelayCommand]
@ -136,6 +144,7 @@ public partial class HomePageViewModel : ObservableObject, INavigationAware
{
hWnd = await SystemControl.StartFromLocalAsync(Config.GenshinStartConfig.InstallPath);
}
if (hWnd == IntPtr.Zero)
{
System.Windows.MessageBox.Show("未找到原神窗口,请先启动原神!");
@ -231,6 +240,7 @@ public partial class HomePageViewModel : ObservableObject, INavigationAware
{
return;
}
Config.GenshinStartConfig.InstallPath = path;
}
});
@ -248,4 +258,4 @@ public partial class HomePageViewModel : ObservableObject, INavigationAware
}
}
}
}
}