public AddinsKey Add(string name, RegistryKey rootPath, string registryPath) { AddinsKey newItem = new AddinsKey(_parent, name, rootPath, registryPath); _items.Add(newItem); _parent.StopFlag = false; return newItem; }
private void CreateRegistryValue(AddinsKey item) { RegistryKey key = item.RootKey.OpenSubKey(item.RegistryPath, true); //key.SetValue(item.SpecificValueName, item.SpecificValueMustHave, item.SpecificValueKindMustHave); key.Close(); }
internal void RaisePropertyChanged(AddinsKey item) { if (null != PropertyChanged) { PropertyChanged(item, new PropertyChangedEventArgs("")); } }
private void DeleteRegistryValue(AddinsKey item) { RegistryKey key = item.RootKey.OpenSubKey(item.RegistryPath, true); //key.DeleteValue(item.SpecificValueName); key.Close(); }
public AddinsKey Add(string name, RegistryKey rootPath, string registryPath) { AddinsKey newItem = new AddinsKey(_parent, name, rootPath, registryPath); _items.Add(newItem); _parent.StopFlag = false; return(newItem); }
internal AddinKey(WatchController root, AddinsKey item, string registryPath, string subKeyName) { _root = root; _parent = item; _registryPath = registryPath; _subKeyName = subKeyName; GetKeyValueCount(); GetValueInfos(); }
internal AddinKey(WatchController root, AddinsKey item, string registryPath, string subKeyName) { _root = root; _parent = item; _registryPath = registryPath; _subKeyName = subKeyName; GetKeyValueCount(); GetValueInfos(); }
public void ShowNotification(AddinsKey item, NotifyKind notfiyKind, RegistryChangeInfo changeInfo) { if (_parent.FirstRun) { return; } string message = GetMessage(notfiyKind); switch (notfiyKind) { case NotifyKind.AddinSubKeysIncrement: AddinSubkeysIncrementInfo newInfo = (AddinSubkeysIncrementInfo)changeInfo; message = String.Format(message, newInfo.RootKey, newInfo.KeyPath, newInfo.KeyName, Environment.NewLine); break; case NotifyKind.AddinSubKeysDecrement: AddinSubkeysDecrementInfo deleteInfo = (AddinSubkeysDecrementInfo)changeInfo; message = String.Format(message, deleteInfo.RootKey, deleteInfo.KeyPath, deleteInfo.KeyName, Environment.NewLine); break; case NotifyKind.AddinSubKeyNameChanged: AddinSubkeyNameChangedInfo nameInfo = (AddinSubkeyNameChangedInfo)changeInfo; message = String.Format(message, nameInfo.RootKey, nameInfo.KeyPath, nameInfo.OldKeyName, nameInfo.NewKeyName, Environment.NewLine); break; default: throw new ArgumentOutOfRangeException(notfiyKind.ToString() + " is not valid in this context"); } if (_parent.NotifyType == NotificationType.MessageBox) { MessageBox.Show(message, "NetOffice.DeveloperToolbox", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { _trayIcon.ShowBalloonTip(2000, message, "NetOffice.DeveloperToolbox " + notfiyKind.ToString(), ToolTipIcon.Info); } if (null != MessageFired) { MessageFired(message, new EventArgs()); } }
void _controller_PropertyChanged(object sender, PropertyChangedEventArgs e) { try { _addinsItemToDisplay = sender as AddinsKey; _disabledItemToDisplay = sender as DisabledKey; _displayedException = sender as Exception; if (null != _addinsItemToDisplay) { this.Invoke(new MethodInvoker(_controller_AddinsKeyChangedInvoke)); } else if (null != _disabledItemToDisplay) { this.Invoke(new MethodInvoker(_controller_DisabledKeyChangedInvoke)); } else if (sender is WatchController) { this.Invoke(new MethodInvoker(_controller_PropertyChangedInvoke)); } else if (sender is Exception) { this.Invoke(new MethodInvoker(WatchNotify_ExceptionThrownInvoke)); } /* * if (null != _addinsItemToDisplay) * { * if (_addinsItemToDisplay.Name == "Outlook") * { * stopFlag = true; * _controller.Enabled = false; * } * } * */ } catch (Exception exception) { ErrorForm errorForm = new ErrorForm(exception, ErrorCategory.NonCritical, _currentLanguageID); errorForm.ShowDialog(this); } }
private void UpdateSubKeys(TreeNode node) { AddinsKey item = node.Tag as AddinsKey; if (null != item) { RegistryKey key = item.RootKey.OpenSubKey(item.RegistryPath); if (null != key) { node.Nodes.Clear(); string[] subKeyNames = key.GetSubKeyNames(); foreach (string subKeyName in subKeyNames) { TreeNode subNode = node.Nodes.Add(subKeyName); subNode.ForeColor = Color.Gray; } key.Close(); } } }
private void CreateRegistryKey(AddinsKey item) { RegistryKey key = item.RootKey.CreateSubKey(item.RegistryPath); key.Close(); }
internal NotifyKind CheckChangedValues(ref RegistryChangeInfo changeInfos) { try { bool openModeWrite = true; if ((_parent.RootKey == Registry.LocalMachine) && (_root.ReadOnlyModeForMachineKeys)) { openModeWrite = false; } RegistryKey key = _parent.RootKey.OpenSubKey(_registryPath, openModeWrite); if (null != key) { string[] valueNames = key.GetValueNames(); int valueCount = key.ValueCount; if (valueCount != _valueCount) { _root.RaisePropertyChanged(Parent); NotifyKind returnKind; if (valueCount > _valueCount) { AddinValuesIncrementInfo incrementInfo = new AddinValuesIncrementInfo(); incrementInfo.RootKey = _parent.RootKey; incrementInfo.KeyPath = _registryPath; incrementInfo.KeyName = _parent.Name; incrementInfo.ValueName = GetNewValueName(valueNames, _valueNames); _valueNames = valueNames; _valueKinds.Add(incrementInfo.ValueName, key.GetValueKind(incrementInfo.ValueName)); _values.Add(incrementInfo.ValueName, key.GetValue(incrementInfo.ValueName)); changeInfos = incrementInfo; returnKind = NotifyKind.AddinValuesIncrement; } else { AddinValuesDecrementInfo decrementInfo = new AddinValuesDecrementInfo(); decrementInfo.RootKey = _parent.RootKey; decrementInfo.KeyPath = _registryPath; decrementInfo.KeyName = _parent.Name; decrementInfo.ValueName = GetDeletedValueName(valueNames, _valueNames); _valueKinds.Remove(decrementInfo.ValueName); _values.Remove(decrementInfo.ValueName); changeInfos = decrementInfo; returnKind = NotifyKind.AddinValuesDecrement; } _valueNames = valueNames; _valueCount = valueCount; key.Close(); return(returnKind); } else { foreach (string item in valueNames) { // name changed if (!AddinsKey.Contains(_valueNames, item)) { _root.RaisePropertyChanged(_parent); key.Close(); AddinValueNameChangedInfo nameInfo = new AddinValueNameChangedInfo(); nameInfo.RootKey = _parent.RootKey; nameInfo.KeyPath = _registryPath; nameInfo.KeyName = _parent.Name; nameInfo.NewValueName = item; nameInfo.OldValueName = GetChangedValueName(valueNames, _valueNames); _valueNames = valueNames; RegistryValueKind refreshKind; object refreshValue = null; _valueKinds.TryGetValue(nameInfo.OldValueName, out refreshKind); _values.TryGetValue(nameInfo.OldValueName, out refreshValue); _valueKinds.Remove(nameInfo.OldValueName); _values.Remove(nameInfo.OldValueName); _valueKinds.Add(nameInfo.NewValueName, refreshKind); _values.Add(nameInfo.NewValueName, refreshValue); changeInfos = nameInfo; return(NotifyKind.AddinValueNameIsChanged); } // value changed object value = key.GetValue(item, null); object oldValue = null; _values.TryGetValue(item, out oldValue); if (!AddinsKey.IsEqual(value, oldValue)) { if ((_root.RestoreLastLoadBehavior) && (item == "LoadBehavior") && (!_root.FirstRun) && (true == openModeWrite) && (true == IsRestoreSituation(oldValue, value))) { key.SetValue("LoadBehavior", oldValue); key.Close(); AddinValueValueRestoredInfo restoredInfo = new AddinValueValueRestoredInfo(); restoredInfo.RootKey = _parent.RootKey; restoredInfo.KeyPath = _registryPath; restoredInfo.KeyName = _parent.Name; restoredInfo.ValueName = item; restoredInfo.OldValue = value; restoredInfo.RestoredValue = oldValue; changeInfos = restoredInfo; return(NotifyKind.AddinLoadBehaviorRestored); } else { _root.RaisePropertyChanged(_parent); _values[item] = value; key.Close(); AddinValueValueChangedInfo valueInfo = new AddinValueValueChangedInfo(); valueInfo.RootKey = _parent.RootKey; valueInfo.KeyPath = _registryPath; valueInfo.KeyName = _parent.Name; valueInfo.ValueName = item; valueInfo.NewValue = value; valueInfo.OldValue = oldValue; changeInfos = valueInfo; return(NotifyKind.AddinValueIsChanged); } } // kind changed RegistryValueKind kind = key.GetValueKind(item); RegistryValueKind oldkind; _valueKinds.TryGetValue(item, out oldkind); if (!AddinsKey.IsEqual(kind, oldkind)) { _root.RaisePropertyChanged(_parent); _valueKinds[item] = kind; key.Close(); AddinValueKindChangedInfo kindInfo = new AddinValueKindChangedInfo(); kindInfo.RootKey = _parent.RootKey; kindInfo.KeyPath = _registryPath; kindInfo.KeyName = _parent.Name; kindInfo.ValueName = item; kindInfo.NewValueKind = kind; kindInfo.OldValueKind = oldkind; changeInfos = kindInfo; return(NotifyKind.AddinValueKindIsChanged); } } key.Close(); } } return(NotifyKind.Nothing); } catch (System.Security.SecurityException exception) { throw new Exception("", exception); } }
private void CreateRegistryKey(AddinsKey item) { RegistryKey key = item.RootKey.CreateSubKey(item.RegistryPath); key.Close(); }
void _controller_PropertyChanged(object sender, PropertyChangedEventArgs e) { try { _addinsItemToDisplay = sender as AddinsKey; _disabledItemToDisplay = sender as DisabledKey; _displayedException = sender as Exception; if (null != _addinsItemToDisplay) this.Invoke(new MethodInvoker(_controller_AddinsKeyChangedInvoke)); else if (null != _disabledItemToDisplay) this.Invoke(new MethodInvoker(_controller_DisabledKeyChangedInvoke)); else if (sender is WatchController) this.Invoke(new MethodInvoker(_controller_PropertyChangedInvoke)); else if (sender is Exception) this.Invoke(new MethodInvoker(WatchNotify_ExceptionThrownInvoke)); /* if (null != _addinsItemToDisplay) { if (_addinsItemToDisplay.Name == "Outlook") { stopFlag = true; _controller.Enabled = false; } } * */ } catch (Exception exception) { ErrorForm errorForm = new ErrorForm(exception, ErrorCategory.NonCritical, _currentLanguageID); errorForm.ShowDialog(this); } }
public void ShowNotification(AddinsKey item, NotifyKind notfiyKind, RegistryChangeInfo changeInfo) { if (_parent.FirstRun) return; string message = GetMessage(notfiyKind); switch (notfiyKind) { case NotifyKind.AddinSubKeysIncrement: AddinSubkeysIncrementInfo newInfo = (AddinSubkeysIncrementInfo)changeInfo; message = String.Format(message, newInfo.RootKey, newInfo.KeyPath, newInfo.KeyName, Environment.NewLine); break; case NotifyKind.AddinSubKeysDecrement: AddinSubkeysDecrementInfo deleteInfo = (AddinSubkeysDecrementInfo)changeInfo; message = String.Format(message, deleteInfo.RootKey, deleteInfo.KeyPath, deleteInfo.KeyName, Environment.NewLine); break; case NotifyKind.AddinSubKeyNameChanged: AddinSubkeyNameChangedInfo nameInfo = (AddinSubkeyNameChangedInfo)changeInfo; message = String.Format(message, nameInfo.RootKey, nameInfo.KeyPath, nameInfo.OldKeyName, nameInfo.NewKeyName, Environment.NewLine); break; default: throw new ArgumentOutOfRangeException(notfiyKind.ToString() + " is not valid in this context"); } if (_parent.NotifyType == NotificationType.MessageBox) MessageBox.Show(message, "NetOffice.DeveloperToolbox", MessageBoxButtons.OK, MessageBoxIcon.Information); else _trayIcon.ShowBalloonTip(2000, message, "NetOffice.DeveloperToolbox " + notfiyKind.ToString(), ToolTipIcon.Info); if (null != MessageFired) MessageFired(message, new EventArgs()); }
private void CreateRegistryValue(AddinsKey item) { RegistryKey key = item.RootKey.OpenSubKey(item.RegistryPath, true); //key.SetValue(item.SpecificValueName, item.SpecificValueMustHave, item.SpecificValueKindMustHave); key.Close(); }
private void DeleteRegistryValue(AddinsKey item) { RegistryKey key = item.RootKey.OpenSubKey(item.RegistryPath, true); //key.DeleteValue(item.SpecificValueName); key.Close(); }
internal void RaisePropertyChanged(AddinsKey item) { if (null != PropertyChanged) PropertyChanged(item, new PropertyChangedEventArgs("")); }