Exemplo n.º 1
0
 private void LoadShellExItems()
 {
     foreach (XmlElement itemXE in shellExXE.GetElementsByTagName("Item"))
     {
         if (!GuidInfo.TryGetGuid(itemXE.GetAttribute("Guid"), out Guid guid))
         {
             continue;
         }
         if (ShellExItem.GetPathAndGuids(ShellExPath).Values.Contains(guid))
         {
             continue;
         }
         ShellExCommonItem item = new ShellExCommonItem
         {
             Image          = ResourceIcon.GetIcon(itemXE.GetAttribute("Icon"))?.ToBitmap() ?? AppImage.DllDefaultIcon,
             Text           = ResourceString.GetDirectString(itemXE.GetAttribute("Text")),
             DefaultKeyName = itemXE.GetAttribute("KeyName"),
             Guid           = guid
         };
         if (string.IsNullOrWhiteSpace(item.Text))
         {
             item.Text = GuidInfo.GetText(guid);
         }
         if (string.IsNullOrWhiteSpace(item.DefaultKeyName))
         {
             item.DefaultKeyName = guid.ToString("B");
         }
         item.SetTip(itemXE.GetAttribute("Tip"));
         list.AddItem(item);
     }
 }
Exemplo n.º 2
0
        public static Dictionary <string, Guid> GetPathAndGuids(string shellExPath)
        {
            Dictionary <string, Guid> dic = new Dictionary <string, Guid>();

            foreach (string cmhPart in CmhParts)
            {
                using (RegistryKey cmKey = RegistryEx.GetRegistryKey($@"{shellExPath}\{cmhPart}"))
                {
                    if (cmKey == null)
                    {
                        continue;
                    }
                    foreach (string keyName in cmKey.GetSubKeyNames())
                    {
                        using (RegistryKey key = cmKey.OpenSubKey(keyName))
                        {
                            if (!GuidInfo.TryGetGuid(key.GetValue("")?.ToString(), out Guid guid))
                            {
                                GuidInfo.TryGetGuid(keyName, out guid);
                            }
                            if (!guid.Equals(Guid.Empty))
                            {
                                dic.Add(key.Name, guid);
                            }
                        }
                    }
                }
            }
            return(dic);
        }
Exemplo n.º 3
0
 private static void DisplayGuidInfo(GuidInfo guidInfo)
 {
     Console.WriteLine();
     Console.WriteLine($"Guid: {guidInfo.Guid}");
     Console.WriteLine($"Expires On: {guidInfo.Expire.Value.ToLocalTime().ToString()}");
     Console.WriteLine($"User: {guidInfo.User}");
 }
Exemplo n.º 4
0
        private void AddUwpModeItem()
        {
            XmlDocument doc = AppDic.ReadXml(AppConfig.WebUwpModeItemsDic,
                                             AppConfig.UserUwpModeItemsDic, Properties.Resources.UwpModeItemsDic);
            List <Guid> guids = new List <Guid>();

            foreach (XmlElement sceneXE in doc.DocumentElement.ChildNodes)
            {
                if (sceneXE.Name == Scene.ToString())
                {
                    foreach (XmlElement itemXE in sceneXE.ChildNodes)
                    {
                        if (GuidEx.TryParse(itemXE.GetAttribute("Guid"), out Guid guid))
                        {
                            if (guids.Contains(guid))
                            {
                                continue;
                            }
                            string uwpName = GuidInfo.GetUwpName(guid);
                            if (!string.IsNullOrEmpty(uwpName))
                            {
                                this.AddItem(new UwpModeItem(uwpName, guid));
                                guids.Add(guid);
                            }
                        }
                    }
                }
            }
        }
 private void LoadShellExItems(XmlElement shellExXE, GroupPathItem groupItem)
 {
     foreach (XmlElement itemXE in shellExXE.SelectNodes("Item"))
     {
         if (!JudgeOSVersion(itemXE))
         {
             continue;
         }
         if (!GuidEx.TryParse(itemXE.GetAttribute("Guid"), out Guid guid))
         {
             continue;
         }
         EnhanceShellExItem item = new EnhanceShellExItem
         {
             FoldGroupItem  = groupItem,
             ShellExPath    = $@"{groupItem.TargetPath}\ShellEx",
             Image          = ResourceIcon.GetIcon(itemXE.GetAttribute("Icon"))?.ToBitmap() ?? AppImage.DllDefaultIcon,
             Text           = ResourceString.GetDirectString(itemXE.GetAttribute("Text")),
             DefaultKeyName = itemXE.GetAttribute("KeyName"),
             Guid           = guid
         };
         if (item.Text.IsNullOrWhiteSpace())
         {
             item.Text = GuidInfo.GetText(guid);
         }
         if (item.DefaultKeyName.IsNullOrWhiteSpace())
         {
             item.DefaultKeyName = guid.ToString("B");
         }
         item.ChkVisible.Checked = item.ItemVisible;
         MyToolTip.SetToolTip(item.ChkVisible, itemXE.GetAttribute("Tip"));
         this.AddItem(item);
     }
 }
 public UwpModeItem(string uwpName, Guid guid)
 {
     this.Guid    = guid;
     this.UwpName = uwpName;
     this.InitializeComponents();
     this.Visible = UwpHelper.GetPackageName(uwpName) != null;
     this.Image   = GuidInfo.GetImage(guid);
     this.Text    = this.ItemText;
 }
