/// <param name="parentPath">子菜单的父菜单的注册表路径</param> public ShellSubMenuForm(string parentPath) { this.ShowInTaskbar = false; this.StartPosition = FormStartPosition.CenterParent; this.MinimumSize = this.Size = new Size(646, 389).DpiZoom(); LstSubItems = new MyListBox { Dock = DockStyle.Fill, Parent = this }; string value = GetValue(parentPath, "SubCommands", null)?.ToString(); if (string.IsNullOrWhiteSpace(value)) { using (var shellKey = RegistryEx.GetRegistryKey($@"{parentPath}\shell")) { if (shellKey != null && shellKey.GetSubKeyNames().Length > 0) { new MultiItemsList(LstSubItems).LoadItems(parentPath); return; } else { using (SubMenuModeForm frm = new SubMenuModeForm()) { frm.ShowDialog(); if (frm.SubMenuMode == 1) { new MultiItemsList(LstSubItems).LoadItems(parentPath); return; } } } } } new CommonMultiItemsList(LstSubItems).LoadItems(parentPath); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); bool isPublic = true; string value = GetValue(ParentPath, "SubCommands", null)?.ToString(); if (value.IsNullOrWhiteSpace()) { using (var shellKey = RegistryEx.GetRegistryKey($@"{ParentPath}\shell")) { if (shellKey != null && shellKey.GetSubKeyNames().Length > 0) { isPublic = false; } else { using (SubMenuModeForm frm = new SubMenuModeForm()) { frm.ShowDialog(); switch (frm.Mode) { case SubMenuModeForm.SubMode.Public: isPublic = true; break; case SubMenuModeForm.SubMode.Private: isPublic = false; break; case SubMenuModeForm.SubMode.None: this.Dispose(); return; } } } } } if (isPublic) { new PulicMultiItemsList(MlbSubItems).LoadItems(ParentPath); this.Text += $"({AppString.Dialog.Public})"; } else { new PrivateMultiItemsList(MlbSubItems).LoadItems(ParentPath); this.Text += $"({AppString.Dialog.Private})"; } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); bool isPublic = true; string value = GetValue(ParentPath, "SubCommands", null)?.ToString(); if (value == null) { isPublic = false; } else if (value.IsNullOrWhiteSpace()) { using (var shellKey = RegistryEx.GetRegistryKey($@"{ParentPath}\shell")) { if (shellKey != null && shellKey.GetSubKeyNames().Length > 0) { isPublic = false; } else { using (SubMenuModeForm frm = new SubMenuModeForm()) { frm.ShowDialog(); switch (frm.Mode) { case SubMenuModeForm.SubMode.Public: isPublic = true; break; case SubMenuModeForm.SubMode.Private: isPublic = false; break; case SubMenuModeForm.SubMode.None: this.Dispose(); return; } } } } } if (isPublic) { LstSubItems = new PulicMultiItemsList(MlbSubItems); ((PulicMultiItemsList)LstSubItems).LoadItems(ParentPath); this.Text += $"({AppString.Dialog.Public})"; } else { LstSubItems = new PrivateMultiItemsList(MlbSubItems); ((PrivateMultiItemsList)LstSubItems).LoadItems(ParentPath); this.Text += $"({AppString.Dialog.Private})"; } LstSubItems.HoveredItemChanged += (sender, a) => { if (!AppConfig.ShowFilePath) { return; } MyListItem item = LstSubItems.HoveredItem; if (item is ITsiFilePathItem pathItem) { string path = pathItem.ItemFilePath; if (File.Exists(path)) { StatusBar.Text = path; return; } } StatusBar.Text = item.Text; }; }