Exemplo n.º 1
0
 private void ComputeHashCore(string[] paths, DataGridViewRow[] rows, int iHashType)
 {
     for (int i = 0; i < paths.Length; i++)
     {
         try {
             byte[] buffer;
             DataGridViewProgressBarCell cell = (DataGridViewProgressBarCell)rows[i].Cells[2];
             using (FileHashStream stream = new FileHashStream(paths[i], ReportCallbackAsync, cell)) {
                 using (HashAlgorithm algorithm = CreateHashAlgorithm(iHashType)) {
                     buffer = algorithm.ComputeHash(stream);
                 }
                 if (stream.IsAborted)
                 {
                     cell.CalculatingStatus = HashCalcStatus.Aborted;
                     return;
                 }
             }
             StringBuilder builder = new StringBuilder(buffer.Length);
             for (int j = 0; j < buffer.Length; j++)
             {
                 builder.Append(buffer[j].ToString("X2"));
             }
             Invoke(new HashInvoker2(SetRowSync), new object[] { paths[i], builder.ToString(), rows[i] });
         }
         catch {
             Invoke(new HashInvoker2(SetRowSync), new object[] { paths[i], VALUE_ERROR, rows[i] });
         }
         if (fCancellationPending)
         {
             return;
         }
     }
 }
 public void FinishProgress(DataGridViewProgressBarCell cell) {
     if(cell.CalculatingStatus == HashCalcStatus.Calculating) {
         cell.CalculatingStatus = HashCalcStatus.Finished;
     }
     cell.EndProgress();
     lstCells.Remove(cell);
 }
Exemplo n.º 3
0
 public void FinishProgress(DataGridViewProgressBarCell cell)
 {
     if (cell.CalculatingStatus == HashCalcStatus.Calculating)
     {
         cell.CalculatingStatus = HashCalcStatus.Finished;
     }
     cell.EndProgress();
     lstCells.Remove(cell);
 }
Exemplo n.º 4
0
            public FileHashStream(string path, ReportProgressCallback callbackCancelAsync, DataGridViewProgressBarCell cell)
            {
                fs = new FileStream(path, FileMode.Open, FileAccess.Read);
                long length = fs.Length;

                fEnoughSize = length > 0x200000L;
                this.callbackCancelAsync = callbackCancelAsync;
                this.cell          = cell;
                this.cell.FileSize = length;
            }
 public void InitializeProgress(DataGridViewProgressBarCell cell) {
     if(cell.ColumnIndex != Index) {
         throw new ArgumentException("cell is not contained in this column.");
     }
     if(!lstCells.Contains(cell)) {
         cell.OldStyle = cell.Style.Clone();
         cell.Value = VALUE_WAITING;
         cell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
         cell.Style.ForeColor = cell.Style.SelectionForeColor = SystemColors.GrayText;
         cell.CalculatingStatus = HashCalcStatus.Calculating;
         lstCells.Add(cell);
     }
 }
Exemplo n.º 6
0
 private void SetRowSync(string path, string strHash, DataGridViewRow row)
 {
     if (dgvHash.IsHandleCreated)
     {
         DataGridViewProgressBarCell cell = (DataGridViewProgressBarCell)row.Cells[2];
         clmn3_Hash.FinishProgress(cell);
         if (cell.CalculatingStatus == HashCalcStatus.Finished)
         {
             row.Cells[2].Value           = strHash;
             row.Cells[2].ToolTipText     = strHash;
             row.Cells[0].Style.BackColor = clrNew;
             SetCellColorByHash(row, strHash);
         }
     }
 }
Exemplo n.º 7
0
 public void InitializeProgress(DataGridViewProgressBarCell cell)
 {
     if (cell.ColumnIndex != Index)
     {
         throw new ArgumentException("cell is not contained in this column.");
     }
     if (!lstCells.Contains(cell))
     {
         cell.OldStyle          = cell.Style.Clone();
         cell.Value             = VALUE_WAITING;
         cell.Style.Alignment   = DataGridViewContentAlignment.MiddleCenter;
         cell.Style.ForeColor   = cell.Style.SelectionForeColor = SystemColors.GrayText;
         cell.CalculatingStatus = HashCalcStatus.Calculating;
         lstCells.Add(cell);
     }
 }
Exemplo n.º 8
0
 private bool ReportCellProgress(DataGridViewProgressBarCell cell)
 {
     cell.Progress(1);
     return(false);
 }
Exemplo n.º 9
0
 private bool ReportCallbackAsync(DataGridViewProgressBarCell cell)
 {
     Invoke(new ReportProgressCallback(ReportCellProgress), new object[] { cell });
     return(fCancellationPending);
 }
Exemplo n.º 10
0
 public FileHashStream(string path, ReportProgressCallback callbackCancelAsync, DataGridViewProgressBarCell cell)
 {
     fs = new FileStream(path, FileMode.Open, FileAccess.Read);
     long length = fs.Length;
     fEnoughSize = length > 0x200000L;
     this.callbackCancelAsync = callbackCancelAsync;
     this.cell = cell;
     this.cell.FileSize = length;
 }
Exemplo n.º 11
0
 private bool ReportCellProgress(DataGridViewProgressBarCell cell)
 {
     cell.Progress(1);
     return false;
 }
Exemplo n.º 12
0
 private bool ReportCallbackAsync(DataGridViewProgressBarCell cell)
 {
     Invoke(new ReportProgressCallback(ReportCellProgress), new object[] { cell });
     return fCancellationPending;
 }