本文整理汇总了C#中System.Windows.Forms.ToolStripItemCollection类的典型用法代码示例。如果您正苦于以下问题:C# ToolStripItemCollection类的具体用法?C# ToolStripItemCollection怎么用?C# ToolStripItemCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ToolStripItemCollection类属于System.Windows.Forms命名空间,在下文中一共展示了ToolStripItemCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopulateItems
private static void PopulateItems(ToolStripItemCollection items, IEnumerable<CommandMenuGroup> groups, CommandRegistry registry)
{
List<CommandMenuGroup> groupList = groups as List<CommandMenuGroup>;
if (groupList == null)
groupList = new List<CommandMenuGroup>(groups);
foreach (CommandMenuGroup group in groupList) {
if (group != groupList[0])
items.Add(new ToolStripSeparator());
foreach (CommandMenuEntry entry in group) {
if (entry.SubMenu != null)
items.Add(BuildToolStripMenu(entry.SubMenu, registry));
else {
CommandRecord record = registry.Lookup(entry.Key);
if (record != null) {
ToolStripMenuItem menuItem = new ToolStripMenuItem() {
Tag = new CommandMenuTag(entry.Key, entry.Param),
Text = record.DisplayName,
Image = record.Image,
ShortcutKeys = record.Shortcut,
ShortcutKeyDisplayString = record.ShortcutDisplay,
ToolTipText = record.Description,
};
if (entry.Default)
menuItem.Font = new Font(menuItem.Font, menuItem.Font.Style | FontStyle.Bold);
items.Add(menuItem);
}
}
}
}
}
示例2: SetToolStripState
//////////////////////////////////////////////////////////////////////////
public void SetToolStripState(ToolStripItemCollection Items)
{
foreach(ToolStripItem Item in Items)
{
string ActName = Item.Tag as string;
if (ActName != null)
{
Action.State St = ActContext.GetState(ActName);
Item.Enabled = ((St & Action.State.Disabled) != Action.State.Disabled);
Item.Visible = ((St & Action.State.Hidden) != Action.State.Hidden);
if (Item is ToolStripButton)
((ToolStripButton)Item).Checked = ((St & Action.State.Checked) == Action.State.Checked);
else if (Item is ToolStripMenuItem)
((ToolStripMenuItem)Item).Checked = ((St & Action.State.Checked) == Action.State.Checked);
}
if(Item is ToolStripDropDownItem)
{
SetToolStripState(((ToolStripDropDownItem)Item).DropDownItems);
}
}
}
示例3: FillMenuItems
private static void FillMenuItems(List<MySQL.Base.MenuItem> itemsBE, ToolStripItemCollection itemsFE)
{
foreach (MySQL.Base.MenuItem itemBE in itemsBE)
{
switch (itemBE.get_type())
{
case MySQL.Base.MenuItemType.MenuSeparator:
{
itemsFE.Add(new ToolStripSeparator());
}
break;
default:
{
ToolStripMenuItem itemFE = new ToolStripMenuItem();
itemFE.Tag = itemBE.get_name();
itemFE.Text = itemBE.get_caption();
itemFE.Enabled = itemBE.get_enabled();
if (MySQL.Base.MenuItemType.MenuCascade == itemBE.get_type())
{
FillMenuItems(itemBE.get_subitems(), itemFE.DropDownItems);
}
else
{
itemFE.Click += new EventHandler(OnMenuItemClick);
}
itemsFE.Add(itemFE);
}
break;
}
}
}
示例4: ToolController
public ToolController(ToolStripItemCollection collection, Viewport viewport, Project project)
{
Tools = collection;
Viewport = viewport;
Viewport.Input.MouseClick += ViewportClick;
Project = project;
}
示例5: BuildMenuContentsForGroup
private static int BuildMenuContentsForGroup(int index, ICommandTarget target, ToolStripItemCollection children, IPoderosaMenuGroup grp) {
int count = 0;
foreach (IPoderosaMenu m in grp.ChildMenus) {
ToolStripMenuItem mi = new ToolStripMenuItem();
children.Insert(index++, mi); //途中挿入のことも
mi.DropDownOpening += new EventHandler(OnPopupMenu);
mi.Enabled = m.IsEnabled(target);
mi.Checked = mi.Enabled ? m.IsChecked(target) : false;
mi.Text = m.Text; //Enabledを先に
mi.Tag = new MenuItemTag(grp, m, target);
IPoderosaMenuFolder folder;
IPoderosaMenuItem leaf;
if ((folder = m as IPoderosaMenuFolder) != null) {
BuildMenuContents(mi, folder);
}
else if ((leaf = m as IPoderosaMenuItem) != null) {
mi.Click += new EventHandler(OnClickMenu);
IGeneralCommand gc = leaf.AssociatedCommand as IGeneralCommand;
if (gc != null)
mi.ShortcutKeyDisplayString = WinFormsUtil.FormatShortcut(CommandManagerPlugin.Instance.CurrentKeyBinds.GetKey(gc));
}
count++;
}
return count;
}
示例6: DoHasSeparators
/// <summary>
/// Recherche une suite de séparateurs consécutifs
/// </summary>
/// <param name="items">collection d'éléments de menus où s'effectue la recherche</param>
/// <param name="from">index du premier élément à considérer</param>
/// <param name="start">index du premier séparateur de la suite</param>
/// <param name="end">index du dernier séparateur de la suite</param>
/// <returns>true si au moins un séparateur a été trouvé</returns>
private static bool DoHasSeparators( ToolStripItemCollection items, int from, ref int start, ref int end ) {
start = from;
end = start - 1;
bool found = false;
// rechercher le premier séparateur
for (int ix = from ; ix < items.Count ; ix++) {
if (!(items[ ix ] is ToolStripSeparator)) continue;
start = ix;
found = true;
break;
}
// pas de séparateur trouvé
if (!found) return false;
// rechercher le dernier séparateur de la suite
end = start;
for (int ix = start + 1 ; ix < items.Count ; ix++) {
if (!(items[ ix ] is ToolStripSeparator)) break;
end = ix;
}
return true;
}
示例7: BuildMenu
public static void BuildMenu(ToolStripItemCollection items, IEnumerable<IEditorScript> scripts, Func<IEditorScript, Task> callback)
{
foreach (var script in scripts)
{
if (script.Name.StartsWith("----"))
{
items.Add(new ToolStripSeparator());
}
else if (script.Children.Any())
{
var item = new ToolStripMenuItem(script.Name);
BuildMenu(item.DropDownItems, script.Children, callback);
items.Add(item);
}
else
{
items.Add(new ToolStripMenuItem(script.Name, null, async (s, ev) =>
{
var text = await script.GetScript(); // Trigger execution
if (!string.IsNullOrEmpty(text))
{
await callback(script);
}
}));
}
}
}
示例8: BuildMenu
public static void BuildMenu(ToolStripItemCollection items, IEnumerable<IEditorScript> scripts, Action<IEditorScript> callback)
{
foreach (var script in scripts)
{
if (script.Name.StartsWith("----"))
{
items.Add(new ToolStripSeparator());
}
else if (script.Children.Any())
{
var item = new ToolStripMenuItem(script.Name);
BuildMenu(item.DropDownItems, script.Children, callback);
items.Add(item);
}
else
{
items.Add(new ToolStripMenuItem(script.Name, null, (s, ev) =>
{
var query = script.Script; // Trigger execution
if (!string.IsNullOrEmpty(query))
{
callback(script);
}
}));
}
}
}
示例9: WireItems
internal void WireItems(ToolStripItemCollection collection)
{
foreach (System.Windows.Forms.ToolStripItem item in collection)
{
ItemAdded(null, new ToolStripItemEventArgs(item));
}
}
示例10: AddMenuItem
public void AddMenuItem(ToolStripItemCollection collection, int index, String fileName, EventHandler handler)
{
ToolStripMenuItem item = new ToolStripMenuItem ();
item.Text = fileName;
item.Click += new EventHandler (handler);
collection.Insert (index, item);
}
示例11: AssertHasNoMenuWithText
/// <summary>
/// Assert that the strip has no menu item with the specified text.
/// </summary>
/// <param name="items"></param>
/// <param name="text"></param>
/// <returns></returns>
private static void AssertHasNoMenuWithText(ToolStripItemCollection items, string text)
{
if (items.Cast<ToolStripItem>().Any(item => item is ToolStripMenuItem && (item as ToolStripMenuItem).Text == text))
{
Assert.Fail("item " + text + " was unexpectedly found in a context menu");
}
}
示例12: Initialize
public void Initialize(IMyGenerationMDI mdi, ToolStripItemCollection menuItems)
{
this.scintilla.AddShortcuts(menuItems);
this._fileId = Guid.NewGuid().ToString();
_mdi = mdi;
RefreshConnectionInfo();
}
示例13: CreateButton
private static void CreateButton(ToolStripItemCollection items, string title, EventHandler handler,
Workitem item)
{
var button = new ToolStripMenuItem(title, null, handler);
items.Add(button);
button.Tag = item;
}
示例14: UpdateControlsForLanguage
internal static void UpdateControlsForLanguage(ToolStripItemCollection toolStripItems)
{
foreach (ToolStripItem i in toolStripItems)
{
if (!String.IsNullOrEmpty(Lang.ResourceManager.GetString(i.Name, Lang.Culture)))
i.Text = Lang.ResourceManager.GetString(i.Name, Lang.Culture);
}
}
示例15: ToolStripDropDownItem
protected ToolStripDropDownItem()
: base()
{
_dropDownItems = new ToolStripItemCollection(Parent, null);
ArrowColor = Color.Black;
ArrowImage = ApplicationBehaviour.Resources.Images.DropDownRightArrow;
}