Beispiel #1
0
        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());
            }
        }
Beispiel #2
0
        internal NotifyKind CheckChangedSubKeys(ref RegistryChangeInfo changeInfo)
        {
            RegistryKey key = _rootKey.OpenSubKey(_registryPath);

            if (null != key)
            {
                string[] subKeyNames = key.GetSubKeyNames();
                int      subKeyCount = key.SubKeyCount;
                if (subKeyCount != _subKeyCount)
                {
                    int oldSubKeyCount = _subKeyCount;
                    _subKeyCount = subKeyCount;
                    key.Close();
                    _parent.RaisePropertyChanged(this);

                    NotifyKind returnKind = NotifyKind.Nothing;
                    if ((subKeyCount > oldSubKeyCount) && (!_parent.FirstRun))
                    {
                        AddinSubkeysIncrementInfo newKeyInfo = new AddinSubkeysIncrementInfo();
                        newKeyInfo.RootKey = _rootKey;
                        newKeyInfo.KeyPath = _registryPath;
                        newKeyInfo.KeyName = GetNewValueName(subKeyNames, _subKeyNames);
                        changeInfo         = newKeyInfo;
                        _subKeyNames       = subKeyNames;
                        returnKind         = NotifyKind.AddinSubKeysIncrement;
                    }
                    else if (!_parent.FirstRun)
                    {
                        AddinSubkeysDecrementInfo deleteKeyInfo = new AddinSubkeysDecrementInfo();
                        deleteKeyInfo.RootKey = _rootKey;
                        deleteKeyInfo.KeyPath = _registryPath;
                        deleteKeyInfo.KeyName = GetDeletedValueName(subKeyNames, _subKeyNames);
                        changeInfo            = deleteKeyInfo;
                        _subKeyNames          = subKeyNames;
                        returnKind            = NotifyKind.AddinSubKeysDecrement;
                    }
                    return(returnKind);
                }
                else
                {
                    NotifyKind returnKind = NotifyKind.Nothing;
                    foreach (string item in subKeyNames)
                    {
                        if (!Contains(_subKeyNames, item))
                        {
                            _parent.RaisePropertyChanged(this);
                            if (!_parent.FirstRun)
                            {
                                AddinSubkeyNameChangedInfo nameInfo = new AddinSubkeyNameChangedInfo();
                                nameInfo.RootKey    = _rootKey;
                                nameInfo.KeyPath    = _registryPath;
                                nameInfo.OldKeyName = item;
                                nameInfo.NewKeyName = GetChangedValueName(subKeyNames, _subKeyNames);
                                changeInfo          = nameInfo;
                                _subKeyNames        = subKeyNames;
                                returnKind          = NotifyKind.AddinSubKeyNameChanged;
                            }
                            break;
                        }
                    }
                    _subKeyNames = subKeyNames;
                    key.Close();
                    return(returnKind);
                }
            }
            return(NotifyKind.Nothing);
        }
Beispiel #3
0
        internal NotifyKind CheckChangedSubKeys(ref RegistryChangeInfo changeInfo)
        {
            RegistryKey key = _rootKey.OpenSubKey(_registryPath);
            if (null != key)
            {
                string[] subKeyNames = key.GetSubKeyNames();
                int subKeyCount = key.SubKeyCount;
                if(subKeyCount != _subKeyCount)
                {
                    int oldSubKeyCount = _subKeyCount;
                    _subKeyCount = subKeyCount;
                    key.Close();
                    _parent.RaisePropertyChanged(this);

                    NotifyKind returnKind = NotifyKind.Nothing;
                    if ((subKeyCount > oldSubKeyCount) && (!_parent.FirstRun))
                    {
                        AddinSubkeysIncrementInfo newKeyInfo = new AddinSubkeysIncrementInfo();
                        newKeyInfo.RootKey = _rootKey;
                        newKeyInfo.KeyPath = _registryPath;
                        newKeyInfo.KeyName =  GetNewValueName(subKeyNames, _subKeyNames);
                        changeInfo = newKeyInfo;
                        _subKeyNames = subKeyNames;
                        returnKind = NotifyKind.AddinSubKeysIncrement;
                    }
                    else if(!_parent.FirstRun)
                    {
                        AddinSubkeysDecrementInfo deleteKeyInfo = new AddinSubkeysDecrementInfo();
                        deleteKeyInfo.RootKey = _rootKey;
                        deleteKeyInfo.KeyPath = _registryPath;
                        deleteKeyInfo.KeyName = GetDeletedValueName(subKeyNames, _subKeyNames);
                        changeInfo = deleteKeyInfo;
                        _subKeyNames = subKeyNames;
                        returnKind = NotifyKind.AddinSubKeysDecrement;
                    }
                    return returnKind;
                }
                else
                {
                    NotifyKind returnKind = NotifyKind.Nothing;
                    foreach (string item in subKeyNames)
                    {
                        if (!Contains(_subKeyNames, item))
                        {
                            _parent.RaisePropertyChanged(this);
                            if (!_parent.FirstRun)
                            { 
                                AddinSubkeyNameChangedInfo nameInfo = new AddinSubkeyNameChangedInfo();
                                nameInfo.RootKey = _rootKey;
                                nameInfo.KeyPath = _registryPath;
                                nameInfo.OldKeyName = item;
                                nameInfo.NewKeyName = GetChangedValueName(subKeyNames, _subKeyNames);
                                changeInfo = nameInfo;
                                _subKeyNames = subKeyNames;
                                returnKind = NotifyKind.AddinSubKeyNameChanged;
                            }
                            break;
                        }
                    }
                    _subKeyNames = subKeyNames;
                    key.Close();
                    return returnKind;
                }
            }
            return NotifyKind.Nothing;
        }