wMenu.cs
using System; using System.Drawing; using System.Windows.Forms; public class WMenu : WCtrl { MenuStrip menu; ToolStripMenuItem currMenu; public WMenu(int fontSize, int iconSize) : base(fontSize) { ctrl = menu = new MenuStrip(); if( fontSize > 0 ) { SetFontSize(fontSize); } if( iconSize > 0 ) { menu.ImageScalingSize = new Size(iconSize, iconSize); } } public WMenu(int fontSize) : this(fontSize,0) {} public WMenu() : this(0,0) {} public void AddMenu( string name ) { currMenu = new ToolStripMenuItem(); currMenu.Text = name; currMenu.Size = new Size(80, 22); menu.Items.Add(this.currMenu); } public void AddMenuItem( string name, Image icon, EventHandler handler ) { ToolStripMenuItem item = new ToolStripMenuItem(); if( icon != null ) { item.Image = icon; } item.Name = name; item.Text = name; item.Size = new Size(180, 22); item.Click += handler; currMenu.DropDownItems.Add(item); } public void AddMenuItem( string name, EventHandler handler ) { AddMenuItem( name, null, handler ); } }
댓글 없음:
댓글 쓰기