Exemplo n.º 7
0
 public UwpModeItem(string uwpName, Guid guid)
 {
     this.Guid    = guid;
     this.UwpName = uwpName;
     this.InitializeComponents();
     ChkVisible.Checked = ItemVisible;
     this.Visible       = File.Exists(ItemFilePath);
     this.Image         = GuidInfo.GetImage(guid);
     this.Text          = this.ItemText;
 }
 private void LoadShellExItems(XmlNode shellExXN, FoldGroupItem groupItem)
 {
     foreach (XmlNode itemXN in shellExXN.SelectNodes("Item"))
     {
         if (!XmlDicHelper.FileExists(itemXN))
         {
             continue;
         }
         if (!XmlDicHelper.JudgeCulture(itemXN))
         {
             continue;
         }
         if (!XmlDicHelper.JudgeOSVersion(itemXN))
         {
             continue;
         }
         if (!GuidEx.TryParse(itemXN.SelectSingleNode("Guid")?.InnerText, out Guid guid))
         {
             continue;
         }
         EnhanceShellExItem item = new EnhanceShellExItem
         {
             FoldGroupItem  = groupItem,
             ShellExPath    = $@"{groupItem.GroupPath}\ShellEx",
             Image          = ResourceIcon.GetIcon(itemXN.SelectSingleNode("Icon")?.InnerText)?.ToBitmap() ?? AppImage.SystemFile,
             DefaultKeyName = itemXN.SelectSingleNode("KeyName")?.InnerText,
             Guid           = guid
         };
         foreach (XmlNode textXE in itemXN.SelectNodes("Text"))
         {
             if (XmlDicHelper.JudgeCulture(textXE))
             {
                 item.Text = ResourceString.GetDirectString(textXE.InnerText);
             }
         }
         if (item.Text.IsNullOrWhiteSpace())
         {
             item.Text = GuidInfo.GetText(guid);
         }
         if (item.DefaultKeyName.IsNullOrWhiteSpace())
         {
             item.DefaultKeyName = guid.ToString("B");
         }
         string tip = "";
         foreach (XmlElement tipXE in itemXN.SelectNodes("Tip"))
         {
             if (XmlDicHelper.JudgeCulture(tipXE))
             {
                 tip = tipXE.GetAttribute("Text");
             }
         }
         ToolTipBox.SetToolTip(item.ChkVisible, tip);
         this.AddItem(item);
     }
 }
 private void AddGuidDic()
 {
     using (AddGuidDicDialog dlg = new AddGuidDicDialog())
     {
         dlg.ItemText = GuidInfo.GetText(Item.Guid);
         dlg.ItemIcon = GuidInfo.GetImage(Item.Guid);
         var location = GuidInfo.GetIconLocation(Item.Guid);
         dlg.ItemIconPath  = location.IconPath;
         dlg.ItemIconIndex = location.IconIndex;
         IniWriter writer = new IniWriter
         {
             FilePath            = AppConfig.UserGuidInfosDic,
             DeleteFileWhenEmpty = true
         };
         string     section  = Item.Guid.ToString();
         MyListItem listItem = (MyListItem)Item;
         if (dlg.ShowDialog() != DialogResult.OK)
         {
             if (dlg.IsDelete)
             {
                 writer.DeleteSection(section);
                 GuidInfo.RemoveDic(Item.Guid);
                 listItem.Text  = Item.ItemText;
                 listItem.Image = GuidInfo.GetImage(Item.Guid);
             }
             return;
         }
         if (dlg.ItemText.IsNullOrWhiteSpace())
         {
             AppMessageBox.Show(AppString.Message.TextCannotBeEmpty);
             return;
         }
         dlg.ItemText = ResourceString.GetDirectString(dlg.ItemText);
         if (dlg.ItemText.IsNullOrWhiteSpace())
         {
             AppMessageBox.Show(AppString.Message.StringParsingFailed);
             return;
         }
         else
         {
             GuidInfo.RemoveDic(Item.Guid);
             writer.SetValue(section, "Text", dlg.ItemText);
             writer.SetValue(section, "Icon", dlg.ItemIconLocation);
             listItem.Text  = dlg.ItemText;
             listItem.Image = dlg.ItemIcon;
         }
     }
 }
 private void RefreshMenuItem()
 {
     TsiClsidLocation.Visible = GuidInfo.GetClsidPath(Item.Guid) != null;
     TsiBlockGuid.Visible     = TsiBlockGuid.Checked = false;
     if (Item is ShellExItem)
     {
         TsiBlockGuid.Visible = true;
         foreach (string path in GuidBlockedList.BlockedPaths)
         {
             if (Microsoft.Win32.Registry.GetValue(path, Item.Guid.ToString("B"), null) != null)
             {
                 TsiBlockGuid.Checked = true; break;
             }
         }
     }
 }
Exemplo n.º 11
0
 public GuidBlockedItem(string value)
 {
     InitializeComponents();
     this.Value = value;
     if (GuidEx.TryParse(value, out Guid guid))
     {
         this.Guid         = guid;
         this.Image        = GuidInfo.GetImage(guid);
         this.ItemFilePath = GuidInfo.GetFilePath(Guid);
     }
     else
     {
         this.Guid  = Guid.Empty;
         this.Image = AppImage.SystemFile;
     }
     this.Text = this.ItemText;
 }
 protected override bool RunDialog(IntPtr hwndOwner)
 {
     using (SubItemsForm frm = new SubItemsForm())
         using (DetailedEditList list = new DetailedEditList())
         {
             var location = GuidInfo.GetIconLocation(this.GroupGuid);
             frm.Icon    = ResourceIcon.GetIcon(location.IconPath, location.IconIndex);
             frm.Text    = AppString.Dialog.DetailedEdit.Replace("%s", GuidInfo.GetText(this.GroupGuid));
             frm.TopMost = AppConfig.TopMost;
             frm.AddList(list);
             list.GroupGuid  = this.GroupGuid;
             list.UseUserDic = XmlDicHelper.DetailedEditGuidDic[this.GroupGuid];
             list.LoadItems();
             frm.ShowDialog();
         }
     return(false);
 }
Exemplo n.º 13
0
        private bool InternalAdd(GuidComponent guidComponent)
        {
            Guid guid = guidComponent.GetGuid();

            GuidInfo info = new GuidInfo(guidComponent);

            if (this.guidToObjectMap.ContainsKey(guid) == false)
            {
                this.guidToObjectMap.Add(guid, info);
                return(true);
            }

            GuidInfo existingInfo = this.guidToObjectMap[guid];

            if (existingInfo.GO != null && existingInfo.GO != guidComponent.gameObject)
            {
                // normally, a duplicate GUID is a big problem, means you won't necessarily be referencing what you expect
                if (Application.isPlaying)
                {
                    Debug.AssertFormat(
                        false,
                        guidComponent,
                        "Guid Collision Detected between {0} and {1}.\nAssigning new Guid. Consider tracking runtime instances using a direct reference or other method.",
                        this.guidToObjectMap[guid].GO != null ? this.guidToObjectMap[guid].GO.name : "NULL",
                        guidComponent != null ? guidComponent.name : "NULL");
                }
                else
                {
                    // however, at editor time, copying an object with a GUID will duplicate the GUID resulting in a collision and repair.
                    // we warn about this just for pedantry reasons, and so you can detect if you are unexpectedly copying these components
                    Debug.LogWarningFormat(guidComponent, "Guid Collision Detected while creating {0}.\nAssigning new Guid.", guidComponent != null ? guidComponent.name : "NULL");
                }

                return(false);
            }

            // if we already tried to find this GUID, but haven't set the game object to anything specific, copy any OnAdd callbacks then call them
            existingInfo.GO = info.GO;
            existingInfo.HandleAddCallback();

            this.guidToObjectMap[guid] = existingInfo;

            return(true);
        }
