mirror of
https://github.com/LorenzCK/OnTopReplica.git
synced 2024-05-20 20:33:06 +12:00
Marginal clean up and fixing of context menu handlers.
This commit is contained in:
parent
0ca078a0a5
commit
bc7ad48fc3
|
@ -151,7 +151,7 @@ namespace OnTopReplica {
|
|||
|
||||
//Same story as above (OnMouseDoubleClick)
|
||||
if (e.Button == System.Windows.Forms.MouseButtons.Right) {
|
||||
OpenContextMenu();
|
||||
OpenContextMenu(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ namespace OnTopReplica {
|
|||
case WM.NCRBUTTONUP:
|
||||
//Open context menu if right button clicked on caption (i.e. all of the window area because of glass)
|
||||
if (m.WParam.ToInt32() == HT.CAPTION) {
|
||||
OpenContextMenu();
|
||||
OpenContextMenu(null);
|
||||
|
||||
m.Result = IntPtr.Zero;
|
||||
return;
|
||||
|
|
|
@ -8,36 +8,20 @@ namespace OnTopReplica {
|
|||
/// <summary>
|
||||
/// Opens the context menu.
|
||||
/// </summary>
|
||||
public void OpenContextMenu() {
|
||||
/// <param name="position">Optional position of the mouse, relative to which the menu is shown.</param>
|
||||
public void OpenContextMenu(Point? position) {
|
||||
Point menuPosition = MousePosition;
|
||||
if (position.HasValue)
|
||||
menuPosition = position.Value;
|
||||
|
||||
if (IsFullscreen) {
|
||||
menuFullscreenContext.Show(MousePosition);
|
||||
menuFullscreenContext.Show(menuPosition);
|
||||
}
|
||||
else {
|
||||
menuContext.Show(MousePosition);
|
||||
menuContext.Show(menuPosition);
|
||||
}
|
||||
}
|
||||
|
||||
private Point RecenterLocation(Control original, Control final) {
|
||||
int origX = original.Location.X + original.Size.Width / 2;
|
||||
int origY = original.Location.Y + original.Size.Height / 2;
|
||||
|
||||
int finX = origX - final.Size.Width / 2;
|
||||
int finY = origY - final.Size.Height / 2;
|
||||
|
||||
//Check boundaries
|
||||
var screen = Screen.FromControl(final);
|
||||
if (finX < screen.WorkingArea.X)
|
||||
finX = screen.WorkingArea.X;
|
||||
if (finX + final.Size.Width > screen.WorkingArea.Width)
|
||||
finX = screen.WorkingArea.Width - final.Size.Width;
|
||||
if (finY < screen.WorkingArea.Y)
|
||||
finY = screen.WorkingArea.Y;
|
||||
if (finY + final.Size.Height > screen.WorkingArea.Height)
|
||||
finY = screen.WorkingArea.Height - final.Size.Height;
|
||||
|
||||
return new Point(finX, finY);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the window's vertical chrome size.
|
||||
/// </summary>
|
||||
|
|
|
@ -165,15 +165,6 @@ namespace OnTopReplica {
|
|||
}
|
||||
|
||||
private void Menu_About_click(object sender, EventArgs e) {
|
||||
/*this.Hide();
|
||||
|
||||
using (var box = new AboutForm()) {
|
||||
box.Location = RecenterLocation(this, box);
|
||||
box.ShowDialog();
|
||||
Location = RecenterLocation(box, this);
|
||||
}
|
||||
|
||||
this.Show();*/
|
||||
this.SetSidePanel(new AboutPanel());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue