public void ChangeValueFromList(string keyPath, RegValueData value) { TreeNode key = GetTreeNode(keyPath); if (key != null) { lstRegistryKeys.Invoke((MethodInvoker) delegate { //Can only change if the value exists in the tag if (key.Tag != null && key.Tag.GetType() == typeof(List <RegValueData>)) { List <RegValueData> ValuesFromNode = (List <RegValueData>)key.Tag; var regValue = ValuesFromNode.Find(item => item.Name == value.Name); regValue.Data = value.Data; if (tvRegistryDirectory.SelectedNode == key) { //Make sure if it is a default value string name = String.IsNullOrEmpty(value.Name) ? DEFAULT_REG_VALUE : value.Name; var index = lstRegistryKeys.Items.IndexOfKey(name); if (index != -1) { RegistryValueLstItem valueItem = (RegistryValueLstItem)lstRegistryKeys.Items[index]; valueItem.Data = value.GetDataAsString(); } } else { tvRegistryDirectory.SelectedNode = key; } } }); } }
public void AddValueToList(string keyPath, RegValueData value) { TreeNode key = GetTreeNode(keyPath); if (key != null) { lstRegistryKeys.Invoke((MethodInvoker) delegate { List <RegValueData> ValuesFromNode = null; if (key.Tag != null && key.Tag.GetType() == typeof(List <RegValueData>)) { ValuesFromNode = (List <RegValueData>)key.Tag; ValuesFromNode.Add(value); } else { //The tag has a incorrect element or is missing data ValuesFromNode = new List <RegValueData>(); ValuesFromNode.Add(value); key.Tag = ValuesFromNode; } //Deactivate sorting lstRegistryKeys.Sorting = SortOrder.None; if (tvRegistryDirectory.SelectedNode == key) { RegistryValueLstItem item = new RegistryValueLstItem(value.Name, value.GetKindAsString(), value.GetDataAsString()); //unselect all lstRegistryKeys.SelectedIndices.Clear(); lstRegistryKeys.Items.Add(item); item.Selected = true; lstRegistryKeys.LabelEdit = true; item.BeginEdit(); } else { tvRegistryDirectory.SelectedNode = key; } }); } }