Exemple #1
0
        public UserInfoPageViewModel(
            UserProvider userProvider,
            NGSettings ngSettings,
            Models.NiconicoSession niconicoSession,
            SubscriptionManager subscriptionManager,
            UserMylistManager userMylistManager,
            Services.HohoemaPlaylist hohoemaPlaylist,
            PageManager pageManager,
            ExternalAccessService externalAccessService,
            NiconicoFollowToggleButtonService followToggleButtonService,
            Commands.Subscriptions.CreateSubscriptionGroupCommand createSubscriptionGroupCommand
            )
            : base(pageManager)
        {
            HasOwnerVideo = true;


            MylistGroups   = new ObservableCollection <MylistGroupListItem>();
            VideoInfoItems = new ObservableCollection <VideoInfoControlViewModel>();

            OpenUserVideoPageCommand = VideoInfoItems.ObserveProperty(x => x.Count)
                                       .Select(x => x > 0)
                                       .ToReactiveCommand()
                                       .AddTo(_CompositeDisposable);

            OpenUserVideoPageCommand.Subscribe(x =>
            {
                PageManager.OpenPage(HohoemaPageType.UserVideo, UserId);
            })
            .AddTo(_CompositeDisposable);

            IsNGVideoOwner = new ReactiveProperty <bool>(false, ReactivePropertyMode.DistinctUntilChanged);

            IsNGVideoOwner.Subscribe(isNgVideoOwner =>
            {
                if (isNgVideoOwner)
                {
                    NgSettings.AddNGVideoOwnerId(UserId, UserName);
                    IsNGVideoOwner.Value = true;
                    Debug.WriteLine(UserName + "をNG動画投稿者として登録しました。");
                }
                else
                {
                    NgSettings.RemoveNGVideoOwnerId(UserId);
                    IsNGVideoOwner.Value = false;
                    Debug.WriteLine(UserName + "をNG動画投稿者の指定を解除しました。");
                }
            });
            NiconicoSession                = niconicoSession;
            SubscriptionManager            = subscriptionManager;
            UserMylistManager              = userMylistManager;
            ExternalAccessService          = externalAccessService;
            FollowToggleButtonService      = followToggleButtonService;
            CreateSubscriptionGroupCommand = createSubscriptionGroupCommand;
            UserProvider = userProvider;
            NgSettings   = ngSettings;
        }
        protected override async void Execute(object parameter)
        {
            if (parameter is Interfaces.IVideoContent)
            {
                var content = parameter as Interfaces.IVideoContent;

                string ownerName = null;
                if (string.IsNullOrEmpty(ownerName))
                {
                    if (content.ProviderType == NicoVideoUserType.User)
                    {
                        try
                        {
                            var userInfo = await UserProvider.GetUser(content.ProviderId);

                            ownerName = userInfo.ScreenName;
                        }
                        catch
                        {
                            return;
                        }
                    }
                    else if (content.ProviderType == NicoVideoUserType.Channel)
                    {
                        var channelInfo = await ChannelProvider.GetChannelInfo(content.ProviderId);

                        ownerName = channelInfo.Name;

                        var channel = Database.NicoVideoOwnerDb.Get(content.ProviderId)
                                      ?? new Database.NicoVideoOwner()
                        {
                            OwnerId  = channelInfo.ChannelId.ToString(),
                            UserType = NicoVideoUserType.Channel,
                        };
                        channel.ScreenName = channelInfo.ScreenName ?? channel.ScreenName;
                        Database.NicoVideoOwnerDb.AddOrUpdate(channel);
                    }
                }

                NgSettings.AddNGVideoOwnerId(content.ProviderId.ToString(), ownerName);
            }
        }
Exemple #3
0
        protected override async void Execute(object parameter)
        {
            if (parameter is Interfaces.IVideoContent)
            {
                var content = parameter as Interfaces.IVideoContent;


                var ownerName = content.ProviderName;
                if (string.IsNullOrEmpty(ownerName))
                {
                    if (content.ProviderType == Mntone.Nico2.Videos.Thumbnail.UserType.User)
                    {
                        try
                        {
                            var userInfo = await UserProvider.GetUser(content.ProviderId);

                            ownerName = userInfo.ScreenName;
                        }
                        catch
                        {
                            return;
                        }
                    }
                    else if (content.ProviderType == Mntone.Nico2.Videos.Thumbnail.UserType.Channel)
                    {
                        var channelInfo = await ChannelProvider.GetChannelInfo(content.ProviderId);

                        ownerName = channelInfo.Name;

                        var channel = Database.NicoVideoOwnerDb.Get(content.ProviderId)
                                      ?? new Database.NicoVideoOwner()
                        {
                            OwnerId  = channelInfo.ChannelId.ToString(),
                            UserType = Mntone.Nico2.Videos.Thumbnail.UserType.Channel,
                        };
                        channel.ScreenName = channelInfo.ScreenName ?? channel.ScreenName;
                        Database.NicoVideoOwnerDb.AddOrUpdate(channel);
                    }
                }

                var dialog = new MessageDialog(
                    $"この変更は投稿者({ownerName} さん)のアプリ内ユーザー情報ページから取り消すことができます。",

                    $"『{ownerName}』さんの投稿動画を非表示にしますか?"
                    );

                dialog.Commands.Add(new UICommand()
                {
                    Label   = "非表示に設定",
                    Invoked = (uicommand) =>
                    {
                        NgSettings.AddNGVideoOwnerId(content.ProviderId.ToString(), ownerName);
                    }
                });
                dialog.Commands.Add(new UICommand()
                {
                    Label = "キャンセル"
                });

                dialog.DefaultCommandIndex = 0;

                await dialog.ShowAsync();
            }
        }