Ejemplo n.º 1
0
        public VideoViewModel(VideoInfo videoInfo, Category category, string siteName, string utilName, bool isDetailsVideo)
            : base(Consts.KEY_NAME, isDetailsVideo ? ((DetailVideoInfo)videoInfo).Title2 : videoInfo.Title)
        {
            VideoInfo      = videoInfo;
            Category       = category;
            SiteName       = siteName;
            SiteUtilName   = utilName;
            IsDetailsVideo = isDetailsVideo;

            _titleProperty          = new WProperty(typeof(string), videoInfo.Title);
            _title2Property         = new WProperty(typeof(string), isDetailsVideo ? ((DetailVideoInfo)videoInfo).Title2 : string.Empty);
            _descriptionProperty    = new WProperty(typeof(string), videoInfo.Description);
            _lengthProperty         = new WProperty(typeof(string), videoInfo.Length);
            _airdateProperty        = new WProperty(typeof(string), videoInfo.Airdate);
            _thumbnailImageProperty = new WProperty(typeof(string), videoInfo.ThumbnailImage);

            _contextMenuEntriesProperty = new WProperty(typeof(ItemsList), null);

            eventDelegator = OnlineVideosAppDomain.Domain.CreateInstanceAndUnwrap(typeof(PropertyChangedDelegator).Assembly.FullName, typeof(PropertyChangedDelegator).FullName) as PropertyChangedDelegator;
            eventDelegator.InvokeTarget = new PropertyChangedExecutor()
            {
                InvokeHandler = (s, e) =>
                {
                    if (e.PropertyName == "ThumbnailImage")
                    {
                        ThumbnailImage = (s as VideoInfo).ThumbnailImage;
                    }
                    else if (e.PropertyName == "Length")
                    {
                        Length = (s as VideoInfo).Length;
                    }
                }
            };
            VideoInfo.PropertyChanged += eventDelegator.EventDelegate;
        }
Ejemplo n.º 2
0
        public CategoryViewModel(Category category)
            : base(Consts.KEY_NAME, category.Name)
        {
            _category = category;

            _nameProperty              = new WProperty(typeof(string), category.Name);
            _descriptionProperty       = new WProperty(typeof(string), category.Description);
            _thumbProperty             = new WProperty(typeof(string), null);
            _estimatedChildrenProperty = new WProperty(typeof(uint?), CalculateChildrenCount());

            if (Category is NextPageCategory)
            {
                Thumb = "NextPage.png";
            }
            else
            {
                eventDelegator = OnlineVideosAppDomain.Domain.CreateInstanceAndUnwrap(typeof(PropertyChangedDelegator).Assembly.FullName, typeof(PropertyChangedDelegator).FullName) as PropertyChangedDelegator;
                eventDelegator.InvokeTarget = new PropertyChangedExecutor()
                {
                    InvokeHandler = (s, e) =>
                    {
                        if (e.PropertyName == "ThumbnailImage")
                        {
                            Thumb = (s as Category).ThumbnailImage;
                        }
                    }
                };
                _category.PropertyChanged += eventDelegator.EventDelegate;
            }
        }