예제 #1
0
        public VideoItemViewModel(VideoModel model) : base(model)
        {
            Source = model;
            Source.AddOnPropertyChanged(this, OnPropertyChanged);

            VideoId         = Source.VideoId;
            Title           = Source.Title;
            Description     = Source.Description;
            Tags            = Source.Tags;
            CategoryTag     = Source.CategoryTag;
            ViewCounter     = Source.ViewCounter;
            MylistCounter   = Source.MylistCounter;
            CommentCounter  = Source.CommentCounter;
            StartTime       = Source.StartTime;
            LastCommentTime = Source.LastCommentTime;
            LengthSeconds   = Source.LengthSeconds;
            ThumbnailUrl    = Source.ThumbnailUrl;
            Thumbnail       = Source.Thumbnail;
            CommunityIcon   = Source.CommunityIcon;
            LastUpdateTime  = Source.LastUpdateTime;
            LastResBody     = Source.LastResBody;
        }
예제 #2
0
        public VideoViewModel(VideoModel source)
        {
            Source = source;

            if (SearchVideoByHistoryModel.Instance.IsSee(Source.VideoId))
            {
                Source.Status = VideoStatus.See;
            }
            else if (SearchVideoByTemporaryModel.Instance.IsNew(Source.VideoId))
            {
                Source.Status = VideoStatus.New;
            }
            else if (SearchVideoByTemporaryModel.Instance.IsTemporary(Source.VideoId))
            {
                Source.Status = VideoStatus.Favorite;
            }

            // 初期値設定
            Thumbnail      = Source.Thumbnail;
            Status         = Source.Status.GetLabel();
            LengthSeconds  = TimeSpan.FromSeconds(Source.LengthSeconds);
            Title          = Source.Title;
            Description    = Source.Description;
            ViewCounter    = Source.ViewCounter;
            MylistCounter  = Source.MylistCounter;
            CommentCounter = Source.CommentCounter;
            StartDate      = Source.StartTime;
            Tags           = Source.Tags;
            Username       = Source.Username;

            // モデル側で変更があったら通知する
            Source.AddOnPropertyChanged(this, (sender, e) =>
            {
                switch (e.PropertyName)
                {
                case nameof(Thumbnail):
                    Thumbnail = Source.Thumbnail;
                    break;

                case nameof(Status):
                    Status = Source.Status.GetLabel();
                    break;

                case nameof(LengthSeconds):
                    LengthSeconds = TimeSpan.FromSeconds(Source.LengthSeconds);
                    break;

                case nameof(Title):
                    Title = Source.Title;
                    break;

                case nameof(Description):
                    Description = Source.Description;
                    break;

                case nameof(ViewCounter):
                    ViewCounter = Source.ViewCounter;
                    break;

                case nameof(MylistCounter):
                    MylistCounter = Source.MylistCounter;
                    break;

                case nameof(CommentCounter):
                    CommentCounter = Source.CommentCounter;
                    break;

                case nameof(StartDate):
                    StartDate = Source.StartTime;
                    break;

                case nameof(Tags):
                    Tags = Source.Tags;
                    break;

                case nameof(Username):
                    Username = Source.Username;
                    break;
                }
            });
        }