示例#1
0
        private void ScanFile(CASCFile file)
        {
            if (scanBackgroundWorker.CancellationPending)
            {
                throw new OperationCanceledException();
            }

            NumScanned++;

            var fileNames = scanner.ScanFile(file);

            if (fileNames.Any())
            {
                // only report progress when not skipping a file, it's faster that way
                int progress            = (int)(NumScanned / (float)NumFiles * 100);
                ScanProgressState state = new ScanProgressState();
                state.NumFilesScanned = NumScanned;
                state.NumFilesTotal   = NumFiles;
                state.CurrentFileName = file.FullName;
                scanBackgroundWorker.ReportProgress(progress, state);

                foreach (var fileName in fileNames)
                {
                    ulong hash = Hasher.ComputeHash(fileName);

                    if ((CASC.Root as WowRootHandler).IsUnknownFile(hash))
                    {
                        BeginInvoke((MethodInvoker)(() => UpdateFileNames(fileName, file.FullName)));
                    }
                }
            }
        }
示例#2
0
 private void scanBackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     scanProgressBar.Value = e.ProgressPercentage;
     if (e.UserState is ScanProgressState)
     {
         ScanProgressState state = (ScanProgressState)e.UserState;
         scanLabel.Text     = "Scanning '" + state.CurrentFileName + "' ...";
         progressLabel.Text = state.NumFilesScanned + "/" + state.NumFilesTotal;
     }
 }
 /// <summary>Constructs the <see cref="ScanEventArgs"/> without an exception.</summary>
 public ScanEventArgs(ScanState state, ScanProgressState progress)
 {
     ScanState     = state;
     ProgressState = progress;
     Exception     = null;
 }
 /// <summary>Constructs the <see cref="ScanEventArgs"/> with an exception.</summary>
 public ScanEventArgs(ScanState state, ScanProgressState progress, Exception exception)
 {
     ScanState     = state;
     ProgressState = progress;
     Exception     = exception;
 }
示例#5
0
文件: ScanForm.cs 项目: aeo24/WoWMap
        private void ScanFile(CASCFile file)
        {
            if (scanBackgroundWorker.CancellationPending)
                throw new OperationCanceledException();

            NumScanned++;

            var fileNames = scanner.ScanFile(file);

            if (fileNames.Any())
            {
                // only report progress when not skipping a file, it's faster that way
                int progress = (int)(NumScanned / (float)NumFiles * 100);
                ScanProgressState state = new ScanProgressState();
                state.NumFilesScanned = NumScanned;
                state.NumFilesTotal = NumFiles;
                state.CurrentFileName = file.FullName;
                scanBackgroundWorker.ReportProgress(progress, state);

                foreach (var fileName in fileNames)
                {
                    ulong hash = Hasher.ComputeHash(fileName);

                    if ((CASC.Root as WowRootHandler).IsUnknownFile(hash))
                    {
                        BeginInvoke((MethodInvoker)(() => UpdateFileNames(fileName, file.FullName)));
                    }
                }
            }
        }