mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-28 17:34:06 +02:00
Add a simple context menu to the tray icon (Restore, Close)
This commit is contained in:
parent
b39a3a05fe
commit
82a3cd8df2
36
Core/FormBrowser.Designer.cs
generated
36
Core/FormBrowser.Designer.cs
generated
@ -25,12 +25,42 @@ protected override void Dispose(bool disposing) {
|
|||||||
private void InitializeComponent() {
|
private void InitializeComponent() {
|
||||||
this.components = new System.ComponentModel.Container();
|
this.components = new System.ComponentModel.Container();
|
||||||
this.trayIcon = new System.Windows.Forms.NotifyIcon(this.components);
|
this.trayIcon = new System.Windows.Forms.NotifyIcon(this.components);
|
||||||
|
this.contextMenuTray = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||||
|
this.restoreToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.closeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.contextMenuTray.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// trayIcon
|
// trayIcon
|
||||||
//
|
//
|
||||||
|
this.trayIcon.ContextMenuStrip = this.contextMenuTray;
|
||||||
this.trayIcon.Icon = global::TweetDck.Properties.Resources.icon;
|
this.trayIcon.Icon = global::TweetDck.Properties.Resources.icon;
|
||||||
this.trayIcon.Click += new System.EventHandler(this.trayIcon_Click);
|
this.trayIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(this.trayIcon_MouseClick);
|
||||||
|
//
|
||||||
|
// contextMenuTray
|
||||||
|
//
|
||||||
|
this.contextMenuTray.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.restoreToolStripMenuItem,
|
||||||
|
this.closeToolStripMenuItem});
|
||||||
|
this.contextMenuTray.Name = "contextMenuTray";
|
||||||
|
this.contextMenuTray.ShowCheckMargin = true;
|
||||||
|
this.contextMenuTray.ShowImageMargin = false;
|
||||||
|
this.contextMenuTray.ShowItemToolTips = false;
|
||||||
|
this.contextMenuTray.Size = new System.Drawing.Size(114, 48);
|
||||||
|
//
|
||||||
|
// restoreToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.restoreToolStripMenuItem.Name = "restoreToolStripMenuItem";
|
||||||
|
this.restoreToolStripMenuItem.Size = new System.Drawing.Size(113, 22);
|
||||||
|
this.restoreToolStripMenuItem.Text = "Restore";
|
||||||
|
this.restoreToolStripMenuItem.Click += new System.EventHandler(this.restoreToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// closeToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.closeToolStripMenuItem.Name = "closeToolStripMenuItem";
|
||||||
|
this.closeToolStripMenuItem.Size = new System.Drawing.Size(113, 22);
|
||||||
|
this.closeToolStripMenuItem.Text = "Close";
|
||||||
|
this.closeToolStripMenuItem.Click += new System.EventHandler(this.closeToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// FormBrowser
|
// FormBrowser
|
||||||
//
|
//
|
||||||
@ -43,6 +73,7 @@ private void InitializeComponent() {
|
|||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||||
this.ResizeEnd += new System.EventHandler(this.FormBrowser_ResizeEnd);
|
this.ResizeEnd += new System.EventHandler(this.FormBrowser_ResizeEnd);
|
||||||
this.Resize += new System.EventHandler(this.FormBrowser_Resize);
|
this.Resize += new System.EventHandler(this.FormBrowser_Resize);
|
||||||
|
this.contextMenuTray.ResumeLayout(false);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -50,6 +81,9 @@ private void InitializeComponent() {
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private System.Windows.Forms.NotifyIcon trayIcon;
|
private System.Windows.Forms.NotifyIcon trayIcon;
|
||||||
|
private System.Windows.Forms.ContextMenuStrip contextMenuTray;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem restoreToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem closeToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,13 @@ private void FormBrowser_ResizeEnd(object sender, EventArgs e){ // also triggers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void trayIcon_Click(object sender, EventArgs e){
|
private void trayIcon_MouseClick(object sender, MouseEventArgs e){
|
||||||
|
if (e.Button == MouseButtons.Left){
|
||||||
|
restoreToolStripMenuItem_Click(sender,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restoreToolStripMenuItem_Click(object sender, EventArgs e){
|
||||||
isLoaded = false;
|
isLoaded = false;
|
||||||
Show();
|
Show();
|
||||||
SetupWindow();
|
SetupWindow();
|
||||||
@ -131,6 +137,10 @@ private void trayIcon_Click(object sender, EventArgs e){
|
|||||||
trayIcon.Visible = false;
|
trayIcon.Visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void closeToolStripMenuItem_Click(object sender, EventArgs e){
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
// callback handlers
|
// callback handlers
|
||||||
|
|
||||||
public void InvokeSafe(Action func){
|
public void InvokeSafe(Action func){
|
||||||
|
Loading…
Reference in New Issue
Block a user