本文整理汇总了C#中System.Windows.Forms.MenuItem类的典型用法代码示例。如果您正苦于以下问题:C# MenuItem类的具体用法?C# MenuItem怎么用?C# MenuItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MenuItem类属于System.Windows.Forms命名空间,在下文中一共展示了MenuItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawMenuItem
/// <summary>
/// �������˵���
/// </summary>
public static void DrawMenuItem(System.Windows.Forms.DrawItemEventArgs e, MenuItem mi)
{
if ( (e.State & DrawItemState.HotLight) == DrawItemState.HotLight )
{
DrawHoverRect(e, mi);
}
else if ( (e.State & DrawItemState.Selected) == DrawItemState.Selected )
{
DrawSelectionRect(e, mi);
}
else
{
Rectangle rect = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width,
e.Bounds.Height -1);
e.Graphics.FillRectangle(new SolidBrush(Globals.MainColor), rect);
e.Graphics.DrawRectangle(new Pen(Globals.MainColor), rect);
}
StringFormat sf = new StringFormat();
//�������־���
sf.LineAlignment = StringAlignment.Center;
sf.Alignment = StringAlignment.Center;
//��������
e.Graphics.DrawString(mi.Text,
Globals.menuFont,
new SolidBrush(Globals.TextColor),
e.Bounds,
sf);
}
示例2: InitializeComponent
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panelBottom = new System.Windows.Forms.Panel();
this.grid = new SourceGrid.Grid();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.mnWindow = new System.Windows.Forms.MenuItem();
this.panelBottom.SuspendLayout();
this.SuspendLayout();
//
// panelBottom
//
this.panelBottom.BackColor = System.Drawing.SystemColors.ControlDark;
this.panelBottom.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panelBottom.Controls.Add(this.grid);
this.panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panelBottom.Location = new System.Drawing.Point(0, 342);
this.panelBottom.Name = "panelBottom";
this.panelBottom.Size = new System.Drawing.Size(772, 128);
this.panelBottom.TabIndex = 1;
//
// grid
//
this.grid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.grid.AutoStretchColumnsToFitWidth = false;
this.grid.AutoStretchRowsToFitHeight = false;
this.grid.BackColor = System.Drawing.SystemColors.Window;
this.grid.CustomSort = false;
this.grid.Location = new System.Drawing.Point(0, 4);
this.grid.Name = "grid";
this.grid.OverrideCommonCmdKey = true;
this.grid.Size = new System.Drawing.Size(768, 120);
this.grid.SpecialKeys = SourceGrid.GridSpecialKeys.Default;
this.grid.TabIndex = 0;
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnWindow});
//
// mnWindow
//
this.mnWindow.Index = 0;
this.mnWindow.Text = "Window";
//
// frmSample25
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(772, 470);
this.Controls.Add(this.panelBottom);
this.IsMdiContainer = true;
this.Menu = this.mainMenu1;
this.Name = "frmSample25";
this.Text = "frmSample25";
this.Load += new System.EventHandler(this.frmSample25_Load);
this.panelBottom.ResumeLayout(false);
this.ResumeLayout(false);
}
示例3: CloneWindowMenuTest
public void CloneWindowMenuTest ()
{
MenuItem menuitem1 = new MenuItem ();
menuitem1.MdiList = true;
MenuItem menuitem2 = menuitem1.CloneMenu ();
Assert.IsTrue (menuitem2.MdiList, "#1");
}
示例4: ListBoxLog
public ListBoxLog(ListBox listBox, string messageFormat, int maxLinesInListbox, bool debug = true)
{
_debug = debug;
_disposed = false;
_listBox = listBox;
_messageFormat = messageFormat;
_maxEntriesInListBox = maxLinesInListbox;
_paused = false;
_canAdd = listBox.IsHandleCreated;
_listBox.SelectionMode = SelectionMode.MultiExtended;
_listBox.HandleCreated += OnHandleCreated;
_listBox.HandleDestroyed += OnHandleDestroyed;
_listBox.DrawItem += DrawItemHandler;
_listBox.KeyDown += KeyDownHandler;
MenuItem[] menuItems = new MenuItem[] { new MenuItem("Copy", new EventHandler(CopyMenuOnClickHandler)) };
_listBox.ContextMenu = new ContextMenu(menuItems);
_listBox.ContextMenu.Popup += new EventHandler(CopyMenuPopupHandler);
_listBox.DrawMode = DrawMode.OwnerDrawFixed;
}
示例5: CreateMenus
private static ContextMenu CreateMenus()
{
MainMenu.MenuItems.Clear();
foreach (IPlugin plugin in pluginsList)
{
MemberInfo info = plugin.GetType();
string pluginName = plugin.GetType().Namespace + '.' + plugin.GetType().Name;
string menuName = ((PluginAttributes)Attribute.GetCustomAttribute(info, typeof(PluginAttributes))).PluginLabel;
MenuItem menuItem = new MenuItem(menuName);
MainMenu.MenuItems.Add(menuItem);
MountPluginMenu(plugin, menuItem, plugin.Menus());
menuItem.Click += (sender, e) =>
{
DoActionPlugin(pluginName, menuName, plugin, null);
};
}
// ===============================================
// Funções Auxiliares
// ===============================================
MainMenu.MenuItems.Add(new MenuItem("Atualizar", (sender, e) =>
{
MainMenu.MenuItems.Clear();
CreateMenus();
}));
MainMenu.MenuItems.Add(new MenuItem("Fechar menu"));
MainMenu.MenuItems.Add(new MenuItem("Sair", (sender, e) => Application.Exit()));
return MainMenu;
}
示例6: MainWindow
public MainWindow()
{
InitializeComponent();
this.notifyIcon = new NotifyIcon();
contextMenu = new ContextMenu();
MenuItem refreshItem = new MenuItem();
refreshItem.Click += new System.EventHandler(this.refreshQuestionNo);
refreshItem.Text = "Refresh";
contextMenu.MenuItems.Add(refreshItem);
MenuItem openItem = new MenuItem();
openItem.Click += new System.EventHandler(this.showApp);
openItem.Text = "Show";
contextMenu.MenuItems.Add(openItem);
MenuItem exitItem = new MenuItem();
exitItem.Click += new System.EventHandler(this.exitApp);
exitItem.Text = "Exit";
contextMenu.MenuItems.Add(exitItem);
dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
}
示例7: ServerLogForm
public ServerLogForm(ShadowsocksController controller)
{
this.controller = controller;
this.Icon = Icon.FromHandle(Resources.ssw128.GetHicon());
InitializeComponent();
this.Width = 760;
Configuration config = controller.GetCurrentConfiguration();
if (config.configs.Count < 8)
{
this.Height = 300;
}
else if (config.configs.Count < 20)
{
this.Height = 300 + (config.configs.Count - 8) * 16;
}
else
{
this.Height = 500;
}
UpdateTexts();
UpdateLog();
this.contextMenu1 = new ContextMenu(new MenuItem[] {
this.clearItem = CreateMenuItem("&Clear", new EventHandler(this.ClearItem_Click)),
});
ServerDataGrid.ContextMenu = contextMenu1;
controller.ConfigChanged += controller_ConfigChanged;
}
示例8: InitializeComponent
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
//
// mainMenu1
//
this.mainMenu1.MenuItems.Add(this.menuItem1);
//
// menuItem1
//
this.menuItem1.MenuItems.Add(this.menuItem2);
this.menuItem1.Text = "Opciones";
//
// menuItem2
//
this.menuItem2.MenuItems.Add(this.menuItem3);
this.menuItem2.Text = "Datos de Lectora";
//
// menuItem3
//
this.menuItem3.Text = "Sincronizar Cortes";
//
// SistemasEtiquetas
//
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(322, 348);
this.Menu = this.mainMenu1;
this.Text = "Sistema de Eitquetas";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
}
示例9: OnLoad
protected override void OnLoad(EventArgs e)
{
var menu = new MainMenu();
MenuItem open = new MenuItem("Open", (s, a) =>
{
using (var dialog = new OpenFileDialogAdapter())
{
dialog.InitialDirectory = "/tmp";
if (dialog.ShowDialog() == DialogResult.OK)
{
m_datafile = new FileInfo(dialog.FileName);
m_painted = false;
}
}
});
MenuItem refresh = new MenuItem("Refresh", (s, a) =>
{
m_painted = false;
this.Invalidate();
});
base.OnLoad(e);
menu.MenuItems.Add(open);
menu.MenuItems.Add(refresh);
Menu = menu;
}
示例10: Notificator
public Notificator(IEventLogger eventLogger, ISettingsManager settingsManager)
{
_eventLogger = eventLogger;
_settingsManager = settingsManager;
var menuItem = new MenuItem(Strings.Exit);
menuItem.Click += menuItem_Click;
var contextMenu = new ContextMenu(new[] {menuItem});
_notifyIcon = new NotifyIcon
{
Icon = new Icon("TryIcon.ico"),
Visible = true,
BalloonTipTitle = Strings.Caution,
Text = Strings.Initializing,
ContextMenu = contextMenu
};
var oneRunTimer = new Timer(3000)
{
AutoReset = false,
Enabled = true
};
oneRunTimer.Elapsed += _timer_Elapsed; // runs only once after aplication start
var timer = new Timer(60000)
{
AutoReset = true,
Enabled = true
};
timer.Elapsed += _timer_Elapsed;
}
示例11: FaceImageControl
public FaceImageControl( FaceImage Face, FaceImageListControl FaceControlParent )
{
this.Face = Face;
this.FaceControlParent = FaceControlParent;
InitializeComponent();
SetBounds( 0, 0, Face.Face.Width, Face.Face.Height );
List<MenuItem> menuitems = new List<MenuItem>();
MenuItem mi;
mi = new MenuItem( "Edit URL" );
mi.Click += new EventHandler( mi_EditURL_Click );
menuitems.Add( mi );
mi = new MenuItem( "Edit Name" );
mi.Click += new EventHandler( mi_EditName_Click );
menuitems.Add( mi );
mi = new MenuItem( "Delete" );
mi.Click += new EventHandler( mi_Delete_Click );
menuitems.Add( mi );
RightClickMenuItems = menuitems.ToArray();
RightClickMenu = new System.Windows.Forms.ContextMenu( RightClickMenuItems );
ImageAttrs = new System.Drawing.Imaging.ImageAttributes();
ColorMatrix = new System.Drawing.Imaging.ColorMatrix();
}
示例12: AddRange
public virtual void AddRange( MenuItem[] items )
{
for( int i=0; i<items.Length; i++ )
{
Add( (MenuItemEx)items[i] );
}
}
示例13: Transformer
public Transformer()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.DoubleBuffer, true);
Text = "COMP 4560: Assignment 5 (A00884869) (Duy Le)";
ResizeRedraw = true;
BackColor = Color.Black;
MenuItem miNewDat = new MenuItem("New &Data...",
new EventHandler(MenuNewDataOnClick));
MenuItem miExit = new MenuItem("E&xit",
new EventHandler(MenuFileExitOnClick));
MenuItem miDash = new MenuItem("-");
MenuItem miFile = new MenuItem("&File",
new MenuItem[] {miNewDat, miDash, miExit});
MenuItem miAbout = new MenuItem("&About",
new EventHandler(MenuAboutOnClick));
Menu = new MainMenu(new MenuItem[] {miFile, miAbout});
//foreach (var button in Controls.OfType<Button>())
//{
// button.Click += button_Click;
//}
_timer = new System.Windows.Forms.Timer();
_timer.Interval = 1;
}
示例14: ShellView
public ShellView()
{
InitializeComponent();
// Check if there was instance before this. If there was-close the current one.
if (ProcessUtilities.ThisProcessIsAlreadyRunning())
{
ProcessUtilities.SetFocusToPreviousInstance("Carnac");
Application.Current.Shutdown();
}
var item = new MenuItem
{
Text = "Exit"
};
item.Click += (sender, args) => Close();
var iconStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Carnac.icon.embedded.ico");
var ni = new NotifyIcon
{
Icon = new Icon(iconStream),
ContextMenu = new ContextMenu(new[] { item })
};
ni.Click += NotifyIconClick;
ni.Visible = true;
}
示例15: AddMenu
public void AddMenu()
{
MainMenu mnuFileMenu = new MainMenu();
option = new MenuItem("&Options");
hlp = new MenuItem("&Help");
aboutDev = new MenuItem("&About Developers");
nGame = new MenuItem("&New Game");
ext = new MenuItem("&Exit");
advanced = new MenuItem("&Show/Hide Developer Console");
advanced.Shortcut = System.Windows.Forms.Shortcut.F1;
mnuFileMenu.MenuItems.Add(option);
mnuFileMenu.MenuItems.Add(hlp);
hlp.MenuItems.Add(aboutDev);
option.MenuItems.Add(nGame);
option.MenuItems.Add(advanced);
option.MenuItems.Add(ext);
nGame.Click += new System.EventHandler(this.menuItems_onClick);
ext.Click += new System.EventHandler(this.menuItems_onClick);
aboutDev.Click += new System.EventHandler(this.menuItems_onClick);
advanced.Click += new System.EventHandler(this.menuItems_onClick);
this.Menu = mnuFileMenu;
}