Esempio n. 1
0
        protected override async void Execute(object parameter)
        {
            var currentMethod = System.Reflection.MethodBase.GetCurrentMethod();
            //Microsoft.AppCenter.Analytics.Analytics.TrackEvent($"{currentMethod.DeclaringType.Name}#{currentMethod.Name}");

            var result = await DialogService.GetTextAsync(
                "LocalPlaylistCreate".Translate(),
                "LocalPlaylistNameTextBoxPlacefolder".Translate(),
                "",
                (s) => !string.IsNullOrWhiteSpace(s)
                );

            if (result != null)
            {
                var localPlaylist = LocalMylistManager.CreatePlaylist(result);

                Debug.WriteLine("ローカルマイリスト作成:" + result);

                if (parameter is IVideoContent content)
                {
                    localPlaylist.AddPlaylistItem(content);
                }
                else if (parameter is string itemId)
                {
                    throw new NotSupportedException();
                }
            }
        }
Esempio n. 2
0
        protected override async void Execute(object parameter)
        {
            var result = await DialogService.GetTextAsync(
                "LocalPlaylistCreate".Translate(),
                "LocalPlaylistNameTextBoxPlacefolder".Translate(),
                "",
                (s) => !string.IsNullOrWhiteSpace(s)
                );

            if (result != null)
            {
                var localMylist   = new Models.LocalMylist.LocalMylistGroup(Guid.NewGuid().ToString(), result);
                var localPlaylist = LocalMylistManager.CreatePlaylist(result);

                Debug.WriteLine("ローカルマイリスト作成:" + result);

                if (parameter is Interfaces.IVideoContent content)
                {
                    localPlaylist.AddPlaylistItem(content);
                }
                else if (parameter is string itemId)
                {
                    throw new NotSupportedException();
                }
            }
        }
 protected override void Execute(object parameter)
 {
     if (parameter is string label)
     {
         _localMylistManager.CreatePlaylist(label);
     }
 }
Esempio n. 4
0
        public async Task <IPlaylist> ChoiceMylist(
            params string[] ignoreMylistId
            )
        {
            const string CreateNewContextLabel = @"@create_new";
            var          mylists      = _userMylistManager.Mylists;
            var          localMylists = _localMylistManager.LocalPlaylists;

            List <ISelectableContainer> selectDialogContent;

            if (false)
            {
                selectDialogContent = new List <ISelectableContainer>()
                {
                    new ChoiceFromListSelectableContainer("マイリスト",
                                                          mylists.Where(x => ignoreMylistId.All(y => x.MylistId != y))
                                                          .Select(x => new SelectDialogPayload()
                    {
                        Label = x.Name, Id = x.MylistId, Context = x
                    })
                                                          ),
                    new ChoiceFromListSelectableContainer("ローカルマイリスト",
                                                          localMylists.Where(x => ignoreMylistId.All(y => x.PlaylistId.Id != y))
                                                          .Select(x => new SelectDialogPayload()
                    {
                        Label = x.Name, Id = x.PlaylistId.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("LocalPlaylist".Translate(),
                                                          localMylists.Where(x => ignoreMylistId.All(y => x.PlaylistId.Id != y))
                                                          .Select(x => new SelectDialogPayload()
                    {
                        Label = x.Name, Id = x.PlaylistId.Id, Context = x
                    })
                                                          ),
                    new ChoiceFromListSelectableContainer("CreateNew".Translate(),
                                                          new [] {
                        new SelectDialogPayload()
                        {
                            Label = "LocalPlaylistCreate".Translate(), Id = "local", Context = CreateNewContextLabel
                        },
                    }
                                                          )
                };
            }

            IPlaylist resultList = null;

            while (resultList == null)
            {
                var result = await _dialogService.ShowContentSelectDialogAsync(
                    "SelectMylist".Translate(),
                    selectDialogContent
                    );

                if (result == null)
                {
                    break;
                }

                if (result?.Context as string == CreateNewContextLabel)
                {
                    if (result.Id == "mylist")
                    {
                        var title = await _dialogService.GetTextAsync(
                            $"MylistCreate".Translate(),
                            $"MylistNameTextBoxPlacefolder".Translate(),
                            validater : (str) => !string.IsNullOrWhiteSpace(str)
                            );

                        await _userMylistManager.AddMylist(title, "", false, MylistSortKey.AddedAt, MylistSortOrder.Desc);

                        resultList = _userMylistManager.Mylists.LastOrDefault(x => x.Name == title);
                    }
                    else //if (result.Id == "local")
                    {
                        var title = await _dialogService.GetTextAsync(
                            $"LocalPlaylistCreate".Translate(),
                            $"LocalPlaylistNameTextBoxPlacefolder".Translate(),
                            validater : (str) => !string.IsNullOrWhiteSpace(str)
                            );

                        resultList = _localMylistManager.CreatePlaylist(title);;
                    }
                }
                else
                {
                    resultList = result?.Context as IPlaylist;
                }
            }

            return(resultList);
        }