private void restoreToolStripMenuItem_Click(object sender, EventArgs e) { if (listBoxVV.SelectedIndex >= 0) { VVItem vvitem = (VVItem)listBoxVV.Items[listBoxVV.SelectedIndex]; DialogResult answer = MessageBox.Show($"Restore {vvitem.ItemName}?", _appName, MessageBoxButtons.YesNo); if (answer == DialogResult.No) { return; } ListView.SelectedListViewItemCollection files = listViewMain.SelectedItems; string sourceDir = $"{comboBoxFolder.Text}\\{treeViewMain.SelectedNode.FullPath}"; string sourceFile = $"{sourceDir}\\{files[0].Text}"; string vvDir = $"{(string)vvConfig.GetValue("VVPath")}\\{treeViewMain.SelectedNode.FullPath}\\{files[0].Text}"; string vvFile = $"{vvDir}\\{vvitem.ItemName}"; try { if (File.Exists(sourceFile)) { File.SetAttributes(sourceFile, FileAttributes.Normal); File.Delete(sourceFile); } File.Copy(vvFile, sourceFile); File.SetAttributes(sourceFile, FileAttributes.Normal); MessageBox.Show($"{vvitem.ItemName} copied to {files[0].Text}", _appName, MessageBoxButtons.OK); treeViewMainRefresh(); } catch (Exception ex) { MessageBox.Show($"Error copying files:\r\n\r\n{ex.Message}", _appName, MessageBoxButtons.OK); return; } } }
private void listViewMain_SelectedIndexChanged(object sender, EventArgs e) { if (selectedListViewIndex >= 0 && selectedListViewIndex < listViewMain.Items.Count) { listViewMain.Items[selectedListViewIndex].BackColor = SystemColors.Window; listViewMain.Items[selectedListViewIndex].ForeColor = SystemColors.WindowText; } selectedListViewIndex = -1; listBoxVVClear(); ListView.SelectedListViewItemCollection files = listViewMain.SelectedItems; if (files.Count == 0) { return; } if (vvConfig != null && vvConfig.Contains("VVPath")) { string vvDir = $"{(string)vvConfig.GetValue("VVPath")}\\{treeViewMain.SelectedNode.FullPath}\\{files[0].Text}"; if (Directory.Exists(vvDir)) { foreach (string filename in Directory.GetFiles(vvDir)) { string baseFilename = filename.Substring(filename.LastIndexOf("\\") + 1); if (baseFilename.Length == 32 && !baseFilename.Contains("_")) { continue; } VVItem item = new VVItem(PathBase(filename)); listBoxVV.Items.Add(item); } } } }