diff --git a/src/TMSpeech.Core/ConfigTypes.cs b/src/TMSpeech.Core/ConfigTypes.cs index 4941b0d..556144b 100644 --- a/src/TMSpeech.Core/ConfigTypes.cs +++ b/src/TMSpeech.Core/ConfigTypes.cs @@ -64,6 +64,7 @@ public static class NotificationConfigTypes public const string NotificationType = "notification.NotificationType"; public const string SensitiveWords = "notification.SensitiveWords"; + public const string HasShownLockUsage = "notification.ShownLockUsage"; public static class NotificationTypeEnum { diff --git a/src/TMSpeech.Core/JobManager.cs b/src/TMSpeech.Core/JobManager.cs index 4e71246..d45b7cb 100644 --- a/src/TMSpeech.Core/JobManager.cs +++ b/src/TMSpeech.Core/JobManager.cs @@ -225,6 +225,9 @@ private void StopRecognize() _audioSource = null; _recognizer = null; + + OnSentenceDone(new SpeechEventArgs()); + OnTextChanged(new SpeechEventArgs()); } public override void Start() diff --git a/src/TMSpeech.Core/Services/Notification/NotificationManager.cs b/src/TMSpeech.Core/Services/Notification/NotificationManager.cs index d365be1..bcb70d5 100644 --- a/src/TMSpeech.Core/Services/Notification/NotificationManager.cs +++ b/src/TMSpeech.Core/Services/Notification/NotificationManager.cs @@ -18,7 +18,7 @@ public void UnregistNotificationService(INotificationService service) public void Notify(string content, string? title, NotificationType type = NotificationType.Info) { if (ConfigManagerFactory.Instance.Get(NotificationConfigTypes.NotificationType) == NotificationConfigTypes.NotificationTypeEnum.None) return; - if (type > _level) + if (type >= _level) { foreach (var service in _services) { diff --git a/src/TMSpeech.GUI/ViewModels/MainViewModel.cs b/src/TMSpeech.GUI/ViewModels/MainViewModel.cs index 21e0f80..6714272 100644 --- a/src/TMSpeech.GUI/ViewModels/MainViewModel.cs +++ b/src/TMSpeech.GUI/ViewModels/MainViewModel.cs @@ -11,6 +11,7 @@ using ReactiveUI.Fody.Helpers; using TMSpeech.Core; using TMSpeech.Core.Plugins; +using TMSpeech.Core.Services.Notification; namespace TMSpeech.GUI.ViewModels; @@ -164,7 +165,16 @@ public MainViewModel() .Select(x => x == JobStatus.Running || x == JobStatus.Paused) .ToPropertyEx(this, x => x.StopButtonVisible); - this.LockCommand = ReactiveCommand.Create(() => { IsLocked = true; }); + this.LockCommand = ReactiveCommand.Create(() => { + IsLocked = true; + // Inform user if user uses it for the first time. + var lockedShown = ConfigManagerFactory.Instance.Get(NotificationConfigTypes.HasShownLockUsage); + if (!lockedShown) + { + ConfigManagerFactory.Instance.Apply(NotificationConfigTypes.HasShownLockUsage, true); + NotificationManager.Instance.Notify("锁定成功", "右键托盘图标以解锁", NotificationType.Info); + } + }); this.PlayCommand = ReactiveCommand.CreateFromTask( async () => { await Task.Run(() => { _jobManager.Start(); }); },