private void toolStripDeleteEntry_Click(object sender, EventArgs e) { try { if (dataGridViewRegistry.SelectedCells.Count == 0) { return; } DataGridViewRow row = dataGridViewRegistry.Rows[dataGridViewRegistry.SelectedCells[0].RowIndex]; if (checkBoxDeleteQuestion.Checked) { string message = string.Format("Möchten Sie den Wert <{0}> löschen?", row.Cells[1].Value); DialogResult dr = MessageBox.Show(message, "Löschen bestätigen", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.No) { return; } } UtilsRegistryEntry entry = dataGridViewRegistry.Rows[dataGridViewRegistry.SelectedCells[0].RowIndex].Tag as UtilsRegistryEntry; entry.Delete(); dataGridViewRegistry.Rows.Remove(row); } catch (Exception exception) { ErrorForm errorForm = new ErrorForm(exception, ErrorCategory.NonCritical, _currentLanguageID); errorForm.ShowDialog(this); } }
private void toolStripEditEntryName_Click(object sender, EventArgs e) { try { if (dataGridViewRegistry.SelectedCells.Count == 0) { return; } DataGridViewRow row = dataGridViewRegistry.Rows[dataGridViewRegistry.SelectedCells[0].RowIndex]; UtilsRegistryEntry entry = row.Tag as UtilsRegistryEntry; ChangeNameDialog changeDialog = new ChangeNameDialog(entry.Name, _currentLanguageID); if (DialogResult.OK == changeDialog.ShowDialog(this)) { entry.Name = changeDialog.EntryNewName; row.Cells[1].Value = changeDialog.EntryNewName; } } catch (Exception exception) { ErrorForm errorForm = new ErrorForm(exception, ErrorCategory.NonCritical, _currentLanguageID); errorForm.ShowDialog(this); } }
private void contextMenuStripEntries_Opening(object sender, CancelEventArgs e) { try { contextMenuStripEntries.Enabled = (null != treeViewRegistry.SelectedNode); if (dataGridViewRegistry.SelectedCells.Count > 0) { DataGridViewRow row = dataGridViewRegistry.Rows[dataGridViewRegistry.SelectedCells[0].RowIndex]; UtilsRegistryEntry entry = row.Tag as UtilsRegistryEntry; if (entry == null) { return; } if (entry.Type == UtilsRegistryEntryType.Normal) { toolStripDeleteEntry.Enabled = true; toolStripEditEntryName.Enabled = true; } else { toolStripDeleteEntry.Enabled = false; toolStripEditEntryName.Enabled = false; } } } catch (Exception exception) { ErrorForm errorForm = new ErrorForm(exception, ErrorCategory.NonCritical, _currentLanguageID); errorForm.ShowDialog(this); } }
private void toolStripEditEntryValue_Click(object sender, EventArgs e) { try { if (dataGridViewRegistry.SelectedCells.Count == 0) { return; } DataGridViewRow row = dataGridViewRegistry.Rows[dataGridViewRegistry.SelectedCells[0].RowIndex]; UtilsRegistryEntry entry = row.Tag as UtilsRegistryEntry; switch (entry.ValueKind) { case RegistryValueKind.ExpandString: case RegistryValueKind.MultiString: case RegistryValueKind.String: case RegistryValueKind.Unknown: ChangeStringDialog stringDialog = new ChangeStringDialog(entry.Name, entry.Value as string, _currentLanguageID); if (DialogResult.OK == stringDialog.ShowDialog(this)) { entry.Value = stringDialog.EntryValue; row.Cells[3].Value = stringDialog.EntryValue; } break; case RegistryValueKind.Binary: ChangeBinaryDialog binaryDialog = new ChangeBinaryDialog(entry.Name, (entry.Value as byte[]), _currentLanguageID); if (DialogResult.OK == binaryDialog.ShowDialog(this)) { entry.Value = binaryDialog.Bytes; row.Cells[3].Value = entry.GetValue(); } break; case RegistryValueKind.DWord: case RegistryValueKind.QWord: ChangeDWordDialog dwordDialog = new ChangeDWordDialog(entry.Name, entry.Value, _currentLanguageID); if (DialogResult.OK == dwordDialog.ShowDialog(this)) { entry.Value = dwordDialog.EntryValue; row.Cells[3].Value = entry.GetValue(); } break; default: throw new ArgumentException(entry.ValueKind.ToString() + " is out of range."); } } catch (Exception exception) { ErrorForm errorForm = new ErrorForm(exception, ErrorCategory.NonCritical, _currentLanguageID); errorForm.ShowDialog(this); } }
private void toolStripCreateDWORDEntry_Click(object sender, EventArgs e) { try { string fullPath = GetFullNodePath(treeViewRegistry.SelectedNode); UtilsRegistryKey key = new UtilsRegistryKey(GetRegistry(treeViewRegistry.SelectedNode), fullPath); UtilsRegistryEntry entry = key.Keys.Add(RegistryValueKind.DWord, 0); dataGridViewRegistry.Rows.Add(); DataGridViewRow row = dataGridViewRegistry.Rows[dataGridViewRegistry.Rows.Count - 1]; Image typeImage = GetValueKindImage(entry.ValueKind); row.Cells[0].Value = typeImage; row.Cells[1].Value = entry.Name; row.Cells[2].Value = entry.ValueKind.ToString(); row.Cells[3].Value = entry.GetValue(); row.Tag = entry; } catch (Exception exception) { ErrorForm errorForm = new ErrorForm(exception, ErrorCategory.NonCritical, _currentLanguageID); errorForm.ShowDialog(this); } }
private void treeViewRegistry_AfterSelect(object sender, TreeViewEventArgs e) { try { TreeNode rootNode = GetRootNode(e.Node); UtilsRegistry regRoot = rootNode.Tag as UtilsRegistry; if ((regRoot.HiveKey == Registry.LocalMachine) && (!_userIsAdmin)) { treeViewRegistry.ContextMenuStrip = contextMenuStripNoAdmin; } else { treeViewRegistry.ContextMenuStrip = contextMenuStripKeys; } toolStripKeyEdit.Enabled = (treeViewRegistry.SelectedNode != null) && (treeViewRegistry.SelectedNode.Parent != null); toolStripKeyDelete.Enabled = (treeViewRegistry.SelectedNode != null) && (treeViewRegistry.SelectedNode.Parent != null); dataGridViewRegistry.Rows.Clear(); if (null == e.Node.Tag) { labelCurrentPath.Text = e.Node.Text; return; } string fullNodePath = GetFullNodePath(treeViewRegistry.SelectedNode); UtilsRegistryKey key = new UtilsRegistryKey(GetRegistry(e.Node), fullNodePath); bool foundDefault = false; foreach (UtilsRegistryEntry item in key.Entries) { if (item.Type == UtilsRegistryEntryType.Default) { foundDefault = true; } string name = item.Name; string valueType = item.ValueKind.ToString(); object value = item.GetValue(); Image typeImage = GetValueKindImage(item.ValueKind); dataGridViewRegistry.Rows.Add(typeImage, name, valueType, value); DataGridViewRow newRow = dataGridViewRegistry.Rows[dataGridViewRegistry.Rows.Count - 1]; newRow.Tag = item; } if (!foundDefault) { UtilsRegistryEntry fakedKey = key.Entries.FakedDefaultKey; string name = fakedKey.Name; string valueType = fakedKey.ValueKind.ToString(); object value = fakedKey.GetValue(); Image typeImage = GetValueKindImage(fakedKey.ValueKind); dataGridViewRegistry.Rows.Insert(0, typeImage, name, valueType, value); DataGridViewRow newRow = dataGridViewRegistry.Rows[0]; newRow.Tag = fakedKey; } labelCurrentPath.Text = key.Path; } catch (Exception exception) { ErrorForm errorForm = new ErrorForm(exception, ErrorCategory.NonCritical, _currentLanguageID); errorForm.ShowDialog(this); } }