Наследование: System.MarshalByRefObject
        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;
            }
        }
Пример #2
0
        public Category(OnlineVideos.Category category)
        {
            Model = category;

            Name = category.Name;
            Description = category.Description;
            ThumbnailImage = category.ThumbnailImage;
            CategoryPath = category.RecursiveName();
            if (category is OnlineVideos.RssLink) EstimatedVideoCount = (category as OnlineVideos.RssLink).EstimatedVideoCount;

            // we cannot attach directly to the PropertyChanged event of the Model as it is in another domain and PropertyChangedEventArgs is not serializable
            eventDelegator = OnlineVideosAppDomain.Domain.CreateInstanceAndUnwrap(typeof(PropertyChangedDelegator).Assembly.FullName, typeof(PropertyChangedDelegator).FullName) as PropertyChangedDelegator;
            eventDelegator.InvokeTarget = new PropertyChangedExecutor() { InvokeHandler = ModelPropertyChanged };
            Model.PropertyChanged += eventDelegator.EventDelegate;
        }
        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;
        }