Exemplo n.º 1
0
 public static CoverBuilder CreateVideo(JryVideoInfo video)
 {
     return(new CoverBuilder(video)
     {
         CoverType = CoverType.Video,
     });
 }
Exemplo n.º 2
0
 public VideoInfoViewModel(SeriesViewModel seriesViewModel, JryVideoInfo source)
     : base(source)
 {
     this.PropertiesMapper    = Mapper;
     this.SeriesView          = seriesViewModel;
     this.IsTrackButtonEnable = !(this.IsUntrackButtonEnable = this.Source.IsTracking);
     this.CoverViewModel.AutoGenerateCoverProvider = new AutoGenerateCoverProvider(this.GetManagers().CoverManager);
 }
        public VideoRoleCollectionViewModel(Series series, JryVideoInfo video)
        {
            this.series = series;
            this.video  = video;

            this.Roles.View.CustomSort = this;
            this.Roles.View.GroupDescriptions?.Add(new PropertyGroupDescription(nameof(VideoRoleViewModel.GroupTitle)));
        }
Exemplo n.º 4
0
 void ViewModel_Created(object sender, JryVideoInfo e)
 {
     if (this.GetUIDispatcher().CheckAccessOrBeginInvoke(this.ViewModel_Created, sender, e))
     {
         var win = this.TryFindParent <AddWindow>();
         win.IsCommited         = true;
         win.DialogResultObject = e;
         win.DialogResult       = true;
     }
 }
Exemplo n.º 5
0
        public async Task <bool> AutoCompleteRoleAsync(VideoRoleManager manager, JryVideoInfo video)
        {
            var imdbId = video.GetValidImdbId();

            if (imdbId != null)
            {
                return(await manager.AutoCreateVideoRoleAsync(video.Id, new RemoteId(RemoteIdType.Imdb, imdbId)));
            }
            return(false);
        }
Exemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="to">after combine will live</param>
        /// <param name="from">after combine will dead</param>
        /// <returns></returns>
        public async Task <CombineResult> CombineAsync(VideoInfoManager manager, JryVideoInfo to, JryVideoInfo from)
        {
            var result = await this.CanCombineAsync(manager, to, from);

            if (result.CanCombine)
            {
                await this.VideoRoleManager.CombineAsync(to.Id, from.Id);

                await manager.CombineAsync(to, from);
            }
            return(result);
        }
Exemplo n.º 7
0
        public async Task <bool> UpgradeAsync(DataCenter dataCenter, JryCover cover)
        {
            string oldCoverId;

            switch (cover.CoverType)
            {
            case CoverType.Artist:

                break;

            case CoverType.Video:
                if (cover.VideoId == null || cover.VideoId == cover.Id)
                {
                    return(true);
                }
                oldCoverId = cover.Id;
                cover.Id   = cover.VideoId;
                await dataCenter.CoverManager.Source.InsertOrUpdateAsync(cover);

                await dataCenter.CoverManager.Source.RemoveAsync(oldCoverId);

                return(true);

            case CoverType.Background:
                if (cover.VideoId == null || JryVideoInfo.CreateBackgroundCoverId(cover.VideoId) == cover.Id)
                {
                    return(true);
                }
                oldCoverId = cover.Id;
                cover.Id   = JryVideoInfo.CreateBackgroundCoverId(cover.VideoId);
                await dataCenter.CoverManager.Source.InsertOrUpdateAsync(cover);

                await dataCenter.CoverManager.Source.RemoveAsync(oldCoverId);

                return(true);

            case CoverType.Role:

                break;
            }

            // return true to update old item, but we remove old item.
            return(false);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 当在派生类中重写时,对值执行验证检查。
        /// </summary>
        /// <returns>
        /// <see cref="T:System.Windows.Controls.ValidationResult"/> 对象。
        /// </returns>
        /// <param name="value">要检查的来自绑定目标的值。</param><param name="cultureInfo">要在此规则中使用的区域性。</param>
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            var text = value as string;

            if (text == null)
            {
                return(new ValidationResult(false, "please input value."));
            }

            int index;

            if (!Int32.TryParse(text, out index))
            {
                return(new ValidationResult(false, "please input number."));
            }

            if (!JryVideoInfo.IsIndexValid(index))
            {
                return(new ValidationResult(false, "this is a invalid index ( 0 < index )."));
            }

            return(ValidationResult.ValidResult);
        }
        /// <summary>
        /// 当在派生类中重写时,对值执行验证检查。
        /// </summary>
        /// <returns>
        /// <see cref="T:System.Windows.Controls.ValidationResult"/> 对象。
        /// </returns>
        /// <param name="value">要检查的来自绑定目标的值。</param><param name="cultureInfo">要在此规则中使用的区域性。</param>
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            var text = value as string;

            if (text == null)
            {
                return(new ValidationResult(false, "please input value."));
            }

            int count;

            if (!Int32.TryParse(text, out count))
            {
                return(new ValidationResult(false, "please input number."));
            }

            if (!JryVideoInfo.IsEpisodesCountValid(count))
            {
                return(new ValidationResult(false, "this is a invalid count ( 0 < count )."));
            }

            return(ValidationResult.ValidResult);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 当在派生类中重写时,对值执行验证检查。
        /// </summary>
        /// <returns>
        /// <see cref="T:System.Windows.Controls.ValidationResult"/> 对象。
        /// </returns>
        /// <param name="value">要检查的来自绑定目标的值。</param><param name="cultureInfo">要在此规则中使用的区域性。</param>
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            var text = value as string;

            if (text == null)
            {
                return(new ValidationResult(false, "please input string."));
            }

            int year;

            if (!Int32.TryParse(text, out year))
            {
                return(new ValidationResult(false, "please input number."));
            }

            if (!JryVideoInfo.IsYearValid(year))
            {
                return(new ValidationResult(false, "this is a invalid year ( 1900 < year < 2100 )."));
            }

            return(ValidationResult.ValidResult);
        }
 public bool IsMatch(Series series, JryVideoInfo video) => this.query?.IsMatch(series, video) ?? video.IsTracking;
