From 7fc898186bbf72101ff9e7bb726be6a804c79525 Mon Sep 17 00:00:00 2001 From: tor4kichi Date: Sat, 18 Dec 2021 12:51:39 +0900 Subject: [PATCH 01/13] =?UTF-8?q?=E3=83=9D=E3=82=A4=E3=83=B3=E3=82=BF?= =?UTF-8?q?=E3=83=BC=E3=82=AB=E3=83=BC=E3=82=BD=E3=83=AB=E8=87=AA=E5=8B=95?= =?UTF-8?q?=E9=9D=9E=E8=A1=A8=E7=A4=BA=E3=81=AE=E6=8C=99=E5=8B=95=E3=82=92?= =?UTF-8?q?=E6=94=B9=E5=96=84=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Input/PointerCursolAutoHideBehavior.cs | 114 +++++++++++++----- 1 file changed, 87 insertions(+), 27 deletions(-) diff --git a/Hohoema/Presentation.Views/Interaction/Input/PointerCursolAutoHideBehavior.cs b/Hohoema/Presentation.Views/Interaction/Input/PointerCursolAutoHideBehavior.cs index 38e559a03..4c021af3d 100644 --- a/Hohoema/Presentation.Views/Interaction/Input/PointerCursolAutoHideBehavior.cs +++ b/Hohoema/Presentation.Views/Interaction/Input/PointerCursolAutoHideBehavior.cs @@ -108,6 +108,11 @@ public static void OnAutoHideDelayPropertyChanged(object sender, DependencyPrope #endregion + private static bool GetIsWindowActive() + { + return Window.Current.CoreWindow.ActivationMode == CoreWindowActivationMode.ActivatedInForeground; + } + public PointerCursolAutoHideBehavior() { @@ -119,37 +124,59 @@ public PointerCursolAutoHideBehavior() protected override void OnAttached() { - base.OnAttached(); - - AssociatedObject.Loaded += AssociatedObject_Loaded; - AssociatedObject.Unloaded += AssociatedObject_Unloaded; - } + _LastCursorPosition = GetPointerPosition(); + _AutoHideTimer.Interval = AutoHideDelay; + _IsCursorInsideAssociatedObject = IsCursorInWindow(); + _prevIsVisible = true; + ResetAutoHideTimer(); - private void AssociatedObject_Loaded(object sender, RoutedEventArgs e) - { - MouseDevice.GetForCurrentView().MouseMoved += CursorSetter_MouseMoved; - + AssociatedObject.PointerEntered -= AssociatedObject_PointerEntered; + AssociatedObject.PointerExited -= AssociatedObject_PointerExited; AssociatedObject.PointerEntered += AssociatedObject_PointerEntered; AssociatedObject.PointerExited += AssociatedObject_PointerExited; - _AutoHideTimer.Interval = AutoHideDelay; + Window.Current.Activated -= Current_Activated; + Window.Current.Activated += Current_Activated; - _IsCursorInsideAssociatedObject = IsCursorInWindow(); + MouseDevice.GetForCurrentView().MouseMoved -= CursorSetter_MouseMoved; + MouseDevice.GetForCurrentView().MouseMoved += CursorSetter_MouseMoved; - ResetAutoHideTimer(); + AssociatedObject.Unloaded -= AssociatedObject_Unloaded; + AssociatedObject.Unloaded += AssociatedObject_Unloaded; + + base.OnAttached(); } + private void Current_Activated(object sender, WindowActivatedEventArgs e) + { + if (e.WindowActivationState != CoreWindowActivationState.Deactivated) + { + ResetAutoHideTimer(); + } + } + bool IsUnlaoded = false; private void AssociatedObject_Unloaded(object sender, RoutedEventArgs e) { - _AutoHideTimer.Stop(); + IsUnlaoded = true; + Window.Current.Activated -= Current_Activated; MouseDevice.GetForCurrentView().MouseMoved -= CursorSetter_MouseMoved; + + _AutoHideTimer.Stop(); Window.Current.CoreWindow.PointerCursor = _DefaultCursor; } + protected override void OnDetaching() + { + AssociatedObject.PointerEntered -= AssociatedObject_PointerEntered; + AssociatedObject.PointerExited -= AssociatedObject_PointerExited; + AssociatedObject.Unloaded -= AssociatedObject_Unloaded; + + base.OnDetaching(); + } private void ResetAutoHideTimer() { @@ -159,44 +186,69 @@ private void ResetAutoHideTimer() { _AutoHideTimer.Start(); } - else - { - CursorVisibilityChanged(true); - } + + CursorVisibilityChanged(true); } bool _prevIsVisible = true; private void CursorVisibilityChanged(bool isVisible) { - if (_DefaultCursor == null) { throw new Models.Infrastructure.HohoemaExpception($"Default cursor is can not be null."); } + if (_DefaultCursor == null) { throw new InvalidOperationException($"Default cursor is can not be null."); } - if ((_prevIsVisible ^ isVisible) && isVisible) - { - Window.Current.CoreWindow.PointerCursor = _DefaultCursor; - var windowBound = Window.Current.CoreWindow.Bounds; - Window.Current.CoreWindow.PointerPosition = new Point(windowBound.Left + _LastCursorPosition.X, windowBound.Top + _LastCursorPosition.Y); - } - else if ((_prevIsVisible ^ isVisible) && !isVisible) + // 表示状態変化のトリガーを検出して処理する + if (_prevIsVisible != isVisible) { - Window.Current.CoreWindow.PointerCursor = null; - _LastCursorPosition = GetPointerPosition(); + if (isVisible) + { + Window.Current.CoreWindow.PointerCursor = _DefaultCursor; + RestoreCursorPosition(); + + Debug.WriteLine($"Show Mouse Cursor."); + } + else + { + Window.Current.CoreWindow.PointerCursor = null; + RecordCursorPosition(); + + Debug.WriteLine($"Hide Mouse Cursor."); + } } _prevIsVisible = isVisible; } + private void RecordCursorPosition() + { + _LastCursorPosition = GetPointerPosition(); + } + + private void RestoreCursorPosition() + { + var windowBound = Window.Current.CoreWindow.Bounds; + Window.Current.CoreWindow.PointerPosition = new Point(windowBound.Left + _LastCursorPosition.X, windowBound.Top + _LastCursorPosition.Y); + } + private void AutoHideTimer_Tick(object sender, object e) { + if (IsUnlaoded) { return; } + if (GetIsWindowActive() is false) { return; } + if (IsAutoHideEnabled && _IsCursorInsideAssociatedObject) { CursorVisibilityChanged(false); } + + Debug.WriteLine("AutoHideTimer Stop!"); } private void CursorSetter_MouseMoved(MouseDevice sender, MouseEventArgs args) { + if (IsUnlaoded) { return; } + + RecordCursorPosition(); + // マウスホイールを動かした時等には移動していなくても呼ばれるがその場合は無視する if (args.MouseDelta.X == 0 && args.MouseDelta.Y == 0) { return; } @@ -207,15 +259,23 @@ private void CursorSetter_MouseMoved(MouseDevice sender, MouseEventArgs args) private void AssociatedObject_PointerEntered(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { + if (IsUnlaoded) { return; } + _IsCursorInsideAssociatedObject = true; + + Debug.WriteLine("PointerEntered"); } private void AssociatedObject_PointerExited(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { + if (IsUnlaoded) { return; } + _IsCursorInsideAssociatedObject = false; CursorVisibilityChanged(true); ResetAutoHideTimer(); + + Debug.WriteLine("PointerExited"); } #region this code copy from VLC WinRT From 50e86f754e14ffe6f56543dfcf2db0df5b89e941 Mon Sep 17 00:00:00 2001 From: tor4kichi Date: Sun, 13 Feb 2022 18:06:53 +0900 Subject: [PATCH 02/13] =?UTF-8?q?DI=E3=82=B3=E3=83=B3=E3=83=86=E3=83=8A?= =?UTF-8?q?=E3=82=92Unity=E3=81=8B=E3=82=89DryIoc=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FixPrism/BindableBaseWithFix.cs | 4 +- Hohoema.Models/Hohoema.Models.csproj | 4 - .../LocalMylist/LocalPlaylist.cs | 4 +- .../Niconico/Follow/FollowItemInfo.cs | 2 +- .../LoginUser/LoginUserMylistPlaylist.cs | 1 - .../LoginUser/LoginUserMylistProvider.cs | 3 +- .../Models.Domain/Niconico/NiconicoSession.cs | 4 +- .../Niconico/User/UserNameProvider.cs | 5 +- .../Models.Domain/Niconico/Video/NicoVideo.cs | 2 +- .../Niconico/Video/NicoVideoProvider.cs | 3 +- .../Video/VideoCacheSettings_Legacy.cs | 5 +- .../Niconico/Video/VideoRankingSettings.cs | 3 +- .../Notification/InAppNotificationMessage.cs | 1 - .../Models.Domain/Pins/HohoemaPin.cs | 6 +- .../Models.Domain/Pins/PinSettings.cs | 1 - .../Player/Live/LiveSuggestion.cs | 6 +- .../Player/MediaPlayerSoundVolumeManager.cs | 2 +- .../Models.Domain/Player/PlayerSettings.cs | 2 +- .../Video/Cache/NicoVideoCacheProgress.cs | 2 +- .../Video/Cache/VideoCacheManagerLegacy.cs | 4 +- .../Player/Video/Comment/VideoComment.cs | 6 +- .../Player/Video/NicoVideoSessionProvider.cs | 6 +- .../DmcVideoStreamingSession.cs | 1 - .../VideoStreamingOriginOrchestrator.cs | 2 +- .../Playlist/BufferedPlaylistItemsSource.cs | 9 +- .../Playlist/HohoemaPlaylistPlayer.cs | 20 ++-- .../Models.Domain/Playlist/QueuePlaylist.cs | 2 +- .../PrepareNextVideoCacheDownloadingResult.cs | 1 - .../VideoCache/VideoCacheManager.cs | 4 +- .../_Settings_Legacy/AccountSettings.cs | 4 +- .../_Settings_Legacy/CacheSettings.cs | 4 +- .../_Settings_Legacy/HohoemaUserSettings.cs | 7 +- .../_Settings_Legacy/PlayerSettings.cs | 14 +-- .../_Settings_Legacy/RankingSettings.cs | 2 +- Hohoema.Models/Models.Helpers/AsyncLock.cs | 6 +- .../Models.Helpers/IAsyncInitialize.cs | 4 +- .../FlagsRepositoryBase.cs | 6 +- .../Models.Infrastructure/ProviderBase.cs | 6 +- Hohoema/App.xaml | 2 +- Hohoema/App.xaml.cs | 110 +++++++++--------- Hohoema/Hohoema.csproj | 3 +- .../PrimaryViewPlayerManager.cs | 8 +- .../SecondaryViewPlayerManager.cs | 3 +- .../PageNavigation/IPageNavigatable.cs | 5 +- .../HohoemaSecondaryViewFrameViewModel.cs | 1 - .../LiveInfoListItemViewModel.cs | 3 +- .../NicoLiveUserIdAddToNGCommand.cs | 1 - .../NicoLiveUserIdRemoveFromNGCommand.cs | 1 - .../Commands/MylistCreateCommand.cs | 3 - .../VideoListItemControlViewModel.cs | 3 +- .../Player/ShowPrimaryViewCommand.cs | 3 +- .../MenuItemViewModel.cs | 1 + .../QueueMenuItemViewModel.cs | 1 + .../LiveInfomationPageViewModel.cs | 3 +- .../Niconico.Search/SearchPageViewModel.cs | 4 - .../LivePlayerPageViewModel.cs | 13 ++- .../_CommentRenderer/CommentRenderer.xaml.cs | 4 +- .../LiveCommentsSidePaneContentViewModel.cs | 2 - .../Controls/HohoemaInAppNotification.xaml.cs | 3 +- .../Dialogs/NiconicoLoginDialog.xaml.cs | 1 - .../Flyouts/LiveListItemFlyout.xaml.cs | 2 - .../Flyouts/MylistItemFlyout.xaml.cs | 1 - .../Flyouts/SubscriptionItemFlyout.xaml.cs | 1 - .../Flyouts/VideoItemFlyout.xaml.cs | 1 - 64 files changed, 159 insertions(+), 192 deletions(-) rename {Hohoema.Models/Models.Domain => Hohoema/Models.UseCase}/PageNavigation/IPageNavigatable.cs (68%) diff --git a/Hohoema.Models/FixPrism/BindableBaseWithFix.cs b/Hohoema.Models/FixPrism/BindableBaseWithFix.cs index 942d54868..4cd95d3b9 100644 --- a/Hohoema.Models/FixPrism/BindableBaseWithFix.cs +++ b/Hohoema.Models/FixPrism/BindableBaseWithFix.cs @@ -11,9 +11,9 @@ namespace Hohoema.FixPrism /// /// Implementation of to simplify models. /// - public abstract class BindableBase : INotifyPropertyChanged, IDisposable + public abstract class ObservableObject : INotifyPropertyChanged, IDisposable { - protected BindableBase() + protected ObservableObject() { } diff --git a/Hohoema.Models/Hohoema.Models.csproj b/Hohoema.Models/Hohoema.Models.csproj index a8f647ae9..135459285 100644 --- a/Hohoema.Models/Hohoema.Models.csproj +++ b/Hohoema.Models/Hohoema.Models.csproj @@ -207,7 +207,6 @@ - @@ -364,9 +363,6 @@ 4.5.4 - - 7.1.0-pre.4 - 1.0.0 diff --git a/Hohoema.Models/Models.Domain/LocalMylist/LocalPlaylist.cs b/Hohoema.Models/Models.Domain/LocalMylist/LocalPlaylist.cs index cc8d5127d..67aaa57e4 100644 --- a/Hohoema.Models/Models.Domain/LocalMylist/LocalPlaylist.cs +++ b/Hohoema.Models/Models.Domain/LocalMylist/LocalPlaylist.cs @@ -5,7 +5,7 @@ using Microsoft.Toolkit.Mvvm.Messaging; using Microsoft.Toolkit.Mvvm.Messaging.Messages; using NiconicoToolkit.Video; -using Prism.Mvvm; +using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Collections.Specialized; @@ -56,7 +56,7 @@ public bool Equals(IPlaylistSortOption other) } } - public sealed class LocalPlaylist : FixPrism.BindableBase, IUserManagedPlaylist + public sealed class LocalPlaylist : FixPrism.ObservableObject, IUserManagedPlaylist { public static LocalPlaylistSortOption[] SortOptions { get; } = new LocalPlaylistSortOption[] { diff --git a/Hohoema.Models/Models.Domain/Niconico/Follow/FollowItemInfo.cs b/Hohoema.Models/Models.Domain/Niconico/Follow/FollowItemInfo.cs index c6a369926..db9bd9e41 100644 --- a/Hohoema.Models/Models.Domain/Niconico/Follow/FollowItemInfo.cs +++ b/Hohoema.Models/Models.Domain/Niconico/Follow/FollowItemInfo.cs @@ -1,4 +1,4 @@ -using Prism.Mvvm; +using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Linq; diff --git a/Hohoema.Models/Models.Domain/Niconico/Mylist/LoginUser/LoginUserMylistPlaylist.cs b/Hohoema.Models/Models.Domain/Niconico/Mylist/LoginUser/LoginUserMylistPlaylist.cs index 3763ab7f1..de537678b 100644 --- a/Hohoema.Models/Models.Domain/Niconico/Mylist/LoginUser/LoginUserMylistPlaylist.cs +++ b/Hohoema.Models/Models.Domain/Niconico/Mylist/LoginUser/LoginUserMylistPlaylist.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using Prism.Ioc; using NiconicoToolkit.Mylist; using Hohoema.Models.Domain.Niconico.Video; using NiconicoToolkit.Account; diff --git a/Hohoema.Models/Models.Domain/Niconico/Mylist/LoginUser/LoginUserMylistProvider.cs b/Hohoema.Models/Models.Domain/Niconico/Mylist/LoginUser/LoginUserMylistProvider.cs index d689f18c3..1a645e46e 100644 --- a/Hohoema.Models/Models.Domain/Niconico/Mylist/LoginUser/LoginUserMylistProvider.cs +++ b/Hohoema.Models/Models.Domain/Niconico/Mylist/LoginUser/LoginUserMylistProvider.cs @@ -7,7 +7,6 @@ using System.Linq; using System.Threading.Tasks; using NiconicoToolkit.Mylist; -using Uno.Extensions; using NiconicoToolkit.Account; using NiconicoToolkit.Mylist.LoginUser; using NiconicoToolkit.Video; @@ -121,7 +120,7 @@ public async Task> GetLoginUserMylistGroups() //IconType = mylistGroup.co, DefaultSortKey = mylistGroup.DefaultSortKey, DefaultSortOrder = mylistGroup.DefaultSortOrder, - SortIndex = res.Data.Mylists.IndexOf(mylistGroup), + SortIndex = Array.IndexOf(res.Data.Mylists, mylistGroup), ThumbnailImages = mylistGroup.SampleItems.Take(3).Select(x => x.Video.Thumbnail.ListingUrl).ToArray(), }; diff --git a/Hohoema.Models/Models.Domain/Niconico/NiconicoSession.cs b/Hohoema.Models/Models.Domain/Niconico/NiconicoSession.cs index 0561cf5d8..a7f7fb952 100644 --- a/Hohoema.Models/Models.Domain/Niconico/NiconicoSession.cs +++ b/Hohoema.Models/Models.Domain/Niconico/NiconicoSession.cs @@ -1,5 +1,5 @@ using Hohoema.Models.Helpers; -using Prism.Mvvm; +using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Diagnostics; @@ -73,7 +73,7 @@ public struct NiconicoSessionLoginErrorEventArgs public Exception Exception { get; set; } } - public sealed class NiconicoSession : FixPrism.BindableBase, IDisposable + public sealed class NiconicoSession : FixPrism.ObservableObject, IDisposable { public NiconicoSession( IMessenger messenger diff --git a/Hohoema.Models/Models.Domain/Niconico/User/UserNameProvider.cs b/Hohoema.Models/Models.Domain/Niconico/User/UserNameProvider.cs index 60de34348..dd2dfe35b 100644 --- a/Hohoema.Models/Models.Domain/Niconico/User/UserNameProvider.cs +++ b/Hohoema.Models/Models.Domain/Niconico/User/UserNameProvider.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using System.Text; using System.Threading.Tasks; - using Uno.Extensions; public sealed class UserNameEntity { @@ -51,7 +50,7 @@ public bool TryResolveUserNameFromCache(uint userId, out string userName) { var cachedName = _userNameRepository.GetName(userId); if (cachedName != null && - DateTime.Now.IsBefore(cachedName.UpdatedAt + UserNameExpire)) + DateTime.Now > cachedName.UpdatedAt + UserNameExpire) { userName = cachedName.Name; return true; @@ -69,7 +68,7 @@ public async ValueTask ResolveUserNameAsync(uint userId) { var cachedName = _userNameRepository.GetName(userId); if (cachedName != null && - DateTime.Now.IsBefore(cachedName.UpdatedAt + UserNameExpire)) + DateTime.Now > cachedName.UpdatedAt + UserNameExpire) { return cachedName.Name; } diff --git a/Hohoema.Models/Models.Domain/Niconico/Video/NicoVideo.cs b/Hohoema.Models/Models.Domain/Niconico/Video/NicoVideo.cs index 0bb6aefed..308f8f8a3 100644 --- a/Hohoema.Models/Models.Domain/Niconico/Video/NicoVideo.cs +++ b/Hohoema.Models/Models.Domain/Niconico/Video/NicoVideo.cs @@ -1,7 +1,7 @@ using LiteDB; using NiconicoToolkit; using NiconicoToolkit.Video; -using Prism.Mvvm; +using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Linq; diff --git a/Hohoema.Models/Models.Domain/Niconico/Video/NicoVideoProvider.cs b/Hohoema.Models/Models.Domain/Niconico/Video/NicoVideoProvider.cs index a7987ae44..f7a0a3bfd 100644 --- a/Hohoema.Models/Models.Domain/Niconico/Video/NicoVideoProvider.cs +++ b/Hohoema.Models/Models.Domain/Niconico/Video/NicoVideoProvider.cs @@ -10,7 +10,6 @@ using System.Diagnostics; using Microsoft.Toolkit.Mvvm.Messaging; using Microsoft.Toolkit.Mvvm.Messaging.Messages; -using Uno.Threading; using System.Threading; using System.Runtime.CompilerServices; using NiconicoToolkit.Video.Watch; @@ -134,7 +133,7 @@ LiteDB.LiteDatabase liteDatabase static TimeSpan ThumbnailExpirationSpan { get; set; } = TimeSpan.FromMinutes(5); - FastAsyncLock _ThumbnailAccessLock = new FastAsyncLock(); + Models.Helpers.AsyncLock _ThumbnailAccessLock = new (); private readonly NicoVideoCacheRepository _nicoVideoRepository; private readonly NicoVideoOwnerCacheRepository _nicoVideoOwnerRepository; diff --git a/Hohoema.Models/Models.Domain/Niconico/Video/VideoCacheSettings_Legacy.cs b/Hohoema.Models/Models.Domain/Niconico/Video/VideoCacheSettings_Legacy.cs index 84d4dfe52..f534dacfd 100644 --- a/Hohoema.Models/Models.Domain/Niconico/Video/VideoCacheSettings_Legacy.cs +++ b/Hohoema.Models/Models.Domain/Niconico/Video/VideoCacheSettings_Legacy.cs @@ -1,5 +1,6 @@ using Hohoema.Models.Infrastructure; -using Prism.Mvvm; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -84,7 +85,7 @@ public NicoVideoQuality CacheQualityOnMeteredNetwork } [DataContract] - public class TagCondition : BindableBase + public class TagCondition : ObservableObject { public TagCondition() { diff --git a/Hohoema.Models/Models.Domain/Niconico/Video/VideoRankingSettings.cs b/Hohoema.Models/Models.Domain/Niconico/Video/VideoRankingSettings.cs index 1dda9ef40..1e82f61a3 100644 --- a/Hohoema.Models/Models.Domain/Niconico/Video/VideoRankingSettings.cs +++ b/Hohoema.Models/Models.Domain/Niconico/Video/VideoRankingSettings.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using Microsoft.Toolkit.Collections; using Hohoema.Models.Infrastructure; -using Uno.Extensions; using NiconicoToolkit.Ranking.Video; namespace Hohoema.Models.Domain.Niconico.Video @@ -76,7 +75,7 @@ public void RemoveHiddenGenre(RankingGenre genre) public void ResetHiddenGenre(IEnumerable genreList) { HiddenGenres.Clear(); - HiddenGenres.AddRange(genreList); + foreach (var genre in genreList) { HiddenGenres.Add(genre); } Save(HiddenGenres, nameof(HiddenGenres)); } diff --git a/Hohoema.Models/Models.Domain/Notification/InAppNotificationMessage.cs b/Hohoema.Models/Models.Domain/Notification/InAppNotificationMessage.cs index 3cf78db75..51d361c5d 100644 --- a/Hohoema.Models/Models.Domain/Notification/InAppNotificationMessage.cs +++ b/Hohoema.Models/Models.Domain/Notification/InAppNotificationMessage.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using System.Windows.Input; using Windows.UI.Xaml.Controls; -using Unity; using I18NPortable; using Microsoft.Toolkit.Mvvm.Messaging.Messages; using NiconicoToolkit.Account; diff --git a/Hohoema.Models/Models.Domain/Pins/HohoemaPin.cs b/Hohoema.Models/Models.Domain/Pins/HohoemaPin.cs index 86f49cb7e..068c5242a 100644 --- a/Hohoema.Models/Models.Domain/Pins/HohoemaPin.cs +++ b/Hohoema.Models/Models.Domain/Pins/HohoemaPin.cs @@ -1,14 +1,12 @@ using Hohoema.Models.Domain.PageNavigation; using LiteDB; -using Prism.Commands; -using Prism.Mvvm; +using Microsoft.Toolkit.Mvvm.ComponentModel; using System.Diagnostics; using System.Windows.Input; -using Unity; namespace Hohoema.Models.Domain.Pins { - public sealed class HohoemaPin : BindableBase + public sealed class HohoemaPin : ObservableObject { [BsonId(autoId:true)] public int Id { get; set; } diff --git a/Hohoema.Models/Models.Domain/Pins/PinSettings.cs b/Hohoema.Models/Models.Domain/Pins/PinSettings.cs index 36f438a36..b94077d34 100644 --- a/Hohoema.Models/Models.Domain/Pins/PinSettings.cs +++ b/Hohoema.Models/Models.Domain/Pins/PinSettings.cs @@ -1,6 +1,5 @@ using Hohoema.Models.Domain.PageNavigation; using Hohoema.Models.Infrastructure; -using Prism.Navigation; using System; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/Hohoema.Models/Models.Domain/Player/Live/LiveSuggestion.cs b/Hohoema.Models/Models.Domain/Player/Live/LiveSuggestion.cs index 70c97c2bc..68dd4ba1d 100644 --- a/Hohoema.Models/Models.Domain/Player/Live/LiveSuggestion.cs +++ b/Hohoema.Models/Models.Domain/Player/Live/LiveSuggestion.cs @@ -1,4 +1,4 @@ -using Prism.Commands; +using Microsoft.Toolkit.Mvvm.Input; using System; using System.Collections.Generic; using System.Linq; @@ -23,12 +23,12 @@ public LiveSuggestion(string title, params SuggestAction[] actions) public class SuggestAction { public string Label { get; private set; } - public DelegateCommand SuggestActionCommand { get; private set; } + public RelayCommand SuggestActionCommand { get; private set; } public SuggestAction(string label, Action action) { Label = label; - SuggestActionCommand = new DelegateCommand(action); + SuggestActionCommand = new RelayCommand(action); } } diff --git a/Hohoema.Models/Models.Domain/Player/MediaPlayerSoundVolumeManager.cs b/Hohoema.Models/Models.Domain/Player/MediaPlayerSoundVolumeManager.cs index b5b259128..ca9da25bc 100644 --- a/Hohoema.Models/Models.Domain/Player/MediaPlayerSoundVolumeManager.cs +++ b/Hohoema.Models/Models.Domain/Player/MediaPlayerSoundVolumeManager.cs @@ -13,7 +13,7 @@ namespace Hohoema.Models.Domain.Player { - public class MediaPlayerSoundVolumeManager : BindableBase + public class MediaPlayerSoundVolumeManager : ObservableObject { public MediaPlayerSoundVolumeManager( PlayerSettings playerSettings, diff --git a/Hohoema.Models/Models.Domain/Player/PlayerSettings.cs b/Hohoema.Models/Models.Domain/Player/PlayerSettings.cs index 877ec354c..b2c42b43a 100644 --- a/Hohoema.Models/Models.Domain/Player/PlayerSettings.cs +++ b/Hohoema.Models/Models.Domain/Player/PlayerSettings.cs @@ -1,7 +1,7 @@ using Microsoft.Toolkit.Uwp.Helpers; using NiconicoToolkit.Live.WatchSession; using Hohoema.FixPrism; -using Prism.Commands; +using Microsoft.Toolkit.Mvvm.Input; using System; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/Hohoema.Models/Models.Domain/Player/Video/Cache/NicoVideoCacheProgress.cs b/Hohoema.Models/Models.Domain/Player/Video/Cache/NicoVideoCacheProgress.cs index a08463852..b3e253ca7 100644 --- a/Hohoema.Models/Models.Domain/Player/Video/Cache/NicoVideoCacheProgress.cs +++ b/Hohoema.Models/Models.Domain/Player/Video/Cache/NicoVideoCacheProgress.cs @@ -15,7 +15,7 @@ namespace Hohoema.Models.Domain.Player.Video.Cache { - public class NicoVideoCacheProgress : BindableBase, IDisposable + public class NicoVideoCacheProgress : ObservableObject, IDisposable { public string VideoId { get; set; } public string VideoTitle { get; set; } diff --git a/Hohoema.Models/Models.Domain/Player/Video/Cache/VideoCacheManagerLegacy.cs b/Hohoema.Models/Models.Domain/Player/Video/Cache/VideoCacheManagerLegacy.cs index a5f22753e..a1baf95d9 100644 --- a/Hohoema.Models/Models.Domain/Player/Video/Cache/VideoCacheManagerLegacy.cs +++ b/Hohoema.Models/Models.Domain/Player/Video/Cache/VideoCacheManagerLegacy.cs @@ -1,5 +1,5 @@ using Hohoema.Models.Helpers; -using Prism.Mvvm; +using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -20,7 +20,7 @@ using System.Collections.Concurrent; using Windows.UI.Notifications; using Microsoft.Toolkit.Uwp.Notifications; -using Prism.Commands; +using Microsoft.Toolkit.Mvvm.Input; using System.Collections.Immutable; using Hohoema.Models.Domain.Niconico.Video; using Hohoema.Models.Domain.Application; diff --git a/Hohoema.Models/Models.Domain/Player/Video/Comment/VideoComment.cs b/Hohoema.Models/Models.Domain/Player/Video/Comment/VideoComment.cs index a9b1fc732..0f81e2e7d 100644 --- a/Hohoema.Models/Models.Domain/Player/Video/Comment/VideoComment.cs +++ b/Hohoema.Models/Models.Domain/Player/Video/Comment/VideoComment.cs @@ -1,7 +1,7 @@ using Hohoema.Models.Domain; using Hohoema.Models.Helpers; -using Prism.Commands; -using Prism.Mvvm; +using Microsoft.Toolkit.Mvvm.Input; +using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Linq; @@ -18,7 +18,7 @@ namespace Hohoema.Models.Domain.Player.Video.Comment { [DataContract] - public class VideoComment : BindableBase, IComment + public class VideoComment : ObservableObject, IComment { // コメントのデータ構造だけで他のことを知っているべきじゃない // このデータを解釈して実際に表示するためのオブジェクトにする部分は処理は diff --git a/Hohoema.Models/Models.Domain/Player/Video/NicoVideoSessionProvider.cs b/Hohoema.Models/Models.Domain/Player/Video/NicoVideoSessionProvider.cs index b2fc6f17a..cba6c59bd 100644 --- a/Hohoema.Models/Models.Domain/Player/Video/NicoVideoSessionProvider.cs +++ b/Hohoema.Models/Models.Domain/Player/Video/NicoVideoSessionProvider.cs @@ -11,7 +11,6 @@ using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; -using Uno.Extensions; using Windows.Foundation; namespace Hohoema.Models.Domain.Player.Video @@ -675,9 +674,8 @@ public static NicoVideoQuality ToNicoVideoQuality(this DmcWatchApiData dmcWatchD var dmcVideoContent = dmcWatchData?.Media.Delivery.Movie.Videos.FirstOrDefault(x => x.Id == qualityId); if (dmcVideoContent != null) { - var qualities = dmcWatchData.Media.Delivery.Movie.Videos; - - var index = qualities.IndexOf(dmcVideoContent); + var qualities = dmcWatchData.Media.Delivery.Movie.Videos; + var index = Array.IndexOf(qualities, dmcVideoContent); // DmcInfo.Quality の要素数は動画によって1~5個まで様々である // また並びは常に先頭が最高画質、最後尾は最低画質(Mobile)となっている diff --git a/Hohoema.Models/Models.Domain/Player/Video/VideoStreamingSession/DmcVideoStreamingSession.cs b/Hohoema.Models/Models.Domain/Player/Video/VideoStreamingSession/DmcVideoStreamingSession.cs index f8ff19bf0..295d372e7 100644 --- a/Hohoema.Models/Models.Domain/Player/Video/VideoStreamingSession/DmcVideoStreamingSession.cs +++ b/Hohoema.Models/Models.Domain/Player/Video/VideoStreamingSession/DmcVideoStreamingSession.cs @@ -8,7 +8,6 @@ using Windows.Media.Streaming.Adaptive; using Windows.UI.Xaml; using Windows.System; -using Uno.Threading; using NiconicoSession = Hohoema.Models.Domain.Niconico.NiconicoSession; using Hohoema.Models.Domain.Niconico.Video; using NiconicoToolkit.Video.Watch; diff --git a/Hohoema.Models/Models.Domain/Player/VideoStreamingOriginOrchestrator.cs b/Hohoema.Models/Models.Domain/Player/VideoStreamingOriginOrchestrator.cs index d525e3fbe..d21e281de 100644 --- a/Hohoema.Models/Models.Domain/Player/VideoStreamingOriginOrchestrator.cs +++ b/Hohoema.Models/Models.Domain/Player/VideoStreamingOriginOrchestrator.cs @@ -5,7 +5,7 @@ using Hohoema.Models.Domain.Player; using Hohoema.Models.Domain.Player.Video; using Hohoema.Models.Domain.Player.Video.Comment; -using Prism.Mvvm; +using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/Hohoema.Models/Models.Domain/Playlist/BufferedPlaylistItemsSource.cs b/Hohoema.Models/Models.Domain/Playlist/BufferedPlaylistItemsSource.cs index d7bc1fa5e..3b14ea92b 100644 --- a/Hohoema.Models/Models.Domain/Playlist/BufferedPlaylistItemsSource.cs +++ b/Hohoema.Models/Models.Domain/Playlist/BufferedPlaylistItemsSource.cs @@ -15,8 +15,6 @@ using System.Reactive.Subjects; using System.Threading; using System.Threading.Tasks; -using Uno.Extensions; -using Uno.Threading; namespace Hohoema.Models.Domain.Playlist { @@ -69,7 +67,7 @@ public BufferedPlaylistItemsSource(IUnlimitedPlaylist playlistItemsSource, IPlay return this.Items[index]; } - FastAsyncLock _loadingLock = new FastAsyncLock(); + Models.Helpers.AsyncLock _loadingLock = new (); public async Task> GetPagedItemsAsync(int pageIndex, int pageSize, CancellationToken ct = default) { @@ -223,7 +221,10 @@ public async Task> GetPagedItemsAsync(int pageIndex, isItemsFilled = true; var items = await _playlistItemsSource.GetAllItemsAsync(SortOption, ct); - Items.AddRange(items); + foreach (var item in items) + { + Items.Add(item); + } } var start = pageIndex * OneTimeLoadingItemsCount; diff --git a/Hohoema.Models/Models.Domain/Playlist/HohoemaPlaylistPlayer.cs b/Hohoema.Models/Models.Domain/Playlist/HohoemaPlaylistPlayer.cs index bfdf0c6cd..b65b12a9c 100644 --- a/Hohoema.Models/Models.Domain/Playlist/HohoemaPlaylistPlayer.cs +++ b/Hohoema.Models/Models.Domain/Playlist/HohoemaPlaylistPlayer.cs @@ -8,11 +8,11 @@ using Hohoema.Models.Infrastructure; using Microsoft.Toolkit.Collections; using Microsoft.Toolkit.Diagnostics; +using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.Messaging; using Microsoft.Toolkit.Mvvm.Messaging.Messages; using Microsoft.Toolkit.Uwp; using NiconicoToolkit.Video; -using Prism.Mvvm; using Reactive.Bindings; using Reactive.Bindings.Extensions; using System; @@ -28,8 +28,6 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Uno.Extensions; -using Uno.Threading; using Windows.Media; using Windows.Media.Core; using Windows.Media.Playback; @@ -91,7 +89,7 @@ public ResolvePlaylistFailedMessage(ResolvePlaylistFailedMessageData value) : ba - public abstract class PlaylistPlayer : BindableBase, IDisposable + public abstract class PlaylistPlayer : ObservableObject, IDisposable { private const int InvalidIndex = -1; private readonly PlayerSettings _playerSettings; @@ -115,7 +113,7 @@ public PlaylistPlayer(PlayerSettings playerSettings, IScheduler scheduler) _IsShuffleEnableSubscriber = _playerSettings.ObserveProperty(x => x.IsShuffleEnable) .Subscribe(enabled => { - _scheduler.Schedule(() => RaisePropertyChanged(nameof(IsShuffleModeRequested))); + _scheduler.Schedule(() => OnPropertyChanged(nameof(IsShuffleModeRequested))); }); } @@ -130,7 +128,7 @@ protected set { if (SetProperty(ref _currentPlaylist, value)) { - RaisePropertyChanged(nameof(CurrentPlaylistSortOptions)); + OnPropertyChanged(nameof(CurrentPlaylistSortOptions)); } } } @@ -148,8 +146,8 @@ public bool IsUnlimitedPlaylistSource { if (SetProperty(ref _isUnlimitedPlaylistSource, value)) { - RaisePropertyChanged(nameof(IsShuffleAndRepeatAvailable)); - RaisePropertyChanged(nameof(IsShuffleModeEnabled)); + OnPropertyChanged(nameof(IsShuffleAndRepeatAvailable)); + OnPropertyChanged(nameof(IsShuffleModeEnabled)); } } } @@ -175,7 +173,7 @@ public IObservable GetBufferedItems() protected async ValueTask Reset(IPlaylist playlist, IPlaylistSortOption sortOption) { - if (CurrentPlaylist == playlist && sortOption.SafeEquals(BufferedPlaylistItemsSource?.SortOption)) + if (CurrentPlaylist == playlist && (sortOption?.Equals(BufferedPlaylistItemsSource?.SortOption) ?? false)) { return BufferedPlaylistItemsSource; } @@ -352,7 +350,7 @@ protected async ValueTask CanGoPreviewAsync_Internal(CancellationToken ct } - FastAsyncLock _lock = new FastAsyncLock(); + Helpers.AsyncLock _lock = new (); public async Task GoNextAsync(CancellationToken ct = default) { using var _ = await _lock.LockAsync(ct); @@ -746,7 +744,7 @@ private async Task UpdatePlayingMediaAsync(IVideoContent item, TimeSpan? s Guard.IsNotNull(_mediaPlayer.PlaybackSession, nameof(_mediaPlayer.PlaybackSession)); - RaisePropertyChanged(nameof(AvailableQualities)); + OnPropertyChanged(nameof(AvailableQualities)); NowPlayingWithCache = videoSession is CachedVideoStreamingSession; _soundVolumeManager.LoudnessCorrectionValue = CurrentPlayingSession.VideoDetails.LoudnessCorrectionValue; diff --git a/Hohoema.Models/Models.Domain/Playlist/QueuePlaylist.cs b/Hohoema.Models/Models.Domain/Playlist/QueuePlaylist.cs index 5400b4bf4..534b66c0b 100644 --- a/Hohoema.Models/Models.Domain/Playlist/QueuePlaylist.cs +++ b/Hohoema.Models/Models.Domain/Playlist/QueuePlaylist.cs @@ -143,7 +143,7 @@ public bool Equals(IPlaylistSortOption other) } } - public class QueuePlaylist : BindableBase, IReadOnlyCollection, INotifyCollectionChanged, IUserManagedPlaylist + public class QueuePlaylist : ObservableObject, IReadOnlyCollection, INotifyCollectionChanged, IUserManagedPlaylist { public static QueuePlaylistSortOption[] SortOptions { get; } = new QueuePlaylistSortOption[] { diff --git a/Hohoema.Models/Models.Domain/VideoCache/PrepareNextVideoCacheDownloadingResult.cs b/Hohoema.Models/Models.Domain/VideoCache/PrepareNextVideoCacheDownloadingResult.cs index 14a8476d9..1c4e6b2c6 100644 --- a/Hohoema.Models/Models.Domain/VideoCache/PrepareNextVideoCacheDownloadingResult.cs +++ b/Hohoema.Models/Models.Domain/VideoCache/PrepareNextVideoCacheDownloadingResult.cs @@ -1,7 +1,6 @@ using NiconicoToolkit.Video; using System; using System.Threading.Tasks; -using Uno.Disposables; namespace Hohoema.Models.Domain.VideoCache { diff --git a/Hohoema.Models/Models.Domain/VideoCache/VideoCacheManager.cs b/Hohoema.Models/Models.Domain/VideoCache/VideoCacheManager.cs index eaab15703..7f9acfd5b 100644 --- a/Hohoema.Models/Models.Domain/VideoCache/VideoCacheManager.cs +++ b/Hohoema.Models/Models.Domain/VideoCache/VideoCacheManager.cs @@ -13,13 +13,13 @@ using Windows.Storage.Search; using XTSSharp; using Hohoema.Models.Domain.Niconico; -using Uno.Disposables; using System.Security.Cryptography; using System.Collections; using Microsoft.Toolkit.Uwp.Helpers; using Hohoema.Models.Domain.Niconico.Video; using Hohoema.Models.Infrastructure; using NiconicoToolkit.Video; +using System.Reactive.Disposables; namespace Hohoema.Models.Domain.VideoCache { @@ -660,7 +660,7 @@ public async ValueTask PrepareNextCacheD } catch { - opCreationResult.DownloadOperation.TryDispose(); + (opCreationResult.DownloadOperation as IDisposable)?.Dispose(); throw; } diff --git a/Hohoema.Models/Models.Domain/_Settings_Legacy/AccountSettings.cs b/Hohoema.Models/Models.Domain/_Settings_Legacy/AccountSettings.cs index 7a9bb867f..e9420102b 100644 --- a/Hohoema.Models/Models.Domain/_Settings_Legacy/AccountSettings.cs +++ b/Hohoema.Models/Models.Domain/_Settings_Legacy/AccountSettings.cs @@ -1,4 +1,4 @@ -using Prism.Mvvm; +using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Linq; @@ -9,7 +9,7 @@ namespace NicoPlayerHohoema.Models { [DataContract] - public class AccountSettings : BindableBase + public class AccountSettings : ObservableObject { public AccountSettings() : base() diff --git a/Hohoema.Models/Models.Domain/_Settings_Legacy/CacheSettings.cs b/Hohoema.Models/Models.Domain/_Settings_Legacy/CacheSettings.cs index 67549023c..1c3a1eacb 100644 --- a/Hohoema.Models/Models.Domain/_Settings_Legacy/CacheSettings.cs +++ b/Hohoema.Models/Models.Domain/_Settings_Legacy/CacheSettings.cs @@ -1,5 +1,5 @@ using Hohoema.Models.Domain.Player.Video; -using Prism.Mvvm; +using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -94,7 +94,7 @@ public NicoVideoQuality_Legacy DefaultCacheQualityOnMeteredNetwork } [DataContract] - public class TagCondition : BindableBase + public class TagCondition : ObservableObject { public TagCondition() { diff --git a/Hohoema.Models/Models.Domain/_Settings_Legacy/HohoemaUserSettings.cs b/Hohoema.Models/Models.Domain/_Settings_Legacy/HohoemaUserSettings.cs index 146c97dd7..a7a77a05c 100644 --- a/Hohoema.Models/Models.Domain/_Settings_Legacy/HohoemaUserSettings.cs +++ b/Hohoema.Models/Models.Domain/_Settings_Legacy/HohoemaUserSettings.cs @@ -1,13 +1,12 @@ -using Hohoema.Models.Domain.Niconico.NicoRepo; -using NiconicoToolkit.NicoRepo; +using NiconicoToolkit.NicoRepo; using System; using System.IO; using System.Linq; +using System.Reactive.Disposables; using System.Runtime.Serialization; using System.Text.Json; using System.Threading; using System.Threading.Tasks; -using Uno.Disposables; using Windows.Storage; namespace Hohoema.Models.Domain.Legacy @@ -134,7 +133,7 @@ public void Dispose() } [DataContract] - public abstract class SettingsBase : FixPrism.BindableBase + public abstract class SettingsBase : FixPrism.ObservableObject { public SettingsBase() { diff --git a/Hohoema.Models/Models.Domain/_Settings_Legacy/PlayerSettings.cs b/Hohoema.Models/Models.Domain/_Settings_Legacy/PlayerSettings.cs index dee57e3ad..21ce0df47 100644 --- a/Hohoema.Models/Models.Domain/_Settings_Legacy/PlayerSettings.cs +++ b/Hohoema.Models/Models.Domain/_Settings_Legacy/PlayerSettings.cs @@ -1,7 +1,7 @@ using Microsoft.Toolkit.Uwp.Helpers; using NiconicoToolkit.Live.WatchSession; using Hohoema.FixPrism; -using Prism.Commands; +using Microsoft.Toolkit.Mvvm.Input; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -357,13 +357,13 @@ public double PlaybackRate } - private DelegateCommand _SetPlaybackRateCommand; - public DelegateCommand SetPlaybackRateCommand + private RelayCommand _SetPlaybackRateCommand; + public RelayCommand SetPlaybackRateCommand { get { return _SetPlaybackRateCommand - ?? (_SetPlaybackRateCommand = new DelegateCommand( + ?? (_SetPlaybackRateCommand = new RelayCommand( (rate) => PlaybackRate = rate.HasValue ? rate.Value : 1.0 , (rate) => rate.HasValue ? rate.Value != PlaybackRate : true) ); @@ -631,13 +631,13 @@ public bool AutoMoveNextVideoOnPlaylistEmpty set { SetProperty(ref _AutoMoveNextVideoOnPlaylistEmpty, value); } } - private DelegateCommand _ToggleShuffleCommand; - public DelegateCommand ToggleShuffleCommand + private RelayCommand _ToggleShuffleCommand; + public RelayCommand ToggleShuffleCommand { get { return _ToggleShuffleCommand - ?? (_ToggleShuffleCommand = new DelegateCommand(() => + ?? (_ToggleShuffleCommand = new RelayCommand(() => { IsShuffleEnable = !IsShuffleEnable; } diff --git a/Hohoema.Models/Models.Domain/_Settings_Legacy/RankingSettings.cs b/Hohoema.Models/Models.Domain/_Settings_Legacy/RankingSettings.cs index 47c61c973..191bdc028 100644 --- a/Hohoema.Models/Models.Domain/_Settings_Legacy/RankingSettings.cs +++ b/Hohoema.Models/Models.Domain/_Settings_Legacy/RankingSettings.cs @@ -1,6 +1,6 @@ using NiconicoToolkit.Ranking.Video; using Hohoema.Models.Helpers; -using Prism.Mvvm; +using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/Hohoema.Models/Models.Helpers/AsyncLock.cs b/Hohoema.Models/Models.Helpers/AsyncLock.cs index 9c23c68be..ce9ffdeae 100644 --- a/Hohoema.Models/Models.Helpers/AsyncLock.cs +++ b/Hohoema.Models/Models.Helpers/AsyncLock.cs @@ -20,13 +20,13 @@ public AsyncLock() m_releaser = Task.FromResult((IDisposable)new Releaser(this)); } - public Task LockAsync() + public Task LockAsync(CancellationToken ct = default) { - var wait = m_semaphore.WaitAsync(); + var wait = m_semaphore.WaitAsync(ct); return wait.IsCompleted ? m_releaser : wait.ContinueWith((_, state) => (IDisposable)state, - m_releaser.Result, CancellationToken.None, + m_releaser.Result, ct, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default); } diff --git a/Hohoema.Models/Models.Helpers/IAsyncInitialize.cs b/Hohoema.Models/Models.Helpers/IAsyncInitialize.cs index aa7181c6d..0ad9c24ff 100644 --- a/Hohoema.Models/Models.Helpers/IAsyncInitialize.cs +++ b/Hohoema.Models/Models.Helpers/IAsyncInitialize.cs @@ -1,4 +1,4 @@ -using Prism.Mvvm; +using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Diagnostics; @@ -20,7 +20,7 @@ public interface IAsyncInitialize } - public abstract class AsyncInitialize : BindableBase, IAsyncInitialize + public abstract class AsyncInitialize : ObservableObject, IAsyncInitialize { public bool IsInitialized { get; private set; } = false; diff --git a/Hohoema.Models/Models.Infrastructure/FlagsRepositoryBase.cs b/Hohoema.Models/Models.Infrastructure/FlagsRepositoryBase.cs index 58b1da74c..fc29da66d 100644 --- a/Hohoema.Models/Models.Infrastructure/FlagsRepositoryBase.cs +++ b/Hohoema.Models/Models.Infrastructure/FlagsRepositoryBase.cs @@ -6,17 +6,17 @@ using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; -using Uno.Threading; using Windows.Storage; using System.Runtime.Serialization.Json; +using Hohoema.Models.Helpers; namespace Hohoema.Models.Infrastructure { - public class FlagsRepositoryBase : BindableBase + public class FlagsRepositoryBase : ObservableObject { private readonly LocalObjectStorageHelper _LocalStorageHelper; - FastAsyncLock _fileUpdateLock = new FastAsyncLock(); + AsyncLock _fileUpdateLock = new AsyncLock(); public FlagsRepositoryBase() { _LocalStorageHelper = new LocalObjectStorageHelper(new SystemTextJsonSerializer()); diff --git a/Hohoema.Models/Models.Infrastructure/ProviderBase.cs b/Hohoema.Models/Models.Infrastructure/ProviderBase.cs index 3f0c77623..7d11618a4 100644 --- a/Hohoema.Models/Models.Infrastructure/ProviderBase.cs +++ b/Hohoema.Models/Models.Infrastructure/ProviderBase.cs @@ -4,9 +4,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -using Uno.Threading; using System.Threading; using NiconicoSession = Hohoema.Models.Domain.Niconico.NiconicoSession; + namespace Hohoema.Models.Infrastructure { public abstract class ProviderBase @@ -18,9 +18,9 @@ public ProviderBase(NiconicoSession niconicoSession) protected NiconicoSession _niconicoSession { get; } - protected static FastAsyncLock _contextLock { get; } = new FastAsyncLock(); + protected static AsyncLock _contextLock { get; } = new AsyncLock(); - static FastAsyncLock _pageAccessLock = new FastAsyncLock(); + static AsyncLock _pageAccessLock = new AsyncLock(); static DateTime LastPageApiAccessTime = DateTime.MinValue; static readonly TimeSpan PageAccessMinimumInterval = TimeSpan.FromSeconds(0.5); diff --git a/Hohoema/App.xaml b/Hohoema/App.xaml index 964bcd40b..e3ab2da46 100644 --- a/Hohoema/App.xaml +++ b/Hohoema/App.xaml @@ -1,6 +1,6 @@ (new InjectionFactory(c => new LocalObjectStorageHelper(new SystemTextJsonSerializer()))); +// unityContainer.Register(made: Made.Of().Parameters.Name("navigationServiceLazy", x => new Lazy(() => unityContainer.Resolve(serviceKey: "PrimaryPlayerNavigationService")))); - unityContainer.RegisterInstance(WeakReferenceMessenger.Default); + unityContainer.UseInstance(new LocalObjectStorageHelper(new SystemTextJsonSerializer())); + + unityContainer.UseInstance(WeakReferenceMessenger.Default); LiteDatabase db = new LiteDatabase($"Filename={Path.Combine(ApplicationData.Current.LocalFolder.Path, "hohoema.db")};"); - unityContainer.RegisterInstance(db); + unityContainer.UseInstance(db); var mainWindowsScheduler = new SynchronizationContextScheduler(SynchronizationContext.Current); // 各ウィンドウごとのスケジューラを作るように - unityContainer.RegisterType(new PerThreadLifetimeManager(), new InjectionFactory(c => SynchronizationContext.Current != null ? new SynchronizationContextScheduler(SynchronizationContext.Current) : mainWindowsScheduler)); - unityContainer.RegisterInstance("MainWindowsScheduler", mainWindowsScheduler); + unityContainer.UseInstance(mainWindowsScheduler); +// unityContainer.RegisterInstance("MainWindowsScheduler", mainWindowsScheduler); - unityContainer.RegisterType(new InjectionFactory(c => + unityContainer.RegisterDelegate(c => { var appearanceSettings = c.Resolve(); if (appearanceSettings.PlayerDisplayView == PlayerDisplayView.PrimaryView) @@ -236,71 +240,71 @@ public override void RegisterTypes(IContainerRegistry container) { return c.Resolve(); } - })); + }); // MediaPlayerを各ウィンドウごとに一つずつ作るように - unityContainer.RegisterType(new PerThreadLifetimeManager()); + container.RegisterSingleton(); // 再生プレイリスト管理のクラスは各ウィンドウごとに一つずつ作成 - unityContainer.RegisterType(new PerThreadLifetimeManager()); + container.RegisterSingleton(); // Service - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); // Models - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); - unityContainer.RegisterSingleton(); + container.RegisterSingleton(); - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); - - unityContainer.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + + container.RegisterSingleton(); - unityContainer.RegisterSingleton(); + container.RegisterSingleton(); - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); // UseCase - unityContainer.RegisterType(new PerThreadLifetimeManager()); - unityContainer.RegisterType(new PerThreadLifetimeManager()); - unityContainer.RegisterType(new PerThreadLifetimeManager()); - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); - unityContainer.RegisterSingleton(); + unityContainer.Register(); + container.Register(); + container.Register(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); - unityContainer.RegisterSingleton(); + container.RegisterSingleton(); - unityContainer.RegisterSingleton(); + container.RegisterSingleton(); // ViewModels - unityContainer.RegisterSingleton(); + container.RegisterSingleton(); // Frameのキャッシュ無効+IncrementalLoadingリスト系ページのViewModelがシングルトン、という構成の場合に // ListViewの読み込み順序が壊れる問題が発生するためVMは都度生成にしている // see@ https://github.com/tor4kichi/Hohoema/issues/836 - unityContainer.RegisterSingleton(); + container.RegisterSingleton(); //unityContainer.RegisterType(new PerThreadLifetimeManager()); //unityContainer.RegisterType(new PerThreadLifetimeManager()); @@ -410,7 +414,7 @@ await TryMigrationAsync(new Type[] // Xaml側で扱いやすくするためApp.xaml上でインスタンス生成させている { var unityContainer = Container.GetContainer(); - unityContainer.RegisterInstance(Resources["FeatureFlags"] as FeatureFlags); + unityContainer.UseInstance(Resources["FeatureFlags"] as FeatureFlags); } // ローカリゼーション用のライブラリを初期化 diff --git a/Hohoema/Hohoema.csproj b/Hohoema/Hohoema.csproj index 5b602d81e..a4bfc53de 100644 --- a/Hohoema/Hohoema.csproj +++ b/Hohoema/Hohoema.csproj @@ -148,6 +148,7 @@ + @@ -853,7 +854,7 @@ 5.0.2 - + 7.1.0-pre.4 diff --git a/Hohoema/Models.UseCase/Niconico.Player/PrimaryViewPlayerManager.cs b/Hohoema/Models.UseCase/Niconico.Player/PrimaryViewPlayerManager.cs index d478e1d56..d1842df0e 100644 --- a/Hohoema/Models.UseCase/Niconico.Player/PrimaryViewPlayerManager.cs +++ b/Hohoema/Models.UseCase/Niconico.Player/PrimaryViewPlayerManager.cs @@ -42,21 +42,21 @@ public sealed class PrimaryViewPlayerManager : Prism.Mvvm.BindableBase, IPlayerV private ApplicationView _view; IScheduler _scheduler; - private readonly Lazy _navigationServiceLazy; + // private readonly Lazy _navigationServiceLazy; private readonly RestoreNavigationManager _restoreNavigationManager; PrimaryPlayerDisplayMode _prevDisplayMode; Models.Helpers.AsyncLock _navigationLock = new Models.Helpers.AsyncLock(); public PrimaryViewPlayerManager(IScheduler scheduler, - [Unity.Attributes.Dependency("PrimaryPlayerNavigationService")] Lazy navigationServiceLazy, + Lazy navigationServiceLazy, RestoreNavigationManager restoreNavigationManager, HohoemaPlaylistPlayer hohoemaPlaylistPlayer ) { _view = ApplicationView.GetForCurrentView(); _scheduler = scheduler; - _navigationServiceLazy = navigationServiceLazy; + //_navigationServiceLazy = navigationServiceLazy; _restoreNavigationManager = restoreNavigationManager; PlaylistPlayer = hohoemaPlaylistPlayer; _navigationService = null; @@ -108,7 +108,7 @@ public async Task NavigationAsync(string pageName, INavigationParameters paramet { if (_navigationService == null) { - _navigationService = _navigationServiceLazy.Value; + _navigationService = App.Current.Container.Resolve("PrimaryPlayerNavigationService"); } if (DisplayMode == PrimaryPlayerDisplayMode.Close) diff --git a/Hohoema/Models.UseCase/Niconico.Player/SecondaryViewPlayerManager.cs b/Hohoema/Models.UseCase/Niconico.Player/SecondaryViewPlayerManager.cs index af35d6e65..ec0f038c3 100644 --- a/Hohoema/Models.UseCase/Niconico.Player/SecondaryViewPlayerManager.cs +++ b/Hohoema/Models.UseCase/Niconico.Player/SecondaryViewPlayerManager.cs @@ -2,13 +2,12 @@ using Hohoema.Models.Domain.Niconico.Video; using Hohoema.Models.Domain.PageNavigation; using Prism.Navigation; -using Prism.Unity; +using Prism.Ioc; using System; using System.Diagnostics; using System.Reactive.Concurrency; using System.Reactive.Linq; using System.Threading.Tasks; -using Unity; using Windows.ApplicationModel.Core; using Windows.Foundation; using Windows.Foundation.Metadata; diff --git a/Hohoema.Models/Models.Domain/PageNavigation/IPageNavigatable.cs b/Hohoema/Models.UseCase/PageNavigation/IPageNavigatable.cs similarity index 68% rename from Hohoema.Models/Models.Domain/PageNavigation/IPageNavigatable.cs rename to Hohoema/Models.UseCase/PageNavigation/IPageNavigatable.cs index 04b3e97f5..939e9ba52 100644 --- a/Hohoema.Models/Models.Domain/PageNavigation/IPageNavigatable.cs +++ b/Hohoema/Models.UseCase/PageNavigation/IPageNavigatable.cs @@ -1,11 +1,12 @@ -using Prism.Navigation; +using Hohoema.Models.Domain.PageNavigation; +using Prism.Navigation; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Hohoema.Models.Domain.PageNavigation +namespace Hohoema.Models.UseCase.PageNavigation { public interface IPageNavigatable { diff --git a/Hohoema/Presentation.ViewModels/HohoemaSecondaryViewFrameViewModel.cs b/Hohoema/Presentation.ViewModels/HohoemaSecondaryViewFrameViewModel.cs index 3defdd249..e1a67bba8 100644 --- a/Hohoema/Presentation.ViewModels/HohoemaSecondaryViewFrameViewModel.cs +++ b/Hohoema/Presentation.ViewModels/HohoemaSecondaryViewFrameViewModel.cs @@ -4,7 +4,6 @@ using System.Text; using System.Threading.Tasks; using Hohoema.Models.Domain; -using Unity; using System.Diagnostics; using Hohoema.Models.Domain.Live; using Hohoema.Models.Helpers; diff --git a/Hohoema/Presentation.ViewModels/Niconico.Live/LiveInfoListItemViewModel.cs b/Hohoema/Presentation.ViewModels/Niconico.Live/LiveInfoListItemViewModel.cs index 4a78f292f..46ffa2efd 100644 --- a/Hohoema/Presentation.ViewModels/Niconico.Live/LiveInfoListItemViewModel.cs +++ b/Hohoema/Presentation.ViewModels/Niconico.Live/LiveInfoListItemViewModel.cs @@ -9,12 +9,11 @@ using NiconicoToolkit.SearchWithPage.Live; using Prism.Commands; using Prism.Mvvm; -using Prism.Unity; +using Prism.Ioc; using System; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; -using Unity; using Hohoema.Presentation.ViewModels.Niconico.Share; using Hohoema.Models.UseCase; using NiconicoToolkit.Live.Cas; diff --git a/Hohoema/Presentation.ViewModels/Niconico.Live/NicoLiveUserIdAddToNGCommand.cs b/Hohoema/Presentation.ViewModels/Niconico.Live/NicoLiveUserIdAddToNGCommand.cs index b379d86f2..94ee2e477 100644 --- a/Hohoema/Presentation.ViewModels/Niconico.Live/NicoLiveUserIdAddToNGCommand.cs +++ b/Hohoema/Presentation.ViewModels/Niconico.Live/NicoLiveUserIdAddToNGCommand.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -using Unity; namespace Hohoema.Presentation.ViewModels.Niconico.Live { diff --git a/Hohoema/Presentation.ViewModels/Niconico.Live/NicoLiveUserIdRemoveFromNGCommand.cs b/Hohoema/Presentation.ViewModels/Niconico.Live/NicoLiveUserIdRemoveFromNGCommand.cs index 1a40a2e32..7716ac5ac 100644 --- a/Hohoema/Presentation.ViewModels/Niconico.Live/NicoLiveUserIdRemoveFromNGCommand.cs +++ b/Hohoema/Presentation.ViewModels/Niconico.Live/NicoLiveUserIdRemoveFromNGCommand.cs @@ -1,6 +1,5 @@ using Hohoema.Models.UseCase.Niconico.Player.Comment; using Prism.Commands; -using Unity; namespace Hohoema.Presentation.ViewModels.Niconico.Live { diff --git a/Hohoema/Presentation.ViewModels/Niconico.Video/Commands/MylistCreateCommand.cs b/Hohoema/Presentation.ViewModels/Niconico.Video/Commands/MylistCreateCommand.cs index 104d95aae..4a55e48df 100644 --- a/Hohoema/Presentation.ViewModels/Niconico.Video/Commands/MylistCreateCommand.cs +++ b/Hohoema/Presentation.ViewModels/Niconico.Video/Commands/MylistCreateCommand.cs @@ -4,13 +4,10 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -using Unity; using System.Diagnostics; using Hohoema.Models.Domain; using Hohoema.Models.Domain.Niconico.Video; using Hohoema.Presentation.Services; -using System.Reflection; -using NiconicoToolkit.Video; using Hohoema.Models.UseCase.Playlist; namespace Hohoema.Presentation.ViewModels.Niconico.Video.Commands diff --git a/Hohoema/Presentation.ViewModels/Niconico.Video/VideoListItemControlViewModel.cs b/Hohoema/Presentation.ViewModels/Niconico.Video/VideoListItemControlViewModel.cs index c797c60c4..3833a49d7 100644 --- a/Hohoema/Presentation.ViewModels/Niconico.Video/VideoListItemControlViewModel.cs +++ b/Hohoema/Presentation.ViewModels/Niconico.Video/VideoListItemControlViewModel.cs @@ -15,7 +15,7 @@ using NiconicoToolkit; using NiconicoToolkit.Video; using Prism.Commands; -using Prism.Unity; +using Prism.Ioc; using Reactive.Bindings.Extensions; using System; using System.Diagnostics; @@ -25,7 +25,6 @@ using System.Threading; using System.Threading.Tasks; using System.Windows.Input; -using Unity; using Hohoema.Models.UseCase.Niconico.Player.Events; using Hohoema.Models.Domain.Playlist; diff --git a/Hohoema/Presentation.ViewModels/Player/ShowPrimaryViewCommand.cs b/Hohoema/Presentation.ViewModels/Player/ShowPrimaryViewCommand.cs index 08be9923f..a481581ca 100644 --- a/Hohoema/Presentation.ViewModels/Player/ShowPrimaryViewCommand.cs +++ b/Hohoema/Presentation.ViewModels/Player/ShowPrimaryViewCommand.cs @@ -6,7 +6,6 @@ using System.Reactive.Concurrency; using System.Text; using System.Threading.Tasks; -using Unity.Attributes; using Windows.UI.ViewManagement; using Windows.UI.Xaml; @@ -16,7 +15,7 @@ public sealed class ShowPrimaryViewCommand : DelegateCommandBase { private readonly IScheduler _scheduler; - public ShowPrimaryViewCommand([Dependency("MainWindowsScheduler")]IScheduler scheduler) + public ShowPrimaryViewCommand(IScheduler scheduler) { _scheduler = scheduler; } diff --git a/Hohoema/Presentation.ViewModels/PrimaryWindowCoreLayout/MenuItemViewModel.cs b/Hohoema/Presentation.ViewModels/PrimaryWindowCoreLayout/MenuItemViewModel.cs index d3eddf80d..c728cf075 100644 --- a/Hohoema/Presentation.ViewModels/PrimaryWindowCoreLayout/MenuItemViewModel.cs +++ b/Hohoema/Presentation.ViewModels/PrimaryWindowCoreLayout/MenuItemViewModel.cs @@ -1,5 +1,6 @@  using Hohoema.Models.Domain.PageNavigation; +using Hohoema.Models.UseCase.PageNavigation; using Hohoema.Presentation.Services; using Prism.Navigation; using System; diff --git a/Hohoema/Presentation.ViewModels/PrimaryWindowCoreLayout/QueueMenuItemViewModel.cs b/Hohoema/Presentation.ViewModels/PrimaryWindowCoreLayout/QueueMenuItemViewModel.cs index abe9bbbe3..e56475b1a 100644 --- a/Hohoema/Presentation.ViewModels/PrimaryWindowCoreLayout/QueueMenuItemViewModel.cs +++ b/Hohoema/Presentation.ViewModels/PrimaryWindowCoreLayout/QueueMenuItemViewModel.cs @@ -14,6 +14,7 @@ using Hohoema.Models.Domain.PageNavigation; using Microsoft.Toolkit.Mvvm.Messaging; using Hohoema.Models.Domain.Playlist; +using Hohoema.Models.UseCase.PageNavigation; namespace Hohoema.Presentation.ViewModels.PrimaryWindowCoreLayout { diff --git a/Hohoema/Presentation.Views.Pages/Niconico.Live/LiveInfomationPageViewModel.cs b/Hohoema/Presentation.Views.Pages/Niconico.Live/LiveInfomationPageViewModel.cs index 0187b8500..408e5f742 100644 --- a/Hohoema/Presentation.Views.Pages/Niconico.Live/LiveInfomationPageViewModel.cs +++ b/Hohoema/Presentation.Views.Pages/Niconico.Live/LiveInfomationPageViewModel.cs @@ -11,7 +11,7 @@ using Hohoema.Models.UseCase.PageNavigation; using Prism.Commands; using Prism.Navigation; -using Prism.Unity; +using Prism.Ioc; using Reactive.Bindings; using Reactive.Bindings.Extensions; using System; @@ -22,7 +22,6 @@ using System.Reactive.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; -using Unity; using Windows.System; using Windows.UI.Xaml; using NiconicoSession = Hohoema.Models.Domain.Niconico.NiconicoSession; diff --git a/Hohoema/Presentation.Views.Pages/Niconico.Search/SearchPageViewModel.cs b/Hohoema/Presentation.Views.Pages/Niconico.Search/SearchPageViewModel.cs index a07488af7..22309517b 100644 --- a/Hohoema/Presentation.Views.Pages/Niconico.Search/SearchPageViewModel.cs +++ b/Hohoema/Presentation.Views.Pages/Niconico.Search/SearchPageViewModel.cs @@ -6,14 +6,10 @@ using System.Collections.ObjectModel; using Reactive.Bindings; using Prism.Commands; -using Prism.Mvvm; using System.Reactive.Linq; using System.Diagnostics; using Reactive.Bindings.Extensions; using Hohoema.Models.UseCase.PageNavigation; - -using Unity; -using Hohoema.Presentation.Services; using Hohoema.Models.UseCase; using NiconicoSession = Hohoema.Models.Domain.Niconico.NiconicoSession; using Hohoema.Models.Domain.Niconico.Search; diff --git a/Hohoema/Presentation.Views.Player/LivePlayerPageViewModel.cs b/Hohoema/Presentation.Views.Player/LivePlayerPageViewModel.cs index 90df6ae1f..7b47978d5 100644 --- a/Hohoema/Presentation.Views.Player/LivePlayerPageViewModel.cs +++ b/Hohoema/Presentation.Views.Player/LivePlayerPageViewModel.cs @@ -23,7 +23,7 @@ using Prism.Commands; using Prism.Mvvm; using Prism.Navigation; -using Prism.Unity; +using Prism.Ioc; using Reactive.Bindings; using Reactive.Bindings.Extensions; using System; @@ -37,8 +37,6 @@ using System.Reactive.Linq; using System.Reactive.Subjects; using System.Threading.Tasks; -using Unity; -using Unity.Resolution; using Uno.Extensions; using Windows.Media.Core; using Windows.Media.Playback; @@ -53,6 +51,7 @@ using Hohoema.Models.UseCase.Playlist; using Hohoema.Models.UseCase.Niconico.Player.Comment; using Hohoema.Models.Domain.Player.Comment; +using Prism.Ioc; namespace Hohoema.Presentation.ViewModels.Player { @@ -1608,8 +1607,12 @@ private SidePaneContentViewModelBase GetSidePaneContent(PlayerSidePaneContentTyp case PlayerSidePaneContentType.Playlist: sidePaneContent = App.Current.Container.Resolve(); break; - case PlayerSidePaneContentType.Comment: - sidePaneContent = App.Current.Container.GetContainer().Resolve(new ParameterOverride("comments", FilterdComments)); + case PlayerSidePaneContentType.Comment: + { + var commentContentVM = App.Current.Container.Resolve(); + commentContentVM.Comments = FilterdComments; + sidePaneContent = commentContentVM; + } break; case PlayerSidePaneContentType.Setting: sidePaneContent = App.Current.Container.Resolve(); diff --git a/Hohoema/Presentation.Views.Player/_CommentRenderer/CommentRenderer.xaml.cs b/Hohoema/Presentation.Views.Player/_CommentRenderer/CommentRenderer.xaml.cs index 1e90ee039..04136d869 100644 --- a/Hohoema/Presentation.Views.Player/_CommentRenderer/CommentRenderer.xaml.cs +++ b/Hohoema/Presentation.Views.Player/_CommentRenderer/CommentRenderer.xaml.cs @@ -23,9 +23,8 @@ using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; -using Unity; using Hohoema.Models.Domain; -using Prism.Unity; +using Prism.Ioc; using System.Text.RegularExpressions; using System.Reactive.Disposables; using Hohoema.Models.Domain.Niconico.Video; @@ -34,7 +33,6 @@ using Reactive.Bindings.Extensions; using Hohoema.Models.Domain.Player; using System.Numerics; -using Uno.Threading; using Microsoft.Extensions.ObjectPool; using System.Reactive; using System.Reactive.Concurrency; diff --git a/Hohoema/Presentation.Views.Player/_PlayerSidePaneContent/LiveCommentsSidePaneContentViewModel.cs b/Hohoema/Presentation.Views.Player/_PlayerSidePaneContent/LiveCommentsSidePaneContentViewModel.cs index c80e079a0..f5f26eccb 100644 --- a/Hohoema/Presentation.Views.Player/_PlayerSidePaneContent/LiveCommentsSidePaneContentViewModel.cs +++ b/Hohoema/Presentation.Views.Player/_PlayerSidePaneContent/LiveCommentsSidePaneContentViewModel.cs @@ -22,7 +22,6 @@ public sealed class LiveCommentsSidePaneContentViewModel : SidePaneContentViewMo { public LiveCommentsSidePaneContentViewModel( CommentFilteringFacade commentFiltering, - Microsoft.Toolkit.Uwp.UI.AdvancedCollectionView comments, IScheduler scheduler, NicoVideoOwnerCacheRepository nicoVideoOwnerRepository, OpenLinkCommand openLinkCommand, @@ -30,7 +29,6 @@ CopyToClipboardCommand copyToClipboardCommand ) { _playerSettings = commentFiltering; - Comments = comments; _scheduler = scheduler; _nicoVideoOwnerRepository = nicoVideoOwnerRepository; OpenLinkCommand = openLinkCommand; diff --git a/Hohoema/Presentation.Views/Controls/HohoemaInAppNotification.xaml.cs b/Hohoema/Presentation.Views/Controls/HohoemaInAppNotification.xaml.cs index ecf9a7510..490cca69e 100644 --- a/Hohoema/Presentation.Views/Controls/HohoemaInAppNotification.xaml.cs +++ b/Hohoema/Presentation.Views/Controls/HohoemaInAppNotification.xaml.cs @@ -1,8 +1,7 @@ using System; using Windows.UI.Xaml.Controls; -using Unity; using System.Collections.Concurrent; -using Prism.Unity; +using Prism.Ioc; using Windows.UI.Xaml; using Windows.UI.ViewManagement; using Windows.UI.Core; diff --git a/Hohoema/Presentation.Views/Dialogs/NiconicoLoginDialog.xaml.cs b/Hohoema/Presentation.Views/Dialogs/NiconicoLoginDialog.xaml.cs index 16740b6dc..8d70f64d9 100644 --- a/Hohoema/Presentation.Views/Dialogs/NiconicoLoginDialog.xaml.cs +++ b/Hohoema/Presentation.Views/Dialogs/NiconicoLoginDialog.xaml.cs @@ -14,7 +14,6 @@ using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; -using Unity; using Hohoema.Models.Helpers; // コンテンツ ダイアログの項目テンプレートについては、https://go.microsoft.com/fwlink/?LinkId=234238 を参照してください diff --git a/Hohoema/Presentation.Views/Flyouts/LiveListItemFlyout.xaml.cs b/Hohoema/Presentation.Views/Flyouts/LiveListItemFlyout.xaml.cs index 732cd16e0..bae2f1a0b 100644 --- a/Hohoema/Presentation.Views/Flyouts/LiveListItemFlyout.xaml.cs +++ b/Hohoema/Presentation.Views/Flyouts/LiveListItemFlyout.xaml.cs @@ -12,8 +12,6 @@ using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; -using Unity; -using Prism.Unity; // The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 diff --git a/Hohoema/Presentation.Views/Flyouts/MylistItemFlyout.xaml.cs b/Hohoema/Presentation.Views/Flyouts/MylistItemFlyout.xaml.cs index 4e5620260..d4793837b 100644 --- a/Hohoema/Presentation.Views/Flyouts/MylistItemFlyout.xaml.cs +++ b/Hohoema/Presentation.Views/Flyouts/MylistItemFlyout.xaml.cs @@ -12,7 +12,6 @@ using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; -using Unity; namespace Hohoema.Presentation.Views.Flyouts { diff --git a/Hohoema/Presentation.Views/Flyouts/SubscriptionItemFlyout.xaml.cs b/Hohoema/Presentation.Views/Flyouts/SubscriptionItemFlyout.xaml.cs index ca171a09d..8cea28935 100644 --- a/Hohoema/Presentation.Views/Flyouts/SubscriptionItemFlyout.xaml.cs +++ b/Hohoema/Presentation.Views/Flyouts/SubscriptionItemFlyout.xaml.cs @@ -12,7 +12,6 @@ using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; -using Unity; namespace Hohoema.Presentation.Views.Flyouts { diff --git a/Hohoema/Presentation.Views/Flyouts/VideoItemFlyout.xaml.cs b/Hohoema/Presentation.Views/Flyouts/VideoItemFlyout.xaml.cs index 697d22d26..50cf1e56a 100644 --- a/Hohoema/Presentation.Views/Flyouts/VideoItemFlyout.xaml.cs +++ b/Hohoema/Presentation.Views/Flyouts/VideoItemFlyout.xaml.cs @@ -1,5 +1,4 @@ using Windows.UI.Xaml.Controls; -using Unity; using Windows.UI.Xaml; using Prism.Ioc; using Hohoema.Models.Domain; From 12f6049eb698359cade3a7cd8dd50c37ece89df3 Mon Sep 17 00:00:00 2001 From: tor4kichi Date: Sun, 13 Feb 2022 18:27:57 +0900 Subject: [PATCH 03/13] =?UTF-8?q?=E8=A6=96=E8=81=B4=E5=B1=A5=E6=AD=B4?= =?UTF-8?q?=E3=81=AE=E8=A1=A8=E7=A4=BA=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84?= =?UTF-8?q?=E5=A0=B4=E5=90=88=E3=81=AB=E5=82=99=E3=81=88=E3=81=A6=E4=BE=8B?= =?UTF-8?q?=E5=A4=96=E3=83=8F=E3=83=B3=E3=83=89=E3=83=AA=E3=83=B3=E3=82=B0?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WatchHistoryPageViewModel.cs | 55 +++++++++++-------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/Hohoema/Presentation.Views.Pages/Niconico.Activity/WatchHistoryPageViewModel.cs b/Hohoema/Presentation.Views.Pages/Niconico.Activity/WatchHistoryPageViewModel.cs index 4454a3a01..c78254c90 100644 --- a/Hohoema/Presentation.Views.Pages/Niconico.Activity/WatchHistoryPageViewModel.cs +++ b/Hohoema/Presentation.Views.Pages/Niconico.Activity/WatchHistoryPageViewModel.cs @@ -106,31 +106,38 @@ public DelegateCommand RefreshCommand var items = await _watchHistoryManager.GetWatchHistoryItemsAsync(); foreach (var x in items) - { - var vm = new HistoryVideoListItemControlViewModel( - x.LastViewedAt.DateTime, - (uint)x.Views, - x.Video.Id, - x.Video.Title, - x.Video.Thumbnail.ListingUrl.OriginalString, - TimeSpan.FromSeconds(x.Video.Duration), - x.Video.RegisteredAt.DateTime - ); - - vm.ProviderId = x.Video.Owner.Id; - vm.ProviderType = x.Video.Owner.OwnerType switch + { + try { - NiconicoToolkit.Video.OwnerType.User => OwnerType.User, - NiconicoToolkit.Video.OwnerType.Channel => OwnerType.Channel, - _ => OwnerType.Hidden - }; - vm.ProviderName = x.Video.Owner.Name; - - vm.CommentCount = x.Video.Count.Comment; - vm.ViewCount = x.Video.Count.View; - vm.MylistCount = x.Video.Count.Mylist; - - Histories.Add(vm); + var vm = new HistoryVideoListItemControlViewModel( + (x.LastViewedAt ?? DateTimeOffset.Now).DateTime, + (uint)(x.Views ?? 0), + x.Video.Id, + x.Video.Title, + x.Video.Thumbnail.ListingUrl.OriginalString, + TimeSpan.FromSeconds(x.Video.Duration), + x.Video.RegisteredAt.DateTime + ); + + vm.ProviderId = x.Video.Owner.Id; + vm.ProviderType = x.Video.Owner.OwnerType switch + { + NiconicoToolkit.Video.OwnerType.User => OwnerType.User, + NiconicoToolkit.Video.OwnerType.Channel => OwnerType.Channel, + _ => OwnerType.Hidden + }; + vm.ProviderName = x.Video.Owner.Name; + + vm.CommentCount = x.Video.Count.Comment; + vm.ViewCount = x.Video.Count.View; + vm.MylistCount = x.Video.Count.Mylist; + + Histories.Add(vm); + } + catch (Exception e) + { + ErrorTrackingManager.TrackError(e); + } } } catch (Exception e) From f0f166dda5cb339ee32a59af9d0a36dbd568da81 Mon Sep 17 00:00:00 2001 From: tor4kichi Date: Sun, 13 Feb 2022 20:28:38 +0900 Subject: [PATCH 04/13] =?UTF-8?q?=E6=8A=95=E7=A8=BF=E8=80=85NG=E3=82=92?= =?UTF-8?q?=E3=83=A9=E3=83=B3=E3=82=AD=E3=83=B3=E3=82=B0=E3=83=9A=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=81=A7=E9=9D=9E=E5=AF=BE=E5=BF=9C=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=80=82=E3=83=A9=E3=83=B3=E3=82=AD=E3=83=B3=E3=82=B0?= =?UTF-8?q?=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=A8=E3=83=8B=E3=82=B3=E3=83=AC?= =?UTF-8?q?=E3=83=9D=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=AE=E8=AA=AD=E3=81=BF?= =?UTF-8?q?=E8=BE=BC=E3=81=BF=E3=82=92=E9=AB=98=E9=80=9F=E5=8C=96=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Hohoema/Package.appxmanifest | 2 +- .../NicoRepoPageViewModel.cs | 13 ++-- .../RankingCategoryPageViewModel.cs | 21 +++--- .../SettingsPage.xaml | 3 + .../Flyouts/VideoItemFlyout.xaml.cs | 69 +++++++++++++------ 5 files changed, 70 insertions(+), 38 deletions(-) diff --git a/Hohoema/Package.appxmanifest b/Hohoema/Package.appxmanifest index 703b7c01c..732f05eda 100644 --- a/Hohoema/Package.appxmanifest +++ b/Hohoema/Package.appxmanifest @@ -1,6 +1,6 @@  - + Hohoema diff --git a/Hohoema/Presentation.Views.Pages/Niconico.NicoRepo/NicoRepoPageViewModel.cs b/Hohoema/Presentation.Views.Pages/Niconico.NicoRepo/NicoRepoPageViewModel.cs index 00597181d..42c11eb02 100644 --- a/Hohoema/Presentation.Views.Pages/Niconico.NicoRepo/NicoRepoPageViewModel.cs +++ b/Hohoema/Presentation.Views.Pages/Niconico.NicoRepo/NicoRepoPageViewModel.cs @@ -200,13 +200,13 @@ public class NicoRepoVideoTimeline : VideoListItemControlViewModel, IVideoConten { private readonly NicoRepoEntry _nicoRepoEntry; - public NicoRepoVideoTimeline(NicoVideo nicoVideo, NicoRepoEntry nicoRepoEntry, NicoRepoMuteContextTrigger itemType) + public NicoRepoVideoTimeline(NicoRepoEntry nicoRepoEntry, NicoRepoMuteContextTrigger itemType) : base(nicoRepoEntry.GetContentId(), nicoRepoEntry.Object.Name, nicoRepoEntry.Object.Image.OriginalString, TimeSpan.Zero, nicoRepoEntry.Updated.DateTime) { _nicoRepoEntry = nicoRepoEntry; ItemTopic = itemType; - VideoId = nicoVideo.VideoId; + //VideoId = nicoRepoEntry.GetContentId(); if (VideoId != VideoId) { SubscribeAll(VideoId); @@ -228,8 +228,8 @@ public NicoRepoVideoTimeline(NicoVideo nicoVideo, NicoRepoEntry nicoRepoEntry, N ProviderType = OwnerType.User; } } - - SetLength(nicoVideo.Length); + + //SetLength(nicoVideo.Length); ItempTopicDescription = NicoRepoTimelineVM.ItemTopictypeToDescription(ItemTopic, _nicoRepoEntry); } @@ -356,8 +356,6 @@ async Task> IIncrementalSource.GetPage var topicTypeMapedEntries = nicoRepoResponse.Data.Select(x => (TopicType: x.GetMuteContextTrigger(), Item: x)).ToList(); var numberIdVideoTopics = topicTypeMapedEntries .Where(x => IsVideoTopic(x.TopicType)); - var videoNicoVideoItems = await _nicoVideoProvider.GetCachedVideoInfoItemsAsync(numberIdVideoTopics.Select(x => (VideoId)x.Item.GetContentId())); - var videoDict = videoNicoVideoItems.ToDictionary(x => x.Id); return topicTypeMapedEntries.Select(item => { @@ -374,8 +372,7 @@ async Task> IIncrementalSource.GetPage try { var id = item.Item.GetContentId(); - var nicoVideo = videoDict[id]; - var vm = new NicoRepoVideoTimeline(nicoVideo, item.Item, topicType); + var vm = new NicoRepoVideoTimeline(item.Item, topicType); return vm as INicoRepoItem; } catch diff --git a/Hohoema/Presentation.Views.Pages/Niconico.VideoRanking/RankingCategoryPageViewModel.cs b/Hohoema/Presentation.Views.Pages/Niconico.VideoRanking/RankingCategoryPageViewModel.cs index 4c461d65c..4e6d5e1de 100644 --- a/Hohoema/Presentation.Views.Pages/Niconico.VideoRanking/RankingCategoryPageViewModel.cs +++ b/Hohoema/Presentation.Views.Pages/Niconico.VideoRanking/RankingCategoryPageViewModel.cs @@ -154,6 +154,7 @@ public RankingGenre RankingGenre public RankingProvider RankingProvider { get; } private readonly NiconicoSession _niconicoSession; + private readonly VideoFilteringSettings _videoFilteringSettings; private readonly NotificationService _notificationService; private readonly FastAsyncLock _updateLock = new FastAsyncLock(); @@ -165,6 +166,7 @@ public RankingCategoryPageViewModel( NicoVideoProvider nicoVideoProvider, RankingProvider rankingProvider, VideoRankingSettings rankingSettings, + VideoFilteringSettings videoFilteringSettings, NotificationService notificationService, VideoPlayWithQueueCommand videoPlayWithQueueCommand, SelectionModeToggleCommand selectionModeToggleCommand @@ -176,6 +178,7 @@ SelectionModeToggleCommand selectionModeToggleCommand NicoVideoProvider = nicoVideoProvider; RankingProvider = rankingProvider; RankingSettings = rankingSettings; + _videoFilteringSettings = videoFilteringSettings; _notificationService = notificationService; VideoPlayWithQueueCommand = videoPlayWithQueueCommand; SelectionModeToggleCommand = selectionModeToggleCommand; @@ -385,7 +388,7 @@ protected override (int, IIncrementalSource IIncrementalSource source = null; try { - source = new CategoryRankingLoadingSource(RankingGenre, SelectedRankingTag.Value?.Tag, SelectedRankingTerm.Value ?? RankingTerm.Hour, _niconicoSession, NicoVideoProvider, _rankingMemoryCache); + source = new CategoryRankingLoadingSource(RankingGenre, SelectedRankingTag.Value?.Tag, SelectedRankingTerm.Value ?? RankingTerm.Hour, _niconicoSession, NicoVideoProvider, _videoFilteringSettings, _rankingMemoryCache); CanChangeRankingParameter.Value = true; @@ -414,6 +417,7 @@ public class CategoryRankingLoadingSource : IIncrementalSource> IIncrementalSource< int head = pageIndex * pageSize; var targetItems = _rankingRssResponse.Items.Skip(head).Take(pageSize); - // Note: 1件あたり8ms 100件800ms 程度の時間が掛かる - var owners = await _nicoVideoProvider.ResolveVideoOwnersAsync(targetItems.Select(x => x.GetVideoId())); - ct.ThrowIfCancellationRequested(); return targetItems.Select((item, offset) => @@ -478,10 +481,12 @@ async Task> IIncrementalSource< vm.ViewCount = itemData.WatchCount; vm.MylistCount = itemData.MylistCount; - var owner = owners[videoId]; - vm.ProviderId = owner.OwnerId; - vm.ProviderName = owner.ScreenName; - vm.ProviderType = owner.UserType; + // Note: ランキングページにおける投稿者NGは扱わないように変更する + // プレ垢であれば追加情報取得してもいいと思うが、長期メンテするには面倒なので対応しない + //var owner = owners[videoId]; + //vm.ProviderId = owner.OwnerId; + //vm.ProviderName = owner.ScreenName; + //vm.ProviderType = owner.UserType; return vm; }); diff --git a/Hohoema/Presentation.Views.Pages/SettingsPage.xaml b/Hohoema/Presentation.Views.Pages/SettingsPage.xaml index 3125061a8..ccccd163a 100644 --- a/Hohoema/Presentation.Views.Pages/SettingsPage.xaml +++ b/Hohoema/Presentation.Views.Pages/SettingsPage.xaml @@ -220,6 +220,9 @@ + + + diff --git a/Hohoema/Presentation.Views/Flyouts/VideoItemFlyout.xaml.cs b/Hohoema/Presentation.Views/Flyouts/VideoItemFlyout.xaml.cs index 50cf1e56a..18fabc496 100644 --- a/Hohoema/Presentation.Views/Flyouts/VideoItemFlyout.xaml.cs +++ b/Hohoema/Presentation.Views/Flyouts/VideoItemFlyout.xaml.cs @@ -84,6 +84,7 @@ public IReadOnlyCollection SourceVideoItems public static SubscriptionManager SubscriptionManager { get; } public static VideoCacheManager VideoCacheManager { get; } public static VideoItemsSelectionContext VideoItemsSelectionContext { get; } + public static VideoFilteringSettings VideoFilteringSettings { get; } private static readonly IMessenger _messenger; @@ -110,6 +111,7 @@ static VideoItemFlyout() SubscriptionManager = App.Current.Container.Resolve(); VideoCacheManager = App.Current.Container.Resolve(); VideoItemsSelectionContext = App.Current.Container.Resolve(); + VideoFilteringSettings = App.Current.Container.Resolve(); OpenLinkCommand = App.Current.Container.Resolve(); CopyToClipboardCommand = App.Current.Container.Resolve(); @@ -235,41 +237,64 @@ private void VideoItemFlyout_Opening(object sender, object e) AddToMylistItem.CommandParameter = dataContext; - var visibleSingleSelectionItem = isMultipleSelection.ToInvisibility(); - OpenVideoInfoPage.Visibility = visibleSingleSelectionItem; - OpenOwnerVideosPage.Visibility = visibleSingleSelectionItem; - AddNgUser.Visibility = visibleSingleSelectionItem; - VideoInfoItemSeparator.Visibility = visibleSingleSelectionItem; - ExternalActionsSeparator.Visibility = visibleSingleSelectionItem; - - if (!isMultipleSelection && content is IVideoContentProvider provider) + if (isMultipleSelection is false) { - bool isUserProvidedVideo = (provider?.ProviderType == OwnerType.User && provider?.ProviderId != null); - OpenOwnerMylistsPage.Visibility = - OpenOwnerSeriesPage.Visibility = isUserProvidedVideo.ToVisibility(); + OpenVideoInfoPage.Visibility = Visibility.Visible; + VideoInfoItemSeparator.Visibility = Visibility.Visible; + ExternalActionsSeparator.Visibility = Visibility.Visible; + + if (content is IVideoContentProvider provider && provider.ProviderId != null) + { + OpenOwnerVideosPage.Visibility = Visibility.Visible; + + bool isUserProvidedVideo = (provider.ProviderType == OwnerType.User && provider.ProviderId != null); + OpenOwnerMylistsPage.Visibility = + OpenOwnerSeriesPage.Visibility = isUserProvidedVideo.ToVisibility(); - OpenOwnerMylistsPage.CommandParameter = - OpenOwnerSeriesPage.CommandParameter = provider?.ProviderId; + OpenOwnerMylistsPage.CommandParameter = + OpenOwnerSeriesPage.CommandParameter = provider?.ProviderId; + + AddSusbcriptionItem.CommandParameter = provider; + AddSusbcriptionItem.Visibility = Visibility.Visible; + } + else + { + OpenOwnerVideosPage.Visibility = Visibility.Collapsed; + OpenOwnerMylistsPage.Visibility = Visibility.Collapsed; + OpenOwnerSeriesPage.Visibility = Visibility.Collapsed; + AddSusbcriptionItem.Visibility = Visibility.Collapsed; + } } else { + OpenVideoInfoPage.Visibility = Visibility.Collapsed; + VideoInfoItemSeparator.Visibility = Visibility.Collapsed; + ExternalActionsSeparator.Visibility = Visibility.Collapsed; + + OpenOwnerVideosPage.Visibility = Visibility.Collapsed; OpenOwnerMylistsPage.Visibility = Visibility.Collapsed; OpenOwnerSeriesPage.Visibility = Visibility.Collapsed; + AddSusbcriptionItem.Visibility = Visibility.Collapsed; } + var visibleSingleSelectionItem = isMultipleSelection.ToInvisibility(); Share.Visibility = visibleSingleSelectionItem; CopySubItem.Visibility = visibleSingleSelectionItem; - AddSusbcriptionItem.Visibility = visibleSingleSelectionItem; - - // プレイリスト LocalMylistItem.CommandParameter = dataContext; - // NG投稿者 - AddNgUser.Visibility = AddNgUser.Command.CanExecute(content).ToVisibility(); - RemoveNgUser.Visibility = RemoveNgUser.Command.CanExecute(content).ToVisibility(); + if (VideoFilteringSettings.NGVideoOwnerUserIdEnable) + { + AddNgUser.Visibility = AddNgUser.Command.CanExecute(content).ToVisibility(); + RemoveNgUser.Visibility = RemoveNgUser.Command.CanExecute(content).ToVisibility(); + } + else + { + AddNgUser.Visibility = Visibility.Collapsed; + RemoveNgUser.Visibility = Visibility.Collapsed; + } // キャッシュ var canNewDownloadCache = VideoCacheManager.IsCacheDownloadAuthorized(); @@ -293,7 +318,8 @@ private void VideoItemFlyout_Opening(object sender, object e) var cachedToVisible = (anyItemsCached).ToVisibility(); DeleteCacheRequest.Visibility = cachedToVisible; - CacheSeparator.Visibility = (notCachedToVisible is Visibility.Visible || cachedToVisible is Visibility.Visible).ToVisibility(); + CacheSeparator.Visibility = ((RemoveNgUser.Visibility == Visibility.Visible || AddNgUser.Visibility == Visibility.Visible) && + notCachedToVisible is Visibility.Visible || cachedToVisible is Visibility.Visible).ToVisibility(); } else { @@ -309,7 +335,8 @@ private void VideoItemFlyout_Opening(object sender, object e) var cachedToVisible = (itemCached).ToVisibility(); DeleteCacheRequest.Visibility = cachedToVisible; - CacheSeparator.Visibility = (notCachedToVisible is Visibility.Visible || cachedToVisible is Visibility.Visible).ToVisibility(); + CacheSeparator.Visibility = ((RemoveNgUser.Visibility == Visibility.Visible || AddNgUser.Visibility == Visibility.Visible) && + notCachedToVisible is Visibility.Visible || cachedToVisible is Visibility.Visible).ToVisibility(); } From 07073e27d21c8149cdfb4cb175fcaccfb9b8a864 Mon Sep 17 00:00:00 2001 From: tor4kichi Date: Mon, 14 Feb 2022 08:31:28 +0900 Subject: [PATCH 05/13] =?UTF-8?q?FixPrism.BindableBase=E3=82=92Microsoft.T?= =?UTF-8?q?oolkit.Mvvm.ComponentModel.ObservableObject=E3=81=AB=E5=B7=AE?= =?UTF-8?q?=E3=81=97=E6=9B=BF=E3=81=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FixPrism/BindableBaseWithFix.cs | 184 ------------------ .../DispatchObservableCollection{T}.cs | 115 ----------- Hohoema.Models/Hohoema.Models.csproj | 3 +- .../Application/AppearanceSettings.cs | 4 +- .../Application/BackupManager.cs | 2 +- .../LocalMylist/LocalPlaylist.cs | 4 +- .../Models.Domain/Niconico/NiconicoSession.cs | 7 +- .../Player/MediaPlayerSoundVolumeManager.cs | 2 +- .../Models.Domain/Player/PlayerSettings.cs | 2 +- .../Video/Cache/NicoVideoCacheProgress.cs | 2 +- .../Playlist/BufferedPlaylistItemsSource.cs | 4 +- .../Models.Domain/Playlist/QueuePlaylist.cs | 12 +- .../_Settings_Legacy/HohoemaUserSettings.cs | 5 +- .../_Settings_Legacy/PlayerSettings.cs | 2 +- .../FlagsRepositoryBase.cs | 6 +- 15 files changed, 25 insertions(+), 329 deletions(-) delete mode 100644 Hohoema.Models/FixPrism/BindableBaseWithFix.cs delete mode 100644 Hohoema.Models/FixPrism/DispatchObservableCollection{T}.cs diff --git a/Hohoema.Models/FixPrism/BindableBaseWithFix.cs b/Hohoema.Models/FixPrism/BindableBaseWithFix.cs deleted file mode 100644 index 4cd95d3b9..000000000 --- a/Hohoema.Models/FixPrism/BindableBaseWithFix.cs +++ /dev/null @@ -1,184 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Threading; -using Windows.System; - -namespace Hohoema.FixPrism -{ - /// - /// Implementation of to simplify models. - /// - public abstract class ObservableObject : INotifyPropertyChanged, IDisposable - { - protected ObservableObject() - { - } - - ReaderWriterLockSlim _lockSlim = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); - Dictionary> _handlersByThread = new Dictionary>(); - - bool _IsDisposed; - /// - /// Occurs when a property value changes. - /// - public event PropertyChangedEventHandler PropertyChanged - { - add - { - if (_IsDisposed) { return; } - - _lockSlim.EnterWriteLock(); - try - { - var currentContext = DispatcherQueue.GetForCurrentThread(); - if (_handlersByThread.TryGetValue(currentContext, out var list)) - { - list.Add(value); - } - else - { - _handlersByThread.Add(currentContext, new List() { value }); - } - } - finally - { - _lockSlim.ExitWriteLock(); - } - } - remove - { - if (_IsDisposed) { return; } - - _lockSlim.EnterWriteLock(); - try - { - foreach (var list in _handlersByThread.Values) - { - list.Remove(value); - } - } - finally - { - _lockSlim.ExitWriteLock(); - } - } - } - - /// - /// Checks if a property already matches a desired value. Sets the property and - /// notifies listeners only when necessary. - /// - /// Type of the property. - /// Reference to a property with both getter and setter. - /// Desired value for the property. - /// Name of the property used to notify listeners. This - /// value is optional and can be provided automatically when invoked from compilers that - /// support CallerMemberName. - /// True if the value was changed, false if the existing value matched the - /// desired value. - protected virtual bool SetProperty(ref T storage, T value, [CallerMemberName] string propertyName = null) - { - if (EqualityComparer.Default.Equals(storage, value)) return false; - - storage = value; - RaisePropertyChanged(propertyName); - - return true; - } - - protected virtual bool SetProperty(ref T? storage, T? value, [CallerMemberName] string propertyName = null) - where T : struct - { - if (EqualityComparer.Default.Equals(storage, value)) - return false; - storage = value; - RaisePropertyChanged(propertyName); - return true; - } - - /// - /// Checks if a property already matches a desired value. Sets the property and - /// notifies listeners only when necessary. - /// - /// Type of the property. - /// Reference to a property with both getter and setter. - /// Desired value for the property. - /// Name of the property used to notify listeners. This - /// value is optional and can be provided automatically when invoked from compilers that - /// support CallerMemberName. - /// Action that is called after the property value has been changed. - /// True if the value was changed, false if the existing value matched the - /// desired value. - protected virtual bool SetProperty(ref T storage, T value, Action onChanged, [CallerMemberName] string propertyName = null) - { - if (EqualityComparer.Default.Equals(storage, value)) return false; - - storage = value; - onChanged?.Invoke(); - RaisePropertyChanged(propertyName); - - return true; - } - - /// - /// Raises this object's PropertyChanged event. - /// - /// Name of the property used to notify listeners. This - /// value is optional and can be provided automatically when invoked from compilers - /// that support . - protected void RaisePropertyChanged([CallerMemberName]string propertyName = null) - { - if (_IsDisposed) { return; } - - _lockSlim.EnterReadLock(); - try - { - foreach (var pair in _handlersByThread) - { - var context = pair.Key; - var handlers = pair.Value; - context.TryEnqueue(() => - { - if (_IsDisposed) { return; } - - _lockSlim.EnterUpgradeableReadLock(); - try - { - var eventArgs = new PropertyChangedEventArgs(propertyName); - foreach (var eventHandler in handlers.ToArray()) - { - OnPropertyChanged(eventHandler, eventArgs); - } - } - finally - { - _lockSlim.ExitUpgradeableReadLock(); - } - }); - } - } - finally - { - _lockSlim.ExitReadLock(); - } - } - - /// - /// Raises this object's PropertyChanged event. - /// - /// The PropertyChangedEventArgs - protected virtual void OnPropertyChanged(PropertyChangedEventHandler handler, PropertyChangedEventArgs args) - { - handler?.Invoke(this, args); - } - - public virtual void Dispose() - { - ((IDisposable)_lockSlim).Dispose(); - _IsDisposed = true; - } - } -} diff --git a/Hohoema.Models/FixPrism/DispatchObservableCollection{T}.cs b/Hohoema.Models/FixPrism/DispatchObservableCollection{T}.cs deleted file mode 100644 index dbb292264..000000000 --- a/Hohoema.Models/FixPrism/DispatchObservableCollection{T}.cs +++ /dev/null @@ -1,115 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Collections.Specialized; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Windows.System; - -namespace Hohoema.FixPrism -{ - public class DispatchObservableCollection : ObservableCollection - { - ReaderWriterLockSlim _lockSlim = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); - Dictionary> _handlersByThread = new (); - - - #region コンストラクタ - public DispatchObservableCollection() - { - } - public DispatchObservableCollection(IEnumerable collection) - : base(collection) - { - } - public DispatchObservableCollection(List list) - : base(list) - { - } - #endregion - - public override event NotifyCollectionChangedEventHandler CollectionChanged - { - add - { - _lockSlim.EnterWriteLock(); - try - { - var currentContext = DispatcherQueue.GetForCurrentThread(); - if (_handlersByThread.TryGetValue(currentContext, out var list)) - { - list.Add(value); - } - else - { - _handlersByThread.Add(currentContext, new List() { value }); - } - } - finally - { - _lockSlim.ExitWriteLock(); - } - } - - remove - { - _lockSlim.EnterWriteLock(); - try - { - foreach (var list in _handlersByThread.Values) - { - list.Remove(value); - } - } - finally - { - _lockSlim.ExitWriteLock(); - } - } - } - - protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e) - { - _lockSlim.EnterReadLock(); - try - { - foreach (var pair in _handlersByThread) - { - var context = pair.Key; - var handlers = pair.Value; - if (context.HasThreadAccess) - { - foreach (var eventHandler in handlers.ToArray()) - { - eventHandler?.Invoke(this, e); - } - } - else - { - context.TryEnqueue(() => - { - _lockSlim.EnterUpgradeableReadLock(); - try - { - foreach (var eventHandler in handlers.ToArray()) - { - eventHandler?.Invoke(this, e); - } - } - finally - { - _lockSlim.ExitUpgradeableReadLock(); - } - }); - } - } - } - finally - { - _lockSlim.ExitReadLock(); - } - } - } -} diff --git a/Hohoema.Models/Hohoema.Models.csproj b/Hohoema.Models/Hohoema.Models.csproj index 135459285..1f6020ae7 100644 --- a/Hohoema.Models/Hohoema.Models.csproj +++ b/Hohoema.Models/Hohoema.Models.csproj @@ -122,8 +122,6 @@ PackageReference - - @@ -376,6 +374,7 @@ NiconicoToolkit.UWP + 14.0 diff --git a/Hohoema.Models/Models.Domain/Application/AppearanceSettings.cs b/Hohoema.Models/Models.Domain/Application/AppearanceSettings.cs index 5e3287c80..8fec9ff62 100644 --- a/Hohoema.Models/Models.Domain/Application/AppearanceSettings.cs +++ b/Hohoema.Models/Models.Domain/Application/AppearanceSettings.cs @@ -86,7 +86,7 @@ public ElementTheme ApplicationTheme Save(internal_theme); _Theme = value; - RaisePropertyChanged(); + OnPropertyChanged(); } } } @@ -121,7 +121,7 @@ public NavigationViewPaneDisplayMode MenuPaneDisplayMode Save(internal_theme); _menuPaneDisplayMode = value; - RaisePropertyChanged(); + OnPropertyChanged(); } } } diff --git a/Hohoema.Models/Models.Domain/Application/BackupManager.cs b/Hohoema.Models/Models.Domain/Application/BackupManager.cs index 8a9945b32..39f855867 100644 --- a/Hohoema.Models/Models.Domain/Application/BackupManager.cs +++ b/Hohoema.Models/Models.Domain/Application/BackupManager.cs @@ -1,4 +1,4 @@ -using Hohoema.FixPrism; +using Microsoft.Toolkit.Mvvm.ComponentModel; using Hohoema.Models.Domain.Niconico.NicoRepo; using Hohoema.Models.Domain.Niconico.Video; using Hohoema.Models.Domain.PageNavigation; diff --git a/Hohoema.Models/Models.Domain/LocalMylist/LocalPlaylist.cs b/Hohoema.Models/Models.Domain/LocalMylist/LocalPlaylist.cs index 67aaa57e4..6af130e57 100644 --- a/Hohoema.Models/Models.Domain/LocalMylist/LocalPlaylist.cs +++ b/Hohoema.Models/Models.Domain/LocalMylist/LocalPlaylist.cs @@ -56,7 +56,7 @@ public bool Equals(IPlaylistSortOption other) } } - public sealed class LocalPlaylist : FixPrism.ObservableObject, IUserManagedPlaylist + public sealed class LocalPlaylist : ObservableObject, IUserManagedPlaylist { public static LocalPlaylistSortOption[] SortOptions { get; } = new LocalPlaylistSortOption[] { @@ -124,7 +124,7 @@ private set if (SetProperty(ref _count, value)) { UpdatePlaylistInfo(); - RaisePropertyChanged(nameof(IUserManagedPlaylist.TotalCount)); + OnPropertyChanged(nameof(IUserManagedPlaylist.TotalCount)); } } } diff --git a/Hohoema.Models/Models.Domain/Niconico/NiconicoSession.cs b/Hohoema.Models/Models.Domain/Niconico/NiconicoSession.cs index a7f7fb952..f61c08859 100644 --- a/Hohoema.Models/Models.Domain/Niconico/NiconicoSession.cs +++ b/Hohoema.Models/Models.Domain/Niconico/NiconicoSession.cs @@ -73,7 +73,7 @@ public struct NiconicoSessionLoginErrorEventArgs public Exception Exception { get; set; } } - public sealed class NiconicoSession : FixPrism.ObservableObject, IDisposable + public sealed class NiconicoSession : ObservableObject { public NiconicoSession( IMessenger messenger @@ -89,11 +89,6 @@ IMessenger messenger } - public override void Dispose() - { - base.Dispose(); - } - private void OnNetworkStatusChanged(object sender) { // Note: Resumingのタイミングで NetworkInformation.NetworkStatusChanged += OnNetworkStatusChanged; をやるとExcpetion HRESULT: diff --git a/Hohoema.Models/Models.Domain/Player/MediaPlayerSoundVolumeManager.cs b/Hohoema.Models/Models.Domain/Player/MediaPlayerSoundVolumeManager.cs index ca9da25bc..64c33a8c6 100644 --- a/Hohoema.Models/Models.Domain/Player/MediaPlayerSoundVolumeManager.cs +++ b/Hohoema.Models/Models.Domain/Player/MediaPlayerSoundVolumeManager.cs @@ -1,4 +1,4 @@ -using Hohoema.FixPrism; +using Microsoft.Toolkit.Mvvm.ComponentModel; using Hohoema.Models.Domain; using Hohoema.Models.Domain.Player; using Reactive.Bindings.Extensions; diff --git a/Hohoema.Models/Models.Domain/Player/PlayerSettings.cs b/Hohoema.Models/Models.Domain/Player/PlayerSettings.cs index b2c42b43a..07be0b5b7 100644 --- a/Hohoema.Models/Models.Domain/Player/PlayerSettings.cs +++ b/Hohoema.Models/Models.Domain/Player/PlayerSettings.cs @@ -1,6 +1,6 @@ using Microsoft.Toolkit.Uwp.Helpers; using NiconicoToolkit.Live.WatchSession; -using Hohoema.FixPrism; +using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.Input; using System; using System.Collections.Generic; diff --git a/Hohoema.Models/Models.Domain/Player/Video/Cache/NicoVideoCacheProgress.cs b/Hohoema.Models/Models.Domain/Player/Video/Cache/NicoVideoCacheProgress.cs index b3e253ca7..342bc6e4f 100644 --- a/Hohoema.Models/Models.Domain/Player/Video/Cache/NicoVideoCacheProgress.cs +++ b/Hohoema.Models/Models.Domain/Player/Video/Cache/NicoVideoCacheProgress.cs @@ -1,6 +1,6 @@ using I18NPortable; using Microsoft.Toolkit.Uwp.Notifications; -using Hohoema.FixPrism; +using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/Hohoema.Models/Models.Domain/Playlist/BufferedPlaylistItemsSource.cs b/Hohoema.Models/Models.Domain/Playlist/BufferedPlaylistItemsSource.cs index 3b14ea92b..94b28d8b7 100644 --- a/Hohoema.Models/Models.Domain/Playlist/BufferedPlaylistItemsSource.cs +++ b/Hohoema.Models/Models.Domain/Playlist/BufferedPlaylistItemsSource.cs @@ -1,4 +1,4 @@ -using Hohoema.FixPrism; +using Microsoft.Toolkit.Mvvm.ComponentModel; using Hohoema.Models.Domain.Niconico.Video; using Microsoft.Toolkit.Collections; using Reactive.Bindings; @@ -126,7 +126,7 @@ public sealed class BufferedShufflePlaylistItemsSource : IBufferedPlaylistItemsS BehaviorSubject _IndexUpdateTimingSubject = new BehaviorSubject(Unit.Default); public IObservable IndexUpdateTiming => _IndexUpdateTimingSubject; - DispatchObservableCollection Items; + ObservableCollection Items; public ReadOnlyReactiveCollection CreateItemsReadOnlyReactiveCollection(IScheduler scheduler) { diff --git a/Hohoema.Models/Models.Domain/Playlist/QueuePlaylist.cs b/Hohoema.Models/Models.Domain/Playlist/QueuePlaylist.cs index 534b66c0b..480bba005 100644 --- a/Hohoema.Models/Models.Domain/Playlist/QueuePlaylist.cs +++ b/Hohoema.Models/Models.Domain/Playlist/QueuePlaylist.cs @@ -1,4 +1,4 @@ -using Hohoema.FixPrism; +using Microsoft.Toolkit.Mvvm.ComponentModel; using Hohoema.Models.Domain.LocalMylist; using Hohoema.Models.Domain.Niconico.Video; using Hohoema.Models.Helpers; @@ -179,7 +179,7 @@ public class QueuePlaylist : ObservableObject, IReadOnlyCollection ((IReadOnlyCollection)Items).Count; - DispatchObservableCollection Items; + ObservableCollection Items; public QueuePlaylist( IMessenger messenger, IScheduler scheduler, @@ -287,7 +287,7 @@ public QueuePlaylistItem Add(IVideoContent video) Items.Add(addedItem); SendAddedMessage(addedItem); AddEntity(addedItem); - RaisePropertyChanged(nameof(IUserManagedPlaylist.TotalCount)); + OnPropertyChanged(nameof(IUserManagedPlaylist.TotalCount)); return addedItem; } @@ -301,7 +301,7 @@ public QueuePlaylistItem Insert(int index, IVideoContent video) Items.Insert(index, addedItem); SendAddedMessage(addedItem); AddEntity(addedItem); - RaisePropertyChanged(nameof(IUserManagedPlaylist.TotalCount)); + OnPropertyChanged(nameof(IUserManagedPlaylist.TotalCount)); index++; foreach (var item in Items.Skip(index)) @@ -332,13 +332,13 @@ public void Remove(IVideoContent removeItem) Items.Remove(item); SendRemovedMessage(item.Index, item); RemoveEntity(removeItem.VideoId); - RaisePropertyChanged(nameof(IUserManagedPlaylist.TotalCount)); + OnPropertyChanged(nameof(IUserManagedPlaylist.TotalCount)); }); // 他アイテムのIndex更新は必要ない // アプリ復帰時に順序が保たれていれば十分 - RaisePropertyChanged(nameof(TotalCount)); + OnPropertyChanged(nameof(TotalCount)); } diff --git a/Hohoema.Models/Models.Domain/_Settings_Legacy/HohoemaUserSettings.cs b/Hohoema.Models/Models.Domain/_Settings_Legacy/HohoemaUserSettings.cs index a7a77a05c..1bcda0be8 100644 --- a/Hohoema.Models/Models.Domain/_Settings_Legacy/HohoemaUserSettings.cs +++ b/Hohoema.Models/Models.Domain/_Settings_Legacy/HohoemaUserSettings.cs @@ -1,4 +1,5 @@ -using NiconicoToolkit.NicoRepo; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using NiconicoToolkit.NicoRepo; using System; using System.IO; using System.Linq; @@ -133,7 +134,7 @@ public void Dispose() } [DataContract] - public abstract class SettingsBase : FixPrism.ObservableObject + public abstract class SettingsBase : ObservableObject { public SettingsBase() { diff --git a/Hohoema.Models/Models.Domain/_Settings_Legacy/PlayerSettings.cs b/Hohoema.Models/Models.Domain/_Settings_Legacy/PlayerSettings.cs index 21ce0df47..edb22a663 100644 --- a/Hohoema.Models/Models.Domain/_Settings_Legacy/PlayerSettings.cs +++ b/Hohoema.Models/Models.Domain/_Settings_Legacy/PlayerSettings.cs @@ -1,6 +1,6 @@ using Microsoft.Toolkit.Uwp.Helpers; using NiconicoToolkit.Live.WatchSession; -using Hohoema.FixPrism; +using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.Input; using System; using System.Collections.Generic; diff --git a/Hohoema.Models/Models.Infrastructure/FlagsRepositoryBase.cs b/Hohoema.Models/Models.Infrastructure/FlagsRepositoryBase.cs index fc29da66d..0f555628d 100644 --- a/Hohoema.Models/Models.Infrastructure/FlagsRepositoryBase.cs +++ b/Hohoema.Models/Models.Infrastructure/FlagsRepositoryBase.cs @@ -1,5 +1,5 @@ using Microsoft.Toolkit.Uwp.Helpers; -using Hohoema.FixPrism; +using Microsoft.Toolkit.Mvvm.ComponentModel; using System.Collections.Generic; using System.ComponentModel; using System.Linq; @@ -54,7 +54,7 @@ protected void Save(T? value, [CallerMemberName] string propertyName = null) _LocalStorageHelper.Save(propertyName, value); } - protected override bool SetProperty(ref T storage, T value, [CallerMemberName] string propertyName = null) + protected new bool SetProperty(ref T storage, T value, [CallerMemberName] string propertyName = null) { if (base.SetProperty(ref storage, value, propertyName)) { @@ -67,7 +67,7 @@ protected override bool SetProperty(ref T storage, T value, [CallerMemberName } } - protected override bool SetProperty(ref T? storage, T? value, [CallerMemberName] string propertyName = null) + protected bool SetProperty(ref T? storage, T? value, [CallerMemberName] string propertyName = null) where T : struct { if (base.SetProperty(ref storage, value, propertyName)) From 91ca3d2abfaf28df3a4a3bbe1e69b5ab4651cb95 Mon Sep 17 00:00:00 2001 From: tor4kichi Date: Mon, 14 Feb 2022 14:01:29 +0900 Subject: [PATCH 06/13] =?UTF-8?q?=E9=9F=B3=E9=87=8F=E5=A4=89=E6=9B=B4?= =?UTF-8?q?=E3=81=8C=E5=8F=8D=E6=98=A0=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84?= =?UTF-8?q?=E5=95=8F=E9=A1=8C=E3=82=92=E8=A7=A3=E6=B6=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Hohoema/App.xaml.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Hohoema/App.xaml.cs b/Hohoema/App.xaml.cs index eed0de644..8fd54cc35 100644 --- a/Hohoema/App.xaml.cs +++ b/Hohoema/App.xaml.cs @@ -284,8 +284,8 @@ public override void RegisterTypes(IContainerRegistry container) // UseCase unityContainer.Register(); - container.Register(); - container.Register(); + container.RegisterSingleton(); + container.RegisterSingleton(); container.RegisterSingleton(); container.RegisterSingleton(); container.RegisterSingleton(); From 07459fcbf6317de6204b4d4f3f5f3361f6ec26e4 Mon Sep 17 00:00:00 2001 From: tor4kichi Date: Mon, 14 Feb 2022 17:13:18 +0900 Subject: [PATCH 07/13] =?UTF-8?q?=E5=8B=95=E7=94=BB=E5=86=8D=E7=94=9F?= =?UTF-8?q?=E7=B5=82=E4=BA=86=E6=99=82=E3=81=AB=E6=AC=A1=E5=8B=95=E7=94=BB?= =?UTF-8?q?=E3=81=8C=E7=84=A1=E3=81=84=E5=A0=B4=E5=90=88=E3=80=81=E5=86=8D?= =?UTF-8?q?=E7=94=9F=E4=B8=AD=E5=8B=95=E7=94=BB=E3=81=AE=E6=83=85=E5=A0=B1?= =?UTF-8?q?=E3=81=8C=E3=82=AF=E3=83=AA=E3=82=A2=E3=81=95=E3=82=8C=E3=81=A6?= =?UTF-8?q?=E3=81=97=E3=81=BE=E3=81=86=E5=95=8F=E9=A1=8C=E3=82=92=E8=A7=A3?= =?UTF-8?q?=E6=B6=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VideoEndedRecommendation.cs | 159 +++++++++--------- .../VideoPlayerPageViewModel.cs | 2 + 2 files changed, 83 insertions(+), 78 deletions(-) diff --git a/Hohoema/Models.UseCase/Niconico.Player/VideoEndedRecommendation.cs b/Hohoema/Models.UseCase/Niconico.Player/VideoEndedRecommendation.cs index 03c362c6a..735880736 100644 --- a/Hohoema/Models.UseCase/Niconico.Player/VideoEndedRecommendation.cs +++ b/Hohoema/Models.UseCase/Niconico.Player/VideoEndedRecommendation.cs @@ -68,112 +68,115 @@ VideoPlayedHistoryRepository videoPlayedHistoryRepository readonly TimeSpan _endedTime = TimeSpan.FromSeconds(-1); bool _endedProcessed; - private async void PlaybackSession_PositionChanged(MediaPlaybackSession sender, object args) + private void PlaybackSession_PositionChanged(MediaPlaybackSession sender, object args) { - using var _ = await _lock.LockAsync(default); - - if (sender.PlaybackState == MediaPlaybackState.None) { return; } - if (_playNext) { return; } - if (_hohoemaPlaylistPlayer.CurrentPlaylistItem == null) { return; } - if (sender.NaturalDuration == TimeSpan.Zero) { return; } - - bool isInsideEndedRange = sender.Position - sender.NaturalDuration > _endedTime; - bool isStopped = sender.PlaybackState == MediaPlaybackState.Paused; - IsEnded.Value = isInsideEndedRange && isStopped; - - try + _scheduler.Schedule(async () => { - if (!IsEnded.Value || _endedProcessed) - { - HasRecomend.Value = HasNextVideo && IsEnded.Value; - return; - } + using var _ = await _lock.LockAsync(default); - var currentVideoId = _hohoemaPlaylistPlayer.CurrentPlaylistItem.VideoId; - _queuePlaylist.Remove(currentVideoId); - _videoPlayedHistoryRepository.VideoPlayed(currentVideoId, sender.Position); + if (sender.PlaybackState == MediaPlaybackState.None) { return; } + if (_playNext) { return; } + if (_hohoemaPlaylistPlayer.CurrentPlaylistItem == null) { return; } + if (sender.NaturalDuration == TimeSpan.Zero) { return; } - if (await _hohoemaPlaylistPlayer.CanGoNextAsync()) + bool isInsideEndedRange = sender.Position - sender.NaturalDuration > _endedTime; + bool isStopped = sender.PlaybackState == MediaPlaybackState.Paused; + IsEnded.Value = isInsideEndedRange && isStopped; + + try { - if (await _hohoemaPlaylistPlayer.GoNextAsync()) + if (!IsEnded.Value || _endedProcessed) { + HasRecomend.Value = HasNextVideo && IsEnded.Value; return; } - } - // _queuePlaylistのアイテム削除後の更新がScheduler上で行われるため、アイテム更新操作が同期的にではなく - // sortablePlaylist.TotalCountが実際とズレる可能性があるため、処理完了を待つ - await Task.Delay(10); + var currentVideoId = _hohoemaPlaylistPlayer.CurrentPlaylistItem.VideoId; + _queuePlaylist.Remove(currentVideoId); + _videoPlayedHistoryRepository.VideoPlayed(currentVideoId, sender.Position); - if (_playerSettings.IsPlaylistLoopingEnabled && _hohoemaPlaylistPlayer.CurrentPlaylist is ISortablePlaylist sortablePlaylist && sortablePlaylist.TotalCount > 0) - { - if (await _hohoemaPlaylistPlayer.PlayAsync(_hohoemaPlaylistPlayer.CurrentPlaylist, _hohoemaPlaylistPlayer.CurrentPlaylistSortOption)) + if (await _hohoemaPlaylistPlayer.CanGoNextAsync()) { - return; + if (await _hohoemaPlaylistPlayer.GoNextAsync()) + { + return; + } } - } - //if (_playerSettings.AutoMoveNextVideoOnPlaylistEmpty) - { - /* - if (_videoPlayer.PlayingVideoId == null) + // _queuePlaylistのアイテム削除後の更新がScheduler上で行われるため、アイテム更新操作が同期的にではなく + // sortablePlaylist.TotalCountが実際とズレる可能性があるため、処理完了を待つ + await Task.Delay(10); + + if (_playerSettings.IsPlaylistLoopingEnabled && _hohoemaPlaylistPlayer.CurrentPlaylist is ISortablePlaylist sortablePlaylist && sortablePlaylist.TotalCount > 0) { - _endedProcessed = true; - _scheduler.Schedule(() => + if (await _hohoemaPlaylistPlayer.PlayAsync(_hohoemaPlaylistPlayer.CurrentPlaylist, _hohoemaPlaylistPlayer.CurrentPlaylistSortOption)) { - HasNextVideo = _videoRelatedContents?.NextVideo != null; - NextVideoTitle = _videoRelatedContents?.NextVideo?.Label; - HasRecomend.Value = HasNextVideo && IsEnded.Value; - }); - return; + return; + } } - */ - if (_series?.Video.Next is not null and var nextVideo) + //if (_playerSettings.AutoMoveNextVideoOnPlaylistEmpty) { - _scheduler.Schedule(() => + /* + if (_videoPlayer.PlayingVideoId == null) { - NextVideoTitle = nextVideo.Title; - HasRecomend.Value = true; - HasNextVideo = true; + _endedProcessed = true; + _scheduler.Schedule(() => + { + HasNextVideo = _videoRelatedContents?.NextVideo != null; + NextVideoTitle = _videoRelatedContents?.NextVideo?.Label; + HasRecomend.Value = HasNextVideo && IsEnded.Value; + }); + return; + } + */ - Debug.WriteLine("シリーズ情報から次の動画を提示: " + nextVideo.Title); - }); + if (_series?.Video.Next is not null and var nextVideo) + { + _scheduler.Schedule(() => + { + NextVideoTitle = nextVideo.Title; + HasRecomend.Value = true; + HasNextVideo = true; - return; - } - } + Debug.WriteLine("シリーズ情報から次の動画を提示: " + nextVideo.Title); + }); - if (TryPlaylistEndActionPlayerClosed()) - { - HasRecomend.Value = HasNextVideo && IsEnded.Value; - _endedProcessed = true; - return; - } + return; + } + } - if (_currentVideoDetail != null) - { - _relatedVideoContentsAggregator.GetRelatedContentsAsync(_currentVideoDetail) - .ContinueWith(async task => - { - var relatedVideos = await task; + if (TryPlaylistEndActionPlayerClosed()) + { + HasRecomend.Value = HasNextVideo && IsEnded.Value; + _endedProcessed = true; + return; + } - _scheduler.Schedule(() => + if (_currentVideoDetail != null) + { + _relatedVideoContentsAggregator.GetRelatedContentsAsync(_currentVideoDetail) + .ContinueWith(async task => { - _videoRelatedContents = relatedVideos; - HasNextVideo = _videoRelatedContents.NextVideo != null; - NextVideoTitle = _videoRelatedContents.NextVideo?.Label; - HasRecomend.Value = HasNextVideo && IsEnded.Value; + var relatedVideos = await task; - Debug.WriteLine("動画情報から次の動画を提示: " + NextVideoTitle); + _scheduler.Schedule(() => + { + _videoRelatedContents = relatedVideos; + HasNextVideo = _videoRelatedContents.NextVideo != null; + NextVideoTitle = _videoRelatedContents.NextVideo?.Label; + HasRecomend.Value = HasNextVideo && IsEnded.Value; + + Debug.WriteLine("動画情報から次の動画を提示: " + NextVideoTitle); + }); }); - }); + } } - } - finally - { - - } + finally + { + + } + }); } diff --git a/Hohoema/Presentation.Views.Player/VideoPlayerPageViewModel.cs b/Hohoema/Presentation.Views.Player/VideoPlayerPageViewModel.cs index 9c96d910a..affebd012 100644 --- a/Hohoema/Presentation.Views.Player/VideoPlayerPageViewModel.cs +++ b/Hohoema/Presentation.Views.Player/VideoPlayerPageViewModel.cs @@ -369,6 +369,8 @@ public async Task OnNavigatedToAsync(INavigationParameters parameters) _hohoemaPlaylistPlayer.ObserveProperty(x => x.CurrentPlaylistItem) .Subscribe(x => { + if (x == null) { return; } + _scheduler.ScheduleAsync(async (s, ct) => { try From 30bcc72d4d50760c14e66e056b8e3d85897142f1 Mon Sep 17 00:00:00 2001 From: tor4kichi Date: Mon, 14 Feb 2022 17:39:44 +0900 Subject: [PATCH 08/13] =?UTF-8?q?=E5=8D=98=E5=93=81=E5=86=8D=E7=94=9F?= =?UTF-8?q?=E6=99=82=E3=81=AB=E8=87=AA=E5=8B=95=E3=81=A7Queue=E4=B8=8A?= =?UTF-8?q?=E3=81=A7=E5=86=8D=E7=94=9F=E3=81=99=E3=82=8B=E6=A9=9F=E8=83=BD?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4=E3=80=82=E3=82=AD=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E3=82=92=E5=86=8D=E7=94=9F=E3=81=99=E3=82=8B=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E3=81=AB=E5=BF=9C=E3=81=98=E3=81=A6=E3=82=AD=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E3=83=97=E3=83=AC=E3=82=A4=E3=83=AA=E3=82=B9=E3=83=88=E3=82=92?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E3=81=99=E3=82=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Playlist/HohoemaPlaylistPlayer.cs | 10 ++++++++-- .../Playlist/VideoPlayRequestMessage.cs | 10 ++++++++++ .../VideoEndedRecommendation.cs | 4 ++-- .../VideoPlayRequestBridgeToPlayer.cs | 18 +++++++++++++----- .../NotificationService.cs | 2 +- .../Commands/VideoPlayCommand.cs | 6 +++--- 6 files changed, 37 insertions(+), 13 deletions(-) diff --git a/Hohoema.Models/Models.Domain/Playlist/HohoemaPlaylistPlayer.cs b/Hohoema.Models/Models.Domain/Playlist/HohoemaPlaylistPlayer.cs index b65b12a9c..ef2cab651 100644 --- a/Hohoema.Models/Models.Domain/Playlist/HohoemaPlaylistPlayer.cs +++ b/Hohoema.Models/Models.Domain/Playlist/HohoemaPlaylistPlayer.cs @@ -217,7 +217,7 @@ protected async ValueTask Reset(IPlaylist playlist protected void SetCurrentContent(IVideoContent video, int index) { - Guard.IsNotNull(BufferedPlaylistItemsSource, nameof(BufferedPlaylistItemsSource)); + //Guard.IsNotNull(BufferedPlaylistItemsSource, nameof(BufferedPlaylistItemsSource)); CurrentPlayingIndex = index; @@ -613,6 +613,12 @@ public async Task ReopenAsync(TimeSpan? position = null) } } } + public async Task PlayWithoutPlaylistAsync(IVideoContent video, TimeSpan? initialPosition) + { + await PlayVideoOnSamePlaylistAsync_Internal(video, initialPosition); + SetCurrentContent(video, 0); + return true; + } public async Task PlayOnCurrentPlaylistAsync(IVideoContent video) { @@ -698,7 +704,7 @@ public async Task PlayAsync(ISortablePlaylist playlist, IPlaylistSortOptio protected override async Task PlayVideoOnSamePlaylistAsync_Internal(IVideoContent item, TimeSpan? startPosition = null) { Guard.IsNotNull(item, nameof(item)); - Guard.IsNotNull(CurrentPlaylistId, nameof(CurrentPlaylistId)); + //Guard.IsNotNull(CurrentPlaylistId, nameof(CurrentPlaylistId)); Guard.IsFalse(item.VideoId == default(VideoId), "Not contain playable VideoId or PlaylistId"); if (startPosition == null diff --git a/Hohoema.Models/Models.Domain/Playlist/VideoPlayRequestMessage.cs b/Hohoema.Models/Models.Domain/Playlist/VideoPlayRequestMessage.cs index 2176c96c7..f7604c4b2 100644 --- a/Hohoema.Models/Models.Domain/Playlist/VideoPlayRequestMessage.cs +++ b/Hohoema.Models/Models.Domain/Playlist/VideoPlayRequestMessage.cs @@ -105,6 +105,16 @@ public static VideoPlayRequestMessage PlayVideoWithQueue(VideoId videoId, TimeSp }; } + public static VideoPlayRequestMessage PlayVideo(VideoId videoId, TimeSpan? initialPosition = null) + { + return new VideoPlayRequestMessage() + { + VideoId = videoId, + Potision = initialPosition, + PlayWithQueue = false, + }; + } + public IVideoContent? PlaylistItem { get; init; } public IPlaylist Playlist { get; init; } public bool? PlayWithQueue { get; init; } diff --git a/Hohoema/Models.UseCase/Niconico.Player/VideoEndedRecommendation.cs b/Hohoema/Models.UseCase/Niconico.Player/VideoEndedRecommendation.cs index 735880736..16fa31757 100644 --- a/Hohoema/Models.UseCase/Niconico.Player/VideoEndedRecommendation.cs +++ b/Hohoema/Models.UseCase/Niconico.Player/VideoEndedRecommendation.cs @@ -301,11 +301,11 @@ public bool HasNextVideo if (_videoRelatedContents?.NextVideo != null) { var nextVideo = _videoRelatedContents.NextVideo; - _messenger.Send(VideoPlayRequestMessage.PlayVideoWithQueue(nextVideo.VideoId)); + _messenger.Send(VideoPlayRequestMessage.PlayVideo(nextVideo.VideoId)); } else if (_series.Video.Next is not null and var nextVideo) { - _messenger.Send(VideoPlayRequestMessage.PlayVideoWithQueue(nextVideo.Id)); + _messenger.Send(VideoPlayRequestMessage.PlayVideo(nextVideo.Id)); } IsEnded.Value = false; diff --git a/Hohoema/Models.UseCase/Niconico.Player/VideoPlayRequestBridgeToPlayer.cs b/Hohoema/Models.UseCase/Niconico.Player/VideoPlayRequestBridgeToPlayer.cs index cf614fee5..3cfffd523 100644 --- a/Hohoema/Models.UseCase/Niconico.Player/VideoPlayRequestBridgeToPlayer.cs +++ b/Hohoema/Models.UseCase/Niconico.Player/VideoPlayRequestBridgeToPlayer.cs @@ -138,7 +138,7 @@ async Task ResolvePlay(VideoPlayRequestMessage mess var factory = _playlistItemsSourceResolver.Resolve(playlist.PlaylistId.Origin); sortOption = factory.DeserializeSortOptions(message.PlaylistSortOptionsAsString); } - else if (sortOption == null) + else if (sortOption == null && playlist != null) { sortOption = playlist.DefaultSortOption; } @@ -148,7 +148,7 @@ async Task ResolvePlay(VideoPlayRequestMessage mess { videoResolved = message.PlaylistItem; } - else if (playlist.PlaylistId == QueuePlaylist.Id) + else if (playlist?.PlaylistId == QueuePlaylist.Id) { if (message.VideoId is not null and VideoId videoId) { @@ -205,14 +205,22 @@ private async Task VideoPlayAsync(IPlaylist playlis { static Task Play(HohoemaPlaylistPlayer player, IPlaylist playlist, IPlaylistSortOption sortOption, IVideoContent playlistItem, TimeSpan? initialPosition) { - if (playlistItem == null) + if (playlistItem != null && playlist != null) + { + Guard.IsAssignableToType(playlist, nameof(playlist)); + return player.PlayAsync(playlist as ISortablePlaylist, sortOption, playlistItem, initialPosition); + } + else if (playlistItem != null) + { + return player.PlayWithoutPlaylistAsync(playlistItem, initialPosition); + } + else if (playlist != null) { return player.PlayAsync(playlist, sortOption); } else { - Guard.IsAssignableToType(playlist, nameof(playlist)); - return player.PlayAsync(playlist as ISortablePlaylist, sortOption, playlistItem, initialPosition); + throw new InvalidOperationException(); } } diff --git a/Hohoema/Presentation.Services/NotificationService.cs b/Hohoema/Presentation.Services/NotificationService.cs index 0518ceeca..956bda8f2 100644 --- a/Hohoema/Presentation.Services/NotificationService.cs +++ b/Hohoema/Presentation.Services/NotificationService.cs @@ -128,7 +128,7 @@ private async Task SubmitVideoContentSuggestion(VideoI Label = "Play".Translate(), Command = new DelegateCommand(() => { - _messenger.Send(VideoPlayRequestMessage.PlayVideoWithQueue(videoId)); + _messenger.Send(VideoPlayRequestMessage.PlayVideo(videoId)); NotificationService.DismissInAppNotification(); }) diff --git a/Hohoema/Presentation.ViewModels/Niconico.Video/Commands/VideoPlayCommand.cs b/Hohoema/Presentation.ViewModels/Niconico.Video/Commands/VideoPlayCommand.cs index 197c2ef87..405566332 100644 --- a/Hohoema/Presentation.ViewModels/Niconico.Video/Commands/VideoPlayCommand.cs +++ b/Hohoema/Presentation.ViewModels/Niconico.Video/Commands/VideoPlayCommand.cs @@ -32,15 +32,15 @@ protected override void Execute(object item) { if (item is string contentId) { - _messenger.Send(VideoPlayRequestMessage.PlayVideoWithQueue(contentId)); + _messenger.Send(VideoPlayRequestMessage.PlayVideo(contentId)); } else if (item is VideoId videoId) { - _messenger.Send(VideoPlayRequestMessage.PlayVideoWithQueue(videoId)); + _messenger.Send(VideoPlayRequestMessage.PlayVideo(videoId)); } else if (item is IVideoContent videoContent) { - _messenger.Send(VideoPlayRequestMessage.PlayVideoWithQueue(videoContent.VideoId)); + _messenger.Send(VideoPlayRequestMessage.PlayVideo(videoContent.VideoId)); } } catch (Exception e) From 7653a08d90d0a2a3024eb4b97f87ad1e81899fc1 Mon Sep 17 00:00:00 2001 From: tor4kichi Date: Mon, 14 Feb 2022 18:26:23 +0900 Subject: [PATCH 09/13] =?UTF-8?q?=E8=A4=87=E6=95=B0=E9=81=B8=E6=8A=9E?= =?UTF-8?q?=E6=99=82=E3=81=AE=E3=82=AD=E3=83=A5=E3=83=BC=E3=81=8B=E3=82=89?= =?UTF-8?q?=E5=89=8A=E9=99=A4=E3=81=AE=E9=A0=85=E7=9B=AE=E3=81=8C=E3=80=8C?= =?UTF-8?q?=E3=81=82=E3=81=A8=E3=81=A7=E8=A6=8B=E3=82=8B=E3=81=8B=E3=82=89?= =?UTF-8?q?=E5=89=8A=E9=99=A4=E3=80=8D=E3=81=A8=E3=81=AA=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=9F=E5=95=8F=E9=A1=8C=E3=82=92=E8=A7=A3=E6=B6=88?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controls/VideoList/VideoItemsListView.xaml | 2 +- .../Controls/VideoList/VideoItemsListView.xaml.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Hohoema/Presentation.Views/Controls/VideoList/VideoItemsListView.xaml b/Hohoema/Presentation.Views/Controls/VideoList/VideoItemsListView.xaml index 8f07961d5..1ef649f58 100644 --- a/Hohoema/Presentation.Views/Controls/VideoList/VideoItemsListView.xaml +++ b/Hohoema/Presentation.Views/Controls/VideoList/VideoItemsListView.xaml @@ -74,7 +74,7 @@ - + diff --git a/Hohoema/Presentation.Views/Controls/VideoList/VideoItemsListView.xaml.cs b/Hohoema/Presentation.Views/Controls/VideoList/VideoItemsListView.xaml.cs index bc318ab74..f7a59ecef 100644 --- a/Hohoema/Presentation.Views/Controls/VideoList/VideoItemsListView.xaml.cs +++ b/Hohoema/Presentation.Views/Controls/VideoList/VideoItemsListView.xaml.cs @@ -11,6 +11,7 @@ using Hohoema.Presentation.ViewModels.Niconico.Video; using Hohoema.Presentation.ViewModels.Niconico.Video.Commands; using Hohoema.Presentation.Views.Flyouts; +using Hohoema.Presentation.Views.Helpers; using Prism.Ioc; using System.Linq; using System.Threading.Tasks; @@ -291,7 +292,7 @@ private void UpdateSelectActionsDisplay() if (_selectionContext.SelectionItems.Any()) { - SelectActions_AddWatchAfter.Visibility = Visibility.Visible; + SelectActions_AddWatchAfter.Visibility = (PlaylistPassToFlyout?.IsQueuePlaylist() is false or null).ToVisibility(); SelectActions_AddLocalMylist.Visibility = Visibility.Visible; if (PlaylistPassToFlyout?.IsQueuePlaylist() ?? false From 7662624de57d0a8613f21ef259b48cde02098ac6 Mon Sep 17 00:00:00 2001 From: tor4kichi Date: Mon, 14 Feb 2022 18:40:24 +0900 Subject: [PATCH 10/13] =?UTF-8?q?=E5=8B=95=E7=94=BB=E3=82=92=E8=A4=87?= =?UTF-8?q?=E6=95=B0=E9=81=B8=E6=8A=9E=E3=81=99=E3=82=8B=E6=99=82=E3=81=AE?= =?UTF-8?q?=E9=81=B8=E6=8A=9E=E6=B8=88=E3=81=BF=E3=81=8C=E5=88=A4=E5=88=A5?= =?UTF-8?q?=E3=81=97=E3=81=A5=E3=82=89=E3=81=84=E5=95=8F=E9=A1=8C=E3=82=92?= =?UTF-8?q?=E8=A7=A3=E6=B6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Hohoema/App.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hohoema/App.xaml b/Hohoema/App.xaml index e3ab2da46..da669a5d4 100644 --- a/Hohoema/App.xaml +++ b/Hohoema/App.xaml @@ -330,7 +330,7 @@ #44707070 -