本文整理汇总了C#中System.Windows.Forms.ToolStripMenuItem类的典型用法代码示例。如果您正苦于以下问题:C# ToolStripMenuItem类的具体用法?C# ToolStripMenuItem怎么用?C# ToolStripMenuItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ToolStripMenuItem类属于System.Windows.Forms命名空间,在下文中一共展示了ToolStripMenuItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Loaded
public override bool Loaded()
{
Grid.Host2 = Host;
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GridUI));
var temp = (string)(resources.GetObject("$this.Text"));
but = new ToolStripMenuItem(temp);
but.Click += but_Click;
bool hit = false;
ToolStripItemCollection col = Host.FPMenuMap.Items;
int index = col.Count;
foreach (ToolStripItem item in col)
{
if (item.Text.Equals(Strings.AutoWP))
{
index = col.IndexOf(item);
((ToolStripMenuItem)item).DropDownItems.Add(but);
hit = true;
break;
}
}
if (hit == false)
col.Add(but);
return true;
}
示例2: MruMenuStripManager
/// <summary>
/// Initializes a new instance of the MRU manager with the specified item to be used as a placeholder for where the MRU items will be placed.
/// </summary>
/// <param name="placeHolderItem">This should be a <see cref="ToolStripMenuItem"/> on the menu where you want the MRU items to be placed.</param>
public MruMenuStripManager(ToolStripMenuItem placeHolderItem)
{
if (placeHolderItem == null)
throw new ArgumentNullException(nameof(placeHolderItem));
_placeHolderItem = placeHolderItem;
LoadPreferences();
}
示例3: ProcessWatchTimer_Tick
private void ProcessWatchTimer_Tick(object sender, EventArgs e) {
while (qadd.Count > 0) {
PolProcess pol = new PolProcess(qadd.Dequeue());
ToolStripMenuItem menuItem = new ToolStripMenuItem(pol.Title);
menuItem.Tag = pol;
WindowerMenuItemProcess.DropDownItems.Add(menuItem);
}
while (qdel.Count > 0) {
Process p = qdel.Dequeue();
foreach (ToolStripMenuItem menuItem in WindowerMenuItemProcess.DropDownItems) {
PolProcess pol = (PolProcess) menuItem.Tag;
if (pol != null && pol.Pid == p.Id) {
WindowerMenuItemProcess.DropDownItems.Remove(menuItem);
break;
}
}
}
if (WindowerMenuItemProcess.DropDownItems.Count == 1) {
ToolStripMenuItem menuItem = (ToolStripMenuItem) WindowerMenuItemProcess.DropDownItems[0];
if (_windower == null || !menuItem.Checked)
WindowerMenuItemProcess_DropDownItemClicked(this, new ToolStripItemClickedEventArgs(menuItem));
}
if (_windower != null && WindowerMenuItemProcess.DropDownItems.Count == 0) {
_windower = null;
WindowerInstanceChanged.Invoke(this, new EventArgs());
}
ProcessWatchTimerTick.Invoke(this, new EventArgs());
}
示例4: AddMenuItems
private void AddMenuItems() {
var toolsMenu = m_host.MainWindow.ToolsMenu.DropDownItems;
m_toolsSeparator = new ToolStripSeparator();
toolsMenu.Add(m_toolsSeparator);
m_mainPopup = new ToolStripMenuItem();
m_mainPopup.Text = "KeePassQiniu";
toolsMenu.Add(m_mainPopup);
m_uploadToolItem = new ToolStripMenuItem();
m_uploadToolItem.Text = "立即上传";
m_uploadToolItem.Click += OnMenuBackupNow;
m_uploadToolItem.Enabled = false;
m_mainPopup.DropDownItems.Add(m_uploadToolItem);
m_downToolItem = new ToolStripMenuItem();
m_downToolItem.Text = "立即下载";
m_downToolItem.Click += OnMenuDown;
m_downToolItem.Enabled = true;
m_mainPopup.DropDownItems.Add(m_downToolItem);
m_toolsSeparator = new ToolStripSeparator();
m_mainPopup.DropDownItems.Add(m_toolsSeparator);
var autoBackup = new ToolStripMenuItem();
autoBackup.Text = "自动同步";
autoBackup.Checked = KeePassQiniuConfig.Default.AutoSync;
autoBackup.Click += OnMenuAutomaticBackup;
autoBackup.Enabled = true;
m_mainPopup.DropDownItems.Add(autoBackup);
var configure = new ToolStripMenuItem();
configure.Text = "配置...";
configure.Click += OnMenuConfig;
configure.Enabled = true;
m_mainPopup.DropDownItems.Add(configure);
}
示例5: Create
/// <summary>
/// Creates this instance.
/// </summary>
/// <returns>ContextMenuStrip</returns>
public ContextMenuStrip Create()
{
// Add the default menu options.
ContextMenuStrip menu = new ContextMenuStrip();
ToolStripMenuItem item;
ToolStripSeparator sep;
this._textmodeItem = new ToolStripMenuItem();
this._textmodeItem.Text = "Text mode";
this._textmodeItem.Enabled = false;
menu.Items.Add(this._textmodeItem);
this.SetTextModeText(BopomofoRegistry.IsSimplifiedEnable(), false);
// About.
item = new ToolStripMenuItem();
item.Text = "About";
item.Click += new EventHandler(this.About_Click);
menu.Items.Add(item);
// Separator.
sep = new ToolStripSeparator();
menu.Items.Add(sep);
// Exit.
item = new ToolStripMenuItem();
item.Text = "Exit";
item.Click += new System.EventHandler(this.Exit_Click);
menu.Items.Add(item);
return menu;
}
示例6: PlanningGridExtDisplayObject
public PlanningGridExtDisplayObject(string name, Color maxColor, Color minColor)
: base(name, maxColor, minColor)
{
string[] gridTypes = Enum.GetNames(typeof(PlanningGrids));
PlanningGrids[] values = (PlanningGrids[])Enum.GetValues(typeof(PlanningGrids));
ToolStripMenuItem menuGetGrid = new ToolStripMenuItem("Get Grid");
for (int i = 0; i < gridTypes.Length; i++) {
ToolStripMenuItem gridItem = new ToolStripMenuItem();
gridItem.Text = gridTypes[i];
gridItem.Tag = values[i];
gridItem.Click += new EventHandler(gridItem_Click);
menuGetGrid.DropDownItems.Add(gridItem);
}
ToolStripMenuItem menuSetMaxColor = new ToolStripMenuItem("Set Max Color", null, menuSetMaxColor_Click);
ToolStripMenuItem menuSetMinColor = new ToolStripMenuItem("Set Min Color", null, menuSetMinColor_Click);
menuItems = new ToolStripMenuItem[] { menuGetGrid, menuSetMaxColor, menuSetMinColor };
colorDialog = new ColorDialog();
colorDialog.AnyColor = true;
colorDialog.AllowFullOpen = true;
colorDialog.FullOpen = true;
}
示例7: ObedienceContext
internal ObedienceContext()
{
//Instantiate the component Module to hold everything
_components = new System.ComponentModel.Container();
Trace.Listeners.Add(new TextWriterTraceListener("C:\\temp\\Obedience.log"));
//Instantiate the NotifyIcon attaching it to the components container and
//provide it an icon, note, you can imbed this resource
_notifyIcon = new NotifyIcon(_components);
_notifyIcon.Icon = Resources.AppIcon;
_notifyIcon.Text = "Obedience";
_notifyIcon.Visible = true;
//Instantiate the context menu and items
var contextMenu = new ContextMenuStrip();
var displayForm = new ToolStripMenuItem();
var exitApplication = new ToolStripMenuItem();
//Attach the menu to the notify icon
_notifyIcon.ContextMenuStrip = contextMenu;
//Setup the items and add them to the menu strip, adding handlers to be created later
displayForm.Text = "Do something";
displayForm.Click += mDisplayForm_Click;
contextMenu.Items.Add(displayForm);
exitApplication.Text = "Exit";
exitApplication.Click += mExitApplication_Click;
contextMenu.Items.Add(exitApplication);
Trace.WriteLine("Obedience started");
scanner = new AcdController(new IPEndPoint(new IPAddress(new byte[] {10, 0, 3, 220}), 5003));
//scanner.Reboot();
Trace.AutoFlush = true;
scanner.ConnectedChanged += new ConnectedChangedEventHandler(scanner_ConnectedChanged);
}
示例8: maakHelpMenu
private void maakHelpMenu()
{
ToolStripDropDownItem menu;
menu = new ToolStripMenuItem("Help");
menu.DropDownItems.Add("Over \"Schets\"", null, this.about);
menuStrip.Items.Add(menu);
}
示例9: InitMenuStrip
private void InitMenuStrip()
{
// New strip menu item
opt_menuitem_dic_ = new Dictionary<uint, ToolStripMenuItem>();
foreach (var opt in Public.opt_name_dic_.Keys)
{
opt_menuitem_dic_[opt] = new ToolStripMenuItem();
}
exit_item_ = new ToolStripMenuItem();
// Set property
menuitem_opt_dic_ = new Dictionary<ToolStripMenuItem, uint>();
foreach (KeyValuePair<uint, ToolStripMenuItem> item in opt_menuitem_dic_)
{
uint opt = item.Key;
ToolStripMenuItem menu_item = item.Value;
menuitem_opt_dic_[menu_item] = opt;
menu_item.Text = Public.opt_name_dic_[opt];
menu_item.Click += new EventHandler(this.opt_menuitemClick);
}
exit_item_.Text = "退出";
exit_item_.Click += new EventHandler(this.exit_toolstripItemClick);
// Notify Menu
notify_menu_ = new ContextMenuStrip();
notify_menu_.Items.Add(opt_menuitem_dic_[TExcState.AWAY_MODE]);
notify_menu_.Items.Add(opt_menuitem_dic_[TExcState.DISPLAY_REQ]);
notify_menu_.Items.Add(opt_menuitem_dic_[TExcState.SYS_REQ]);
notify_menu_.Items.Add(new ToolStripSeparator());
notify_menu_.Items.Add(opt_menuitem_dic_[TExcState.AWAKE_IN_LID_CLODE]);
notify_menu_.Items.Add(new ToolStripSeparator());
notify_menu_.Items.Add(exit_item_);
}
示例10: FileMenu
private ToolStripMenuItem FileMenu()
{
var itemFile = new ToolStripMenuItem(Language.T("File"));
ItemSaveAs = new ToolStripMenuItem(Language.T("Save As") + "...");
ItemSaveAs.Click += SaveAsOnClick;
itemFile.DropDownItems.Add(ItemSaveAs);
var item = new ToolStripMenuItem(Language.T("Page Setup") + "...");
item.Click += PageSetupOnClick;
itemFile.DropDownItems.Add(item);
ItemPrint = new ToolStripMenuItem(Language.T("Print") + "...") {ShortcutKeys = Keys.Control | Keys.P};
ItemPrint.Click += PrintDialogOnClick;
itemFile.DropDownItems.Add(ItemPrint);
ItemPreview = new ToolStripMenuItem(Language.T("Print Preview") + "...");
ItemPreview.Click += PreviewOnClick;
itemFile.DropDownItems.Add(ItemPreview);
itemFile.DropDownItems.Add(new ToolStripSeparator());
ItemProps = new ToolStripMenuItem(Language.T("Properties") + "...");
ItemProps.Click += PropertiesOnClick;
itemFile.DropDownItems.Add(ItemProps);
itemFile.DropDownItems.Add(new ToolStripSeparator());
item = new ToolStripMenuItem(Language.T("Exit"));
item.Click += ExitOnClick;
itemFile.DropDownItems.Add(item);
return itemFile;
}
示例11: Create
/// <summary>
/// Is the About box displayed?
/// </summary>
//bool isAboutLoaded = false;
/// <summary>
/// Creates this instance.
/// </summary>
/// <returns>ContextMenuStrip</returns>
public ContextMenuStrip Create()
{
// Add the default menu options.
ContextMenuStrip menu = new ContextMenuStrip();
ToolStripMenuItem item;
//ToolStripSeparator sep;
// Windows Explorer.
item = new ToolStripMenuItem();
item.Text = "Submit Ticket";
item.Click += new EventHandler(Explorer_Click);
item.Image = Resources.Explorer;
menu.Items.Add(item);
//Printer
item = new ToolStripMenuItem();
item.Text = "Manage Printers";
item.Click += new EventHandler(Print_Click);
item.Image = Resources.Exit;
menu.Items.Add(item);
// About.
item = new ToolStripMenuItem();
item.Text = "About";
item.Click += new EventHandler(About_Click);
item.Image = Resources.About;
menu.Items.Add(item);
// Separator.
//sep = new ToolStripSeparator();
//menu.Items.Add(sep);
return menu;
}
示例12: MainForm
public MainForm()
{
InitializeComponent();
_defaultContextMenuStripBackColor = contextMenuStrip1.Items[0].BackColor;
var defaultTasks = Settings.Default.DefaultTasks.Split(';');
foreach (var defaultTask in defaultTasks)
comboBox1.Items.Add(defaultTask);
foreach (var item in comboBox1.Items)
{
_taskList.AddTask(item.ToString());
var toolStripItem = new ToolStripMenuItem {Text = item.ToString()};
toolStripItem.MouseUp += ToolStripItemMouseUp;
contextMenuStrip1.Items.Add(toolStripItem);
}
for (var i = 0; i < contextMenuStrip1.Items.Count; i++)
if (contextMenuStrip1.Items[i].Text.Equals("Beenden"))
{
_contextMenuTaskStartIndex = i + 2;
break;
}
SetTrayTaskListColors(defaultTasks[0]);
TopMostToolStripMenuItem.Checked = Settings.Default.AlwaysOnTop;
TopMost = TopMostToolStripMenuItem.Checked;
autoHideToolStripMenuItem.Checked = Settings.Default.AutoHide;
//set version information
versionToolStripMenuItem.Text = string.Format("Über {0} v{1}", Application.ProductName,
Application.ProductVersion);
}
示例13: BuildConfigItems
private void BuildConfigItems()
{
ClearConfigItems();
var config = Configuration.Load();
if (config.ProfileConfigurations.Any())
{
var menuItem = new ToolStripSeparator();
_configItems.Add(menuItem);
_trayMenu.Items.Add(menuItem);
}
foreach (var profileConfig in config.ProfileConfigurations)
{
var isSelected = profileConfig.Name.ToLowerInvariant() == config.CurrentConfiguration.ToLowerInvariant();
var menuItem = new ToolStripMenuItem(profileConfig.Name);
menuItem.CheckOnClick = true;
menuItem.Checked = isSelected;
menuItem.Tag = profileConfig.Name;
menuItem.Click += (sender, e) => { SelectConfiguration(((ToolStripMenuItem)sender).Tag.ToString()); };
_configItems.Add(menuItem);
_trayMenu.Items.Add(menuItem);
}
}
示例14: Load
public void Load(Form parentForm, ToolStripMenuItem editorMenu)
{
m_Parent = parentForm;
m_MenuItem = editorMenu.DropDownItems.Add("Edit map...");
m_MenuItem.Click += new EventHandler(m_MenuItem_Click);
m_MenuItem.Tag = this; // Required !
}
示例15: TrayIcon
public TrayIcon()
{
_updateMenuItem = new ToolStripMenuItem(TrayIconStrings.NoUpdate, Resources.Update, OnUpdateClick) {Enabled = false};
_trayIcon.ContextMenuStrip = _settingsMenu;
_availablePlaybackDevices = AppModel.Instance.AvailablePlaybackDevices;
_availableRecordingDevices = AppModel.Instance.AvailableRecordingDevices;
PopulateSettingsMenu();
_selectionMenu.Items.Add(TrayIconStrings.NoDevSel, Resources.Settings, (sender, e) => ShowSettings());
_trayIcon.MouseClick += (sender, e) =>
{
if (e.Button == MouseButtons.Left)
{
UpdateDeviceSelectionList();
_trayIcon.ContextMenuStrip = _selectionMenu;
var mi = typeof (NotifyIcon).GetMethod("ShowContextMenu",
BindingFlags.Instance | BindingFlags.NonPublic);
mi.Invoke(_trayIcon, null);
_trayIcon.ContextMenuStrip = _settingsMenu;
}
};
UpdateDeviceSelectionList();
SetEventHandlers();
}