本文整理汇总了C#中System.Windows.Forms.ToolStripMenuItem.GetCurrentParent方法的典型用法代码示例。如果您正苦于以下问题:C# ToolStripMenuItem.GetCurrentParent方法的具体用法?C# ToolStripMenuItem.GetCurrentParent怎么用?C# ToolStripMenuItem.GetCurrentParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ToolStripMenuItem
的用法示例。
在下文中一共展示了ToolStripMenuItem.GetCurrentParent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindParent
private Form FindParent(ToolStripMenuItem item)
{
Form parentForm = null;
if (item.GetCurrentParent() is ContextMenuStrip) {
ContextMenuStrip contextMenu = item.GetCurrentParent() as ContextMenuStrip;
if (contextMenu.SourceControl != null) {
parentForm = contextMenu.SourceControl.FindForm();
}
else {
parentForm = contextMenu.FindForm();
}
}
else if (item.GetCurrentParent() is ToolStrip) {
parentForm = item.GetCurrentParent().FindForm();
}
return parentForm;
}
示例2: GetCurrentParent
public void GetCurrentParent ()
{
ToolStripMenuItem tsmiFile = new ToolStripMenuItem ("File");
ToolStripMenuItem tsmiHelp = new ToolStripMenuItem ("Help");
ToolStripMenuItem tsmiQuit = new ToolStripMenuItem ("Quit");
ToolStripMenuItem tsmiAbout = new ToolStripMenuItem ("About");
tsmiFile.DropDownItems.Add (tsmiQuit);
tsmiHelp.DropDownItems.Add (tsmiAbout);
MenuStrip menu = new MenuStrip ();
menu.Items.Add (tsmiFile);
menu.Items.Add (tsmiHelp);
ToolStrip parent = tsmiFile.GetCurrentParent ();
Assert.IsNotNull (parent, "A1");
Assert.AreEqual (parent.GetType ().Name, typeof (MenuStrip).Name, "A2");
Assert.AreEqual (parent, menu, "A3");
//because it's not visible?:
Assert.IsNull (tsmiQuit.GetCurrentParent (), "A4");
}
示例3: SetCheckedToolTip
private void SetCheckedToolTip(ToolStripMenuItem item, bool state)
{
if (item == null)
return;
if (item.GetCurrentParent() == null)
return;
if (item.GetCurrentParent().InvokeRequired)
{
SetCheckedToolTipCB d = new SetCheckedToolTipCB(SetCheckedToolTip);
item.GetCurrentParent().Invoke(d, new object[] { item, state });
}
else
{
item.Checked = state;
}
}
示例4: GetMenuItemFromString
public void GetMenuItemFromString(string path, ToolStripMenuItem item)
{
if (path.ToLower().StartsWith("new/")) {
ToolStripMenuItem toolstrip = null;
string path2 = path.Substring("new/".Length);
foreach (ToolStripMenuItem item2 in Parent.MenuStrip.Items) {
if (item2.Text == path2) {
toolstrip = item2;
}
}
ToolStripMenuItem tmpitem = new ToolStripMenuItem("[plugin helper]") { Name = "pluginhelper" };
if (toolstrip == null) {
toolstrip = new ToolStripMenuItem(path2, null, new ToolStripMenuItem[] { tmpitem });
} else {
toolstrip.DropDownItems["pluginhelper"].GetCurrentParent().Items.Add(item);
return;
}
tmpitem.Visible = false;
//Parent.MenuStrip.Items.Insert(Parent.MenuStrip.Items.IndexOfKey("INSERT"), toolstrip);
Parent.MenuStrip.Items.Add(toolstrip);
//toolstrip.Owner = Parent.MenuStrip
tmpitem.GetCurrentParent().Items.Add(item);
return;
} else if (path.ToLower().StartsWith("file")) {
Parent.newToolStripMenuItem1.GetCurrentParent().Items.Add(item);
return;
} else if (path.ToLower().StartsWith("tools")) {
Parent.optionsToolStripMenuItem1.GetCurrentParent().Items.Add(item);
return;
} else if (path.ToLower().StartsWith("help")) {
Parent.helpToolStripMenuItem2.GetCurrentParent().Items.Add(item);
return;
} else if (path.ToLower().StartsWith("build")) {
Parent.buildToolStripMenuItem.GetCurrentParent().Items.Add(item);
return;
}
Parent.pluginsToolStripMenuItem.GetCurrentParent().Items.Add(item);
return;
}
示例5: GetMenuItemFromString
public void GetMenuItemFromString(string path, int index, ToolStripMenuItem item)
{
if (path.ToLower().StartsWith("new/")) {
ToolStripMenuItem toolstrip = null;
string path2 = path.Substring("new/".Length);
foreach (ToolStripMenuItem item2 in MainForm.Instance.MenuStrip.Items) {
if (item2.Text == path2) {
toolstrip = item2;
}
}
ToolStripMenuItem tmpitem = new ToolStripMenuItem("[plugin helper]") { Name = "pluginhelper" };
if (toolstrip == null) {
toolstrip = new ToolStripMenuItem(path2, null, new ToolStripMenuItem[] { tmpitem });
} else {
if (index > toolstrip.DropDownItems["pluginhelper"].GetCurrentParent().Items.Count)
toolstrip.DropDownItems["pluginhelper"].GetCurrentParent().Items.Add(item);
else
toolstrip.DropDownItems["pluginhelper"].GetCurrentParent().Items.Insert(index, item);
return;
}
tmpitem.Visible = false;
MainForm.Instance.MenuStrip.Items.Add(toolstrip);
//toolstrip.Owner = MainForm.Instance.MenuStrip
if (index > tmpitem.GetCurrentParent().Items.Count)
tmpitem.GetCurrentParent().Items.Add(item);
else
tmpitem.GetCurrentParent().Items.Insert(index, item);
return;
} else if (path.ToLower().StartsWith("file")) {
if (index > MainForm.Instance.newToolStripMenuItem.GetCurrentParent().Items.Count)
MainForm.Instance.newToolStripMenuItem.GetCurrentParent().Items.Add(item);
else
MainForm.Instance.newToolStripMenuItem.GetCurrentParent().Items.Insert(index, item);
return;
} else if (path.ToLower().StartsWith("tools")) {
if (index > MainForm.Instance.optionsToolStripMenuItem.GetCurrentParent().Items.Count)
MainForm.Instance.optionsToolStripMenuItem.GetCurrentParent().Items.Add(item);
else
MainForm.Instance.optionsToolStripMenuItem.GetCurrentParent().Items.Insert(index, item);
return;
} else if (path.ToLower().StartsWith("help")) {
if (index > MainForm.Instance.helpToolStripMenuItem.GetCurrentParent().Items.Count)
MainForm.Instance.helpToolStripMenuItem.GetCurrentParent().Items.Add(item);
else
MainForm.Instance.helpToolStripMenuItem.GetCurrentParent().Items.Insert(index, item);
return;
} else if (path.ToLower().StartsWith("macros")) {
if (index > MainForm.Instance.macrosToolStripMenuItem.DropDownItems[0].GetCurrentParent().Items.Count)
MainForm.Instance.macrosToolStripMenuItem.DropDownItems[0].GetCurrentParent().Items.Add(item);
else
MainForm.Instance.macrosToolStripMenuItem.DropDownItems[0].GetCurrentParent().Items.Insert(index, item);
return;
}
if (index > MainForm.Instance.optionsToolStripMenuItem.GetCurrentParent().Items.Count)
MainForm.Instance.optionsToolStripMenuItem.GetCurrentParent().Items.Add(item);
else
MainForm.Instance.optionsToolStripMenuItem.GetCurrentParent().Items.Insert(index, item);
return;
}