Exemplo n.º 14
0
 public GuidBlockedItem(string value)
 {
     InitializeComponents();
     this.Value = value;
     if (GuidEx.TryParse(value, out Guid guid))
     {
         this.Guid         = guid;
         this.Text         = GuidInfo.GetText(guid);
         this.Image        = GuidInfo.GetImage(guid);
         this.ItemFilePath = GuidInfo.GetFilePath(Guid);
     }
     else
     {
         this.Guid  = Guid.Empty;
         this.Text  = AppString.MessageBox.MalformedGuid;
         this.Image = AppImage.DllDefaultIcon;
     }
     this.Text += "\n" + value;
 }
Exemplo n.º 15
0
        private void LoadCommonItems()
        {
            List <string> values = new List <string>();

            Array.ForEach(GuidBlockedItem.BlockedPaths, path =>
            {
                using (RegistryKey key = RegistryEx.GetRegistryKey(path))
                    if (key != null)
                    {
                        values.AddRange(key.GetValueNames());
                    }
            });
            Array.ForEach(values.Distinct(StringComparer.OrdinalIgnoreCase).ToArray(), value =>
            {
                if (GuidInfo.TryGetGuid(value, out Guid guid, out string guidPath))
                {
                    this.AddItem(new GuidBlockedItem(guid, guidPath));
                }
            });
Exemplo n.º 16
0
        public bool Add(Guid guid, GameObject gameObject)
        {
            if (guid == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(guid), "There was an attempt to add empty Guid.");
            }
            if (gameObject == null)
            {
                throw new ArgumentNullException(nameof(gameObject), "There was an attempt to add NULL GameObject.");
            }

            GuidInfo info = new GuidInfo(gameObject);

            if (!guidToObjectMap.ContainsKey(guid))
            {
                guidToObjectMap.Add(guid, info);
                return(true);
            }

            GuidInfo existingInfo = guidToObjectMap[guid];

            if (existingInfo.gameObject != null && existingInfo.gameObject != gameObject)
            {
                // normally, a duplicate GUID is a big problem, means you won't necessarily be referencing what you expect
                if (Application.isPlaying)
                {
                    Debug.AssertFormat(false, gameObject, "Guid Collision Detected between {0} and {1}.\nAssigning new Guid. Consider tracking runtime instances using a direct reference or other method.", (guidToObjectMap[guid].gameObject != null ? guidToObjectMap[guid].gameObject.name : "NULL"), (gameObject != null ? gameObject.name : "NULL"));
                }
                else
                {
                    // however, at editor time, copying an object with a GUID will duplicate the GUID resulting in a collision and repair.
                    // we warn about this just for pedantry reasons, and so you can detect if you are unexpectedly copying these components
                    Debug.LogWarningFormat(gameObject, "Guid Collision Detected while creating {0}.\nAssigning new Guid.", (gameObject != null ? gameObject.name : "NULL"));
                }
                return(false);
            }

            // if we already tried to find this GUID, but haven't set the game object to anything specific, copy any OnAdd callbacks then call them
            existingInfo.gameObject = info.gameObject;
            existingInfo.HandleAddCallback();
            guidToObjectMap[guid] = existingInfo;
            return(true);
        }
Exemplo n.º 17
0
        public void LoadItems()
        {
            try
            {
                foreach (XmlElement groupXE in ReadXml().DocumentElement.ChildNodes)
                {
                    Guid guid = Guid.Empty;
                    if (groupXE.HasAttribute("Guid") && !GuidInfo.TryGetGuid(groupXE.GetAttribute("Guid"), out guid))
                    {
                        continue;
                    }

                    GroupPathItem groupItem = new GroupPathItem(groupXE.GetAttribute("RegPath"), ObjectPath.PathType.Registry)
                    {
                        Text  = groupXE.GetAttribute("Text"),
                        Image = GuidInfo.GetImage(guid),
                    };
                    if (groupItem.Text.IsNullOrWhiteSpace())
                    {
                        groupItem.Text = GuidInfo.GetText(guid);
                    }
                    this.AddItem(groupItem);

                    foreach (XmlElement itemXE in groupXE.ChildNodes)
                    {
                        XmlElement verXE = (XmlElement)itemXE.SelectSingleNode("OSVersion");
                        if (!EnhanceMenusList.JudgeOSVersion(verXE))
                        {
                            continue;
                        }
                        RegRuleItem.ItemInfo itemInfo = new RegRuleItem.ItemInfo
                        {
                            Text            = itemXE.GetAttribute("Text"),
                            Tip             = itemXE.GetAttribute("Tip"),
                            RestartExplorer = itemXE.HasAttribute("RestartExplorer"),
                        };

                        XmlNodeList           ruleXNList = itemXE.GetElementsByTagName("Rule");//Rules
                        RegRuleItem.RegRule[] rules      = new RegRuleItem.RegRule[ruleXNList.Count];
                        for (int i = 0; i < ruleXNList.Count; i++)
                        {
                            XmlElement ruleXE = (XmlElement)ruleXNList[i];
                            rules[i] = new RegRuleItem.RegRule
                            {
                                RegPath      = ruleXE.GetAttribute("RegPath"),
                                ValueName    = ruleXE.GetAttribute("ValueName"),
                                TurnOnValue  = ruleXE.GetAttribute("On"),
                                TurnOffValue = ruleXE.GetAttribute("Off"),
                                ValueKind    = GetValueKind(ruleXE.GetAttribute("ValueKind"))
                            };
                            if (string.IsNullOrEmpty(rules[i].RegPath))
                            {
                                rules[i].RegPath = groupItem.TargetPath;
                            }
                            else if (rules[i].RegPath.StartsWith("\\"))
                            {
                                rules[i].RegPath = groupItem.TargetPath + rules[i].RegPath;
                            }
                        }

                        this.AddItem(new RegRuleItem(rules, itemInfo)
                        {
                            FoldGroupItem = groupItem, HasImage = false
                        });
                    }
                    groupItem.IsFold = true;
                }
            }
            catch { }
        }
        private void OpenClsidPath()
        {
            string clsidPath = GuidInfo.GetClsidPath(Item.Guid);

            ExternalProgram.JumpRegEdit(clsidPath, null, AppConfig.OpenMoreRegedit);
        }
        public void LoadItems()
        {
            try
            {
                XmlDocument doc = AppDic.ReadXml(AppConfig.WebThirdRulesDic,
                                                 AppConfig.UserThirdRulesDic, Properties.Resources.ThirdRulesDic);
                foreach (XmlElement groupXE in doc.DocumentElement.ChildNodes)
                {
                    Guid guid = Guid.Empty;
                    if (groupXE.HasAttribute("Guid"))
                    {
                        if (GuidEx.TryParse(groupXE.GetAttribute("Guid"), out guid))
                        {
                            if (!File.Exists(GuidInfo.GetFilePath(guid)))
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }

                    GroupPathItem       groupItem;
                    bool                isIniGroup = groupXE.HasAttribute("IsIniGroup");
                    string              attribute  = isIniGroup ? "FilePath" : "RegPath";
                    ObjectPath.PathType pathType   = isIniGroup ? ObjectPath.PathType.File : ObjectPath.PathType.Registry;
                    groupItem = new GroupPathItem(groupXE.GetAttribute(attribute), pathType)
                    {
                        Text  = groupXE.GetAttribute("Text"),
                        Image = GuidInfo.GetImage(guid)
                    };
                    if (groupItem.Text.IsNullOrWhiteSpace())
                    {
                        groupItem.Text = GuidInfo.GetText(guid);
                    }
                    this.AddItem(groupItem);

                    string GetRuleFullRegPath(string regPath)
                    {
                        if (string.IsNullOrEmpty(regPath))
                        {
                            regPath = groupItem.TargetPath;
                        }
                        else if (regPath.StartsWith("\\"))
                        {
                            regPath = groupItem.TargetPath + regPath;
                        }
                        return(regPath);
                    };

                    foreach (XmlElement itemXE in groupXE.ChildNodes)
                    {
                        if (!EnhanceMenusList.JudgeOSVersion(itemXE))
                        {
                            continue;
                        }
                        RuleItem ruleItem;
                        ItemInfo info = new ItemInfo
                        {
                            Text            = itemXE.GetAttribute("Text"),
                            Tip             = itemXE.GetAttribute("Tip"),
                            RestartExplorer = itemXE.HasAttribute("RestartExplorer"),
                        };
                        int defaultValue = 0, maxValue = 0, minValue = 0;
                        if (itemXE.HasAttribute("IsNumberItem"))
                        {
                            XmlElement ruleXE = (XmlElement)itemXE.SelectSingleNode("Rule");
                            defaultValue = ruleXE.HasAttribute("Default") ? Convert.ToInt32(ruleXE.GetAttribute("Default")) : 0;
                            maxValue     = ruleXE.HasAttribute("Max") ? Convert.ToInt32(ruleXE.GetAttribute("Max")) : int.MaxValue;
                            minValue     = ruleXE.HasAttribute("Min") ? Convert.ToInt32(ruleXE.GetAttribute("Min")) : int.MinValue;
                        }

                        if (isIniGroup)
                        {
                            XmlElement ruleXE  = (XmlElement)itemXE.SelectSingleNode("Rule");
                            string     iniPath = ruleXE.GetAttribute("FilePath");
                            if (iniPath.IsNullOrWhiteSpace())
                            {
                                iniPath = groupItem.TargetPath;
                            }
                            string section = ruleXE.GetAttribute("Section");
                            string keyName = ruleXE.GetAttribute("KeyName");
                            if (itemXE.HasAttribute("IsNumberItem"))
                            {
                                var rule = new NumberIniRuleItem.IniRule
                                {
                                    IniPath      = iniPath,
                                    Section      = section,
                                    KeyName      = keyName,
                                    DefaultValue = defaultValue,
                                    MaxValue     = maxValue,
                                    MinValue     = maxValue
                                };
                                ruleItem = new NumberIniRuleItem(rule, info);
                            }
                            else if (itemXE.HasAttribute("IsStringItem"))
                            {
                                var rule = new StringIniRuleItem.IniRule
                                {
                                    IniPath  = iniPath,
                                    Secation = section,
                                    KeyName  = keyName
                                };
                                ruleItem = new StringIniRuleItem(rule, info);
                            }
                            else
                            {
                                var rule = new VisbleIniRuleItem.IniRule
                                {
                                    IniPath      = iniPath,
                                    Section      = section,
                                    KeyName      = keyName,
                                    TurnOnValue  = ruleXE.HasAttribute("On") ? ruleXE.GetAttribute("On") : null,
                                    TurnOffValue = ruleXE.HasAttribute("Off") ? ruleXE.GetAttribute("Off") : null,
                                };
                                ruleItem = new VisbleIniRuleItem(rule, info);
                            }
                        }

                        else
                        {
                            if (itemXE.HasAttribute("IsNumberItem"))
                            {
                                XmlElement ruleXE = (XmlElement)itemXE.SelectSingleNode("Rule");
                                var        rule   = new NumberRegRuleItem.RegRule
                                {
                                    RegPath      = GetRuleFullRegPath(ruleXE.GetAttribute("RegPath")),
                                    ValueName    = ruleXE.GetAttribute("ValueName"),
                                    ValueKind    = GetValueKind(ruleXE.GetAttribute("ValueKind")),
                                    DefaultValue = defaultValue,
                                    MaxValue     = maxValue,
                                    MinValue     = minValue
                                };
                                ruleItem = new NumberRegRuleItem(rule, info);
                            }
                            else if (itemXE.HasAttribute("IsStringItem"))
                            {
                                XmlElement ruleXE = (XmlElement)itemXE.SelectSingleNode("Rule");
                                var        rule   = new StringRegRuleItem.RegRule
                                {
                                    RegPath   = GetRuleFullRegPath(ruleXE.GetAttribute("RegPath")),
                                    ValueName = ruleXE.GetAttribute("ValueName"),
                                };
                                ruleItem = new StringRegRuleItem(rule, info);
                            }
                            else
                            {
                                XmlNodeList ruleXNList = itemXE.SelectNodes("Rule");
                                var         rules      = new VisibleRegRuleItem.RegRule[ruleXNList.Count];
                                for (int i = 0; i < ruleXNList.Count; i++)
                                {
                                    XmlElement ruleXE = (XmlElement)ruleXNList[i];
                                    rules[i] = new VisibleRegRuleItem.RegRule
                                    {
                                        RegPath      = GetRuleFullRegPath(ruleXE.GetAttribute("RegPath")),
                                        ValueName    = ruleXE.GetAttribute("ValueName"),
                                        ValueKind    = GetValueKind(ruleXE.GetAttribute("ValueKind")),
                                        TurnOnValue  = ruleXE.HasAttribute("On") ? ruleXE.GetAttribute("On") : null,
                                        TurnOffValue = ruleXE.HasAttribute("Off") ? ruleXE.GetAttribute("Off") : null,
                                    };
                                }
                                ruleItem = new VisibleRegRuleItem(rules, info);
                            }
                        }
                        this.AddItem(ruleItem);
                        ruleItem.HasImage      = false;
                        ruleItem.FoldGroupItem = groupItem;
                    }
                    groupItem.IsFold = true;
                    groupItem.HideWhenNoSubItem();
                }
            }
            catch { }
        }
Exemplo n.º 20
0
        private void LoadDocItems(string xmlPath, GroupPathItem groupItem)
        {
            if (!File.Exists(xmlPath))
            {
                return;
            }
            this.AddItem(groupItem);
            XmlDocument doc = new XmlDocument();

            try { doc.LoadXml(File.ReadAllText(xmlPath, EncodingType.GetType(xmlPath)).Trim()); }
            catch (Exception e) { MessageBoxEx.Show(e.Message); return; }
            foreach (XmlElement groupXE in doc.DocumentElement.ChildNodes)
            {
                try
                {
                    Guid guid = Guid.Empty;
                    if (groupXE.HasAttribute("Guid"))
                    {
                        if (GuidEx.TryParse(groupXE.GetAttribute("Guid"), out guid))
                        {
                            if (!File.Exists(GuidInfo.GetFilePath(guid)))
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }

                    SubGroupItem        subGroupItem;
                    bool                isIniGroup = groupXE.HasAttribute("IsIniGroup");
                    string              attribute  = isIniGroup ? "FilePath" : "RegPath";
                    ObjectPath.PathType pathType   = isIniGroup ? ObjectPath.PathType.File : ObjectPath.PathType.Registry;
                    subGroupItem = new SubGroupItem(groupXE.GetAttribute(attribute), pathType)
                    {
                        Text  = groupXE.GetAttribute("Text"),
                        Image = GuidInfo.GetImage(guid)
                    };
                    if (subGroupItem.Text.IsNullOrWhiteSpace())
                    {
                        subGroupItem.Text = GuidInfo.GetText(guid);
                    }
                    this.AddItem(subGroupItem);

                    string GetRuleFullRegPath(string regPath)
                    {
                        if (string.IsNullOrEmpty(regPath))
                        {
                            regPath = subGroupItem.TargetPath;
                        }
                        else if (regPath.StartsWith("\\"))
                        {
                            regPath = subGroupItem.TargetPath + regPath;
                        }
                        return(regPath);
                    };

                    foreach (XmlElement itemXE in groupXE.ChildNodes)
                    {
                        try
                        {
                            if (!EnhanceMenusList.JudgeOSVersion(itemXE))
                            {
                                continue;
                            }
                            RuleItem ruleItem;
                            ItemInfo info = new ItemInfo
                            {
                                Text            = itemXE.GetAttribute("Text"),
                                Tip             = itemXE.GetAttribute("Tip"),
                                RestartExplorer = itemXE.HasAttribute("RestartExplorer"),
                            };
                            int defaultValue = 0, maxValue = 0, minValue = 0;
                            if (itemXE.HasAttribute("IsNumberItem"))
                            {
                                XmlElement ruleXE = (XmlElement)itemXE.SelectSingleNode("Rule");
                                defaultValue = ruleXE.HasAttribute("Default") ? Convert.ToInt32(ruleXE.GetAttribute("Default")) : 0;
                                maxValue     = ruleXE.HasAttribute("Max") ? Convert.ToInt32(ruleXE.GetAttribute("Max")) : int.MaxValue;
                                minValue     = ruleXE.HasAttribute("Min") ? Convert.ToInt32(ruleXE.GetAttribute("Min")) : int.MinValue;
                            }

                            if (isIniGroup)
                            {
                                XmlElement ruleXE  = (XmlElement)itemXE.SelectSingleNode("Rule");
                                string     iniPath = ruleXE.GetAttribute("FilePath");
                                if (iniPath.IsNullOrWhiteSpace())
                                {
                                    iniPath = subGroupItem.TargetPath;
                                }
                                string section = ruleXE.GetAttribute("Section");
                                string keyName = ruleXE.GetAttribute("KeyName");
                                if (itemXE.HasAttribute("IsNumberItem"))
                                {
                                    var rule = new NumberIniRuleItem.IniRule
                                    {
                                        IniPath      = iniPath,
                                        Section      = section,
                                        KeyName      = keyName,
                                        DefaultValue = defaultValue,
                                        MaxValue     = maxValue,
                                        MinValue     = maxValue
                                    };
                                    ruleItem = new NumberIniRuleItem(rule, info);
                                }
                                else if (itemXE.HasAttribute("IsStringItem"))
                                {
                                    var rule = new StringIniRuleItem.IniRule
                                    {
                                        IniPath  = iniPath,
                                        Secation = section,
                                        KeyName  = keyName
                                    };
                                    ruleItem = new StringIniRuleItem(rule, info);
                                }
                                else
                                {
                                    var rule = new VisbleIniRuleItem.IniRule
                                    {
                                        IniPath      = iniPath,
                                        Section      = section,
                                        KeyName      = keyName,
                                        TurnOnValue  = ruleXE.HasAttribute("On") ? ruleXE.GetAttribute("On") : null,
                                        TurnOffValue = ruleXE.HasAttribute("Off") ? ruleXE.GetAttribute("Off") : null,
                                    };
                                    ruleItem = new VisbleIniRuleItem(rule, info);
                                }
                            }
                            else
                            {
                                if (itemXE.HasAttribute("IsNumberItem"))
                                {
                                    XmlElement ruleXE = (XmlElement)itemXE.SelectSingleNode("Rule");
                                    var        rule   = new NumberRegRuleItem.RegRule
                                    {
                                        RegPath      = GetRuleFullRegPath(ruleXE.GetAttribute("RegPath")),
                                        ValueName    = ruleXE.GetAttribute("ValueName"),
                                        ValueKind    = GetValueKind(ruleXE.GetAttribute("ValueKind")),
                                        DefaultValue = defaultValue,
                                        MaxValue     = maxValue,
                                        MinValue     = minValue
                                    };
                                    ruleItem = new NumberRegRuleItem(rule, info);
                                }
                                else if (itemXE.HasAttribute("IsStringItem"))
                                {
                                    XmlElement ruleXE = (XmlElement)itemXE.SelectSingleNode("Rule");
                                    var        rule   = new StringRegRuleItem.RegRule
                                    {
                                        RegPath   = GetRuleFullRegPath(ruleXE.GetAttribute("RegPath")),
                                        ValueName = ruleXE.GetAttribute("ValueName"),
                                    };
                                    ruleItem = new StringRegRuleItem(rule, info);
                                }
                                else
                                {
                                    XmlNodeList ruleXNList = itemXE.SelectNodes("Rule");
                                    var         rules      = new VisibleRegRuleItem.RegRule[ruleXNList.Count];
                                    for (int i = 0; i < ruleXNList.Count; i++)
                                    {
                                        XmlElement ruleXE = (XmlElement)ruleXNList[i];
                                        rules[i] = new VisibleRegRuleItem.RegRule
                                        {
                                            RegPath   = GetRuleFullRegPath(ruleXE.GetAttribute("RegPath")),
                                            ValueName = ruleXE.GetAttribute("ValueName"),
                                            ValueKind = GetValueKind(ruleXE.GetAttribute("ValueKind"))
                                        };
                                        string turnOn  = ruleXE.HasAttribute("On") ? ruleXE.GetAttribute("On") : null;
                                        string turnOff = ruleXE.HasAttribute("Off") ? ruleXE.GetAttribute("Off") : null;
                                        switch (rules[i].ValueKind)
                                        {
                                        case RegistryValueKind.Binary:
                                            rules[i].TurnOnValue = turnOn != null?EnhanceMenusList.ConvertToBinary(turnOn) : null;

                                            rules[i].TurnOffValue = turnOff != null?EnhanceMenusList.ConvertToBinary(turnOff) : null;

                                            break;

                                        case RegistryValueKind.DWord:
                                            if (turnOn == null)
                                            {
                                                rules[i].TurnOnValue = null;
                                            }
                                            else
                                            {
                                                rules[i].TurnOnValue = Convert.ToInt32(turnOn);
                                            }
                                            if (turnOff == null)
                                            {
                                                rules[i].TurnOffValue = null;
                                            }
                                            else
                                            {
                                                rules[i].TurnOffValue = Convert.ToInt32(turnOff);
                                            }
                                            break;

                                        default:
                                            rules[i].TurnOnValue  = turnOn;
                                            rules[i].TurnOffValue = turnOff;
                                            break;
                                        }
                                    }
                                    ruleItem = new VisibleRegRuleItem(rules, info);
                                }
                            }
                            this.AddItem(ruleItem);
                            ruleItem.FoldGroupItem = subGroupItem;
                        }
                        catch { continue; }
                    }
                    subGroupItem.HideWhenNoSubItem();
                    subGroupItem.FoldGroupItem = groupItem;
                }
                catch { continue; }
            }
            groupItem.IsFold = true;
            groupItem.HideWhenNoSubItem();
        }
Exemplo n.º 21
0
 private void AddGuidDic()
 {
     using (AddGuidDicDialog dlg = new AddGuidDicDialog())
     {
         dlg.ItemText = GuidInfo.GetText(Item.Guid);
         dlg.ItemIcon = GuidInfo.GetImage(Item.Guid);
         var location = GuidInfo.GetIconLocation(Item.Guid);
         dlg.ItemIconPath  = location.IconPath;
         dlg.ItemIconIndex = location.IconIndex;
         IniWriter writer = new IniWriter
         {
             FilePath            = AppConfig.UserGuidInfosDic,
             DeleteFileWhenEmpty = true
         };
         string section = Item.Guid.ToString();
         if (dlg.ShowDialog() != DialogResult.OK)
         {
             if (dlg.IsDelete)
             {
                 writer.DeleteSection(section);
                 GuidInfo.ItemTextDic.Remove(Item.Guid);
                 GuidInfo.ItemImageDic.Remove(Item.Guid);
                 GuidInfo.IconLocationDic.Remove(Item.Guid);
                 GuidInfo.UserDic.RootDic.Remove(section);
                 ((MyListItem)Item).Text  = Item.ItemText;
                 ((MyListItem)Item).Image = GuidInfo.GetImage(Item.Guid);
             }
             return;
         }
         string name = ResourceString.GetDirectString(dlg.ItemText);
         if (!name.IsNullOrWhiteSpace())
         {
             writer.SetValue(section, "Text", dlg.ItemText);
             ((MyListItem)Item).Text = name;
             if (GuidInfo.ItemTextDic.ContainsKey(Item.Guid))
             {
                 GuidInfo.ItemTextDic[Item.Guid] = name;
             }
             else
             {
                 GuidInfo.ItemTextDic.Add(Item.Guid, name);
             }
         }
         else
         {
             MessageBoxEx.Show(AppString.Message.StringParsingFailed);
             return;
         }
         if (dlg.ItemIconLocation != null)
         {
             writer.SetValue(section, "Icon", dlg.ItemIconLocation);
             location = new GuidInfo.IconLocation {
                 IconPath = dlg.ItemIconPath, IconIndex = dlg.ItemIconIndex
             };
             if (GuidInfo.IconLocationDic.ContainsKey(Item.Guid))
             {
                 GuidInfo.IconLocationDic[Item.Guid] = location;
             }
             else
             {
                 GuidInfo.IconLocationDic.Add(Item.Guid, location);
             }
             ((MyListItem)Item).Image = dlg.ItemIcon;
             if (GuidInfo.ItemImageDic.ContainsKey(Item.Guid))
             {
                 GuidInfo.ItemImageDic[Item.Guid] = dlg.ItemIcon;
             }
             else
             {
                 GuidInfo.ItemImageDic.Add(Item.Guid, dlg.ItemIcon);
             }
         }
     }
 }
Exemplo n.º 22
0
        public void LoadItems()
        {
            this.ClearItems();
            XmlDocument doc1 = new XmlDocument();

            if (!File.Exists(Program.AppDataThirdRulesDicPath))
            {
                File.WriteAllText(Program.AppDataThirdRulesDicPath, Properties.Resources.ThirdRulesDic, Encoding.UTF8);
            }
            doc1.Load(Program.AppDataThirdRulesDicPath);
            if (File.Exists(Program.ThirdRulesDicPath))
            {
                XmlDocument doc2 = new XmlDocument();
                doc2.Load(Program.ThirdRulesDicPath);
                foreach (XmlNode xn in doc2.DocumentElement.ChildNodes)
                {
                    XmlNode node = doc1.ImportNode(xn, true);
                    doc1.DocumentElement.AppendChild(node);
                }
            }
            foreach (XmlElement groupXE in doc1.DocumentElement.ChildNodes)
            {
                if (!GuidInfo.TryGetGuid(groupXE.GetAttribute("Guid"), out Guid guid) &&
                    !groupXE.HasAttribute("Common"))
                {
                    continue;
                }

                GroupPathItem groupItem = new GroupPathItem
                {
                    Text       = groupXE.GetAttribute("Text"),
                    TargetPath = groupXE.GetAttribute("RegPath"),
                    PathType   = ObjectPath.PathType.Registry,
                    Image      = GuidInfo.GetImage(guid),
                };
                if (string.IsNullOrWhiteSpace(groupItem.Text))
                {
                    groupItem.Text = GuidInfo.GetText(guid);
                }
                this.AddItem(groupItem);

                foreach (XmlElement itemXE in groupXE.ChildNodes)
                {
                    RegRuleItem.ItemInfo itemInfo = new RegRuleItem.ItemInfo
                    {
                        Text            = itemXE.GetAttribute("Text"),
                        Tip             = itemXE.GetAttribute("Tip"),
                        RestartExplorer = itemXE.HasAttribute("RestartExplorer"),
                    };

                    XmlNodeList           ruleXNList = itemXE.GetElementsByTagName("Rule");//Rules
                    RegRuleItem.RegRule[] rules      = new RegRuleItem.RegRule[ruleXNList.Count];
                    for (int i = 0; i < ruleXNList.Count; i++)
                    {
                        XmlElement ruleXE = (XmlElement)ruleXNList[i];
                        rules[i] = new RegRuleItem.RegRule
                        {
                            RegPath      = ruleXE.GetAttribute("RegPath"),
                            ValueName    = ruleXE.GetAttribute("ValueName"),
                            TurnOnValue  = ruleXE.GetAttribute("On"),
                            TurnOffValue = ruleXE.GetAttribute("Off"),
                            ValueKind    = GetValueKind(ruleXE.GetAttribute("ValueKind"))
                        };
                        if (string.IsNullOrEmpty(rules[i].RegPath))
                        {
                            rules[i].RegPath = groupItem.TargetPath;
                        }
                        else if (rules[i].RegPath.StartsWith("\\"))
                        {
                            rules[i].RegPath = groupItem.TargetPath + rules[i].RegPath;
                        }
                    }

                    this.AddItem(new RegRuleItem(rules, itemInfo)
                    {
                        FoldGroupItem = groupItem
                    });
                }
                groupItem.IsFold = true;
            }
        }
        public override void LoadItems()
        {
            base.LoadItems();
            int         index = this.UseUserDic ? 1 : 0;
            XmlDocument doc   = XmlDicHelper.DetailedEditDic[index];

            if (doc?.DocumentElement == null)
            {
                return;
            }
            foreach (XmlNode groupXN in doc.DocumentElement.ChildNodes)
            {
                try
                {
                    List <Guid> guids    = new List <Guid>();
                    XmlNodeList guidList = groupXN.SelectNodes("Guid");
                    foreach (XmlNode guidXN in guidList)
                    {
                        if (!GuidEx.TryParse(guidXN.InnerText, out Guid guid))
                        {
                            continue;
                        }
                        if (!File.Exists(GuidInfo.GetFilePath(guid)))
                        {
                            continue;
                        }
                        if (this.GroupGuid != Guid.Empty && this.GroupGuid != guid)
                        {
                            continue;
                        }
                        guids.Add(guid);
                    }
                    if (guidList.Count > 0 && guids.Count == 0)
                    {
                        continue;
                    }

                    FoldGroupItem       groupItem;
                    bool                isIniGroup = groupXN.SelectSingleNode("IsIniGroup") != null;
                    string              attribute  = isIniGroup ? "FilePath" : "RegPath";
                    ObjectPath.PathType pathType   = isIniGroup ? ObjectPath.PathType.File : ObjectPath.PathType.Registry;
                    groupItem = new FoldGroupItem(groupXN.SelectSingleNode(attribute)?.InnerText, pathType);
                    foreach (XmlElement textXE in groupXN.SelectNodes("Text"))
                    {
                        if (XmlDicHelper.JudgeCulture(textXE))
                        {
                            groupItem.Text = ResourceString.GetDirectString(textXE.GetAttribute("Value"));
                        }
                    }
                    if (guids.Count > 0)
                    {
                        groupItem.Tag = guids;
                        if (groupItem.Text.IsNullOrWhiteSpace())
                        {
                            groupItem.Text = GuidInfo.GetText(guids[0]);
                        }
                        groupItem.Image = GuidInfo.GetImage(guids[0]);
                        string filePath  = GuidInfo.GetFilePath(guids[0]);
                        string clsidPath = GuidInfo.GetClsidPath(guids[0]);
                        if (filePath != null || clsidPath != null)
                        {
                            groupItem.ContextMenuStrip.Items.Add(new ToolStripSeparator());
                        }
                        if (filePath != null)
                        {
                            ToolStripMenuItem tsi = new ToolStripMenuItem(AppString.Menu.FileLocation);
                            tsi.Click += (sender, e) => ExternalProgram.JumpExplorer(filePath, AppConfig.OpenMoreExplorer);
                            groupItem.ContextMenuStrip.Items.Add(tsi);
                        }
                        if (clsidPath != null)
                        {
                            ToolStripMenuItem tsi = new ToolStripMenuItem(AppString.Menu.ClsidLocation);
                            tsi.Click += (sender, e) => ExternalProgram.JumpRegEdit(clsidPath, null, AppConfig.OpenMoreRegedit);
                            groupItem.ContextMenuStrip.Items.Add(tsi);
                        }
                    }
                    XmlNode iconXN = groupXN.SelectSingleNode("Icon");
                    using (Icon icon = ResourceIcon.GetIcon(iconXN?.InnerText))
                    {
                        if (icon != null)
                        {
                            groupItem.Image = icon.ToBitmap();
                        }
                    }
                    this.AddItem(groupItem);

                    string GetRuleFullRegPath(string regPath)
                    {
                        if (string.IsNullOrEmpty(regPath))
                        {
                            regPath = groupItem.GroupPath;
                        }
                        else if (regPath.StartsWith("\\"))
                        {
                            regPath = groupItem.GroupPath + regPath;
                        }
                        return(regPath);
                    };

                    foreach (XmlElement itemXE in groupXN.SelectNodes("Item"))
                    {
                        try
                        {
                            if (!XmlDicHelper.JudgeOSVersion(itemXE))
                            {
                                continue;
                            }
                            RuleItem ruleItem;
                            ItemInfo info = new ItemInfo();
                            foreach (XmlElement textXE in itemXE.SelectNodes("Text"))
                            {
                                if (XmlDicHelper.JudgeCulture(textXE))
                                {
                                    info.Text = ResourceString.GetDirectString(textXE.GetAttribute("Value"));
                                }
                            }
                            foreach (XmlElement tipXE in itemXE.SelectNodes("Tip"))
                            {
                                if (XmlDicHelper.JudgeCulture(tipXE))
                                {
                                    info.Tip = ResourceString.GetDirectString(tipXE.GetAttribute("Value"));
                                }
                            }
                            info.RestartExplorer = itemXE.SelectSingleNode("RestartExplorer") != null;

                            int defaultValue = 0, maxValue = 0, minValue = 0;
                            if (itemXE.SelectSingleNode("IsNumberItem") != null)
                            {
                                XmlElement ruleXE = (XmlElement)itemXE.SelectSingleNode("Rule");
                                defaultValue = ruleXE.HasAttribute("Default") ? Convert.ToInt32(ruleXE.GetAttribute("Default")) : 0;
                                maxValue     = ruleXE.HasAttribute("Max") ? Convert.ToInt32(ruleXE.GetAttribute("Max")) : int.MaxValue;
                                minValue     = ruleXE.HasAttribute("Min") ? Convert.ToInt32(ruleXE.GetAttribute("Min")) : int.MinValue;
                            }

                            if (isIniGroup)
                            {
                                XmlElement ruleXE  = (XmlElement)itemXE.SelectSingleNode("Rule");
                                string     iniPath = ruleXE.GetAttribute("FilePath");
                                if (iniPath.IsNullOrWhiteSpace())
                                {
                                    iniPath = groupItem.GroupPath;
                                }
                                string section = ruleXE.GetAttribute("Section");
                                string keyName = ruleXE.GetAttribute("KeyName");
                                if (itemXE.SelectSingleNode("IsNumberItem") != null)
                                {
                                    var rule = new NumberIniRuleItem.IniRule
                                    {
                                        IniPath      = iniPath,
                                        Section      = section,
                                        KeyName      = keyName,
                                        DefaultValue = defaultValue,
                                        MaxValue     = maxValue,
                                        MinValue     = maxValue
                                    };
                                    ruleItem = new NumberIniRuleItem(rule, info);
                                }
                                else if (itemXE.SelectSingleNode("IsStringItem") != null)
                                {
                                    var rule = new StringIniRuleItem.IniRule
                                    {
                                        IniPath  = iniPath,
                                        Secation = section,
                                        KeyName  = keyName
                                    };
                                    ruleItem = new StringIniRuleItem(rule, info);
                                }
                                else
                                {
                                    var rule = new VisbleIniRuleItem.IniRule
                                    {
                                        IniPath      = iniPath,
                                        Section      = section,
                                        KeyName      = keyName,
                                        TurnOnValue  = ruleXE.HasAttribute("On") ? ruleXE.GetAttribute("On") : null,
                                        TurnOffValue = ruleXE.HasAttribute("Off") ? ruleXE.GetAttribute("Off") : null,
                                    };
                                    ruleItem = new VisbleIniRuleItem(rule, info);
                                }
                            }
                            else
                            {
                                if (itemXE.SelectSingleNode("IsNumberItem") != null)
                                {
                                    XmlElement ruleXE = (XmlElement)itemXE.SelectSingleNode("Rule");
                                    var        rule   = new NumberRegRuleItem.RegRule
                                    {
                                        RegPath      = GetRuleFullRegPath(ruleXE.GetAttribute("RegPath")),
                                        ValueName    = ruleXE.GetAttribute("ValueName"),
                                        ValueKind    = XmlDicHelper.GetValueKind(ruleXE.GetAttribute("ValueKind"), RegistryValueKind.DWord),
                                        DefaultValue = defaultValue,
                                        MaxValue     = maxValue,
                                        MinValue     = minValue
                                    };
                                    ruleItem = new NumberRegRuleItem(rule, info);
                                }
                                else if (itemXE.SelectSingleNode("IsStringItem") != null)
                                {
                                    XmlElement ruleXE = (XmlElement)itemXE.SelectSingleNode("Rule");
                                    var        rule   = new StringRegRuleItem.RegRule
                                    {
                                        RegPath   = GetRuleFullRegPath(ruleXE.GetAttribute("RegPath")),
                                        ValueName = ruleXE.GetAttribute("ValueName"),
                                    };
                                    ruleItem = new StringRegRuleItem(rule, info);
                                }
                                else
                                {
                                    XmlNodeList ruleXNList = itemXE.SelectNodes("Rule");
                                    var         rules      = new VisibleRegRuleItem.RegRule[ruleXNList.Count];
                                    for (int i = 0; i < ruleXNList.Count; i++)
                                    {
                                        XmlElement ruleXE = (XmlElement)ruleXNList[i];
                                        rules[i] = new VisibleRegRuleItem.RegRule
                                        {
                                            RegPath   = GetRuleFullRegPath(ruleXE.GetAttribute("RegPath")),
                                            ValueName = ruleXE.GetAttribute("ValueName"),
                                            ValueKind = XmlDicHelper.GetValueKind(ruleXE.GetAttribute("ValueKind"), RegistryValueKind.DWord)
                                        };
                                        string turnOn  = ruleXE.HasAttribute("On") ? ruleXE.GetAttribute("On") : null;
                                        string turnOff = ruleXE.HasAttribute("Off") ? ruleXE.GetAttribute("Off") : null;
                                        switch (rules[i].ValueKind)
                                        {
                                        case RegistryValueKind.Binary:
                                            rules[i].TurnOnValue = turnOn != null?XmlDicHelper.ConvertToBinary(turnOn) : null;

                                            rules[i].TurnOffValue = turnOff != null?XmlDicHelper.ConvertToBinary(turnOff) : null;

                                            break;

                                        case RegistryValueKind.DWord:
                                            if (turnOn == null)
                                            {
                                                rules[i].TurnOnValue = null;
                                            }
                                            else
                                            {
                                                rules[i].TurnOnValue = Convert.ToInt32(turnOn);
                                            }
                                            if (turnOff == null)
                                            {
                                                rules[i].TurnOffValue = null;
                                            }
                                            else
                                            {
                                                rules[i].TurnOffValue = Convert.ToInt32(turnOff);
                                            }
                                            break;

                                        default:
                                            rules[i].TurnOnValue  = turnOn;
                                            rules[i].TurnOffValue = turnOff;
                                            break;
                                        }
                                    }
                                    ruleItem = new VisibleRegRuleItem(rules, info);
                                }
                            }
                            this.AddItem(ruleItem);
                            ruleItem.FoldGroupItem = groupItem;
                            ruleItem.HasImage      = ruleItem.Image != null;
                            ruleItem.Indent();
                        }
                        catch { continue; }
                    }
                    groupItem.SetVisibleWithSubItemCount();
                }
                catch { continue; }
            }
        }