Exemplo n.º 1
0
        protected override async void Execute(object parameter)
        {
            var hohoemaApp = HohoemaCommnadHelper.GetHohoemaApp();
            var playlist   = hohoemaApp.Playlist;

            var dialogService = App.Current.Container.Resolve <Services.HohoemaDialogService>();
            var data          = new Dialogs.MylistGroupEditData()
            {
            };
            var result = await dialogService.GetTextAsync("新しいローカルマイリストを作成", "ローカルマイリスト名", "", (s) => !string.IsNullOrWhiteSpace(s));

            if (result != null)
            {
                var newMylist = playlist.CreatePlaylist(Guid.NewGuid().ToString(), result);

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

                if (parameter is Interfaces.IVideoContent || parameter is string)
                {
                    if (newMylist.AddItemCommand?.CanExecute(parameter) ?? false)
                    {
                        newMylist.AddItemCommand.Execute(parameter);
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected override async void Execute(object parameter)
        {
            var hohoemaApp    = HohoemaCommnadHelper.GetHohoemaApp();
            var mylistManager = hohoemaApp.UserMylistManager;

            var dialogService = App.Current.Container.Resolve <Services.HohoemaDialogService>();
            var data          = new Dialogs.MylistGroupEditData()
            {
            };
            var result = await dialogService.ShowCreateMylistGroupDialogAsync(data);

            if (result)
            {
                var mylistCreateResult = await mylistManager.AddMylist(data.Name, data.Description, data.IsPublic, data.MylistDefaultSort, data.IconType);

                Debug.WriteLine("マイリスト作成:" + mylistCreateResult);
            }

            if (parameter is Interfaces.IVideoContent || parameter is string)
            {
                var mylist = mylistManager.UserMylists.FirstOrDefault(x => x.Label == data.Name);
                if (mylist.AddItemCommand?.CanExecute(parameter) ?? false)
                {
                    mylist.AddItemCommand.Execute(parameter);
                }
            }
        }
Exemplo n.º 3
0
        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            ProcessingBarrier.Visibility = Visibility.Visible;
            LoginProgressRing.IsActive   = true;

            var defer = args.GetDeferral();

            bool isTwoFactorLogin = false;

            try
            {
                var hohoemaApp = HohoemaCommnadHelper.GetHohoemaApp();

                var mail     = Mail.Text;
                var password = Password.Password;
                var result   = await hohoemaApp.SignIn(mail, password, twoFactorAuth : async() =>
                {
                    isTwoFactorLogin = true;

                    defer.Complete();

                    await Task.Delay(200);
                });

                if (IsRememberPassword.IsOn)
                {
                    await AccountManager.AddOrUpdateAccount(mail, password);

                    AccountManager.SetPrimaryAccountId(mail);
                }
                else
                {
                    AccountManager.SetPrimaryAccountId("");
                    AccountManager.RemoveAccount(mail);
                }

                if (!isTwoFactorLogin &&
                    (result == Mntone.Nico2.NiconicoSignInStatus.Failed || result == Mntone.Nico2.NiconicoSignInStatus.ServiceUnavailable))
                {
                    args.Cancel = true;
                }
            }
            finally
            {
                if (!isTwoFactorLogin)
                {
                    defer.Complete();
                }

                ProcessingBarrier.Visibility = Visibility.Collapsed;
                LoginProgressRing.IsActive   = false;
            }
        }