Exemplo n.º 12
0
 public VideoInfoRef(string seriesId, JryVideoInfo obj)
     : base(obj)
 {
     this.SeriesId = seriesId;
 }
Exemplo n.º 13
0
            public bool IsMatch(Series series, JryVideoInfo video)
            {
                if (series == null)
                {
                    throw new ArgumentNullException(nameof(series));
                }
                if (video == null)
                {
                    throw new ArgumentNullException(nameof(video));
                }

                var queryParameter = this.QueryParameter;

                switch (queryParameter.Mode)
                {
                case Series.QueryMode.Any:
                    return(true);

                case Series.QueryMode.OriginText:
                    if (series.Names.Any(z => z.Contains(queryParameter.Keyword, StringComparison.OrdinalIgnoreCase)) ||
                        video.Names.Any(z => z.Contains(queryParameter.Keyword, StringComparison.OrdinalIgnoreCase)))
                    {
                        return(true);
                    }
                    break;

                case Series.QueryMode.SeriesId:
                    if (series.Id == queryParameter.Keyword)
                    {
                        return(true);
                    }
                    break;

                case Series.QueryMode.VideoId:
                    if (video.Id == queryParameter.Keyword)
                    {
                        return(true);
                    }
                    break;

                case Series.QueryMode.EntityId:
                    return(true);

                case Series.QueryMode.DoubanId:
                    if (video.DoubanId == queryParameter.Keyword)
                    {
                        return(true);
                    }
                    break;

                case Series.QueryMode.Tag:
                    if ((series.Tags != null && series.Tags.Any(z => z == queryParameter.Keyword)) ||
                        (video.Tags != null && video.Tags.Any(z => z == queryParameter.Keyword)))
                    {
                        return(true);
                    }
                    break;

                case Series.QueryMode.VideoType:
                    if (video.Type == queryParameter.Keyword)
                    {
                        return(true);
                    }
                    break;

                case Series.QueryMode.VideoYear:
                    if (video.Year.ToString() == queryParameter.Keyword)
                    {
                        return(true);
                    }
                    break;

                case Series.QueryMode.ImdbId:
                    if (video.ImdbId == queryParameter.Keyword)
                    {
                        return(true);
                    }
                    break;

                case Series.QueryMode.Star:
                    return(this.starArray.Contains(video.Star));

                default:
                    throw new ArgumentOutOfRangeException();
                }

                return(false);
            }
Exemplo n.º 14
0
        public static SelectResult <JryVideoInfo> Select(Window parent, SeriesViewModel source, JryVideoInfo without = null, string defaultId = null)
        {
            var dialog = new VideoSelectorWindow()
            {
                Owner = parent
            };

            if (without != null)
            {
                dialog.SelectVideoControl.ViewModel.Withouts.Add(without.Id);
            }
            dialog.SelectVideoControl.Initialize(source, defaultId);

            return(dialog.ShowDialog() == true
                ? SelectResult <JryVideoInfo> .Selected(dialog.SelectVideoControl.ViewModel.Items.Selected?.Source)
                : SelectResult <JryVideoInfo> .NonAccept);
        }