diff --git a/src/MeoAsstGui/Helper/AsstProxy.cs b/src/MeoAsstGui/Helper/AsstProxy.cs index 3449834f8e..aadae17033 100644 --- a/src/MeoAsstGui/Helper/AsstProxy.cs +++ b/src/MeoAsstGui/Helper/AsstProxy.cs @@ -200,7 +200,7 @@ namespace MeoAsstGui } var mainModel = _container.Get(); - mainModel.Inited = true; + mainModel.SetInited(); mainModel.Idle = true; var settingsModel = _container.Get(); Execute.OnUIThread(async () => diff --git a/src/MeoAsstGui/Helper/ToastNotification.cs b/src/MeoAsstGui/Helper/ToastNotification.cs index 3c4ab2ed50..91c02416ba 100644 --- a/src/MeoAsstGui/Helper/ToastNotification.cs +++ b/src/MeoAsstGui/Helper/ToastNotification.cs @@ -273,16 +273,10 @@ namespace MeoAsstGui // 系统按钮 private string _buttonSystemText = null; - private string _buttonSystemUrl; - /// /// Gets or sets the button system URL. /// - public string ButtonSystemUrl - { - get => _buttonSystemUrl; - set => _buttonSystemUrl = value; - } + public string ButtonSystemUrl { get; set; } private bool _buttonSystemEnabled = false; @@ -404,7 +398,7 @@ namespace MeoAsstGui { if (_buttonSystemEnabled) { - Uri burl = new Uri(_buttonSystemUrl); + Uri burl = new Uri(ButtonSystemUrl); new ToastContentBuilder() .AddText(_notificationTitle) .AddText(_contentCollection.ToString()) diff --git a/src/MeoAsstGui/ViewModels/SettingsViewModel.cs b/src/MeoAsstGui/ViewModels/SettingsViewModel.cs index 8cd1d4f63a..2d5e1f7add 100644 --- a/src/MeoAsstGui/ViewModels/SettingsViewModel.cs +++ b/src/MeoAsstGui/ViewModels/SettingsViewModel.cs @@ -429,10 +429,7 @@ namespace MeoAsstGui /// /// Gets the server type. /// - public string ServerType - { - get => _serverMapping[ClientType]; - } + public string ServerType => _serverMapping[ClientType]; /* 基建设置 */ @@ -1559,35 +1556,30 @@ namespace MeoAsstGui } /* 界面设置 */ -#pragma warning disable SA1401 // Fields should be private -#pragma warning disable IDE1006 /// - /// Gets or sets a value indicating whether to use tray icon. + /// Gets a value indicating whether to use tray icon. /// - public bool UseTray = true; - -#pragma warning restore SA1401 // Fields should be private -#pragma warning restore IDE1006 + public bool UseTray => true; /* private bool _useTray = Convert.ToBoolean(ViewStatusStorage.Get("GUI.UseTray", bool.TrueString)); public bool UseTray { - get => _useTray; - set - { - SetAndNotify(ref _useTray, value); - ViewStatusStorage.Set("GUI.UseTray", value.ToString()); - var trayObj = _container.Get(); - trayObj.SetVisible(value); + get => _useTray; + set + { + SetAndNotify(ref _useTray, value); + ViewStatusStorage.Set("GUI.UseTray", value.ToString()); + var trayObj = _container.Get(); + trayObj.SetVisible(value); - if (!Convert.ToBoolean(value)) - { - MinimizeToTray = false; - } - } + if (!Convert.ToBoolean(value)) + { + MinimizeToTray = false; + } + } }*/ private bool _minimizeToTray = Convert.ToBoolean(ViewStatusStorage.Get("GUI.MinimizeToTray", bool.FalseString)); @@ -1708,21 +1700,18 @@ namespace MeoAsstGui { case InverseClearType.Clear: taskQueueModel.InverseMode = false; - taskQueueModel.InverseShowVisibility = Visibility.Collapsed; - taskQueueModel.NotInverseShowVisibility = Visibility.Visible; + taskQueueModel.ShowInverse = false; taskQueueModel.SelectedAllWidth = 90; break; case InverseClearType.Inverse: taskQueueModel.InverseMode = true; - taskQueueModel.InverseShowVisibility = Visibility.Collapsed; - taskQueueModel.NotInverseShowVisibility = Visibility.Visible; + taskQueueModel.ShowInverse = false; taskQueueModel.SelectedAllWidth = 90; break; case InverseClearType.ClearInverse: - taskQueueModel.InverseShowVisibility = Visibility.Visible; - taskQueueModel.NotInverseShowVisibility = Visibility.Collapsed; + taskQueueModel.ShowInverse = true; taskQueueModel.SelectedAllWidth = TaskQueueViewModel.SelectedAllWidthWhenBoth; break; } diff --git a/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs b/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs index a6f61fabcf..a505d7100a 100644 --- a/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs +++ b/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs @@ -97,19 +97,22 @@ namespace MeoAsstGui trayIcon.SetTaskQueueViewModel(this); } - // public void ShowButton() - // { - // Visible = Visibility.Visible; - // Hibernate = true; - // } + /* + public void ShowButton() + { + Visible = Visibility.Visible; + Hibernate = true; + } - // private Visibility _visible = Visibility.Collapsed; + private Visibility _visible = Visibility.Collapsed; + + public Visibility Visible + { + get => _visible; + set => SetAndNotify(ref _visible, value); + } + */ - // public Visibility Visible - // { - // get => _visible; - // set => SetAndNotify(ref _visible, value); - // } private readonly System.Windows.Forms.Timer _timer = new System.Windows.Forms.Timer(); private void InitTimer() @@ -556,6 +559,11 @@ namespace MeoAsstGui } } + /// + /// The width of "Select All" when both. + /// + public const int SelectedAllWidthWhenBoth = 80; + private int _selectedAllWidth = ViewStatusStorage.Get("GUI.InverseClearMode", "Clear") == "ClearInverse" ? SelectedAllWidthWhenBoth : 85; @@ -568,11 +576,6 @@ namespace MeoAsstGui set => SetAndNotify(ref _selectedAllWidth, value); } - /// - /// The width of "Select All" when both. - /// - public const int SelectedAllWidthWhenBoth = 80; - private int _inverseSelectedWidth = 90; /// @@ -584,28 +587,15 @@ namespace MeoAsstGui set => SetAndNotify(ref _inverseSelectedWidth, value); } - private Visibility _inverseShowVisibility = - ViewStatusStorage.Get("GUI.InverseClearMode", "Clear") == "ClearInverse" ? Visibility.Visible : Visibility.Collapsed; + private bool _showInverse = ViewStatusStorage.Get("GUI.InverseClearMode", "Clear") == "ClearInverse"; /// - /// Gets or sets the visibility of "Select inversely". + /// Gets or sets a value indicating whether "Select inversely" is visible. /// - public Visibility InverseShowVisibility + public bool ShowInverse { - get => _inverseShowVisibility; - set => SetAndNotify(ref _inverseShowVisibility, value); - } - - private Visibility _notInverseShowVisibility = - ViewStatusStorage.Get("GUI.InverseClearMode", "Clear") == "ClearInverse" ? Visibility.Collapsed : Visibility.Visible; - - /// - /// Gets or sets the visibility of "Not inversion". - /// - public Visibility NotInverseShowVisibility - { - get => _notInverseShowVisibility; - set => SetAndNotify(ref _notInverseShowVisibility, value); + get => _showInverse; + set => SetAndNotify(ref _showInverse, value); } private string _inverseShowText = Convert.ToBoolean(ViewStatusStorage.Get("MainFunction.InverseMode", bool.FalseString)) ? Localization.GetString("Inverse") : Localization.GetString("Clear"); @@ -1251,42 +1241,39 @@ namespace MeoAsstGui /* public void CheckAndShutdown() { - if (Shutdown) - { - System.Diagnostics.Process.Start("shutdown.exe", "-s -t 60"); + if (Shutdown) + { + System.Diagnostics.Process.Start("shutdown.exe", "-s -t 60"); - var result = _windowManager.ShowMessageBox("已刷完,即将关机,是否取消?", "提示", MessageBoxButton.OK, MessageBoxImage.Question); - if (result == MessageBoxResult.OK) - { - System.Diagnostics.Process.Start("shutdown.exe", "-a"); - } - } - if (Hibernate) - { - System.Diagnostics.Process.Start("shutdown.exe", "-h"); - } - if (Suspend) - { - System.Diagnostics.Process.Start("rundll32.exe", "powrprof.dll,SetSuspendState 0,1,0"); - } + var result = _windowManager.ShowMessageBox("已刷完,即将关机,是否取消?", "提示", MessageBoxButton.OK, MessageBoxImage.Question); + if (result == MessageBoxResult.OK) + { + System.Diagnostics.Process.Start("shutdown.exe", "-a"); + } + } + if (Hibernate) + { + System.Diagnostics.Process.Start("shutdown.exe", "-h"); + } + if (Suspend) + { + System.Diagnostics.Process.Start("rundll32.exe", "powrprof.dll,SetSuspendState 0,1,0"); + } } */ - private bool _inited = false; + /// + /// Gets a value indicating whether it is initialized. + /// + public bool Inited { get; private set; } = false; /// - /// Gets or sets a value indicating whether it is initialized. + /// Sets it initialized. /// - public bool Inited + public void SetInited() { - get => _inited; - set - { - if (value) - { - SetAndNotify(ref _inited, value); - } - } + Inited = true; + NotifyOfPropertyChange("Inited"); } private bool _idle = false; @@ -1320,56 +1307,58 @@ namespace MeoAsstGui set => SetAndNotify(ref _fightTaskRunning, value); } - // private bool _shutdown = false; + /* + private bool _shutdown = false; - // public bool Shutdown - // { - // get => return _shutdown; - // set - // { - // SetAndNotify(ref _shutdown, value); - // - // if (value) - // { - // Hibernate = false; - // Suspend = false; - // } - // } - // } + public bool Shutdown + { + get => return _shutdown; + set + { + SetAndNotify(ref _shutdown, value); - // private bool _hibernate = false; // 休眠 + if (value) + { + Hibernate = false; + Suspend = false; + } + } + } - // public bool Hibernate - // { - // get => return _hibernate; - // set - // { - // SetAndNotify(ref _hibernate, value); - // - // if (value) - // { - // Shutdown = false; - // Suspend = false; - // } - // } - // } + private bool _hibernate = false; // 休眠 - // private bool _suspend = false; // 待机 + public bool Hibernate + { + get => return _hibernate; + set + { + SetAndNotify(ref _hibernate, value); - // public bool Suspend - // { - // get => return _suspend; - // set - // { - // SetAndNotify(ref _suspend, value); - // - // if (value) - // { - // Shutdown = false; - // Hibernate = false; - // } - // } - // } + if (value) + { + Shutdown = false; + Suspend = false; + } + } + } + + private bool _suspend = false; // 待机 + + public bool Suspend + { + get => return _suspend; + set + { + SetAndNotify(ref _suspend, value); + + if (value) + { + Shutdown = false; + Hibernate = false; + } + } + } + */ /// /// Gets or sets the list of all stages. diff --git a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs index be42d60d78..a91e231121 100644 --- a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs +++ b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs @@ -117,29 +117,31 @@ namespace MeoAsstGui set => SetAndNotify(ref _updateUrl, value); } - // public FlowDocument UpdateInfoDocument - // { - // get - // { - // try - // { - // return MarkdownXaml.ToFlowDocument(UpdateInfo, s_markdownPipeline); - // } - // catch (Exception) - // { - // // 不知道为什么有一部分用户的电脑上,用 MarkdownXaml 解析直接就会 crash - // // 换另一个库再试一遍 - // try - // { - // return new MdXaml.Markdown().Transform(UpdateInfo); - // } - // catch (Exception) - // { - // return new FlowDocument(); - // } - // } - // } - // } + /* + public FlowDocument UpdateInfoDocument + { + get + { + try + { + return MarkdownXaml.ToFlowDocument(UpdateInfo, s_markdownPipeline); + } + catch (Exception) + { + // 不知道为什么有一部分用户的电脑上,用 MarkdownXaml 解析直接就会 crash + // 换另一个库再试一遍 + try + { + return new MdXaml.Markdown().Transform(UpdateInfo); + } + catch (Exception) + { + return new FlowDocument(); + } + } + } + } + */ /// /// Gets a value indicating whether it is the first boot after updating. diff --git a/src/MeoAsstGui/Views/TaskQueueView.xaml b/src/MeoAsstGui/Views/TaskQueueView.xaml index da055ecf4c..e2b4636dce 100644 --- a/src/MeoAsstGui/Views/TaskQueueView.xaml +++ b/src/MeoAsstGui/Views/TaskQueueView.xaml @@ -87,7 +87,7 @@ Command="{s:Action InverseSelected}" Content="{Binding InverseShowText}" IsEnabled="{Binding Idle}" - Visibility="{Binding InverseShowVisibility}"> + Visibility="{c:Binding ShowInverse}"> + Visibility="{c:Binding Path=!ShowInverse}" />