Esempio n. 1
0
 public void ShowResults(Search s)
 {
     FileInfo f = null;
     for (int y = 0; y < s.ResultLst.Count; ++y) {
         f = new FileInfo(s.ResultLst[y].Filename);
         dg[0, y].Value = Fcn.FileName(s.ResultLst[y].Filename);
         dg[1, y].Value = Fcn.FileName(s.ResultLst[y].Results);
         dg[2, y].Value = s.ResultLst[y].Filename;
         dg[3, y].Value = Fcn.Extension(s.ResultLst[y].Filename);
         dg[4, y].Value = File.GetLastWriteTime(s.ResultLst[y].Filename);
         dg[5, y].Value = f.Length.ToString();
         if (s.ResultLst[y].Encoding != null)
             dg[6, y].Value = s.ResultLst[y].Encoding.EncodingName;
         else
             dg[6, y].Value = "<Desconhecida>";
         if (y < s.ResultLst.Count - 1) {
             SetControlPropertyValue(dg, "RowCount", dg.RowCount + 1);
         }
     }
     statusStrip.Items[0].Text = "Padrão presente em " + s.ResultLst.Count + " arquivo(s), de um total de " + s.FileLst.Count + " arquivos. Tempo decorrido ";
     if (s.ElapsedSpan.Seconds < 1)
         statusStrip.Items[0].Text += s.ElapsedSpan.Milliseconds + " milissegundos.";
     else
         if (s.ElapsedSpan.Minutes < 1)
             statusStrip.Items[0].Text += s.ElapsedSpan.Seconds + " segundo(s) e " + s.ElapsedSpan.Milliseconds + " milissegundos.";
         else
             statusStrip.Items[0].Text += (s.ElapsedSpan.Seconds / 60) + " minutos(s) e " + (s.ElapsedSpan.Seconds % 60) + " segundo(s).";
     SetControlPropertyValue(this, "Cursor", Cursors.Default);
     SetControlPropertyValue(dg, "Cursor", Cursors.Default);
     MessageBox.Show("Busca finalizada!");
     SetControlPropertyValue(btnDir, "Enabled", true);
     SetControlPropertyValue(BtnSearch, "Enabled", true);
 }
Esempio n. 2
0
 private void BtnSearch_Click(object sender, EventArgs e)
 {
     string pattern = txtTermo.Text;
     if (pattern == String.Empty || txtDir.Text == String.Empty) {
         MessageBox.Show("É necessário selecionar o diretório e termo procurado.", "Aviso");
         return;
     }
     if (!Directory.Exists(txtDir.Text)) {
         MessageBox.Show("Este é um diretório inválido.", "Aviso");
         return;
     }
     progressBar.Value = 0;
     lbProgress.Text = "Calculando...";
     statusStrip.Items[0].Text = "Buscando...";
     BtnSearch.Enabled = false;
     btnDir.Enabled = false;
     if (cbxSearchWholeWord.Checked)
         txtTermo.Text = Search.RemoveRegExSpecialChars(txtTermo.Text);
     string path = txtDir.Text;
     File.WriteAllText("Search.cfg", txtDir.Text);
     dg.RowCount = 1;
     for (int i = 0; i < dg.ColumnCount; ++i)
         dg[i, 0].Value = "";
     Cursor = Cursors.WaitCursor;
     dg.Cursor = Cursors.WaitCursor;
     s = new Search(pattern, path, cbxCaseSensitive.Checked, cbxSearchBinaryFiles.Checked, cbxSearchWholeWord.Checked,
        cbxUseRegularExpressions.Checked, cbxAlsoSearchInFilenames.Checked, cbxOnlySearchInFileNames.Checked, cbxDecodeHtml.Checked, this);
     trd = new Thread(new ThreadStart(s.StartSearch));
     trd.IsBackground = true;
     trd.Start();
 }