mirror of
https://github.com/Royce551/FRESHMusicPlayer.git
synced 2025-01-22 10:51:52 -05:00
actually unsubscribe to events
This commit is contained in:
parent
5bfa6de374
commit
6ac9679947
3 changed files with 13 additions and 2 deletions
|
@ -6,7 +6,7 @@
|
|||
xmlns:vm="using:FRESHMusicPlayer.ViewModels"
|
||||
xmlns:resx ="clr-namespace:FRESHMusicPlayer.Properties"
|
||||
mc:Ignorable="d" Width="500" Height="300"
|
||||
x:Class="FRESHMusicPlayer.Views.Lyrics" WindowStartupLocation="CenterOwner"
|
||||
x:Class="FRESHMusicPlayer.Views.Lyrics" WindowStartupLocation="CenterOwner" Closing="OnClosing"
|
||||
Title="{x:Static resx:Resources.Lyrics}">
|
||||
<Window.DataContext>
|
||||
<vm:LyricsViewModel/>
|
||||
|
|
|
@ -2,6 +2,7 @@ using Avalonia;
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using FRESHMusicPlayer.ViewModels;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace FRESHMusicPlayer.Views
|
||||
{
|
||||
|
@ -23,6 +24,11 @@ namespace FRESHMusicPlayer.Views
|
|||
return this;
|
||||
}
|
||||
|
||||
private void OnClosing(object sender, CancelEventArgs e)
|
||||
{
|
||||
(DataContext as LyricsViewModel)?.Deinitialize();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
|
|
|
@ -117,7 +117,7 @@ namespace FRESHMusicPlayer.Views
|
|||
ViewModel.Volume += ((float)((e.Delta.Y) / 100) * 3);
|
||||
}
|
||||
|
||||
private void OnKeyDown(object sender, KeyEventArgs e)
|
||||
private async void OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Source is not TextBox or ListBoxItem)
|
||||
switch (e.Key)
|
||||
|
@ -155,6 +155,11 @@ namespace FRESHMusicPlayer.Views
|
|||
}
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.OemTilde:
|
||||
var dialog = new TextEntryBox().SetStuff(Properties.Resources.FilePathOrUrl);
|
||||
await dialog.ShowDialog(this);
|
||||
if (dialog.OK) ViewModel.Player.PlayMusic((dialog.DataContext as TextEntryBoxViewModel).Text);
|
||||
break;
|
||||
case Key.F1:
|
||||
InterfaceUtils.OpenURL("https://royce551.github.io/FRESHMusicPlayer/docs/index.html");
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue