public override void LoadItems() { base.LoadItems(); int index = this.UseUserDic ? 1 : 0; XmlDocument doc = XmlDicHelper.EnhanceMenusDic[index]; if (doc?.DocumentElement == null) { return; } foreach (XmlNode xn in doc.DocumentElement.ChildNodes) { try { Image image = null; string text = null; string path = xn.SelectSingleNode("RegPath")?.InnerText; foreach (XmlElement textXE in xn.SelectNodes("Text")) { if (XmlDicHelper.JudgeCulture(textXE)) { text = ResourceString.GetDirectString(textXE.GetAttribute("Value")); } } if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(text)) { continue; } if (!string.IsNullOrEmpty(this.ScenePath) && !path.Equals(this.ScenePath, StringComparison.OrdinalIgnoreCase)) { continue; } string iconLocation = xn.SelectSingleNode("Icon")?.InnerText; using (Icon icon = ResourceIcon.GetIcon(iconLocation)) { image = icon?.ToBitmap(); image = image ?? AppImage.NotFound; } FoldGroupItem groupItem = new FoldGroupItem(path, ObjectPath.PathType.Registry) { Image = image, Text = text }; this.AddItem(groupItem); XmlNode shellXN = xn.SelectSingleNode("Shell"); XmlNode shellExXN = xn.SelectSingleNode("ShellEx"); if (shellXN != null) { LoadShellItems(shellXN, groupItem); } if (shellExXN != null) { LoadShellExItems(shellExXN, groupItem); } groupItem.SetVisibleWithSubItemCount(); } catch { continue; } } }
public ChangeIconMenuItem(ITsiIconItem item) : base(AppString.Menu.ChangeIcon) { this.Click += (sender, e) => { using (IconDialog dlg = new IconDialog()) { dlg.IconPath = item.IconPath; dlg.IconIndex = item.IconIndex; if (dlg.ShowDialog() != DialogResult.OK) { return; } using (Icon icon = ResourceIcon.GetIcon(dlg.IconPath, dlg.IconIndex)) { Image image = icon?.ToBitmap(); if (image == null) { return; } item.Image = image; item.IconPath = dlg.IconPath; item.IconIndex = dlg.IconIndex; item.IconLocation = $"{dlg.IconPath},{dlg.IconIndex}"; } } }; }
public static Image GetImage(Guid guid) { if (ItemImageDic.TryGetValue(guid, out Image image)) { return(image); } IconLocation location = GetIconLocation(guid); string iconPath = location.IconPath; int iconIndex = location.IconIndex; if (iconPath == null && iconIndex == 0) { image = AppImage.DllDefaultIcon; } else if (Path.GetFileName(iconPath).ToLower() == "shell32.dll" && iconIndex == 0) { image = AppImage.DllDefaultIcon; } else { image = ResourceIcon.GetIcon(iconPath, iconIndex)?.ToBitmap() ?? AppImage.DllDefaultIcon; } ItemImageDic.Add(guid, image); return(image); }
public ChangeIconMenuItem(ITsiIconItem item) : base(AppString.Menu.ChangeIcon) { this.Click += (sender, e) => { using (IconDialog dlg = new IconDialog()) { dlg.IconPath = item.IconPath; dlg.IconIndex = item.IconIndex; if (dlg.ShowDialog() != DialogResult.OK) { return; } item.IconPath = dlg.IconPath; item.IconIndex = dlg.IconIndex; item.IconLocation = $"{dlg.IconPath},{dlg.IconIndex}"; using (Icon icon = ResourceIcon.GetIcon(dlg.IconPath, dlg.IconIndex)) { item.Image = icon.ToBitmap(); } } }; MyListItem listItem = (MyListItem)item; listItem.Disposed += (sender, e) => item.ItemIcon?.Dispose(); listItem.ImageDoubleClick += (sender, e) => { if (this.Enabled) { this.OnClick(null); } }; }
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); } }
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); } }
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); } }
public static Icon ChangeIcon(ref string iconPath, ref int iconIndex) { using (IconDialog dlg = new IconDialog { IconPath = iconPath, IconIndex = iconIndex }) { if (dlg.ShowDialog() != DialogResult.OK) { return(null); } iconPath = dlg.IconPath; iconIndex = dlg.IconIndex; } return(ResourceIcon.GetIcon(iconPath, iconIndex)); }
private void SelectIcon() { using (IconDialog dlg = new IconDialog()) { dlg.IconPath = this.ItemIconPath; dlg.IconIndex = this.ItemIconIndex; if (dlg.ShowDialog() != DialogResult.OK) { return; } ItemIconPath = dlg.IconPath; ItemIconIndex = dlg.IconIndex; picIcon.Image = ResourceIcon.GetIcon(ItemIconPath, ItemIconIndex).ToBitmap(); } }
private void LoadShellItems(XmlElement shellXE, GroupPathItem groupItem) { foreach (XmlElement itemXE in shellXE.GetElementsByTagName("Item")) { XmlElement verXE = (XmlElement)itemXE.SelectSingleNode("OSVersion"); if (!JudgeOSVersion(verXE)) { continue; } XmlElement szXE = (XmlElement)itemXE.SelectSingleNode("Value/REG_SZ"); string keyName = itemXE.GetAttribute("KeyName"); if (keyName.IsNullOrWhiteSpace()) { continue; } string regPath = $@"{groupItem.TargetPath}\shell\{keyName}"; EnhanceShellItem item = new EnhanceShellItem() { RegPath = $@"{groupItem.TargetPath}\shell\{keyName}", FoldGroupItem = groupItem, ItemXE = itemXE }; if (szXE != null) { item.Text = ResourceString.GetDirectString(szXE.GetAttribute("MUIVerb")); if (szXE.HasAttribute("Icon")) { item.Image = ResourceIcon.GetIcon(szXE.GetAttribute("Icon"))?.ToBitmap(); } else if (szXE.HasAttribute("HasLUAShield")) { item.Image = AppImage.Shield; } } if (item.Image == null) { item.Image = AppImage.NotFound; } if (item.Text.IsNullOrWhiteSpace()) { item.Text = keyName; } item.ChkVisible.Checked = item.ItemVisible; MyToolTip.SetToolTip(item.ChkVisible, itemXE.GetAttribute("Tip")); this.AddItem(item); } }
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); }
private void LoadShellItems() { foreach (XmlElement itemXE in shellXE.GetElementsByTagName("Item")) { XmlElement szXE = (XmlElement)itemXE.SelectSingleNode("Value/REG_SZ"); string keyName = itemXE.GetAttribute("KeyName"); if (string.IsNullOrWhiteSpace(keyName)) { continue; } ShellCommonItem item = new ShellCommonItem { DefaultKeyName = keyName, ItemXE = itemXE }; if (szXE != null) { item.Text = ResourceString.GetDirectString(szXE.GetAttribute("MUIVerb")); if (szXE.HasAttribute("Icon")) { item.Image = ResourceIcon.GetIcon(szXE.GetAttribute("Icon"))?.ToBitmap(); } else if (szXE.HasAttribute("HasLUAShield")) { item.Image = AppImage.Shield; } } if (item.Image == null) { item.Image = AppImage.NotFound; } if (string.IsNullOrWhiteSpace(item.Text)) { item.Text = item.DefaultKeyName; } item.SetTip(itemXE.GetAttribute("Tip")); list.AddItem(item); } }
private void SelectIcon() { using (IconDialog dlg = new IconDialog()) { dlg.IconPath = this.ItemIconPath; dlg.IconIndex = this.ItemIconIndex; if (dlg.ShowDialog() != DialogResult.OK) { return; } using (Icon icon = ResourceIcon.GetIcon(dlg.IconPath, dlg.IconIndex)) { Image image = icon?.ToBitmap(); if (image == null) { return; } picIcon.Image = image; this.ItemIconPath = dlg.IconPath; this.ItemIconIndex = dlg.IconIndex; } } }
private GroupPathItem GetGroupPathItem(XmlNode xn) { string path; string text; Image image; switch (xn.Name) { case "File": path = ShellList.MENUPATH_FILE; text = AppString.SideBar.File; image = AppImage.File; break; case "Folder": path = ShellList.MENUPATH_FOLDER; text = AppString.SideBar.Folder; image = AppImage.Folder; break; case "Directory": path = ShellList.MENUPATH_FOLDER; text = AppString.SideBar.Directory; image = AppImage.Directory; break; case "Background": path = ShellList.MENUPATH_BACKGROUND; text = AppString.SideBar.Background; image = AppImage.Background; break; case "Desktop": path = ShellList.MENUPATH_DESKTOP; //Vista没有桌面右键菜单的独立注册表项 if (WindowsOsVersion.IsEqualVista) { path = ShellList.MENUPATH_BACKGROUND; } text = AppString.SideBar.Desktop; image = AppImage.Desktop; break; case "Drive": path = ShellList.MENUPATH_DRIVE; text = AppString.SideBar.Drive; image = AppImage.Drive; break; case "AllObjects": path = ShellList.MENUPATH_ALLOBJECTS; text = AppString.SideBar.AllObjects; image = AppImage.AllObjects; break; case "Computer": path = ShellList.MENUPATH_COMPUTER; text = AppString.SideBar.Computer; image = AppImage.Computer; break; case "RecycleBin": path = ShellList.MENUPATH_RECYCLEBIN; text = AppString.SideBar.RecycleBin; image = AppImage.RecycleBin; break; default: XmlElement xe = (XmlElement)xn; path = xe.GetAttribute("RegPath"); text = ResourceString.GetDirectString(xe.GetAttribute("Text")); if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(text)) { return(null); } image = ResourceIcon.GetIcon(xe.GetAttribute("Icon"))?.ToBitmap() ?? AppImage.NotFound; break; } GroupPathItem groupItem = new GroupPathItem(path, ObjectPath.PathType.Registry) { Image = image, Text = text }; return(groupItem); }
private void LoadShellItems(XmlElement shellXE, GroupPathItem groupItem) { foreach (XmlElement itemXE in shellXE.SelectNodes("Item")) { if (!JudgeOSVersion(itemXE)) { continue; } if (!FileExists(itemXE)) { continue; } XmlElement szXE = (XmlElement)itemXE.SelectSingleNode("Value/REG_SZ"); string keyName = itemXE.GetAttribute("KeyName"); if (keyName.IsNullOrWhiteSpace()) { continue; } EnhanceShellItem item = new EnhanceShellItem() { RegPath = $@"{groupItem.TargetPath}\shell\{keyName}", FoldGroupItem = groupItem, ItemXE = itemXE }; if (szXE != null) { item.Text = ResourceString.GetDirectString(szXE.GetAttribute("MUIVerb")); if (szXE.HasAttribute("Icon")) { item.Image = ResourceIcon.GetIcon(szXE.GetAttribute("Icon"))?.ToBitmap(); } else if (szXE.HasAttribute("HasLUAShield")) { item.Image = AppImage.Shield; } else { XmlElement cmdXE = (XmlElement)itemXE.SelectSingleNode("SubKey/Command"); if (cmdXE != null) { Icon icon = null; if (cmdXE.HasAttribute("Default")) { string filePath = ObjectPath.ExtractFilePath(cmdXE.GetAttribute("Default")); icon = ResourceIcon.GetIcon(filePath); } item.Image = icon?.ToBitmap(); icon?.Dispose(); } } } if (item.Image == null) { item.Image = AppImage.NotFound; } if (item.Text.IsNullOrWhiteSpace()) { item.Text = keyName; } item.ChkVisible.Checked = item.ItemVisible; string tip = itemXE.GetAttribute("Tip"); if (itemXE.GetElementsByTagName("CreateFile").Count > 0) { if (!tip.IsNullOrWhiteSpace()) { tip += "\n"; } tip += AppString.Tip.CommandFiles; if (System.Diagnostics.Debugger.IsAttached) { item.ChkVisible.Checked = item.ItemVisible = true; } } MyToolTip.SetToolTip(item.ChkVisible, tip); this.AddItem(item); } }
public void LoadItems() { try { foreach (XmlNode xn in ReadXml().DocumentElement.ChildNodes) { string path = null; string text = null; Image image = null; switch (xn.Name) { case "File": path = ShellList.MENUPATH_FILE; text = AppString.SideBar.File; image = AppImage.File; break; case "Folder": path = ShellList.MENUPATH_FOLDER; text = AppString.SideBar.Folder; image = AppImage.Folder; break; case "Directory": path = ShellList.MENUPATH_FOLDER; text = AppString.SideBar.Directory; image = AppImage.Directory; break; case "Background": path = ShellList.MENUPATH_BACKGROUND; text = AppString.SideBar.Background; image = AppImage.Background; break; case "Desktop": path = ShellList.MENUPATH_DESKTOP; //Vista没有桌面右键菜单的独立注册表项 if (WindowsOsVersion.IsEqualVista) { path = ShellList.MENUPATH_BACKGROUND; } text = AppString.SideBar.Desktop; image = AppImage.Desktop; break; case "Drive": path = ShellList.MENUPATH_DRIVE; text = AppString.SideBar.Drive; image = AppImage.Drive; break; case "AllObjects": path = ShellList.MENUPATH_ALLOBJECTS; text = AppString.SideBar.AllObjects; image = AppImage.AllObjects; break; case "Computer": path = ShellList.MENUPATH_COMPUTER; text = AppString.SideBar.Computer; image = AppImage.Computer; break; case "RecycleBin": path = ShellList.MENUPATH_RECYCLEBIN; text = AppString.SideBar.RecycleBin; image = AppImage.RecycleBin; break; default: XmlElement xe = (XmlElement)xn; path = xe.GetAttribute("RegPath"); text = ResourceString.GetDirectString(xe.GetAttribute("Text")); image = ResourceIcon.GetIcon(xe.GetAttribute("Icon"))?.ToBitmap() ?? AppImage.NotFound; break; } if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(text)) { continue; } GroupPathItem groupItem = new GroupPathItem(path, ObjectPath.PathType.Registry) { Image = image, Text = text, }; this.AddItem(groupItem); XmlElement shellXE = (XmlElement)xn.SelectSingleNode("Shell"); XmlElement shellExXE = (XmlElement)xn.SelectSingleNode("ShellEx"); if (shellXE != null) { LoadShellItems(shellXE, groupItem); } if (shellExXE != null) { LoadShellExItems(shellExXE, groupItem); } groupItem.IsFold = true; } } catch { } }
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; } } }
private static Image GetIconImage(string dllName, int iconIndex) { using (Icon icon = ResourceIcon.GetIcon(dllName, iconIndex)) return(icon?.ToBitmap()); }
private void LoadShellItems(XmlNode shellXN, FoldGroupItem groupItem) { foreach (XmlElement itemXE in shellXN.SelectNodes("Item")) { if (!XmlDicHelper.FileExists(itemXE)) { continue; } if (!XmlDicHelper.JudgeCulture(itemXE)) { continue; } if (!XmlDicHelper.JudgeOSVersion(itemXE)) { continue; } string keyName = itemXE.GetAttribute("KeyName"); if (keyName.IsNullOrWhiteSpace()) { continue; } EnhanceShellItem item = new EnhanceShellItem() { RegPath = $@"{groupItem.GroupPath}\shell\{keyName}", FoldGroupItem = groupItem, ItemXE = itemXE }; foreach (XmlElement szXE in itemXE.SelectNodes("Value/REG_SZ")) { if (!XmlDicHelper.JudgeCulture(szXE)) { continue; } if (szXE.HasAttribute("MUIVerb")) { item.Text = ResourceString.GetDirectString(szXE.GetAttribute("MUIVerb")); } if (szXE.HasAttribute("Icon")) { item.Image = ResourceIcon.GetIcon(szXE.GetAttribute("Icon"))?.ToBitmap(); } else if (szXE.HasAttribute("HasLUAShield")) { item.Image = AppImage.Shield; } } if (item.Image == null) { XmlElement cmdXE = (XmlElement)itemXE.SelectSingleNode("SubKey/Command"); if (cmdXE != null) { Icon icon = null; if (cmdXE.HasAttribute("Default")) { string filePath = ObjectPath.ExtractFilePath(cmdXE.GetAttribute("Default")); icon = ResourceIcon.GetIcon(filePath); } else { XmlNode fileXE = cmdXE.SelectSingleNode("FileName"); if (fileXE != null) { string filePath = ObjectPath.ExtractFilePath(fileXE.InnerText); icon = ResourceIcon.GetIcon(filePath); } } item.Image = icon?.ToBitmap(); icon?.Dispose(); } } if (item.Image == null) { item.Image = AppImage.NotFound; } if (item.Text.IsNullOrWhiteSpace()) { item.Text = keyName; } string tip = ""; foreach (XmlElement tipXE in itemXE.SelectNodes("Tip")) { if (XmlDicHelper.JudgeCulture(tipXE)) { tip = tipXE.GetAttribute("Value"); } } if (itemXE.GetElementsByTagName("CreateFile").Count > 0) { if (!tip.IsNullOrWhiteSpace()) { tip += "\n"; } tip += AppString.Tip.CommandFiles; } ToolTipBox.SetToolTip(item.ChkVisible, tip); this.AddItem(item); } }