diff --git a/src/MaaWpfGui/Constants/ConfigurationKeys.cs b/src/MaaWpfGui/Constants/ConfigurationKeys.cs index f802eae19a..1e607c0e57 100644 --- a/src/MaaWpfGui/Constants/ConfigurationKeys.cs +++ b/src/MaaWpfGui/Constants/ConfigurationKeys.cs @@ -111,7 +111,7 @@ namespace MaaWpfGui.Constants public const string InfrastReceptionMessageBoardReceive = "Infrast.ReceptionMessageBoardReceive"; public const string ContinueTraining = "Infrast.ContinueTraining"; public const string DefaultInfrast = "Infrast.DefaultInfrast"; - public const string IsCustomInfrastFileReadOnly = "Infrast.IsCustomInfrastFileReadOnly"; + public const string IsCustomInfrastFileReadOnly = "Infrast.IsCustomInfrastFileReadOnly"; // 已废弃 public const string DormFilterNotStationedEnabled = "Infrast.DormFilterNotStationedEnabled"; public const string DormTrustEnabled = "Infrast.DormTrustEnabled"; public const string OriginiumShardAutoReplenishment = "Infrast.OriginiumShardAutoReplenishment"; diff --git a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/InfrastSettingsUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/InfrastSettingsUserControlModel.cs index 71ee8aa6cc..f170b1c2b0 100644 --- a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/InfrastSettingsUserControlModel.cs +++ b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/InfrastSettingsUserControlModel.cs @@ -301,7 +301,7 @@ public class InfrastSettingsUserControlModel : TaskViewModel private string _defaultInfrast = ConfigurationHelper.GetValue(ConfigurationKeys.DefaultInfrast, UserDefined); - private const string UserDefined = "user_defined"; + public const string UserDefined = "user_defined"; /// /// Gets or sets the uses of drones. @@ -315,31 +315,14 @@ public class InfrastSettingsUserControlModel : TaskViewModel if (_defaultInfrast != UserDefined) { CustomInfrastFile = @"resource\custom_infrast\" + value; - IsCustomInfrastFileReadOnly = true; - } - else - { - IsCustomInfrastFileReadOnly = false; } + NotifyOfPropertyChange(nameof(IsCustomInfrastFileReadOnly)); ConfigurationHelper.SetValue(ConfigurationKeys.DefaultInfrast, value); } } - private bool _isCustomInfrastFileReadOnly = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.IsCustomInfrastFileReadOnly, bool.FalseString)); - - /// - /// Gets or sets a value indicating whether CustomInfrastFile is read-only - /// - public bool IsCustomInfrastFileReadOnly - { - get => _isCustomInfrastFileReadOnly; - set - { - SetAndNotify(ref _isCustomInfrastFileReadOnly, value); - ConfigurationHelper.SetValue(ConfigurationKeys.IsCustomInfrastFileReadOnly, value.ToString()); - } - } + public bool IsCustomInfrastFileReadOnly => _defaultInfrast != UserDefined; private bool _dormFilterNotStationedEnabled = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.DormFilterNotStationedEnabled, bool.TrueString));