Beispiel #1
0
 public PlaylistHandler(IPlaylistTreeHandler handler, IPlaylistStoreHandler playlistStoreHandler, ILocalSettingHandler settingHandler, ILogger logger, IVideoPlaylistConverter converter, IVideoStoreHandler videoStoreHandler, IPlaylistInfoContainer playlistInfoContainer, IVideoInfoContainer videoInfoContainer)
 {
     this._treeHandler          = handler;
     this._playlistStoreHandler = playlistStoreHandler;
     this._settingHandler       = settingHandler;
     this._logger                = logger;
     this._converter             = converter;
     this._videoStoreHandler     = videoStoreHandler;
     this._playlistInfoContainer = playlistInfoContainer;
     this._videoInfoContainer    = videoInfoContainer;
 }
Beispiel #2
0
        public void SetUp()
        {
            ///・名前
            ///各IDを漢数字に置き換えたもの
            ///・ツリー構造
            ///親(1)─子(2)─子(4)─子(5)
            ///     └子(3)       ┠子(6)
            ///                   └子(7)
            var first = new STypes::Playlist()
            {
                Id = 1, IsRoot = true, PlaylistName = "一", IsTemporary = true
            };
            var second = new STypes::Playlist()
            {
                Id = 2, PlaylistName = "二", IsDownloadFailedHistory = true
            };
            var third = new STypes::Playlist()
            {
                Id = 3, PlaylistName = "三", IsDownloadSucceededHistory = true
            };
            var fourth = new STypes::Playlist()
            {
                Id = 4, PlaylistName = "四"
            };
            var fifth = new STypes::Playlist()
            {
                Id = 5, PlaylistName = "五"
            };
            var sixth = new STypes::Playlist()
            {
                Id = 6, PlaylistName = "六"
            };
            var seventh = new STypes::Playlist()
            {
                Id = 7, PlaylistName = "七"
            };

            //親を設定
            second.ParentPlaylist  = first;
            third.ParentPlaylist   = first;
            fourth.ParentPlaylist  = second;
            fifth.ParentPlaylist   = fourth;
            sixth.ParentPlaylist   = fourth;
            seventh.ParentPlaylist = fourth;

            //全て追加
            var playlists = new List <STypes::Playlist>()
            {
                first, second, third, fourth, fifth, sixth, seventh
            };

            this.handler = new PlaylistTreeHandler(new PlaylistSettingsHandlerStab());
            this.handler.Initialize(playlists.Select(p => NonBindableTreePlaylistInfo.ConvertToTreePlaylistInfo(p)).ToList());
        }
Beispiel #3
0
        public Current(ILocalSettingHandler settingHandler, IPlaylistTreeHandler treeHandler)
        {
            this.settingHandler = settingHandler;
            this.treeHandler    = treeHandler;

            this.SelectedPlaylist    = new ReactiveProperty <ITreePlaylistInfo?>();
            this.IsTemporaryPlaylist = this.SelectedPlaylist
                                       .Select(p => p?.IsTemporary ?? false)
                                       .ToReadOnlyReactiveProperty();

            this.SelectedPlaylist.Subscribe(value =>
            {
                if (value is not null)
                {
                    string?defaultFolder = this.settingHandler.GetStringSetting(SettingsEnum.DefaultFolder);

                    if (string.IsNullOrEmpty(defaultFolder))
                    {
                        defaultFolder = FileFolder.DefaultDownloadDir;
                    }
                    else if (defaultFolder.Contains("<autoMap>"))
                    {
                        List <string> ancesnter = this.treeHandler.GetListOfAncestor(value.Id);
                        if (ancesnter.Count > 1)
                        {
                            ancesnter = ancesnter.GetRange(1, ancesnter.Count - 1);
                        }
                        string path   = string.Join('\\', ancesnter);
                        defaultFolder = defaultFolder.Replace("<autoMap>", path);
                    }

                    this.PlaylistFolderPath = value.Folderpath.IsNullOrEmpty() ?  defaultFolder : value.Folderpath;
                }
                else
                {
                    this.PlaylistFolderPath = string.Empty;
                }
            });
            this.SelectedPlaylist.Zip(this.SelectedPlaylist.Skip(1), (x, y) => new { OldValue = x, NewValue = y })
            .Subscribe(v =>
            {
                if (v.OldValue is null)
                {
                    return;
                }
                this.PrevSelectedPlaylistID = v.OldValue.Id;
            });
            this.CurrentSelectedIndex = new ReactiveProperty <int>();
        }