diff --git a/Source/Controls/BilgeButton.cs b/Source/Controls/BilgeButton.cs index f9216e2..656157c 100644 --- a/Source/Controls/BilgeButton.cs +++ b/Source/Controls/BilgeButton.cs @@ -116,6 +116,13 @@ protected override void OnPaint(PaintEventArgs e) { e.Graphics.DrawImageTranslucent(Image, Selected ? 1 : .75f, imageX - offset, imageY - offset); } + protected override void OnClick(EventArgs e) { + // Only allow left click to raise click event. + if ((e as MouseEventArgs)?.Button.HasFlag(MouseButtons.Left) ?? false) { + base.OnClick(e); + } + } + private void BilgeButton_Click(object sender, EventArgs e) { if (ToggleButton) { Selected = !Selected; @@ -133,13 +140,13 @@ private void BilgeButton_MouseLeave(object sender, EventArgs e) { } private void BilgeButton_MouseDown(object sender, MouseEventArgs e) { - if ((e.Button & MouseButtons.Left) > 0) { + if (e.Button.HasFlag(MouseButtons.Left)) { IsMouseDown = true; } } private void BilgeButton_MouseUp(object sender, MouseEventArgs e) { - if ((e.Button & MouseButtons.Left) > 0) { + if (e.Button.HasFlag(MouseButtons.Left)) { IsMouseDown = false; } } diff --git a/Source/Forms/NetGraphForm.cs b/Source/Forms/NetGraphForm.cs index a1f952f..5f97937 100644 --- a/Source/Forms/NetGraphForm.cs +++ b/Source/Forms/NetGraphForm.cs @@ -217,7 +217,7 @@ private void settings_Click(object sender, EventArgs e) { } private void trayIcon_MouseClick(object sender, MouseEventArgs e) { - if ((e.Button & MouseButtons.Left) > 0) { + if (e.Button.HasFlag(MouseButtons.Left)) { ToggleWindowVisibility(); } } @@ -241,14 +241,14 @@ private void NetGraphForm_Resize(object sender, EventArgs e) { private void NetGraphForm_MouseDown(object sender, MouseEventArgs e) { // Record drag start location. - if ((e.Button & MouseButtons.Left) > 0) { + if (e.Button.HasFlag(MouseButtons.Left)) { dragPoint = e.Location; } } private void NetGraphForm_MouseMove(object sender, MouseEventArgs e) { // Drag form. - if ((e.Button & MouseButtons.Left) > 0) { + if (e.Button.HasFlag(MouseButtons.Left)) { var container = Screen.FromRectangle(Bounds).WorkingArea; var x = Location.X + e.X - dragPoint.X; var y = Location.Y + e.Y - dragPoint.Y;