本文整理汇总了C#中System.Windows.Forms.ContextMenu类的典型用法代码示例。如果您正苦于以下问题:C# ContextMenu类的具体用法?C# ContextMenu怎么用?C# ContextMenu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContextMenu类属于System.Windows.Forms命名空间,在下文中一共展示了ContextMenu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: 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;
}
示例3: 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);
}
示例4: 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;
}
示例5: PrinterListContextMenu
private ContextMenu PrinterListContextMenu()
{
var contextMenu = new ContextMenu();
var properties = new MenuItem
{
Index = 0,
Text = "Properties"
};
properties.Click += Properties_Click;
var setAsDefault = new MenuItem
{
Index = 1,
Text = "Set As Default"
};
setAsDefault.Click += SetAsDefault_Click;
var viewDetails = new MenuItem
{
Index = 1,
Text = "View Details"
};
viewDetails.Click += ViewDetails_Click;
contextMenu.MenuItems.AddRange(new MenuItem[] { setAsDefault , viewDetails,properties });
return contextMenu;
}
示例6: SysTrayApp
public SysTrayApp()
{
// Create a simple tray menu
trayMenu = new ContextMenu();
// Create a tray icon
trayIcon = new NotifyIcon();
trayIcon.Text = "AudioSwitcher";
trayIcon.Icon = new Icon(Resources.speaker, 40, 40);
// Add menu to tray icon and show it
trayIcon.ContextMenu = trayMenu;
trayIcon.Visible = true;
// Count sound-devices
foreach (var tuple in GetDevices())
{
deviceCount += 1;
}
// Populate device list when menu is opened
trayIcon.ContextMenu.Popup += PopulateDeviceList;
// Register MEH on trayicon leftclick
trayIcon.MouseUp += new MouseEventHandler(TrayIcon_LeftClick);
}
示例7: CreatePrivateMessageControl
public PrivateMessageControl CreatePrivateMessageControl(string userName)
{
var pmControl = new PrivateMessageControl(userName) { Dock = DockStyle.Fill };
var isFriend = Program.FriendManager.Friends.Contains(userName);
User user;
var isOffline = !Program.TasClient.ExistingUsers.TryGetValue(userName, out user);
var icon = isOffline ? ZklResources.grayuser : TextImage.GetUserImage(userName);
var contextMenu = new ContextMenu();
if (!isFriend)
{
var closeButton = new MenuItem();
closeButton.Click += (s, e) => toolTabs.RemovePrivateTab(userName);
contextMenu.MenuItems.Add(closeButton);
}
toolTabs.AddTab(userName, userName, pmControl, icon, ToolTipHandler.GetUserToolTipString(userName), 0);
pmControl.ChatLine +=
(s, e) =>
{
if (Program.TasClient.IsLoggedIn)
{
if (Program.TasClient.ExistingUsers.ContainsKey(userName)) Program.TasClient.Say(SayPlace.User, userName, e.Data, false);
else Program.TasClient.Say(SayPlace.User, GlobalConst.NightwatchName, e.Data, false, string.Format("!pm {0} ", userName)); // send using PM
}
};
return pmControl;
}
示例8: LogViewer
public LogViewer(string spacefilter, AssemblaTicketWindow.LoginSucceedDel loginsuccess,string User, string Pw)
{
namefilter = spacefilter;
loginsucceed = loginsuccess;
user = User;
pw = Pw;
if (loginsucceed == null)
loginsucceed = new AssemblaTicketWindow.LoginSucceedDel(succeed);
InitializeComponent();
if (namefilter!=string.Empty)
{
Text = PROGRAM + " " + namefilter;
Invalidate();
}
ContextMenu = new ContextMenu();
ContextMenu.MenuItems.Add("View", new EventHandler(view));
ContextMenu.MenuItems.Add("Ticket", new EventHandler(aticket));
ContextMenu.MenuItems.Add("Delete", new EventHandler(del));
DoubleClick += new EventHandler(LogViewerMain_DoubleClick);
_logs.DoubleClick += new EventHandler(_logs_DoubleClick);
_logs.SelectionMode = SelectionMode.MultiExtended;
_logs.Sorted = true;
init();
fsw = new System.IO.FileSystemWatcher(PATH,WILDEXT);
fsw.IncludeSubdirectories = false;
fsw.Changed += new System.IO.FileSystemEventHandler(fsw_Changed);
fsw.Created += new System.IO.FileSystemEventHandler(fsw_Created);
}
示例9: Options
public Options()
{
InitializeComponent();
_slots = new Slot[] { new Slot(1, lbl360_1, btnSlot1Settings),
new Slot(2, lbl360_2, btnSlot2Settings), new Slot(3, lbl360_3, btnSlot3Settings),
new Slot(4, lbl360_4, btnSlot4Settings) };
_menu = new ContextMenu();
_menu.MenuItems.Add("Options...", OnOptionsClick);
_menu.MenuItems.Add("Exit", OnExit);
_icon = new NotifyIcon();
_icon.Text = Assembly.GetExecutingAssembly().GetName().Name;
_icon.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);
_icon.ContextMenu = _menu;
_icon.Visible = true;
_icon.DoubleClick += _icon_DoubleClick;
lbl360_1.DoubleClick += Xbox360Label_DoubleClick;
lbl360_2.DoubleClick += Xbox360Label_DoubleClick;
lbl360_3.DoubleClick += Xbox360Label_DoubleClick;
lbl360_4.DoubleClick += Xbox360Label_DoubleClick;
_StartInterface();
}
示例10: btnLogin_Click
private void btnLogin_Click(object sender, EventArgs e)
{
string response = network.HttpPost("http://www.status3gaming.com/gmtool/", "user=" + txtUsername.Text + "&pass=" + txtPassword.Text);
if(response == "0"){
MessageBox.Show("Failed Login", "Response", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
else if (Regex.IsMatch(response, "[0-9A-Fa-f]{40}"))
{
Program.SetHash(response);
MessageBox.Show("Successfully Logged In", "Response", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
this.Visible = false;
//Create Context Menu for system tray.
sysTrayMenu = new ContextMenu();
sysTrayMenu.MenuItems.Add("Check for new tickets...", OnRefresh);
sysTrayMenu.MenuItems.Add("Quit", OnExit);
sysTrayIcon = new NotifyIcon();
sysTrayIcon.Text = "GM Tool";
sysTrayIcon.Icon = Properties.Resources.Tray;
// Add menu to tray icon and show it.
sysTrayIcon.ContextMenu = sysTrayMenu;
sysTrayIcon.Visible = true;
sysTrayIcon.BalloonTipClicked += new EventHandler(sysTrayIcon_BaloonTipClicked);
sysTrayIcon.ShowBalloonTip(5000, "GM Tool", "Tray Monitor Active", ToolTipIcon.None);
timer.Start();
}
}
示例11: ConnectStatus
public ConnectStatus(MainWindow window)
{
this.window = window;
icon = new NotifyIcon();
icon.Visible = true;
icon.DoubleClick += (sender, e) => {
window.WindowState = System.Windows.WindowState.Normal;
window.Activate();
};
var menu = new ContextMenu();
menu.MenuItems.Add(resources["AddRules"] as string, (sender, e) => {
Rules.OpenEditor(false);
});
menu.MenuItems.Add(resources["Exit"] as string, (sender, e) => {
System.Windows.Application.Current.Shutdown();
});
icon.ContextMenu = menu;
SetStatus(Status.Stopped, resources["NotConnected"] as string);
System.Windows.Application.Current.Exit += (sender, e) => {
icon.Dispose();
};
}
示例12: Main
public Main()
{
InitializeComponent();
string headerText = string.Format("InfiniPad v{0}", Globals.getVersion());
this.Icon = Properties.Resources.icon;
this.Text = headerText;
hk = new Hotkeys();
nfi = new NotifyIcon();
nfi.Icon = Properties.Resources.icon;
nfi.Visible = true;
nfi.Text = headerText;
nfi.MouseClick += nfiClicked;
ContextMenu ctm = new ContextMenu();
ctm.MenuItems.Add("Exit", new EventHandler(nfiExit));
nfi.ContextMenu = ctm;
hk.ReapplyHotkeys();
Globals.CreateMoveDir();
#region movefile
#if !DEBUG
Globals.moveFile(Globals.MoveToDir + "InfiniPad.exe");
#endif
#endregion
}
示例13: InitContext
void InitContext()
{
ContextMenu = new ContextMenu();
ContextMenu.MenuItems.Add("Play", new EventHandler(rightplay));
ContextMenu.MenuItems.Add("Reset", new EventHandler(rightreset));
ContextMenu.MenuItems.Add("Debugs", new EventHandler(rightdebugs));
}
示例14: SystemTray
internal SystemTray(KyruApplication app)
{
this.app = app;
trayMenu = new ContextMenu();
trayMenu.MenuItems.Add("Log in", OnLogin);
trayMenu.MenuItems.Add("Connect", OnRegisterNode);
trayMenu.MenuItems.Add("-");
trayMenu.MenuItems.Add("System status", OnSystemStatus);
trayMenu.MenuItems.Add("-");
trayMenu.MenuItems.Add("Exit", OnExit);
trayIcon = new NotifyIcon();
nodesIcon = new List<Icon>();
for (int i = 0; i < 4; i++){
nodesIcon.Add(new Icon("Icons/kyru"+ i.ToString() + ".ico"));
}
//TimerElapsed();
trayIcon.MouseDoubleClick += OnLogin;
trayIcon.ContextMenu = trayMenu;
trayIcon.Visible = true;
TimerElapsed();
KyruTimer.Register(this, 2);
}
示例15: MainForm
public MainForm()
{
InitializeComponent();
// Create a simple tray menu with only one item.
trayMenu = new ContextMenu();
trayMenu.MenuItems.Add("Exit", OnExit);
// Create a tray icon. In this example we use a
// standard system icon for simplicity, but you
// can of course use your own custom icon too.
trayIcon = new NotifyIcon();
trayIcon.Text = "WurmTimer";
trayIcon.Icon = Properties.Resources.wurm_icon;
// Add menu to tray icon and show it.
trayIcon.ContextMenu = trayMenu;
trayIcon.Visible = true;
trayIcon.DoubleClick += new EventHandler(trayIcon_DoubleClick);
trayIcon.BalloonTipClicked += new EventHandler(trayIcon_BalloonTipClicked);
this.Icon = Properties.Resources.wurm_icon;
players = new List<Player>();
if (!LoadConfig())
players.Add(new Player());
checkLog.Checked = true;
}