From 75788873ca147dfbd30dae51def2c62678eaab87 Mon Sep 17 00:00:00 2001 From: rmbgame Date: Fri, 28 May 2021 12:34:14 +0800 Subject: [PATCH] save --- .../CommandLineTools.cs | 18 +++++- src/ST.Client.Desktop.Windows/UI/JumpLists.cs | 60 +++++++++++++------ .../Services/ISteamService.cs | 2 +- .../Implementation/SteamServiceImpl.cs | 2 +- .../Pages/SteamAccountPageViewModel.cs | 2 + 5 files changed, 62 insertions(+), 22 deletions(-) diff --git a/src/ST.Client.Desktop.Avalonia.App/CommandLineTools.cs b/src/ST.Client.Desktop.Avalonia.App/CommandLineTools.cs index 5a9219575..7eaba31fd 100644 --- a/src/ST.Client.Desktop.Avalonia.App/CommandLineTools.cs +++ b/src/ST.Client.Desktop.Avalonia.App/CommandLineTools.cs @@ -128,13 +128,28 @@ namespace System.Application.UI // -clt c -silence var common = new Command("c", "common"); common.AddOption(new Option("-silence", "静默启动(不弹窗口)")); - common.Handler = CommandHandler.Create((bool silence) => + common.Handler = CommandHandler.Create((bool silence, long steamuser) => { IsMinimize = silence; MainHandlerByCLT(); }); rootCommand.AddCommand(common); + // -clt steam -account + var steamuser = new Command("steam", "Steam相关操作"); + common.AddOption(new Option("-account", "指定对应steam用户名")); + common.Handler = CommandHandler.Create((string account) => + { + if (!string.IsNullOrEmpty(account)) + { + initStartup(DILevel.Steam); + //ISteamService.Instance.TryKillSteamProcess(); + //ISteamService.Instance.SetCurrentUser(account); + //ISteamService.Instance.StartSteam(); + } + }); + rootCommand.AddCommand(common); + // -clt app -id 632360 var unlock_achievement = new Command("app", "打开成就解锁窗口"); unlock_achievement.AddOption(new Option("-id", "指定一个Steam游戏Id")); @@ -157,7 +172,6 @@ namespace System.Application.UI var day = 86400000; while (true) Threading.Thread.Sleep(day); - } } catch (Exception ex) diff --git a/src/ST.Client.Desktop.Windows/UI/JumpLists.cs b/src/ST.Client.Desktop.Windows/UI/JumpLists.cs index ceb681268..90172e1b6 100644 --- a/src/ST.Client.Desktop.Windows/UI/JumpLists.cs +++ b/src/ST.Client.Desktop.Windows/UI/JumpLists.cs @@ -1,4 +1,4 @@ -#pragma warning disable CA1416 // 验证平台兼容性 +#pragma warning disable CA1416 // 验证平台兼容性 extern alias JumpLists; using JumpLists::System.Windows.Shell; using AvaloniaApplication = Avalonia.Application; @@ -22,26 +22,50 @@ namespace System.Application.UI }; //jumpList1.JumpItemsRejected += JumpList1_JumpItemsRejected; //jumpList1.JumpItemsRemovedByUser += JumpList1_JumpItemsRemovedByUser; - jumpList1.JumpItems.Add(new JumpTask - { - Title = "Notepad", - Description = "Open Notepad.", - ApplicationPath = @"C:\Windows\notepad.exe", - IconResourcePath = @"C:\Windows\notepad.exe", - }); - jumpList1.JumpItems.Add(new JumpTask - { - Title = "Read Me", - Description = "Open readme.txt in Notepad.", - ApplicationPath = @"C:\Windows\notepad.exe", - IconResourcePath = @"C:\Windows\System32\imageres.dll", - IconResourceIndex = 14, - WorkingDirectory = @"C:\Users\Public\Documents", - Arguments = "readme.txt", - }); + //jumpList1.JumpItems.Add(new JumpTask + //{ + // Title = "RuaRua", + // Description = "以该账号启动Steam", + // ApplicationPath = AppHelper.ProgramPath, + // Arguments = "-clt steam -account rmbadmin", + // IconResourcePath = AppHelper.ProgramPath, + //}); + //jumpList1.JumpItems.Add(new JumpTask + //{ + // Title = "DarkMaple", + // Description = "以该账号启动Steam", + // ApplicationPath = AppHelper.ProgramPath, + // Arguments = "-clt steam -account kuafaaf", + // IconResourcePath = AppHelper.ProgramPath, + //}); + //jumpList1.JumpItems.Add(new JumpTask + //{ + // Title = "Read Me", + // Description = "Open readme.txt in Notepad.", + // ApplicationPath = @"C:\Windows\notepad.exe", + // IconResourcePath = @"C:\Windows\System32\imageres.dll", + // IconResourceIndex = 14, + // WorkingDirectory = @"C:\Users\Public\Documents", + // Arguments = "readme.txt", + //}); JumpList.SetJumpList(AvaloniaApplication.Current, jumpList1); } + + public static void AddJumpTask(JumpTask task) + { + var jumpList1 = new JumpList + { + ShowRecentCategory = true, + ShowFrequentCategory = true, + }; + //jumpList1.JumpItemsRejected += JumpList1_JumpItemsRejected; + //jumpList1.JumpItemsRemovedByUser += JumpList1_JumpItemsRemovedByUser; + jumpList1.JumpItems.Add(task); + JumpList.SetJumpList(AvaloniaApplication.Current, jumpList1); + } + + //static void AddJumpTask() //{ // // Configure a new JumpTask. diff --git a/src/ST.Client.Desktop/Services/ISteamService.cs b/src/ST.Client.Desktop/Services/ISteamService.cs index daf4017f3..6d642a1e4 100644 --- a/src/ST.Client.Desktop/Services/ISteamService.cs +++ b/src/ST.Client.Desktop/Services/ISteamService.cs @@ -57,7 +57,7 @@ namespace System.Application.Services /// 启动 Steam /// /// - void StartSteam(string? arguments); + void StartSteam(string? arguments = null); /// /// 获取最后一次自动登陆 Steam 用户名称 diff --git a/src/ST.Client.Desktop/Services/Implementation/SteamServiceImpl.cs b/src/ST.Client.Desktop/Services/Implementation/SteamServiceImpl.cs index d0d4fc3c2..00a2826c8 100644 --- a/src/ST.Client.Desktop/Services/Implementation/SteamServiceImpl.cs +++ b/src/ST.Client.Desktop/Services/Implementation/SteamServiceImpl.cs @@ -123,7 +123,7 @@ namespace System.Application.Services.Implementation return default; } - public void StartSteam(string? arguments) + public void StartSteam(string? arguments = null) { if (!string.IsNullOrEmpty(SteamProgramPath)) { diff --git a/src/ST.Client.Desktop/UI/ViewModels/Pages/SteamAccountPageViewModel.cs b/src/ST.Client.Desktop/UI/ViewModels/Pages/SteamAccountPageViewModel.cs index 2bdaa074b..4e853b314 100644 --- a/src/ST.Client.Desktop/UI/ViewModels/Pages/SteamAccountPageViewModel.cs +++ b/src/ST.Client.Desktop/UI/ViewModels/Pages/SteamAccountPageViewModel.cs @@ -124,6 +124,8 @@ namespace System.Application.UI.ViewModels _SteamUsersSourceList.Refresh(); + + this.WhenAnyValue(x => x.SteamUsers) .Subscribe(items => items? .ToObservableChangeSet()