Change some MainForm event handlers to delegate typed properties
makes encapsulation easier
This commit is contained in:
parent
499b59a0bd
commit
e3c54b2268
|
@ -3230,8 +3230,6 @@
|
|||
this.Load += new System.EventHandler(this.MainForm_Load);
|
||||
this.Shown += new System.EventHandler(this.MainForm_Shown);
|
||||
this.Enter += new System.EventHandler(this.MainForm_Enter);
|
||||
this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.MainForm_MouseClick);
|
||||
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.MainForm_MouseMove);
|
||||
this.Resize += new System.EventHandler(this.MainForm_Resize);
|
||||
this.MainformMenu.ResumeLayout(false);
|
||||
this.MainformMenu.PerformLayout();
|
||||
|
|
|
@ -2613,25 +2613,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
AutohideCursor(false);
|
||||
}
|
||||
|
||||
public void MainForm_MouseWheel(object sender, MouseEventArgs e)
|
||||
{
|
||||
MouseWheelTracker += e.Delta;
|
||||
}
|
||||
public MouseEventHandler MainForm_MouseWheel { get; }
|
||||
|
||||
public void MainForm_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
AutohideCursor(false);
|
||||
}
|
||||
public MouseEventHandler MainForm_MouseMove { get; }
|
||||
|
||||
public void MainForm_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
AutohideCursor(false);
|
||||
if (Config.ShowContextMenu && e.Button == MouseButtons.Right)
|
||||
{
|
||||
MainFormContextMenu.Show(
|
||||
PointToScreen(new Point(e.X, e.Y + MainformMenu.Height)));
|
||||
}
|
||||
}
|
||||
public MouseEventHandler MainForm_MouseClick { get; }
|
||||
|
||||
private void MainForm_Resize(object sender, EventArgs e)
|
||||
{
|
||||
|
|
|
@ -371,6 +371,17 @@ namespace BizHawk.Client.EmuHawk
|
|||
Sound?.StartSound();
|
||||
};
|
||||
|
||||
MouseClick += MainForm_MouseClick = (sender, e) =>
|
||||
{
|
||||
AutohideCursor(false);
|
||||
if (Config.ShowContextMenu && e.Button == MouseButtons.Right)
|
||||
{
|
||||
MainFormContextMenu.Show(PointToScreen(new Point(e.X, e.Y + MainformMenu.Height)));
|
||||
}
|
||||
};
|
||||
MouseMove += MainForm_MouseMove = (sender, e) => AutohideCursor(false);
|
||||
MainForm_MouseWheel = (sender, e) => MouseWheelTracker += e.Delta;
|
||||
|
||||
Input.Instance.MainFormInputAllowedCallback = yieldAlt => {
|
||||
// the main form gets input
|
||||
if (ActiveForm == this)
|
||||
|
|
|
@ -28,9 +28,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
// pass through these events to the form. we might need a more scalable solution for mousedown etc. for zapper and whatnot.
|
||||
// http://stackoverflow.com/questions/547172/pass-through-mouse-events-to-parent-control (HTTRANSPARENT)
|
||||
GraphicsControl.MouseDoubleClick += HandleFullscreenToggle;
|
||||
GraphicsControl.MouseClick += (o, e) => _mainForm.MainForm_MouseClick(o, e);
|
||||
GraphicsControl.MouseMove += (o, e) => _mainForm.MainForm_MouseMove(o, e);
|
||||
GraphicsControl.MouseWheel += (o, e) => _mainForm.MainForm_MouseWheel(o, e);
|
||||
GraphicsControl.MouseClick += _mainForm.MainForm_MouseClick;
|
||||
GraphicsControl.MouseMove += _mainForm.MainForm_MouseMove;
|
||||
GraphicsControl.MouseWheel += _mainForm.MainForm_MouseWheel;
|
||||
}
|
||||
|
||||
private bool _isDisposed;
|
||||
|
|
Loading…
Reference in New Issue