NotifyIcon contextmenu on left click

This commit is contained in:
2015-10-30 23:13:52 +01:00
parent ff706d1bf5
commit c7db59a8ab
2 changed files with 20 additions and 13 deletions
+12 -12
View File
@@ -36,11 +36,11 @@
this.ArtistListBox = new System.Windows.Forms.ListBox();
this.MainPanel = new System.Windows.Forms.Panel();
this.SplitContainer = new System.Windows.Forms.SplitContainer();
this.PlaylistBox = new System.Windows.Forms.ListBox();
this.PlaylistListLabel = new System.Windows.Forms.Label();
this.AlbumListLabel = new System.Windows.Forms.Label();
this.ArtistListLabel = new System.Windows.Forms.Label();
this.GenreListLabel = new System.Windows.Forms.Label();
this.PlaylistBox = new System.Windows.Forms.ListBox();
this.MenuStrip = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
@@ -186,6 +186,16 @@
this.SplitContainer.SplitterWidth = 8;
this.SplitContainer.TabIndex = 9;
//
// PlaylistBox
//
this.PlaylistBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.PlaylistBox.FormattingEnabled = true;
this.PlaylistBox.Location = new System.Drawing.Point(0, 0);
this.PlaylistBox.Name = "PlaylistBox";
this.PlaylistBox.Size = new System.Drawing.Size(760, 131);
this.PlaylistBox.TabIndex = 4;
this.PlaylistBox.Visible = false;
//
// PlaylistListLabel
//
this.PlaylistListLabel.AutoSize = true;
@@ -223,16 +233,6 @@
this.GenreListLabel.TabIndex = 4;
this.GenreListLabel.Text = "Genre";
//
// PlaylistBox
//
this.PlaylistBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.PlaylistBox.FormattingEnabled = true;
this.PlaylistBox.Location = new System.Drawing.Point(0, 0);
this.PlaylistBox.Name = "PlaylistBox";
this.PlaylistBox.Size = new System.Drawing.Size(760, 131);
this.PlaylistBox.TabIndex = 4;
this.PlaylistBox.Visible = false;
//
// MenuStrip
//
this.MenuStrip.BackColor = System.Drawing.SystemColors.WindowFrame;
@@ -439,7 +439,7 @@
this.NotifyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("NotifyIcon.Icon")));
this.NotifyIcon.Text = "NotifyIcon";
this.NotifyIcon.Visible = true;
this.NotifyIcon.Click += new System.EventHandler(this.NotifyIcon_Click);
this.NotifyIcon.MouseUp += new System.Windows.Forms.MouseEventHandler(this.NotifyIcon_Click);
//
// NotifyMenuStrip
//
+8 -1
View File
@@ -7,6 +7,7 @@ using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -191,7 +192,7 @@ namespace MusicPlayer
LabelCurrentTime.Text = Main.SecondsToTimestamp((int)(((double)PositionTrackBar.Value / 1000) * main.audio.CurrentSong.Seconds));
}
private void NotifyIcon_Click(object sender, EventArgs e)
private void NotifyIcon_Click(object sender, MouseEventArgs e)
{
/*
if (p.Visible)
@@ -199,6 +200,12 @@ namespace MusicPlayer
else
p.Visible = true;
*/
if (e.Button == MouseButtons.Left)
{
MethodInfo mi = typeof(NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance | BindingFlags.NonPublic);
mi.Invoke(NotifyIcon, null);
}
}
private void overviewToolStripMenuItem_Click(object sender, EventArgs e)