Beispiel #1
0
 private void SearchButn_Click(object sender, EventArgs e)
 {
     RichtxtResult.Clear();
     if (Searchtxtx.Text != "")
     {
         string    input = Utility.RemoveAarab(Searchtxtx.Text.Trim().Replace("لا", "ال"));
         Stopwatch sw    = new Stopwatch();
         sw.Start();
         dfiForSearch = LuceneBussines.SearchIndex(input);
         sw.Stop();
         GridResult.DataSource          = dfiForSearch.ToList();
         Resultlbl.Text                 = dfiForSearch.Count().ToString();
         SearchTimelbl.Text             = sw.Elapsed.TotalSeconds.ToString();
         label5.Visible                 = true;
         label4.Visible                 = true;
         GridResult.Visible             = true;
         GridResult.Columns[0].Visible  = false;
         GridResult.Columns[1].Visible  = false;
         GridResult.Columns[8].Visible  = false;
         GridResult.Columns[9].Visible  = false;
         GridResult.Columns[12].Visible = false;
         GridResult.Columns[13].Visible = false;
         GridResult.Columns[14].Visible = false;
         ShowFilebtn.Visible            = true;
         RichtxtResult.Visible          = true;
     }
     else
     {
         MessageBox.Show("یک مقدار را برای جستجو وارد کنید");
     }
 }
Beispiel #2
0
 private void GridResult_MouseClick(object sender, MouseEventArgs e)
 {
     if (GridResult.Rows != null && GridResult.Rows.Count > 0)
     {
         //var searchvalue = Searchtxtx.Text.Trim().Replace("لا","ال");
         var  searchvalue     = GridResult.CurrentRow.Cells[4].Value.ToString();
         var  searchvaluelist = searchvalue.Split(new[] { " + " }, StringSplitOptions.None);
         bool flag            = false;
         RichtxtResult.Clear();
         var finddfi =
             dfiForSearch.FirstOrDefault(
                 x => x.ID == Convert.ToInt32(GridResult.CurrentRow.Cells[0].Value.ToString()));
         foreach (var item in finddfi.ResultText.Split('#'))
         {
             var hasval = ShowResultinRichtxt(finddfi, item, searchvalue);
             if (!hasval && searchvaluelist.Any())
             {
                 for (int j = 0; j < searchvaluelist.Count(); j++)
                 {
                     if (!ShowResultinRichtxt(finddfi, item, searchvaluelist[j]))
                     {
                         try
                         {
                             int s = j + 1;
                             hasval = ShowResultinRichtxt(finddfi, item,
                                                          searchvaluelist[j] + searchvaluelist[s]);
                             if (hasval)
                             {
                                 flag = true;
                             }
                         }
                         catch
                         {
                         }
                     }
                     else
                     {
                         flag = true;
                     }
                 }
             }
             else
             {
                 flag = true;
             }
         }
         if (!flag)
         {
             RichtxtResult.Text = "Sorry Can't Load Text." + Environment.NewLine + GridResult.CurrentRow.Cells[3].Value.ToString();
         }
     }
 }
Beispiel #3
0
        private bool ShowResultinRichtxt(DataForIndex finddfi, string item, string searchvalue)
        {
            int index = item.IndexOf(searchvalue, StringComparison.Ordinal);

            if (index != -1)
            {
                if (finddfi.IsFarsiArabic == true)
                {
                    string term = searchvalue;
                    if (!finddfi.HarfArabic.Contains("#"))
                    {
                        term  = term.Replace(finddfi.HarfArabic, finddfi.HarfFarsi);
                        index = item.IndexOf(term);
                    }
                }
                if (index >= 0)
                {
                    RichtxtResult.AppendText(item.Substring(0, index));
                    RichtxtResult.SelectionBackColor = Color.Yellow;
                    Font fonttext = RichtxtResult.SelectionFont;
                    RichtxtResult.SelectionFont = new Font("Tahoma", 12, FontStyle.Bold);
                    RichtxtResult.AppendText(item.Substring(index, searchvalue.Length));
                    RichtxtResult.SelectionBackColor = Color.White;
                    RichtxtResult.SelectionFont      = new Font(fonttext, FontStyle.Regular);
                    RichtxtResult.AppendText(
                        item.Substring(index + searchvalue.Length, item.Length - (index + searchvalue.Length)) +
                        Environment.NewLine + "//////////////////" + Environment.NewLine);
                    return(true);
                }
            }
            else
            {
                return(false);
            }
            return(false);
        }