/// <summary> /// コンストラクタ /// </summary> internal PlaylistContentViewViewModel( IYouTubeService youTubeService, IWebClientService webClientService, IPlaylistListViewViewModel playlistListViewViewModel) { m_YouTubeService = youTubeService; m_WebClientService = webClientService; m_PlaylistListViewViewModel = playlistListViewViewModel; playlistListViewViewModel.SelectionChanged += PlaylistListViewViewModel_SelectionChanged; Title = new ReactivePropertySlim <string>().AddTo(m_Disposables); Description = new ReactivePropertySlim <string>().AddTo(m_Disposables); PlaylistItemList = new ReactiveCollection <PlaylistItemViewModel>().AddTo(m_Disposables); // コマンドの生成 Playlist = new ReactivePropertySlim <Playlist?>().AddTo(m_Disposables); CanAddVideosToPlaylistItemAsync = new ReactivePropertySlim <bool>().AddTo(m_Disposables); CanRemovePlaylistItemAsync = new ReactivePropertySlim <bool>().AddTo(m_Disposables); CanMovePlaylistItemAsync = new ReactivePropertySlim <bool>().AddTo(m_Disposables); CanClonePlaylistItemsFromPlaylist = new ReactivePropertySlim <bool>().AddTo(m_Disposables); CanAddOrClonePlaylistItems = new ReactivePropertySlim <bool>().AddTo(m_Disposables); Playlist.Subscribe(v => { CanAddVideosToPlaylistItemAsync.Value = (v != null); CanRemovePlaylistItemAsync.Value = (v != null); CanMovePlaylistItemAsync.Value = (v != null); CanClonePlaylistItemsFromPlaylist.Value = (v != null); CanAddOrClonePlaylistItems.Value = (v != null); }); AddVideosToPlaylistItemAsyncCommand = CanAddVideosToPlaylistItemAsync .ToReactiveCommand() .WithSubscribe(async() => await AddVideosToPlaylistItemAsync()) .AddTo(m_Disposables); RemovePlaylistItemAsyncCommand = CanRemovePlaylistItemAsync .ToReactiveCommand() .WithSubscribe(async() => await RemovePlaylistItemAsync()) .AddTo(m_Disposables); MovePlaylistItemAsyncCommand = CanMovePlaylistItemAsync .ToReactiveCommand <IPlaylistListViewItemViewModel>() .WithSubscribe(async param => await MovePlaylistItemAsync(param)) .AddTo(m_Disposables); ClonePlaylistItemsFromPlaylistCommand = CanClonePlaylistItemsFromPlaylist .ToReactiveCommand() .WithSubscribe(async() => await ClonePlaylistItemsFromPlaylist()) .AddTo(m_Disposables); AddOrClonePlaylistItemsCommand = CanAddOrClonePlaylistItems .ToReactiveCommand() .WithSubscribe(async() => await AddOrClonePlaylistItems()) .AddTo(m_Disposables); // ダイアログを表示するインタラクションを保持 ShowAddPlaylistItemDialog = new Interaction <Unit, AddPlaylistItemDialogViewModel>(); ShowClonePlaylistItemsDialog = new Interaction <Unit, ClonePlaylistItemsDialogViewModel>(); ShowAddOrClonePlaylistItemsDialog = new Interaction <Unit, AddOrClonePlaylistItemsDialogViewModel>(); }
/// <summary> /// コンストラクタ /// </summary> /// <param name="playlistListViewViewModel"></param> /// <param name="playlistContentViewViewModel"></param> public MainWindowViewModel(IPlaylistListViewViewModel playlistListViewViewModel, IPlaylistContentViewViewModel playlistContentViewViewModel) { PlaylistListViewViewModel = playlistListViewViewModel; PlaylistContentViewViewModel = playlistContentViewViewModel; }