public void RegisterItem(ToolStripPath path, IToolStripItemCodon toolStripItem) { ToolStripItem view = (ToolStripItem)toolStripItem.View; if (path.PathPoints.Count == 1) { if (path.PathPoints[0].Index.HasValue) { int index = path.PathPoints[0].Index.Value; if (index >= this.Items.Count) { index = this.Items.Count; } this.Items.Insert(index, view); } else { this.Items.Add(view); } } else { ToolStripMenuItemView targetItem = null; ToolStripItemCollection targetItemCollection = this.Items; for (int i = 1; i < path.PathPoints.Count; i++) { foreach (ToolStripMenuItemView targetItemDoozer in targetItemCollection) { IToolStripItemView doozer = targetItemDoozer as IToolStripItemView; if (doozer == null) { continue; } if (doozer.Codon.PathPoint == path.PathPoints[i].Name) { targetItem = targetItemDoozer; targetItemCollection = targetItemDoozer.DropDownItems; break; } } } if (targetItem != null) { if (path.PathPoints[path.PathPoints.Count - 1].Index.HasValue) { int index = path.PathPoints[path.PathPoints.Count - 1].Index.Value; if (index >= targetItem.DropDownItems.Count) { index = targetItem.DropDownItems.Count; } targetItem.DropDownItems.Insert(index, view); } else { targetItem.DropDownItems.Add(view); } } } }
public void RegisterItem(ToolStripPath path, IToolStripItemCodon toolStripItem) { ToolStripView toolStrip = this.GetToolStrip(path.PathPoints[0].Name); if (toolStrip == null && path.PathPoints.Count == 1) { toolStrip = this.CreateToolStrip(path.PathPoints[0].Name); } toolStrip.RegisterItem(path.Cut(0), toolStripItem); }
public ToolStripPath Cut(int index) { ToolStripPath newPath = new ToolStripPath(); for (int i = index; i < _pathPoints.Count; i++) { newPath.PathPoints.Add(_pathPoints[i]); } return(newPath); }
public void RegisterItem(string path, IToolStripItemCodon item) { if (String.IsNullOrEmpty(path) || item == null) { Debug.Assert(false, "RegisterToolStripItem,没有指定path或toolStripItem"); return; } ToolStripPath toolStripPath = new ToolStripPath(path); if (toolStripPath.IsEmpty) { Debug.Assert(false, "RegisterToolStripItem,toolStripPath.IsEmpty"); return; } IToolStripDropDownItemCodon targetItem = null; ToolStripItemCodonCollection targetItemCollection = this; for (int i = 0; i < toolStripPath.PathPoints.Count; i++) { foreach (IToolStripItemCodon targetItemCodon in targetItemCollection) { if (targetItemCodon.PathPoint == toolStripPath.PathPoints[i].Name && targetItemCodon is IToolStripDropDownItemCodon) { targetItem = targetItemCodon as IToolStripDropDownItemCodon; targetItemCollection = targetItem.Items; break; } } } if (targetItem != null) { if (toolStripPath.PathPoints[toolStripPath.PathPoints.Count - 1].Index.HasValue) { int index = toolStripPath.PathPoints[toolStripPath.PathPoints.Count - 1].Index.Value; if (index >= targetItem.Items.Count) { index = targetItem.Items.Count; } targetItem.Items.Insert(index, item); } else { targetItem.Items.Add(item); } } }
public void RegisterItem(ToolStripPath path, IToolStripItemCodon toolStripItem) { if (path.PathPoints.Count > 1) { throw new NotImplementedException("工具栏暂不支持多级注册项"); } toolStripItem.Owner = this.Codon; ToolStripMenuItemView item = toolStripItem.View as ToolStripMenuItemView; if (path.PathPoints[0].Index.HasValue) { this.Items.Insert(path.PathPoints[0].Index.Value, item); } else { this.Items.Add(item); } }
public ItemRegisterEventArgs(ToolStripPath path, IToolStripItemCodon codon, ToolStripItem item) { Path = path; Codon = codon; Item = item; }