From 158e4fdd9e9c9e621134d44d3ab348b1253cc34a Mon Sep 17 00:00:00 2001 From: zzyyyl Date: Wed, 14 Sep 2022 23:10:29 +0800 Subject: [PATCH 1/3] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserControl/FightSettingsUserControl.xaml | 2 +- src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml index 44eb2804dd..97ce39ca5e 100644 --- a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml +++ b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml @@ -171,7 +171,7 @@ ItemsSource="{Binding StageList}" SelectedValue="{Binding Stage1}" SelectedValuePath="Value" - Visibility="{Binding NotCustomStageCode, Converter={StaticResource Boolean2VisibilityConverter}}" /> + Visibility="{c:Binding !CustomStageCode}" /> + /// Gets or sets a value indicating whether to use custom stage code. + /// public bool CustomStageCode { get => _customStageCode; set { SetAndNotify(ref _customStageCode, value); - NotCustomStageCode = !value; var settingsModel = _container.Get(); AlternateStageDisplay = !value && settingsModel.UseAlternateStage; } } - private bool _notCustomStageCode = !Convert.ToBoolean(ViewStatusStorage.Get("GUI.CustomStageCode", bool.FalseString)); - - public bool NotCustomStageCode - { - get => _notCustomStageCode; - set => SetAndNotify(ref _notCustomStageCode, value); - } - private bool _useMedicine = Convert.ToBoolean(ViewStatusStorage.Get("MainFunction.UseMedicine", bool.FalseString)); /// From 05346100e42ac0911112655da7347760aca2299e Mon Sep 17 00:00:00 2001 From: zzyyyl Date: Wed, 14 Sep 2022 23:34:58 +0800 Subject: [PATCH 2/3] perf: fix c# warnings & suggestions --- src/MeoAsstGui/Helper/AsstProxy.cs | 3 +- src/MeoAsstGui/Helper/ComboBoxExtensions.cs | 13 ++++++++ src/MeoAsstGui/Helper/StageInfo.cs | 1 - src/MeoAsstGui/ViewModels/CopilotViewModel.cs | 2 -- src/MeoAsstGui/ViewModels/DepotViewModel.cs | 32 +++++++++++++++---- .../ViewModels/SettingsViewModel.cs | 3 ++ 6 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/MeoAsstGui/Helper/AsstProxy.cs b/src/MeoAsstGui/Helper/AsstProxy.cs index f90a811f46..0992a3f14f 100644 --- a/src/MeoAsstGui/Helper/AsstProxy.cs +++ b/src/MeoAsstGui/Helper/AsstProxy.cs @@ -936,7 +936,7 @@ namespace MeoAsstGui { string resultContent = string.Empty; JArray result_array = (JArray)subTaskDetails["result"]; - int level = (int)subTaskDetails["level"]; + /* int level = (int)subTaskDetails["level"]; */ foreach (var combs in result_array) { int tag_level = (int)combs["level"]; @@ -1243,6 +1243,7 @@ namespace MeoAsstGui /// 宿舍进驻心情阈值。 /// 宿舍是否使用未进驻筛选标签 /// 宿舍是否使用蹭信赖功能 + /// 制造站搓玉是否补货 /// 是否成功。 public bool AsstAppendInfrast(string[] order, string uses_of_drones, double dorm_threshold, bool dorm_filter_not_stationed_enabled, bool dorm_trust_enabled, bool originium_shard_auto_replenishment) { diff --git a/src/MeoAsstGui/Helper/ComboBoxExtensions.cs b/src/MeoAsstGui/Helper/ComboBoxExtensions.cs index 28c94583b6..8aabd6ae7d 100644 --- a/src/MeoAsstGui/Helper/ComboBoxExtensions.cs +++ b/src/MeoAsstGui/Helper/ComboBoxExtensions.cs @@ -1,3 +1,16 @@ +// +// MeoAsstGui - A part of the MeoAssistantArknights project +// Copyright (C) 2021 MistEO and Contributors +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY +// + using System.Windows.Controls; using System.Windows.Input; diff --git a/src/MeoAsstGui/Helper/StageInfo.cs b/src/MeoAsstGui/Helper/StageInfo.cs index 025b83db4c..5120d543f3 100644 --- a/src/MeoAsstGui/Helper/StageInfo.cs +++ b/src/MeoAsstGui/Helper/StageInfo.cs @@ -72,7 +72,6 @@ namespace MeoAsstGui /// /// Determine whether the stage associated activity is closed /// - /// Current day of week /// Whether activity is closed public bool IsActivityClosed() { diff --git a/src/MeoAsstGui/ViewModels/CopilotViewModel.cs b/src/MeoAsstGui/ViewModels/CopilotViewModel.cs index 810fbd68a3..51b339657a 100644 --- a/src/MeoAsstGui/ViewModels/CopilotViewModel.cs +++ b/src/MeoAsstGui/ViewModels/CopilotViewModel.cs @@ -37,9 +37,7 @@ namespace MeoAsstGui /// public class CopilotViewModel : Screen { -#pragma warning disable IDE0052 // 删除未读的私有成员 private readonly IWindowManager _windowManager; -#pragma warning restore IDE0052 // 删除未读的私有成员 private readonly IContainer _container; /// diff --git a/src/MeoAsstGui/ViewModels/DepotViewModel.cs b/src/MeoAsstGui/ViewModels/DepotViewModel.cs index bde2eb52d6..3d55f69a0e 100644 --- a/src/MeoAsstGui/ViewModels/DepotViewModel.cs +++ b/src/MeoAsstGui/ViewModels/DepotViewModel.cs @@ -1,4 +1,4 @@ -// +// // MeoAsstGui - A part of the MeoAssistantArknights project // Copyright (C) 2021 MistEO and Contributors // @@ -12,6 +12,7 @@ // using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using System.Windows; using Newtonsoft.Json.Linq; @@ -62,18 +63,28 @@ namespace MeoAsstGui set => SetAndNotify(ref _depotResult, value); } + /// + /// Gets or sets the ArkPlanner result. + /// public string ArkPlannerResult { get; set; } = string.Empty; + /// + /// Gets or sets the Lolicon result. + /// public string LoliconResult { get; set; } = string.Empty; + /// + /// parse of depot recognition result + /// + /// detailed json-style parameters + /// Success or not public bool Parse(JObject details) { string result = string.Empty; int count = 0; - foreach (var item in details["arkplanner"]["object"]["items"]) + foreach (var item in details["arkplanner"]["object"]["items"].Cast()) { - var itemObj = (JObject)item; - result += (string)itemObj["name"] + " : " + (int)itemObj["have"] + "\t"; + result += (string)item["name"] + " : " + (int)item["have"] + "\t"; if (++count == 4) { result += "\n"; @@ -98,25 +109,34 @@ namespace MeoAsstGui private bool _done = false; + /// + /// Gets or sets a value indicating whether depot info is parsed. + /// public bool Done { get => _done; set => SetAndNotify(ref _done, value); } + /// + /// Export depot info to ArkPlanner. + /// public void ExportToArkplanner() { Clipboard.SetDataObject(ArkPlannerResult); DepotInfo = Localization.GetString("CopiedToClipboard"); } + /// + /// Export depot info to Lolicon. + /// public void ExportToLolicon() { Clipboard.SetDataObject(LoliconResult); DepotInfo = Localization.GetString("CopiedToClipboard"); } - private void clear() + private void Clear() { DepotResult = string.Empty; ArkPlannerResult = string.Empty; @@ -144,7 +164,7 @@ namespace MeoAsstGui } DepotInfo = Localization.GetString("Identifying"); - clear(); + Clear(); asstProxy.AsstStartDepot(); } diff --git a/src/MeoAsstGui/ViewModels/SettingsViewModel.cs b/src/MeoAsstGui/ViewModels/SettingsViewModel.cs index e690e8c2fb..c14c3138e9 100644 --- a/src/MeoAsstGui/ViewModels/SettingsViewModel.cs +++ b/src/MeoAsstGui/ViewModels/SettingsViewModel.cs @@ -1702,6 +1702,9 @@ namespace MeoAsstGui private bool _customStageCode = Convert.ToBoolean(ViewStatusStorage.Get("GUI.CustomStageCode", bool.FalseString)); + /// + /// Gets or sets a value indicating whether to use custom stage code. + /// public bool CustomStageCode { get => _customStageCode; From 24a1bbaf7f06e1f2da41cf54874c4ae9947cc0f7 Mon Sep 17 00:00:00 2001 From: zzyyyl Date: Wed, 14 Sep 2022 23:50:48 +0800 Subject: [PATCH 3/3] perf: Use `c:Binding` instead of `Converter` to handle `Visibility`. --- .../UserControl/FightSettingsUserControl.xaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml index 97ce39ca5e..304413c44f 100644 --- a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml +++ b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml @@ -93,7 +93,7 @@ Content="{DynamicResource AssignedMaterial}" IsChecked="{Binding IsSpecifiedDrops}" ToolTip="{DynamicResource NoAutoNavigation}" /> - + + Visibility="{c:Binding IsSpecifiedDrops}" /> @@ -146,7 +146,7 @@ TextAlignment="Center" TextWrapping="Wrap" /> - + + Visibility="{c:Binding CustomStageCode}" /> + Visibility="{c:Binding AlternateStageDisplay}" /> + Visibility="{c:Binding AlternateStageDisplay}" />