public Form1() { InitializeComponent(); //we need this for our custom listbox, cause the basic one don't support mutlilines SearchListBox.DrawMode = DrawMode.OwnerDrawVariable; //load up our list of stop words, you can add or remove words from the list //look for stopwords.txt in the same directory as the executable stopwords = readStopWords(path_to_stopwords); //if our DB exist we will load it into the program if (File.Exists(root_path_to_xml_DB)) { loadXMLdb(root_path_to_xml_DB); index_table = new IndexTable(); } //else we will give message about empty DB and ask to supply docs else { MessageBox.Show("Empty Database", "Empty Database", MessageBoxButtons.OK, MessageBoxIcon.Information); addFilesToPostFileWithIndexAndPaths(); index_table = new IndexTable(selected_paths_dictinary, stopwords); } //deleteFileFromPostFileWithIndexAndPaths(@"C:\Users\AlexGruber\Desktop\WpfApplication3\WpfApplication3\bin\Debug\Data\Test2.txt"); this.KeyPreview = true; this.KeyDown += new KeyEventHandler(Form1_KeyDown); }
public DeleteFile(Dictionary<int, string> selected_paths_dictinary, IndexTable index_table) { InitializeComponent(); index_table_DeleteFile = index_table; DeleteFilelistBox.DataSource = new BindingSource(selected_paths_dictinary, null); DeleteFilelistBox.DisplayMember = "Value"; DeleteFilelistBox.ValueMember = "Key"; }
//function fires up only when adding new files/file to the DB private void addNewFileToPostFileWithIndexAndPaths(IndexTable index_table) { open_file_dialog.Multiselect = true; open_file_dialog.DefaultExt = ".txt"; open_file_dialog.Filter = "TXT Files (*.txt)|*.txt"; open_file_dialog.ShowDialog(); var newpaths = (from newpath in open_file_dialog.FileNames.ToList() let found = selected_paths_dictinary.Any(existpath => existpath.Value == Path.Combine(root_path_to_localDbFolder , Path.GetFileName(newpath))) where !found select newpath).ToList(); if (newpaths.Count > 0) copyFilesToLocalDbStorage(newpaths.ToArray(), root_path_to_localDbFolder); int start_key_for_index = selected_paths_dictinary.Keys.Last(); foreach (string path in newpaths) { int last_key = selected_paths_dictinary.Keys.Last(); selected_paths_dictinary.Add(++last_key, Path.Combine(root_path_to_localDbFolder, Path.GetFileName(path))); } createLocalPostFileWithIndexAndPaths(root_path_to_paging_file); index_table.updateWithNewDoc(selected_paths_dictinary,stopwords, start_key_for_index); MessageBox.Show("Complete"); }