Esempio n. 1
0
        public void ShowNotification(DisabledKey item, NotifyKind notfiyKind, RegistryChangeInfo changeInfo)
        {
            if (_parent.FirstRun)
            {
                return;
            }
            string message = GetMessage(notfiyKind);

            switch (notfiyKind)
            {
            case NotifyKind.DisabledItemNew:
                NewDeactivatedElementInfo newInfo = (NewDeactivatedElementInfo)changeInfo;
                message = string.Format(message, newInfo.OfficeProductVersion, newInfo.Name, Environment.NewLine);
                break;

            case NotifyKind.DisabledItemDelete:
                DeleteDeactivatedElementInfo deleteInfo = (DeleteDeactivatedElementInfo)changeInfo;
                message = string.Format(message, deleteInfo.OfficeProductVersion, deleteInfo.Name, 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());
            }
        }
Esempio n. 2
0
        internal NotifyKind CheckChangedValueCount(ref RegistryChangeInfo changeInfos)
        {
            RegistryKey key = _rootKey.OpenSubKey(_registryPath);

            if (null == key)
            {
                bool found = false;
                foreach (string keyExists in _keyExists)
                {
                    if (keyExists == (RootKey.ToString() + "\\" + _registryPath))
                    {
                        found = true;
                        break;
                    }
                }
                if (found)
                {
                    _parent.RaisePropertyChanged(this);
                    _keyExists.Remove(RootKey.ToString() + "\\" + _registryPath);
                }
            }
            else
            {
                bool found = false;
                foreach (string keyExists in _keyExists)
                {
                    if (keyExists == (RootKey.ToString() + "\\" + _registryPath))
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    _keyExists.Add(RootKey.ToString() + "\\" + _registryPath);
                }

                string[] valueNames = key.GetValueNames();
                int      valueCount = key.ValueCount;
                if (valueCount != _lastValueCount)
                {
                    _parent.RaisePropertyChanged(this);

                    NotifyKind returnKind;
                    if ((valueCount > _lastValueCount) && (!_parent.FirstRun))
                    {
                        NewDeactivatedElementInfo newElementInfo = new NewDeactivatedElementInfo();
                        newElementInfo.RootKey = _rootKey;
                        newElementInfo.KeyPath = _registryPath;

                        string newValueName = GetNewValueName(valueNames, _valueNames);
                        object regValue     = key.GetValue(newValueName, null);
                        regValue            = DisabledValue.ConvertDisabledItemValueName(regValue, newValueName);
                        newElementInfo.Name = regValue as string;
                        newElementInfo.OfficeProductVersion = OfficeProductVersion;
                        changeInfos = newElementInfo;
                        _valueNames = valueNames;
                        returnKind  = NotifyKind.DisabledItemNew;
                    }
                    else if (!_parent.FirstRun)
                    {
                        DeleteDeactivatedElementInfo deleteElementInfo = new DeleteDeactivatedElementInfo();
                        deleteElementInfo.RootKey = _rootKey;
                        deleteElementInfo.KeyPath = _registryPath;
                        deleteElementInfo.Name    = GetDeletedValueName(valueNames, _valueNames);

                        string convertedName = null;
                        _convertedNames.TryGetValue(deleteElementInfo.Name, out convertedName);
                        _convertedNames.Remove(deleteElementInfo.Name);
                        deleteElementInfo.Name = convertedName;

                        deleteElementInfo.OfficeProductVersion = OfficeProductVersion;
                        changeInfos = deleteElementInfo;
                        _valueNames = valueNames;
                        returnKind  = NotifyKind.DisabledItemDelete;
                    }
                    else
                    {
                        foreach (string name in valueNames)
                        {
                            string existingName = null;
                            _convertedNames.TryGetValue(name, out existingName);
                            if (null == existingName)
                            {
                                object regValue = key.GetValue(name, null);
                                regValue = DisabledValue.ConvertDisabledItemValueName(regValue, name);
                                _convertedNames.Add(name, regValue as string);
                            }
                        }
                        returnKind = NotifyKind.Nothing;
                    }


                    _lastValueCount = valueCount;
                    return(returnKind);
                }
                _valueNames = valueNames;
                key.Close();
            }
            return(NotifyKind.Nothing);
        }
Esempio n. 3
0
        internal NotifyKind CheckChangedValueCount(ref RegistryChangeInfo changeInfos)
        {
            RegistryKey key = _rootKey.OpenSubKey(_registryPath);
            if (null == key)
            {
                bool found = false;
                foreach (string keyExists in _keyExists)
                {
                    if (keyExists == (RootKey.ToString() + "\\" + _registryPath))
                    {
                        found = true;
                        break;
                    }
                }
                if (found)
                { 
                    _parent.RaisePropertyChanged(this);
                    _keyExists.Remove(RootKey.ToString() + "\\" + _registryPath);
                }
            }
            else 
            { 
                bool found = false;
                foreach (string keyExists in _keyExists)
                {
                    if(keyExists == (RootKey.ToString() +"\\" + _registryPath))
                    {
                        found = true;
                        break;
                    }
                }
                if(!found)
                    _keyExists.Add(RootKey.ToString() + "\\" + _registryPath);

                string[] valueNames = key.GetValueNames();
                int valueCount = key.ValueCount;
                if (valueCount != _lastValueCount)
                {
                    _parent.RaisePropertyChanged(this);

                    NotifyKind returnKind;
                    if ((valueCount > _lastValueCount) && (!_parent.FirstRun))
                    {
                        NewDeactivatedElementInfo newElementInfo = new NewDeactivatedElementInfo();
                        newElementInfo.RootKey = _rootKey;
                        newElementInfo.KeyPath = _registryPath;

                        string newValueName = GetNewValueName(valueNames, _valueNames);
                        object regValue = key.GetValue(newValueName, null);
                        regValue = DisabledValue.ConvertDisabledItemValueName(regValue, newValueName);
                        newElementInfo.Name = regValue as string;
                        newElementInfo.OfficeProductVersion = OfficeProductVersion;
                        changeInfos = newElementInfo;
                        _valueNames = valueNames;
                        returnKind = NotifyKind.DisabledItemNew;
                    }
                    else if (!_parent.FirstRun)
                    {
                        DeleteDeactivatedElementInfo deleteElementInfo = new DeleteDeactivatedElementInfo();
                        deleteElementInfo.RootKey = _rootKey;
                        deleteElementInfo.KeyPath = _registryPath;
                        deleteElementInfo.Name = GetDeletedValueName(valueNames, _valueNames);

                        string convertedName = null;
                        _convertedNames.TryGetValue(deleteElementInfo.Name, out convertedName);
                        _convertedNames.Remove(deleteElementInfo.Name);
                        deleteElementInfo.Name = convertedName;

                        deleteElementInfo.OfficeProductVersion = OfficeProductVersion;
                        changeInfos = deleteElementInfo;
                        _valueNames = valueNames;
                        returnKind = NotifyKind.DisabledItemDelete;
                    }
                    else
                    {
                        foreach (string name in valueNames)
                        {
                            string existingName = null;
                            _convertedNames.TryGetValue(name, out existingName);
                            if (null == existingName)
                            {
                                object regValue = key.GetValue(name, null);
                                regValue = DisabledValue.ConvertDisabledItemValueName(regValue, name);
                                _convertedNames.Add(name, regValue as string);
                            }
                        }
                        returnKind = NotifyKind.Nothing;
                    }


                    _lastValueCount = valueCount;
                    return returnKind;
                }
                _valueNames = valueNames;
                key.Close();
            }
            return NotifyKind.Nothing;
        }