Beispiel #1
0
        /* CRC */
        private static byte[] CalculateCRC(string chksmFile)
        {
            List <byte> checksum = new List <byte>();
            var         crc64    = new Crc64Iso();

            using (FileStream fs = File.Open(chksmFile, FileMode.Open))
            {
                foreach (byte b in crc64.ComputeHash(fs))
                {
                    checksum.Add(b);
                }
            }

            return(checksum.ToArray());
        }
Beispiel #2
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); };
        }