예제 #1
0
        public VideoDetailsPageViewModel(VideoRecord _record) : this()
        {
            vid = _record.Vid;

            Icon.Value = _record.Icon;

            Playlist.Value = VideoAccesser.CheckIfInPlaylist(_record);
            Favorite.Value = _record.Favorite;

            ScoreUI     = new ScoreEntity(_record.Score);
            IntensityUI = new IntensityEntity(_record.Intensity);
            DurationUI  = new DurationEntity(_record.Duration);

            foreach (var tag in _record.Tags)
            {
                VideoTags.Entities.Insert(VideoTags.Entities.Count - 1, new TagEntity(tag, VideoTags.Entities));
            }

            Alias.Value      = _record.Alias;
            Series.Value     = _record.Series;
            Alt_Alias.Value  = _record.Alt_Alias;
            Alt_Series.Value = _record.Alt_Series;

            Duration.Value = _record.Duration.ToString(@"mm\:ss");
            Bitrate.Value  = Math.Round(_record.File_Size / _record.Duration.TotalSeconds).ToString() + "bps";
            Frame.Value    = _record.Resolution;
            Format.Value   = _record.Format;

            FilePath.Value  = _record.File_Path;
            FileName.Value  = _record.File_Name;
            Extention.Value = _record.File_Extention;
            FileSize.Value  = Math.Round(_record.File_Size / 1048576d, 1).ToString() + "MB";

            Screenlist.Value = _record.Screenlist.Screenlist;

            Icon.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateIcon(vid, Icon.Value); };

            Playlist.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { throw new NotImplementedException(); };
            Favorite.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateFavorite(vid, Favorite.Value); };

            ScoreUI.PropertyChanged     += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateScore(vid, ScoreUI.Score.Value); };
            IntensityUI.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateIntensity(vid, IntensityUI.Intensity.Value); };

            VideoTags.Entities.ListChanged += (object o, ListChangedEventArgs e) => {
                if (e.ListChangedType == ListChangedType.ItemChanged)
                {
                    var collection = (BindingList <TagEntityBase>)o;
                    var tag        = (TagEntity)collection[e.NewIndex];

                    VideoAccesser.UpsertTag(vid, tag.Text, tag.Intensity, tag.Deleted);
                }
            };

            Alias.PropertyChanged      += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateAlias(vid, Alias.Value); };
            Series.PropertyChanged     += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateSeries(vid, Series.Value); };
            Alt_Alias.PropertyChanged  += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateAltAlias(vid, Alt_Alias.Value); };
            Alt_Series.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateAltSeries(vid, Alt_Series.Value); };

            Screenlist.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpsertScreenlist(vid, Screenlist.Value); };
        }
예제 #2
0
        public DurationEntity(TimeSpan _duration, DurationEntity _parent)
        {
            if (_duration.TotalMinutes < 20)
            {
                Duration = new Observable <string>()
                {
                    Value = "Short"
                };
                Background = new Observable <SolidColorBrush>()
                {
                    Value = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FCBF49"))
                };
            }
            else if (_duration.TotalMinutes < 30)
            {
                Duration = new Observable <string>()
                {
                    Value = "Medium"
                };
                Background = new Observable <SolidColorBrush>()
                {
                    Value = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#83B692"))
                };
            }
            else
            {
                Duration = new Observable <string>()
                {
                    Value = "Long"
                };
                Background = new Observable <SolidColorBrush>()
                {
                    Value = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#247BA0"))
                };
            }

            ChangeState = new Command(new Action(() => {
                _parent.Duration.Value   = Duration.Value;
                _parent.Background.Value = Background.Value;
            }));
        }
