private void ProcessAudio(IAudioSource file, string displayPath, string displayFilename)
        {
            this.Dispatcher.BeginInvokeAction(() =>
            {
                this.textStatus.Text        = this.processedFiles + " / " + this.totalFiles;
                this.progressChecksum.Value = 0;
            });

            AudioChecksumCalculator calculator = new AudioChecksumCalculator(file);

            calculator.ProgressChanged +=
                ProgressBarUpdater.CreateHandler(this.Dispatcher, this.progressChecksum, () => this.shouldCancel);
            calculator.ComputeHashes();
            uint crc32 = calculator.CRC32;

            ++this.processedFiles;

            file.Close();

            this.Dispatcher.BeginInvokeAction(() =>
            {
                this.textStatus.Text = this.processedFiles + " / " + this.totalFiles;
                this.listChecksums.Items.Add(new AudioChecksumItem()
                {
                    Path     = displayPath,
                    Filename = displayFilename,
                    Checksum = crc32.ToString("X8")
                });
            });
        }
Exemplo n.º 2
0
 internal bool HandleInstallerQuit(bool doRunOnClose)
 {
     ProgressBarUpdater.Close();
     foreach (KeyValuePair <string, InstallationPackage> pkg in _packageDictionary)
     {
         pkg.Value.Quit(doRunOnClose);
     }
     CleanWorkDir();
     return(true);
 }
        public AudioFormatAnalysisWindow(ICollectionSessionFactory factory)
            : base(factory)
        {
            this.bucketCollection = new FormatBucketCollection();
            this.localBuckets     = new FormatBucketCollection();
            this.fileBuckets      = new ObservableCollection <FileBucket>();
            this.localFileBuckets = new ObservableCollection <FileBucket>();

            InitializeComponent();

            this.listFormats.ItemsSource = this.bucketCollection;
            this.listFiles.ItemsSource   = this.fileBuckets;

            this.ProgressChanged += ProgressBarUpdater.CreateHandler(this.Dispatcher, this.busyIndicator, () => false, p =>
            {
                this.bucketCollection.Add(this.localBuckets);
                this.localBuckets.Clear();
                this.fileBuckets.AddRange(this.localFileBuckets);
                this.localFileBuckets.Clear();
            });
            new Task(this.CalculateAudioFormats).Start();
        }
        private void WorkerTask()
        {
            EncodingTargetScanner scanner = new EncodingTargetScanner(this.CollectionManager, this.encodingTarget);

            scanner.ProgressChanged += ProgressBarUpdater.CreateHandler(this.Dispatcher, this.progressScan, () => this.cancelScanning);
            this.scanResult          = scanner.Scan();

            if (!this.cancelScanning)
            {
                this.Dispatcher.InvokeAction(() =>
                {
                    this.groupTracksToEncode.Header = "Tracks To Encode (" + scanResult.ReleasesToEncodeTrackCount + ")";
                    this.groupFilesToDelete.Header  = "Files To Delete (" + scanResult.FilesToDelete.Length + ")";

                    List <TrackToEncodeListViewItem> tracksToEncode = new List <TrackToEncodeListViewItem>();
                    foreach (var releaseToEncode in this.scanResult.ReleasesToEncode)
                    {
                        foreach (var trackToEncode in releaseToEncode.Tracklist)
                        {
                            tracksToEncode.Add(new TrackToEncodeListViewItem()
                            {
                                Release = releaseToEncode.JoinedAlbumArtists + " - " + releaseToEncode.Title,
                                Title   = trackToEncode.Title
                            });
                        }
                    }
                    this.listTracksToEncode.ItemsSource = tracksToEncode;

                    this.listFilesToDelete.ItemsSource = this.scanResult.FilesToDelete.ToArray();

                    this.btnSync.IsEnabled =
                        this.scanResult.ReleasesToEncodeTrackCount > 0 ||
                        this.scanResult.FilesToDelete.Length > 0;
                });
            }
        }
Exemplo n.º 5
0
        internal void HandleProgressUpdate(InstallationPackage pkg)
        {
            lock (progressLock)
            {
                if (pkg.InstallationState >= InstallationPackage.State.DownloadStart && pkg.DwnldBytesOffset > 0)
                {
                    if (!pkg.hasUpdatedTotal)
                    {
                        dwnldBytesTotal    += pkg.DwnldBytesTotal;
                        pkg.hasUpdatedTotal = true;
                        pkgRunningCounter++;
                    }

                    dwnldBytesReceived += pkg.DwnldBytesOffset;
                    currentProgress     = Math.Round(100.0 * dwnldBytesReceived / dwnldBytesTotal);
                }

                if (pkg.isProgressCompleted && !pkg.isUpdatedProgressCompleted)
                {
                    pkgCompletedCounter++;
                    if (pkg.hasUpdatedTotal)
                    {
                        pkgRunningCounter--;
                    }
                    pkg.isUpdatedProgressCompleted = true;
#if DEBUG
                    Logger.GetLogger().Info($"[{pkg.Name}] Package progress completed");
#endif
                }

                if (_packageDictionary.Count > pkgRunningCounter + pkgCompletedCounter)
                {
                    return;
                }

                if (currentProgress > 100 || _packageDictionary.Count == pkgCompletedCounter)
                {
                    currentProgress = 100;
                }

                if ((DateTime.Now - progressSampleTime).TotalMilliseconds < 100 && currentProgress != 100)
                {
                    return;
                }

                progressSampleCnt = progressSampleCnt < 50 ? progressSampleCnt + 1 : 1;
                avgDwnldSpeed     = avgDwnldSpeed * (progressSampleCnt - 1) / progressSampleCnt + CalcCurrentDownloadSpeed(dwnldBytesReceived) / progressSampleCnt;

                progressSampleTime = DateTime.Now;

                string errorMessage = string.Empty;
                if (pkg.InstallationState == InstallationPackage.State.Error && !pkg.isOptional)
                {
                    errorMessage = pkg.ErrorMessage;
                }

                ProgressEventArgs progressEvent = new ProgressEventArgs(errorMessage, Convert.ToInt32(currentProgress),
                                                                        dwnldBytesReceived, dwnldBytesTotal, avgDwnldSpeed, _packageDictionary.Count == pkgCompletedCounter);

                ProgressBarUpdater.HandleProgress(progressEvent);
            }
        }
Exemplo n.º 6
0
 public DistanceObv(ProgressBarUpdater parent)
 {
     Parent = parent;
 }