private void dataGridViewRegistry_SelectionChanged(object sender, EventArgs e) { try { if (null != treeViewRegistry.SelectedNode) { TreeNode rootNode = GetRootNode(treeViewRegistry.SelectedNode); UtilsRegistry regRoot = rootNode.Tag as UtilsRegistry; if ((regRoot.HiveKey == Registry.LocalMachine) && (!_userIsAdmin)) { dataGridViewRegistry.ContextMenuStrip = contextMenuStripNoAdmin; } else { dataGridViewRegistry.ContextMenuStrip = contextMenuStripEntries; } } toolStripDeleteEntry.Enabled = (dataGridViewRegistry.SelectedCells.Count > 0); toolStripEditEntryName.Enabled = (dataGridViewRegistry.SelectedCells.Count > 0); toolStripEditEntryValue.Enabled = (dataGridViewRegistry.SelectedCells.Count > 0); } catch (Exception exception) { ErrorForm errorForm = new ErrorForm(exception, ErrorCategory.NonCritical, _currentLanguageID); errorForm.ShowDialog(this); } }
private void dataGridViewRegistry_KeyDown(object sender, KeyEventArgs e) { try { TreeNode rootNode = GetRootNode(treeViewRegistry.SelectedNode); UtilsRegistry regRoot = rootNode.Tag as UtilsRegistry; if ((regRoot.HiveKey == Registry.LocalMachine) && (!_userIsAdmin)) { return; } switch (e.KeyCode) { case Keys.Return: toolStripEditEntryValue_Click(this, new EventArgs()); break; case Keys.Delete: toolStripDeleteEntry_Click(this, new EventArgs()); break; default: break; } } catch (Exception exception) { ErrorForm errorForm = new ErrorForm(exception, ErrorCategory.NonCritical, _currentLanguageID); errorForm.ShowDialog(this); } }
public RegistryEditorControl() { try { InitializeComponent(); if (!DesignMode) { _localMachine32 = new UtilsRegistry(Registry.LocalMachine, @"Software\Microsoft\Office"); _currentUser32 = new UtilsRegistry(Registry.CurrentUser, @"Software\Microsoft\Office"); if (Is64Bit) { _localMachine64 = new UtilsRegistry(Registry.LocalMachine, @"Software\Wow6432Node\Microsoft\Office"); _currentUser64 = new UtilsRegistry(Registry.CurrentUser, @"Software\Wow6432Node\Microsoft\Office"); } _userIsAdmin = IsAdministrator(); pictureBoxNoAdminHint.Visible = !_userIsAdmin; labelNoAdminHint.Visible = !_userIsAdmin; labelNoAdminHintIcon.Visible = !_userIsAdmin; } } catch (Exception exception) { ErrorForm errorForm = new ErrorForm(exception, ErrorCategory.NonCritical, _currentLanguageID); errorForm.ShowDialog(this); } }
private void toolStripKeyDelete_Click(object sender, EventArgs e) { try { if (0 == treeViewRegistry.SelectedNodes.Count) { return; } string[] fullPathSelectedNodes = GetNodePaths(treeViewRegistry.SelectedNodes); TreeNode parentNode = null; if ((null != treeViewRegistry.SelectedNode.PrevNode) && (treeViewRegistry.SelectedNodes.Count == 1)) { parentNode = treeViewRegistry.SelectedNode.PrevNode; } else { parentNode = treeViewRegistry.SelectedNode.Parent; } if (checkBoxDeleteQuestion.Checked) { string nodeNames = GetNodeNames(treeViewRegistry.SelectedNodes); string message = string.Format("Möchten Sie den Schlüssel löschen?{1}{1}{0}", nodeNames, Environment.NewLine); DialogResult dr = MessageBox.Show(message, "Löschen bestätigen", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.No) { return; } } UtilsRegistry registryRoot = GetRegistry(treeViewRegistry.SelectedNode); foreach (string fullPath in fullPathSelectedNodes) { UtilsRegistryKey key = new UtilsRegistryKey(registryRoot, fullPath); key.Delete(); } treeViewRegistry.SelectedNode = parentNode; buttonRefresh_Click(this, new EventArgs()); } catch (Exception exception) { ErrorForm errorForm = new ErrorForm(exception, ErrorCategory.NonCritical, _currentLanguageID); errorForm.ShowDialog(this); } }
private void dataGridViewRegistry_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { TreeNode rootNode = GetRootNode(treeViewRegistry.SelectedNode); UtilsRegistry regRoot = rootNode.Tag as UtilsRegistry; if ((regRoot.HiveKey == Registry.LocalMachine) && (!_userIsAdmin)) { return; } toolStripEditEntryValue_Click(this, new EventArgs()); } catch (Exception exception) { ErrorForm errorForm = new ErrorForm(exception, ErrorCategory.NonCritical, _currentLanguageID); errorForm.ShowDialog(this); } }
private string GetFullNodePath(TreeNode node) { TreeNode rootNode = node; while (rootNode.Parent != null) { rootNode = rootNode.Parent; } UtilsRegistry registry = rootNode.Tag as UtilsRegistry; string path = registry.Key.Path; int position = node.FullPath.IndexOf("\\", StringComparison.InvariantCultureIgnoreCase); if (position > -1) { path += node.FullPath.Substring(position); } return(path); }
public void SetDocumentState(string filename, DocumentState state) { UtilsRegistry .OpenUserSoftwareKey(Globals.RegKeyDocumentStates) .SaveRegistryJson <DocumentState>(filename, state); }
public DocumentState GetDocumentState(string filename) { return(UtilsRegistry .OpenUserSoftwareKey(Globals.RegKeyDocumentStates) .LoadRegistryJson <DocumentState>(filename)); }
public static void ConfigureContainer(IServiceCollection services) { UtilsRegistry.Load(services); }
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); } }