예제 #3
0
        public VideoDetailsPageViewModel(string _path) : this()
        {
            vid = Guid.NewGuid().ToString();
            VideoAccesser.CreateNewRecord(vid);

            EditMode.Value = true;

            var fileInfo  = new FileInfo(_path);
            var mediaInfo = MediaAccessor.GetMetaData(_path);

            VideoAccesser.UpdateScore(vid, -1);
            VideoAccesser.UpdateFavorite(vid, false);
            VideoAccesser.UpdateIntensity(vid, "N/A");

            VideoAccesser.UpdateAlias(vid, fileInfo.Name);
            Alias.Value = fileInfo.Name;

            VideoAccesser.UpdateSeries(vid, fileInfo.DirectoryName);
            Series.Value = fileInfo.DirectoryName;

            VideoAccesser.UpdateDuration(vid, mediaInfo.Metadata.Duration);
            Duration.Value = mediaInfo.Metadata.Duration.ToString(@"mm\:ss");
            Bitrate.Value  = Math.Round(fileInfo.Length / mediaInfo.Metadata.Duration.TotalSeconds).ToString() + "bps";

            VideoAccesser.UpdateResolution(vid, mediaInfo.Metadata.VideoData.FrameSize);
            Frame.Value = mediaInfo.Metadata.VideoData.FrameSize;

            VideoAccesser.UpdateFormat(vid, mediaInfo.Metadata.VideoData.Format);
            Format.Value = mediaInfo.Metadata.VideoData.Format;

            VideoAccesser.UpdateFilePath(vid, fileInfo.FullName);
            FilePath.Value = fileInfo.FullName;

            VideoAccesser.UpdateFileName(vid, fileInfo.Name);
            FileName.Value = fileInfo.Name;

            VideoAccesser.UpdateFileExtention(vid, fileInfo.Extension);
            Extention.Value = fileInfo.Extension;

            VideoAccesser.UpdateFileSize(vid, fileInfo.Length);
            FileSize.Value = Math.Round(fileInfo.Length / 1048576d, 1).ToString() + "MB";

            ScoreUI     = new ScoreEntity();
            IntensityUI = new IntensityEntity();
            DurationUI  = new DurationEntity(mediaInfo.Metadata.Duration);

            LoadingIndicatorVisibility.Value = Visibility.Visible;

            Task.Factory.StartNew(new Action(() => {
                BitmapSource result = MediaAccessor.CreateGridScreenlist(mediaInfo, LoadingIndicatorCurrent, LoadingIndicatorMax);

                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { Screenlist.Value = result; }));
                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { LoadingIndicatorVisibility.Value = Visibility.Hidden; }));

                var crc64   = new Crc64Iso();
                string hash = string.Empty;

                using (var fs = File.Open(fileInfo.FullName, FileMode.Open))
                    foreach (var b in crc64.ComputeHash(fs))
                    {
                        hash += b.ToString("x2").ToLower();
                    }

                VideoAccesser.UpdateChecksum(vid, hash);
            }));

            Icon.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateIcon(vid, Icon.Value); };

            Playlist.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { throw new NotImplementedException(); };
            Favorite.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateFavorite(vid, Favorite.Value); };

            ScoreUI.PropertyChanged     += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateScore(vid, ScoreUI.Score.Value); };
            IntensityUI.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateIntensity(vid, IntensityUI.Intensity.Value); };

            VideoTags.Entities.ListChanged += (object o, ListChangedEventArgs e) => {
                if (e.ListChangedType == ListChangedType.ItemChanged)
                {
                    var collection = (BindingList <TagEntityBase>)o;
                    var tag        = (TagEntity)collection[e.NewIndex];

                    VideoAccesser.UpsertTag(vid, tag.Text, tag.Intensity, tag.Deleted);
                }
            };

            Alias.PropertyChanged      += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateAlias(vid, Alias.Value); };
            Series.PropertyChanged     += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateSeries(vid, Series.Value); };
            Alt_Alias.PropertyChanged  += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateAltAlias(vid, Alt_Alias.Value); };
            Alt_Series.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpdateAltSeries(vid, Alt_Series.Value); };

            Screenlist.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { VideoAccesser.UpsertScreenlist(vid, Screenlist.Value); };
        }