diff --git a/Trdo/App.xaml.cs b/Trdo/App.xaml.cs index 65d57c5..0ca9768 100644 --- a/Trdo/App.xaml.cs +++ b/Trdo/App.xaml.cs @@ -11,7 +11,6 @@ using Trdo.Pages; using Trdo.Services; using Trdo.ViewModels; -using Windows.UI; using Windows.UI.ViewManagement; using WinUIEx; @@ -157,16 +156,36 @@ private void InitializeTrayIcon() private void TrayIcon_ContextMenu(TrayIcon sender, TrayIconEventArgs args) { - args.Flyout = CreateFlyout(); + if (SettingsService.TrayClickBehavior == 1) + { + // Swapped: right click plays/pauses (fall back to flyout if no station selected) + if (_playerVm.CanPlay) + { + _playerVm.Toggle(); + _ = UpdateTrayIconAsync(); + return; + } + } + + // Default: right click opens flyout; also fallback when no station is available + ShowFlyout(args); } private void TrayIcon_Selected(TrayIcon sender, TrayIconEventArgs args) { + if (SettingsService.TrayClickBehavior == 1) + { + // Swapped: left click opens flyout + ShowFlyout(args); + return; + } + + // Default: left click plays/pauses // Check if we can play (have stations available and one selected) if (!_playerVm.CanPlay) { // No stations available, show the flyout to encourage user to add a station - args.Flyout = CreateFlyout(); + ShowFlyout(args); return; } @@ -175,6 +194,12 @@ private void TrayIcon_Selected(TrayIcon sender, TrayIconEventArgs args) _ = UpdateTrayIconAsync(); } + private void ShowFlyout(TrayIconEventArgs args) + { + WindowPlacementService.CapturePointerAnchor(); + args.Flyout = CreateFlyout(); + } + private Flyout CreateFlyout() { Flyout flyout = new() @@ -190,6 +215,7 @@ private Flyout CreateFlyout() flyout.Opened += (s, e) => { + WindowPlacementService.CapturePointerAnchor(); // Clear the back stack when flyout opens to prevent accumulation Services.NavigationService.Instance.ClearBackStack(); }; @@ -272,7 +298,7 @@ private void UpdatePlayPauseCommandText() } else if (_playerVm.IsPlaying) { - + // Include now playing info if available if (_playerVm.HasNowPlaying) { diff --git a/Trdo/Assets/apple_music.svg b/Trdo/Assets/apple_music.svg new file mode 100644 index 0000000..6b5affd --- /dev/null +++ b/Trdo/Assets/apple_music.svg @@ -0,0 +1,5 @@ + diff --git a/Trdo/Assets/discogs.svg b/Trdo/Assets/discogs.svg new file mode 100644 index 0000000..957eeec --- /dev/null +++ b/Trdo/Assets/discogs.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Trdo/Assets/ytmusic.svg b/Trdo/Assets/ytmusic.svg new file mode 100644 index 0000000..f9df22a --- /dev/null +++ b/Trdo/Assets/ytmusic.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/Trdo/Controls/ManualStationWindow.xaml b/Trdo/Controls/ManualStationWindow.xaml new file mode 100644 index 0000000..b222264 --- /dev/null +++ b/Trdo/Controls/ManualStationWindow.xaml @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Trdo/Controls/ManualStationWindow.xaml.cs b/Trdo/Controls/ManualStationWindow.xaml.cs new file mode 100644 index 0000000..2c7cc49 --- /dev/null +++ b/Trdo/Controls/ManualStationWindow.xaml.cs @@ -0,0 +1,60 @@ +using Trdo.Models; +using Trdo.Services; +using Trdo.ViewModels; +using WinUIEx; + +namespace Trdo.Controls; + +/// +/// A small standalone window for manually adding or editing a radio station. +/// Opens as a pop-out window so that closing the tray flyout does not clear the form fields. +/// +public sealed partial class ManualStationWindow : WindowEx +{ + public AddStationViewModel ViewModel { get; } + + public ManualStationWindow() + { + InitializeComponent(); + + ViewModel = new AddStationViewModel(); + ViewModel.SetPlayerViewModel(PlayerViewModel.Shared); + + ExtendsContentIntoTitleBar = true; + SetTitleBar(ModernTitlebar); + + Activated += ManualStationWindow_Activated; + } + + /// + /// Opens the window pre-filled with the given station's data for editing. + /// + public void LoadStationForEdit(RadioStation station) + { + ViewModel.LoadStationForEdit(station); + } + + private void ManualStationWindow_Activated(object sender, Microsoft.UI.Xaml.WindowActivatedEventArgs args) + { + // Focus the station name field once the window is ready + if (args.WindowActivationState != Microsoft.UI.Xaml.WindowActivationState.Deactivated) + { + WindowPlacementService.PositionWindowNearAnchor(this, 400, 500); + StationNameTextBox.Focus(Microsoft.UI.Xaml.FocusState.Programmatic); + Activated -= ManualStationWindow_Activated; + } + } + + private void SaveButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) + { + if (ViewModel.Save()) + { + Close(); + } + } + + private void CancelButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) + { + Close(); + } +} diff --git a/Trdo/Controls/TutorialWindow.xaml.cs b/Trdo/Controls/TutorialWindow.xaml.cs index 0f8327f..758c27c 100644 --- a/Trdo/Controls/TutorialWindow.xaml.cs +++ b/Trdo/Controls/TutorialWindow.xaml.cs @@ -13,6 +13,16 @@ public TutorialWindow() ExtendsContentIntoTitleBar = true; SetTitleBar(ModernTitlebar); + Activated += TutorialWindow_Activated; + } + + private void TutorialWindow_Activated(object sender, Microsoft.UI.Xaml.WindowActivatedEventArgs args) + { + if (args.WindowActivationState == Microsoft.UI.Xaml.WindowActivationState.Deactivated) + return; + + WindowPlacementService.PositionWindowNearAnchor(this, 400, 600); + Activated -= TutorialWindow_Activated; } private void Button_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) diff --git a/Trdo/Package.appxmanifest b/Trdo/Package.appxmanifest index 09ba118..acd1508 100644 --- a/Trdo/Package.appxmanifest +++ b/Trdo/Package.appxmanifest @@ -11,7 +11,7 @@ + Version="1.9.1.0" /> diff --git a/Trdo/Pages/FavoritesPage.xaml b/Trdo/Pages/FavoritesPage.xaml index 591b8c1..d8cc599 100644 --- a/Trdo/Pages/FavoritesPage.xaml +++ b/Trdo/Pages/FavoritesPage.xaml @@ -31,7 +31,9 @@ HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="12" - Visibility="{x:Bind ViewModel.Favorites.Count, Mode=OneWay, Converter={StaticResource CountToEmptyStateVisibilityConverter}}"> + Visibility="{x:Bind ViewModel.Favorites.Count, + Mode=OneWay, + Converter={StaticResource CountToEmptyStateVisibilityConverter}}"> + Visibility="{x:Bind ViewModel.Favorites.Count, + Mode=OneWay, + Converter={StaticResource CountToHasItemsVisibilityConverter}}"> + + + + @@ -22,198 +51,360 @@ - - - - - - - - - + + + + + + + + + + + - - - - - - - - + + + + + + +