too many to add

This commit is contained in:
TheXamlGuy
2024-01-29 22:03:36 +00:00
parent 3917639e8d
commit c546ca2343
44 changed files with 573 additions and 94 deletions
@@ -1,39 +1,43 @@
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
namespace Hyperbar.Widget.MediaController.Windows;
public class MediaButtonViewModel(IServiceFactory serviceFactory,
[NotificationHandler(nameof(PlaybackButtonType))]
public partial class MediaButtonViewModel(IServiceFactory serviceFactory,
IMediator mediator,
IDisposer disposer,
ITemplateFactory templateFactory,
PlaybackButtonType buttonType,
PlaybackButtonType playbackButtonType,
Guid guid = default,
string? text = null,
string? icon = null,
RelayCommand? command = null) :
WidgetButtonViewModel(serviceFactory, mediator, disposer, templateFactory, guid, text, icon, command),
IInitialization,
INotificationHandler<Changed<PlaybackInformation>>
IInitialization
{
public Task Handle(Changed<PlaybackInformation> notification,
[ObservableProperty]
private PlaybackButtonType playbackButtonType = playbackButtonType;
public Task Handle(Changed<MediaControllerPlaybackStatus> notification,
CancellationToken cancellationToken)
{
if (notification.Value is PlaybackInformation information)
if (notification.Value is MediaControllerPlaybackStatus information)
{
switch (buttonType)
{
case PlaybackButtonType.Play:
Visible = information.Status is PlaybackStatus.Paused;
break;
case PlaybackButtonType.Pause:
Visible = information.Status is PlaybackStatus.Playing;
break;
}
//switch (buttonType)
//{
// case PlaybackButtonType.Play:
// Visible = information.Status is PlaybackStatus.Paused;
// break;
// case PlaybackButtonType.Pause:
// Visible = information.Status is PlaybackStatus.Playing;
// break;
//}
}
return Task.CompletedTask;
}
public override async Task InitializeAsync() =>
await Mediator.PublishAsync<Request<PlaybackInformation>>();
//public override async Task InitializeAsync() =>
// await Mediator.PublishAsync<Request<PlaybackInformation>>();
}