From cd74725561cf8ddc66b935e9d62cd1d81294aa90 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Sat, 9 Mar 2024 21:53:30 +0100 Subject: [PATCH] infobar errors --- .../Strings/en-US/HomeViewResources.resw | 3 + .../Home/HomeViewModel.cs | 53 ++-- .../VDownload.Core.Views/Home/HomeView.xaml | 248 +++++++++--------- .../Subscriptions/SubscriptionsView.xaml | 2 +- 4 files changed, 158 insertions(+), 148 deletions(-) diff --git a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomeViewResources.resw b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomeViewResources.resw index 5601658..8462c2e 100644 --- a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomeViewResources.resw +++ b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomeViewResources.resw @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Error + Download all diff --git a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs index 8dd6d3f..a6bb706 100644 --- a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs +++ b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs @@ -23,13 +23,6 @@ namespace VDownload.Core.ViewModels.Home { #region ENUMS - public enum OptionBarMessageIconType - { - None, - ProgressRing, - Error - } - public enum OptionBarContentType { None, @@ -80,6 +73,11 @@ namespace VDownload.Core.ViewModels.Home [ObservableProperty] private Type _mainContent; + [ObservableProperty] + private string _optionBarError; + + [ObservableProperty] + private bool _optionBarIsErrorOpened; [ObservableProperty] private OptionBarContentType _optionBarContent; @@ -88,7 +86,7 @@ namespace VDownload.Core.ViewModels.Home private string _optionBarMessage; [ObservableProperty] - private OptionBarMessageIconType _optionBarMessageIcon; + private bool _optionBarLoading; [ObservableProperty] private bool _optionBarLoadSubscriptionButtonChecked; @@ -149,8 +147,10 @@ namespace VDownload.Core.ViewModels.Home MainContent = _downloadsView; OptionBarContent = OptionBarContentType.None; - OptionBarMessageIcon = OptionBarMessageIconType.None; + OptionBarLoading = false; OptionBarMessage = null; + OptionBarError = null; + OptionBarIsErrorOpened = true; OptionBarLoadSubscriptionButtonChecked = false; OptionBarVideoSearchButtonChecked = false; OptionBarPlaylistSearchButtonChecked = false; @@ -164,7 +164,7 @@ namespace VDownload.Core.ViewModels.Home public async Task LoadFromSubscription() { MainContent = _downloadsView; - OptionBarMessageIcon = OptionBarMessageIconType.None; + OptionBarLoading = false; OptionBarMessage = null; if (OptionBarLoadSubscriptionButtonChecked) @@ -174,7 +174,7 @@ namespace VDownload.Core.ViewModels.Home OptionBarPlaylistSearchButtonChecked = false; OptionBarSearchNotPending = false; - OptionBarMessageIcon = OptionBarMessageIconType.ProgressRing; + OptionBarLoading = true; OptionBarMessage = _stringResourcesService.HomeViewResources.Get("OptionBarMessageLoading"); SubscriptionsVideoList subList = new SubscriptionsVideoList { Name = _stringResourcesService.CommonResources.Get("SubscriptionVideoListName") }; @@ -217,7 +217,7 @@ namespace VDownload.Core.ViewModels.Home } OptionBarSearchNotPending = true; - OptionBarMessageIcon = OptionBarMessageIconType.None; + OptionBarLoading = false; } } @@ -225,7 +225,7 @@ namespace VDownload.Core.ViewModels.Home public void VideoSearchShow() { OptionBarSearchNotPending = true; - OptionBarMessageIcon = OptionBarMessageIconType.None; + OptionBarLoading = false; OptionBarMessage = null; MainContent = _downloadsView; @@ -245,7 +245,7 @@ namespace VDownload.Core.ViewModels.Home public void PlaylistSearchShow() { OptionBarSearchNotPending = true; - OptionBarMessageIcon = OptionBarMessageIconType.None; + OptionBarLoading = false; OptionBarMessage = null; MainContent = _downloadsView; @@ -265,7 +265,7 @@ namespace VDownload.Core.ViewModels.Home public async Task VideoSearchStart() { OptionBarSearchNotPending = false; - OptionBarMessageIcon = OptionBarMessageIconType.ProgressRing; + OptionBarLoading = true; OptionBarMessage = _stringResourcesService.HomeViewResources.Get("OptionBarMessageLoading"); Video video; @@ -275,9 +275,10 @@ namespace VDownload.Core.ViewModels.Home } catch (MediaSearchException ex) { - OptionBarMessageIcon = OptionBarMessageIconType.Error; - OptionBarMessage = _stringResourcesService.SearchResources.Get(ex.StringCode); + OptionBarError = _stringResourcesService.SearchResources.Get(ex.StringCode); OptionBarSearchNotPending = true; + OptionBarLoading = false; + OptionBarMessage = null; return; } @@ -286,7 +287,7 @@ namespace VDownload.Core.ViewModels.Home MainContent = _videoView; OptionBarSearchNotPending = true; - OptionBarMessageIcon = OptionBarMessageIconType.None; + OptionBarLoading = false; OptionBarMessage = null; } @@ -294,7 +295,7 @@ namespace VDownload.Core.ViewModels.Home public async Task PlaylistSearchStart() { OptionBarSearchNotPending = false; - OptionBarMessageIcon = OptionBarMessageIconType.ProgressRing; + OptionBarLoading = true; OptionBarMessage = _stringResourcesService.HomeViewResources.Get("OptionBarMessageLoading"); Playlist playlist; @@ -304,9 +305,10 @@ namespace VDownload.Core.ViewModels.Home } catch (MediaSearchException ex) { - OptionBarMessageIcon = OptionBarMessageIconType.Error; - OptionBarMessage = _stringResourcesService.SearchResources.Get(ex.StringCode); + OptionBarError = _stringResourcesService.SearchResources.Get(ex.StringCode); OptionBarSearchNotPending = true; + OptionBarLoading = false; + OptionBarMessage = null; return; } @@ -315,7 +317,7 @@ namespace VDownload.Core.ViewModels.Home MainContent = _videoCollectionView; OptionBarSearchNotPending = true; - OptionBarMessageIcon = OptionBarMessageIconType.None; + OptionBarLoading = false; OptionBarMessage = null; } @@ -339,6 +341,13 @@ namespace VDownload.Core.ViewModels.Home } } + [RelayCommand] + public void CloseError() + { + OptionBarError = null; + OptionBarIsErrorOpened = true; + } + #endregion diff --git a/VDownload.Core/VDownload.Core.Views/Home/HomeView.xaml b/VDownload.Core/VDownload.Core.Views/Home/HomeView.xaml index 25a1322..f9e900b 100644 --- a/VDownload.Core/VDownload.Core.Views/Home/HomeView.xaml +++ b/VDownload.Core/VDownload.Core.Views/Home/HomeView.xaml @@ -25,130 +25,128 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -