private void listBox_timkiem_DoubleClick(object sender, EventArgs e) { ListBox list = sender as ListBox; if (list.SelectedItem != null) { XTxt.WriteFirstLine(XPath.pathfile_history_file, list.SelectedItem.ToString()); string path = list.SelectedItem.ToString(); bool IsExists = false; if (System.IO.File.GetAttributes(path).HasFlag(FileAttributes.Directory)) { IsExists = System.IO.Directory.Exists(path); } else { IsExists = System.IO.File.Exists(path); } if (IsExists) { fDetail f = new fDetail(path); f.Show(); } else { MessageBox.Show("File không tồn tại"); } } }
private void listBox_timkiem_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index >= 0) { ListBox listBox = sender as ListBox; string path = listBox.Items[e.Index] as string; if (rd_TXT.Checked) { string lineresult = XTxt.GetLineHaveKeyWord(path, keyword); XTextInfo fileInfo = new XTextInfo(path, lineresult); // Draw the background. e.DrawBackground(); fileInfo.DrawItem(e.Graphics, e.Bounds, this.Font, false); } else if (rd_word.Checked) { XInfo fileInfo = new XInfo(path); // Draw the background. e.DrawBackground(); fileInfo.DrawItem(e.Graphics, e.Bounds, this.Font, false); } } }
bool search(string root, string keyword) { if (rd_TXT.Checked) { return(XTxt.Search(root, keyword)); } else { return(XWord.SearchInWord(root, keyword)); } }
private void listBox_timkiem_DoubleClick(object sender, EventArgs e) { ListBox list = sender as ListBox; Loaifile a = rd_word.Checked ? Loaifile.Word : Loaifile.Txt; if (list.SelectedItem != null) { XTxt.WriteFirstLine(XPath.pathfile_history_file, list.SelectedItem.ToString()); fOpenText f = new fOpenText(list.SelectedItem.ToString(), keyword, a); f.Show(); } }
public fOpenText(string path, Loaifile loai) { InitializeComponent(); this.path = path; if (loai == Loaifile.Txt) { richTextBox1.Text = XTxt.ReadText(path); } else if (loai == Loaifile.Word) { richTextBox1.Rtf = XWord.ReadWord(path); } }
void loadLichsuTen() { string[] result = XTxt.ReadLineText(XPath.pathfile_history_name).ToArray(); if (result.Count() == 0) { listBox_tu.Items.Add("Không có từ tìm kiếm gần đây"); } else { foreach (string item in result) { listBox_tu.Items.Add(item); } } }
void loadLichsuFile() { string[] result = XTxt.ReadLineText(XPath.pathfile_history_file).ToArray(); if (result.Count() == 0) { listBox_file.DrawMode = DrawMode.Normal; listBox_file.Items.Add("Không có file mở gần đây"); } else { foreach (string item in result) { XInfo temp = new XInfo(item); listBox_file.Items.Add(temp); } } }
public fOpenText(string path, string tuboiden, Loaifile loai) { InitializeComponent(); this.path = path; if (loai == Loaifile.Txt) { richTextBox1.Text = XTxt.ReadText(path); } else if (loai == Loaifile.Word) { richTextBox1.Rtf = XWord.ReadWord(path); } //boi dam tu tim kiem this.Boldstring = tuboiden; textBox1.Text = Boldstring; boiden(); }
private void button2_Click(object sender, EventArgs e) { ts = new Thread(Runsearch); if (backgroundWorker1.IsBusy) { ts.Abort(); backgroundWorker1.CancelAsync(); } else { progressBar1.Value = progressBar1.Minimum; btnSearch.Text = "Stop"; XTxt.WriteFirstLine(XPath.pathfile_history_name, keyword); listBox_timkiem.Items.Clear(); lblProgress.Text = "Đang tìm kiếm file"; ts.IsBackground = true; ts.Start(); backgroundWorker1.RunWorkerAsync(); } }
private void openFileToolStripMenuItem_Click(object sender, EventArgs e) { open = new OpenFileDialog(); open.Title = "Chọn file text đuôi .txt"; open.Filter = "All Files|*.*"; if (open.ShowDialog() == DialogResult.OK) { try { if (open.FileName.Contains(".doc") || open.FileName.Contains(".docx")) { richTextBox1.Rtf = XWord.ReadWord(open.FileName); } else { richTextBox1.Text = XTxt.ReadText(open.FileName); } } catch (Exception ex) { MessageBox.Show("Đã xảy ra lỗi" + ex.Message); } } }