本文整理汇总了C#中System.Windows.Forms.MenuStrip类的典型用法代码示例。如果您正苦于以下问题:C# MenuStrip类的具体用法?C# MenuStrip怎么用?C# MenuStrip使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MenuStrip类属于System.Windows.Forms命名空间,在下文中一共展示了MenuStrip类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: buildMenu
/// <summary>
///
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
public MenuStrip buildMenu(String file)
{
MenuStrip mainMenu = new MenuStrip();
// read file
XmlDocument doc = new XmlDocument();
doc.Load(file);
// read
XmlNodeList menuList = doc.SelectNodes("//MainMenu/Menu");
if (menuList != null)
{
IEnumerator menuListEnum =
menuList.GetEnumerator();
while (menuListEnum.MoveNext())
{
XmlNode menu = (XmlNode)menuListEnum.Current;
// create menu
ToolStripMenuItem formMenuItem = new ToolStripMenuItem();
formMenuItem.Text = menu.Attributes["label"].Value;
XmlNodeList menuItemList = menu.ChildNodes;
IEnumerator menuItemListEnum = menuItemList.GetEnumerator();
while (menuItemListEnum.MoveNext())
{
XmlNode menuItem = (XmlNode)menuItemListEnum.Current;
ToolStripMenuItem childMenuItem = new ToolStripMenuItem();
childMenuItem.Text = menuItem.Attributes["label"].Value;
formMenuItem.DropDownItems.Add(childMenuItem);
}
}
}
return null;
}
示例2: Activate
public void Activate()
{
if (_isActivated) return;
var headerControls = App.CompositionContainer.GetExportedValues<IHeaderControl>().ToList();
// Activate only if there are no other IHeaderControl implementations and
// custom HeaderControl not yet set
if (App.HeaderControl == null &&
headerControls.Count == 1 && headerControls[0].GetType() == GetType())
{
_isActivated = true;
var container = new ToolStripPanel {Dock = DockStyle.Top};
Shell.Controls.Add(container);
var menuStrip = new MenuStrip { Name = DEFAULT_GROUP_NAME, Dock = DockStyle.Top };
Shell.Controls.Add(menuStrip);
Initialize(container, menuStrip);
// Add default buttons
container.SuspendLayout();
menuStrip.SuspendLayout();
new DefaultMenuBars(App).Initialize(this);
container.ResumeLayout();
menuStrip.ResumeLayout();
}
}
示例3: AddMenuStrip
/// <summary>
/// Adds the one and only MenuStrip
/// Throws ApplicationException if this is called multiple times.
/// </summary>
public void AddMenuStrip(MenuStrip menuStrip)
{
if (m_MenuStrip != null)
throw new ApplicationException("Can only add a MenuStrip once");
TopToolStripPanel.Controls.Add(menuStrip);
}
示例4: GenerateMenu
/// <summary>
/// Création et immersion des éléments de menu
/// </summary>
private void GenerateMenu() {
if ( !Registry.Has( MainKeys.KeyMainMenu ) ) return;
ToolStripMenuItem itemReport = new ToolStripMenuItem( "Etat du gestionnaire des plugins dynamiques", global::Psl.Properties.Resources.IconProperties, itemReport_OnClick );
itemReport.MergeAction = MergeAction.Insert;
itemReport.MergeIndex = 9000;
itemReport.ImageTransparentColor = System.Drawing.Color.Magenta;
ToolStripSeparator itemReportSep = new ToolStripSeparator();
itemReportSep.MergeAction = MergeAction.Insert;
itemReportSep.MergeIndex = 9000;
ToolStripMenuItem itemAbout = new ToolStripMenuItem( "A propos du gestionnaire des plugins dynamiques", global::Psl.Properties.Resources.IconAbout, itemAbout_OnClick );
itemAbout.MergeAction = MergeAction.Insert;
itemAbout.MergeIndex = 9000;
itemAbout.ImageTransparentColor = System.Drawing.Color.Magenta;
ToolStripMenuItem itemHelpAbout = new ToolStripMenuItem( "A propos..." );
itemHelpAbout.MergeAction = MergeAction.MatchOnly;
itemHelpAbout.MergeIndex = 1;
itemHelpAbout.DropDownItems.Add( itemAbout );
ToolStripMenuItem menuHelp = new ToolStripMenuItem( "&?" );
menuHelp.MergeAction = MergeAction.MatchOnly;
menuHelp.MergeIndex = 9999;
menuHelp.DropDownItems.Add( itemHelpAbout );
menuHelp.DropDownItems.Add( itemReportSep );
menuHelp.DropDownItems.Add( itemReport );
MenuStrip mainMenu = new MenuStrip();
mainMenu.Items.Add( menuHelp );
Registry.MergeInMainMenu( mainMenu );
}
示例5: GetMainMenuStrip
static MenuStrip GetMainMenuStrip() {
var menu=new MenuStrip();
menu.Items.Add(FileStripItem());
return menu;
}
示例6: Workspace
/// <summary>
/// The default constructor sets the base controls.
/// </summary>
protected Workspace()
{
// Graphical measures
Graphics g = CreateGraphics();
SizeF sizeString = g.MeasureString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890", Font);
Data.HorizontalDLU = (sizeString.Width/62)/4;
Data.VerticalDLU = sizeString.Height/8;
g.Dispose();
TsTradeControl = new ToolStrip();
MainMenuStrip = new MenuStrip();
PnlWorkspace = new Panel();
StatusStrip = new StatusStrip();
// Panel Workspace
PnlWorkspace.Parent = this;
PnlWorkspace.Dock = DockStyle.Fill;
PnlWorkspace.Padding = new Padding(2);
PnlWorkspace.AllowDrop = true;
PnlWorkspace.DragEnter += Workspace_DragEnter;
PnlWorkspace.DragDrop += WorkspaceDragDrop;
// Tool Strip Trade control
TsTradeControl.Parent = this;
TsTradeControl.Dock = DockStyle.Top;
// Main menu
MainMenuStrip.Parent = this;
MainMenuStrip.Dock = DockStyle.Top;
// Status bar
StatusStrip.Parent = this;
StatusStrip.Dock = DockStyle.Bottom;
}
示例7: Bind
public static void Bind(MenuStrip ms)
{
foreach (ToolStripMenuItem item in ms.Items)
{
Bind(item, item.Text);
}
}
示例8: MainMenu
public MainMenu(MainForm mainForm)
{
_mainForm = mainForm;
_menuStrip = new MenuStrip();
Initialize();
}
示例9: Form1
public Form1()
{
InitializeComponent();
m = new MenuStrip();
//добавляем меню верхнего уровня
ToolStripMenuItem file= (ToolStripMenuItem)m.Items.Add("File");
ToolStripMenuItem edit = (ToolStripMenuItem)m.Items.Add("Edit");
this.MainMenuStrip = m;
this.Controls.Add(m); //добавляем меню на форму
//добавляем выпадающее меню для пункта Edit
edit.DropDownItems.Add("Cut");
//добавляем сепаратор
edit.DropDownItems.Add(new ToolStripSeparator());
edit.DropDownItems.Add("Copy");
//добавляем сепаратор
edit.DropDownItems.Add(new ToolStripSeparator());
edit.DropDownItems.Add("Pastle");
//Добвыляем выпадающее меню для пункта File
ToolStripMenuItem close = (ToolStripMenuItem)file.DropDownItems.Add("Close");
//связываем меню с акселератором Alt+C
close.ShortcutKeys = Keys.Alt | Keys.C;
close.ShowShortcutKeys = true; //отображать акселераторы
//добавляем обработчик для пункта меня Close
close.Click += new EventHandler(close_Click);
}
示例10: deshabilitarMenu
public void deshabilitarMenu(MenuStrip m)
{
amistadesToolStripMenuItem.Enabled = false;
publicacionesToolStripMenuItem.Enabled = false;
modificarUsuarioMenuItem.Enabled = false;
bajaUsuarioMenuItem.Enabled = false;
}
示例11: MenuCommandUiManager
/// <summary>
/// Setup constructor
/// </summary>
/// <param name="menu">Target menu. Commands are added/removed from here</param>
/// <param name="triggerDataFactory">Factory used to create trigger data</param>
/// <exception cref="ArgumentNullException">Thrown if menu or triggerDataFactory are null</exception>
public MenuCommandUiManager( MenuStrip menu, ICommandTriggerDataFactory triggerDataFactory )
{
Arguments.CheckNotNull( menu, "menu" );
Arguments.CheckNotNull( triggerDataFactory, "triggerDataFactory" );
m_Menu = menu;
m_TriggerDataFactory = triggerDataFactory;
}
示例12: FormBrowseMenus
public FormBrowseMenus(MenuStrip menuStrip)
{
_menuStrip = menuStrip;
CreateAdditionalMainMenuItems();
Translate();
}
示例13: VisibleMain
public void VisibleMain(MenuStrip menu)
{
if (this.mSysEnv.TerminalInfo.UserKind == 4)
{
this.Change(menu, Enum.GetNames(typeof(InvisibleKioskMain)), false, false);
}
}
示例14: InitializeComponents
void InitializeComponents()
{
var menuStrip = new MenuStrip();
saveToolStripMenuItem = new ToolStripMenuItem { Visible = false };
closeToolStripMenuItem = new ToolStripMenuItem { Visible = false };
openToolStripMenuItem = new ToolStripMenuItem { Visible = false };
newToolStripMenuItem = new ToolStripMenuItem { Visible = false };
menuStrip.SuspendLayout();
SuspendLayout();
menuStrip.Items.Add(saveToolStripMenuItem);
menuStrip.Items.Add(closeToolStripMenuItem);
menuStrip.Items.Add(openToolStripMenuItem);
menuStrip.Items.Add(newToolStripMenuItem);
saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
closeToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
openToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.O;
newToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.N;
Controls.Add(menuStrip);
Size = new Size(800, 600);
Text = "DevPad";
WindowState = FormWindowState.Maximized;
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
ResumeLayout(false);
PerformLayout();
MainMenuStrip = menuStrip;
}
示例15: EnableMain
public void EnableMain(MenuStrip menu, bool enable)
{
if (this.mSysEnv.TerminalInfo.UserKind == 4)
{
this.Change(menu, Enum.GetNames(typeof(EnableKioskMain)), true, enable);
}
}