private void optionsButton_Click(object sender, EventArgs e) { OptionsDlg dlg = new OptionsDlg(this); dlg.InitDlg(m_options); if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { m_options.SaveOptions(m_optionsPath); Reload(); } }
public void Run(OptionsDlg dlg, ListView list, string inputPath, string pattern) { Dictionary <string, ListViewItem> oldItems = new Dictionary <string, ListViewItem>(); foreach (ListViewItem item in list.Items) { oldItems[item.Text] = item; } list.SuspendLayout(); bool gotOne = false; if (Directory.Exists(inputPath)) { foreach (string path in Directory.GetFiles(inputPath, pattern)) { string itemName = GetItemName(path); gotOne = true; ListViewItem oldItem; string key = itemName.ToLowerInvariant(); if (oldItems.TryGetValue(key, out oldItem)) { oldItems.Remove(key); } else { ListViewItem newItem = new ListViewItem(itemName); list.Items.Add(newItem); newItem.SubItems.Add(""); dlg.SetLastSubItemName(newItem, "Edit"); } } } AdjustDeleteList(oldItems); foreach (ListViewItem item in oldItems.Values) { list.Items.Remove(item); } list.ResumeLayout(); if (!gotOne) { MessageBox.Show(dlg, "Did not find any files in " + inputPath, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }