mirror of
https://github.com/jayfunc/BetterLyrics.git
synced 2026-01-13 03:34:55 +08:00
88 lines
2.5 KiB
C#
88 lines
2.5 KiB
C#
using BetterLyrics.WinUI3.Helper;
|
|
using BetterLyrics.WinUI3.Services;
|
|
using BetterLyrics.WinUI3.Views;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using CommunityToolkit.Mvvm.Messaging;
|
|
using CommunityToolkit.Mvvm.Messaging.Messages;
|
|
using Microsoft.UI.Xaml;
|
|
using System;
|
|
using WinUIEx;
|
|
|
|
namespace BetterLyrics.WinUI3.ViewModels
|
|
{
|
|
public partial class SystemTrayViewModel(ISettingsService settingsService) : BaseViewModel(settingsService), IRecipient<PropertyChangedMessage<bool>>
|
|
{
|
|
[ObservableProperty]
|
|
[NotifyPropertyChangedRecipients]
|
|
public partial bool IsLyricsWindowLocked { get; set; } = false;
|
|
|
|
[ObservableProperty]
|
|
public partial string ToolTipText { get; set; } = MetadataHelper.AppName;
|
|
|
|
public void Receive(PropertyChangedMessage<bool> message)
|
|
{
|
|
if (message.Sender is LyricsWindowViewModel)
|
|
{
|
|
if (message.PropertyName == nameof(LyricsWindowViewModel.IsLyricsWindowLocked))
|
|
{
|
|
if (IsLyricsWindowLocked != message.NewValue)
|
|
{
|
|
IsLyricsWindowLocked = message.NewValue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
[RelayCommand]
|
|
private static void ExitApp()
|
|
{
|
|
WindowHelper.ExitApp();
|
|
}
|
|
|
|
[RelayCommand]
|
|
private static void RestartApp()
|
|
{
|
|
WindowHelper.RestartApp();
|
|
}
|
|
|
|
[RelayCommand]
|
|
private static void ResetWindowPosition()
|
|
{
|
|
LyricsWindow? lyricsWindow = WindowHelper.GetWindowByWindowType<LyricsWindow>();
|
|
if (lyricsWindow != null)
|
|
{
|
|
lyricsWindow.MoveAndResize(0, 0, 800, 600);
|
|
}
|
|
}
|
|
|
|
[RelayCommand]
|
|
private static void OpenSettings()
|
|
{
|
|
WindowHelper.OpenWindow<SettingsWindow>();
|
|
}
|
|
|
|
[RelayCommand]
|
|
private static void OpenMusicGallery()
|
|
{
|
|
WindowHelper.OpenWindow<MusicGalleryWindow>();
|
|
}
|
|
|
|
[RelayCommand]
|
|
private static void OpenLyricsWindow()
|
|
{
|
|
WindowHelper.OpenWindow<LyricsWindow>();
|
|
}
|
|
|
|
[RelayCommand]
|
|
private void UnlockWindow()
|
|
{
|
|
var window = WindowHelper.GetWindowByWindowType<LyricsWindow>();
|
|
if (window == null) return;
|
|
|
|
DesktopModeHelper.SetClickThrough(window, false);
|
|
IsLyricsWindowLocked = false;
|
|
}
|
|
}
|
|
}
|