/// <param name="parentPath">子菜单的父菜单的注册表路径</param> public void LoadItems(string parentPath) { this.ParentPath = parentPath; string value = GetValue(ParentPath, "SubCommands", null)?.ToString(); Array.ForEach(value.Split(';'), cmd => SubKeyNames.Add(cmd.TrimStart())); SubKeyNames.RemoveAll(string.IsNullOrEmpty); using (var shellKey = RegistryEx.GetRegistryKey(ShellItem.CommandStorePath, false, true)) { foreach (string keyName in SubKeyNames) { using (var key = shellKey.OpenSubKey(keyName)) { MyListItem item; if (key != null) { item = new SubShellItem(this, keyName); } else if (keyName == "|") { item = new SeparatorItem(this); } else { item = new InvalidItem(this, keyName); } this.AddItem(item); } } } }
private void AddSeparator() { this.SubKeyNames.Add("|"); WriteRegistry(); SeparatorItem item = new SeparatorItem(this); this.AddItem(item); this.HoveredItem = item; }
public override object Add(SeparatorItem item) { return(null); }
public override void Add(SeparatorItem item) { }
/// <summary> /// Adds a visible separator. /// </summary> /// <param name="item">The item.</param> public override void Add(SeparatorItem item) { Guard.ArgumentNotNull(item, "item"); _nextItemBeginsGroup = true; }
/// <summary> /// Sets up the handler to respond to buttons pressed on a ribbon or toolbar. /// </summary> private void AddButtons() { const string ShapeEditorMenuKey = "kShapeEditor"; SeparatorItem separatorMove = new SeparatorItem(ShapeEditorMenuKey, "Shape Editor"); SeparatorItem separatorSnap = new SeparatorItem(ShapeEditorMenuKey, "Shape Editor"); _header.Add(new RootItem(ShapeEditorMenuKey, "Shape Editing")); _newShapeFile = new SimpleActionItem(ShapeEditorMenuKey, ShapeEditorResources.New, NewButtonClick) { GroupCaption = "Shape Editor", SmallImage = ShapeEditorResources.NewShapefile.ToBitmap(), RootKey = HeaderControl.HomeRootItemKey }; _header.Add(_newShapeFile); _addShape = new SimpleActionItem(ShapeEditorMenuKey, ShapeEditorResources.Add_Shape, AddShapeButtonClick) { GroupCaption = "Shape Editor", SmallImage = ShapeEditorResources.NewShape.ToBitmap(), RootKey = HeaderControl.HomeRootItemKey }; _header.Add(_addShape); _header.Add(separatorMove); _moveVertex = new SimpleActionItem(ShapeEditorMenuKey, ShapeEditorResources.Move_Vertex, MoveVertexButtonClick) { GroupCaption = "Shape Editor", SmallImage = ShapeEditorResources.move, RootKey = HeaderControl.HomeRootItemKey }; _header.Add(_moveVertex); _shapeDraggingActivButton = new SimpleActionItem(ShapeEditorMenuKey, ShapeEditorResources.ShapeDragging_InActive, ShapeDraggingActivButtonClick) { GroupCaption = "Shape Editor", Enabled = false, SmallImage = System.Drawing.SystemIcons.Asterisk.ToBitmap() }; _header.Add(_shapeDraggingActivButton); _showVerticesCheck = new CheckBoxActionItem(ShapeEditorMenuKey, ShapeEditorResources.ShowVerticesIndex_Label, ShowVerticesActivCheckChanged) { GroupCaption = "Shape Editor", Caption = ShapeEditorResources.ShowVerticesIndex_Label, Checked = false, ToolTipText = ShapeEditorResources.ShowVerticesIndex_InActive, RootKey = HeaderControl.HomeRootItemKey }; _showVerticesCheck.CheckedChanged += ShowVerticesActivCheckChanged; _header.Add(_showVerticesCheck); _header.Add(separatorSnap); _snapping = new SimpleActionItem(ShapeEditorMenuKey, ShapeEditorResources.Snapping_Settings, SnappingButtonClick) { GroupCaption = "Shape Editor", SmallImage = ShapeEditorResources.SnappingIcon.ToBitmap(), RootKey = HeaderControl.HomeRootItemKey }; _header.Add(_snapping); _snappingActivCheck = new CheckBoxActionItem(ShapeEditorMenuKey, ShapeEditorResources.Snapping_Label, SnappingActivCheckChanged) { GroupCaption = "Shape Editor", Caption = ShapeEditorResources.Snapping_Label, Checked = true, ToolTipText = ShapeEditorResources.Snapping_Active, RootKey = HeaderControl.HomeRootItemKey }; _snappingActivCheck.CheckedChanged += SnappingActivCheckChanged; _header.Add(_snappingActivCheck); }