Ejemplo n.º 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); };
        }
Ejemplo n.º 2
0
        public ScoreEntity(int _score, ScoreEntity _parent)
        {
            Score = new Observable <int>()
            {
                Value = _score
            };
            Background = new Observable <SolidColorBrush>();

            switch (_score)
            {
            case -1:
                Background.Value = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#C0C0C0"));
                break;

            case 1:
            case 2:
                Background.Value = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F25F5C"));
                break;

            case 3:
            case 4:
                Background.Value = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FCBF49"));
                break;

            case 5:
            case 6:
                Background.Value = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#83B692"));
                break;

            case 7:
            case 8:
                Background.Value = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#247BA0"));
                break;

            case 9:
            case 10:
                Background.Value = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#582C83"));
                break;
            }

            ChangeState = new Command(new Action(() => {
                _parent.Score.Value      = Score.Value;
                _parent.Background.Value = Background.Value;

                _parent.MenuOpened.Value = false;
                _parent.NotifyPropertyChanged("Intensity");
            }));
        }
Ejemplo n.º 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); };
        }