/// <summary> /// Handles the Click event of the buttonRebuildIndex control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void buttonRebuildIndex_Click(object sender, EventArgs e) { List <string> layerfileIndexSearchPaths = new List <string>(); if (layerfileIndexSearchPaths.Count.Equals(0)) { MessageBox.Show("There are no search paths specified in the Layer.Config", "Search Layer Files", MessageBoxButtons.OK); } else { Cursor.Current = Cursors.WaitCursor; List <string> paths = new List <string>(); foreach (string path in layerfileIndexSearchPaths) { paths.Add(path); } LayerfileIndexBuilder builder = new LayerfileIndexBuilder(); builder.Progress += new ProgressEventHandler(RebuildProgressHandler); builder.BuildNewIndex(paths); builder.Progress -= RebuildProgressHandler; Cursor.Current = Cursors.Default; } }
private void ApplyKeywordFilter() { if (!string.IsNullOrEmpty(comboBoxFilter.Text)) { string[] words = comboBoxFilter.Text.Split(' '); StringBuilder criteria = new StringBuilder(); int counter = 0; foreach (string word in words) { counter++; if (counter > 1) { criteria.Append(" OR "); } criteria.Append(" (lyrname LIKE '%" + word + "%' OR lyrdescription LIKE '%" + word + "%') "); Cursor.Current = Cursors.WaitCursor; DataTable table = new DataTable(); List <string> paths = new List <string>(); LayerfileIndexBuilder builder = new LayerfileIndexBuilder(); string indexPath = builder.GetDefaultIndexFilePath(); if (System.IO.File.Exists(indexPath)) { string connectionString = "Data Source=" + indexPath + ";Version=3;"; using (SQLiteConnection connection = new SQLiteConnection(connectionString)) { connection.Open(); string sql = "SELECT lyrname, lyrdescription,lyrfilename,lyrfullpath,lyrrevision,lyrgid,daterecmodified FROM layerfile " + "WHERE " + criteria.ToString(); System.Diagnostics.Debug.WriteLine(sql); using (SQLiteCommand command = new SQLiteCommand(sql, connection)) { using (SQLiteDataAdapter adapter = new SQLiteDataAdapter(command)) { adapter.Fill(table); dataGridView.DataSource = table; } } connection.Close(); } } Cursor.Current = Cursors.Default; } } }