added multilang and settings
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using CursorLang.Models;
|
||||
|
||||
namespace CursorLang.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Связывает слежение за раскладкой с показом подсказки.
|
||||
/// Живёт всё время работы приложения независимо от открытых окон.
|
||||
/// </summary>
|
||||
public sealed class LayoutNotificationCoordinator : IDisposable
|
||||
{
|
||||
private readonly IKeyboardLayoutService _layoutService;
|
||||
private readonly ILayoutPopupService _popupService;
|
||||
|
||||
public LayoutNotificationCoordinator(IKeyboardLayoutService layoutService, ILayoutPopupService popupService)
|
||||
{
|
||||
_layoutService = layoutService;
|
||||
_popupService = popupService;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_layoutService.LayoutChanged += OnLayoutChanged;
|
||||
_layoutService.Start();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_layoutService.LayoutChanged -= OnLayoutChanged;
|
||||
_layoutService.Stop();
|
||||
}
|
||||
|
||||
private void OnLayoutChanged(object? sender, LayoutChangedEventArgs e)
|
||||
{
|
||||
// При переходе в другое приложение раскладка меняется без участия
|
||||
// пользователя, и всплывающая подсказка была бы навязчивой
|
||||
if (e.Reason == LayoutChangeReason.UserSwitched)
|
||||
{
|
||||
_popupService.Show(e.Layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user