Exemplo n.º 1
0
 private void MakeDefaultPlaylist()
 {
     if (DefaultPlaylist == null)
     {
         DefaultPlaylist = new LocalMylistGroup(HohoemaPlaylist.WatchAfterPlaylistId, "あとで見る");
     }
 }
Exemplo n.º 2
0
        public async Task <Interfaces.IUserOwnedMylist> ChoiceMylist(
            params string[] ignoreMylistId
            )
        {
            const string CreateNewContextLabel = @"@create_new";
            var          mylists      = UserMylistManager.Mylists;
            var          localMylists = LocalMylistManager.Mylists;

            List <ISelectableContainer> selectDialogContent;

            if (false)
            {
                selectDialogContent = new List <ISelectableContainer>()
                {
                    new ChoiceFromListSelectableContainer("マイリスト",
                                                          mylists.Where(x => ignoreMylistId.All(y => x.Id != y))
                                                          .Select(x => new SelectDialogPayload()
                    {
                        Label = x.Label, Id = x.Id, Context = x
                    })
                                                          ),
                    new ChoiceFromListSelectableContainer("ローカルマイリスト",
                                                          localMylists.Where(x => ignoreMylistId.All(y => x.Id != y))
                                                          .Select(x => new SelectDialogPayload()
                    {
                        Label = x.Label, Id = x.Id, Context = x
                    })
                                                          ),
                    new ChoiceFromListSelectableContainer("新規作成",
                                                          new [] {
                        new SelectDialogPayload()
                        {
                            Label = "マイリストを作成", Id = "mylist", Context = CreateNewContextLabel
                        },
                        new SelectDialogPayload()
                        {
                            Label = "ローカルマイリストを作成", Id = "local", Context = CreateNewContextLabel
                        },
                    }
                                                          )
                };
            }
            else
            {
                selectDialogContent = new List <ISelectableContainer>()
                {
                    new ChoiceFromListSelectableContainer("ローカルマイリスト",
                                                          localMylists.Where(x => ignoreMylistId.All(y => x.Id != y))
                                                          .Select(x => new SelectDialogPayload()
                    {
                        Label = x.Label, Id = x.Id, Context = x
                    })
                                                          ),
                    new ChoiceFromListSelectableContainer("新規作成",
                                                          new [] {
                        new SelectDialogPayload()
                        {
                            Label = "ローカルマイリストを作成", Id = "local", Context = CreateNewContextLabel
                        },
                    }
                                                          )
                };
            }

            Interfaces.IUserOwnedMylist resultList = null;
            while (resultList == null)
            {
                var result = await ShowContentSelectDialogAsync(
                    "追加先マイリストを選択",
                    selectDialogContent
                    );

                if (result == null)
                {
                    break;
                }

                if (result?.Context as string == CreateNewContextLabel)
                {
                    var mylistTypeLabel = result.Id == "mylist" ? "マイリスト" : "ローカルマイリスト";
                    var title           = await GetTextAsync(
                        $"{mylistTypeLabel}を作成",
                        $"{mylistTypeLabel}名",
                        validater : (str) => !string.IsNullOrWhiteSpace(str)
                        );

                    if (title == null)
                    {
                        continue;
                    }

                    if (result.Id == "mylist")
                    {
                        await UserMylistManager.AddMylist(title, "", false, Mntone.Nico2.Mylist.MylistDefaultSort.FirstRetrieve_Descending, Mntone.Nico2.Mylist.IconType.Default);

                        resultList = UserMylistManager.Mylists.FirstOrDefault(x => x.Label == title);
                    }
                    else //if (result.Id == "local")
                    {
                        var localMylist = new LocalMylistGroup(Guid.NewGuid().ToString(), title);
                        LocalMylistManager.Mylists.Add(localMylist);
                        resultList = localMylist;
                    }
                }
                else
                {
                    resultList = result?.Context as Interfaces.IUserOwnedMylist;
                }
            }

            return(resultList);
        }