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.Load += new System.EventHandler(this.MainForm_Load);
|
||||||
this.Shown += new System.EventHandler(this.MainForm_Shown);
|
this.Shown += new System.EventHandler(this.MainForm_Shown);
|
||||||
this.Enter += new System.EventHandler(this.MainForm_Enter);
|
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.Resize += new System.EventHandler(this.MainForm_Resize);
|
||||||
this.MainformMenu.ResumeLayout(false);
|
this.MainformMenu.ResumeLayout(false);
|
||||||
this.MainformMenu.PerformLayout();
|
this.MainformMenu.PerformLayout();
|
||||||
|
|
|
@ -2613,25 +2613,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
AutohideCursor(false);
|
AutohideCursor(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MainForm_MouseWheel(object sender, MouseEventArgs e)
|
public MouseEventHandler MainForm_MouseWheel { get; }
|
||||||
{
|
|
||||||
MouseWheelTracker += e.Delta;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MainForm_MouseMove(object sender, MouseEventArgs e)
|
public MouseEventHandler MainForm_MouseMove { get; }
|
||||||
{
|
|
||||||
AutohideCursor(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MainForm_MouseClick(object sender, MouseEventArgs e)
|
public MouseEventHandler MainForm_MouseClick { get; }
|
||||||
{
|
|
||||||
AutohideCursor(false);
|
|
||||||
if (Config.ShowContextMenu && e.Button == MouseButtons.Right)
|
|
||||||
{
|
|
||||||
MainFormContextMenu.Show(
|
|
||||||
PointToScreen(new Point(e.X, e.Y + MainformMenu.Height)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MainForm_Resize(object sender, EventArgs e)
|
private void MainForm_Resize(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -371,6 +371,17 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Sound?.StartSound();
|
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 => {
|
Input.Instance.MainFormInputAllowedCallback = yieldAlt => {
|
||||||
// the main form gets input
|
// the main form gets input
|
||||||
if (ActiveForm == this)
|
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.
|
// 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)
|
// http://stackoverflow.com/questions/547172/pass-through-mouse-events-to-parent-control (HTTRANSPARENT)
|
||||||
GraphicsControl.MouseDoubleClick += HandleFullscreenToggle;
|
GraphicsControl.MouseDoubleClick += HandleFullscreenToggle;
|
||||||
GraphicsControl.MouseClick += (o, e) => _mainForm.MainForm_MouseClick(o, e);
|
GraphicsControl.MouseClick += _mainForm.MainForm_MouseClick;
|
||||||
GraphicsControl.MouseMove += (o, e) => _mainForm.MainForm_MouseMove(o, e);
|
GraphicsControl.MouseMove += _mainForm.MainForm_MouseMove;
|
||||||
GraphicsControl.MouseWheel += (o, e) => _mainForm.MainForm_MouseWheel(o, e);
|
GraphicsControl.MouseWheel += _mainForm.MainForm_MouseWheel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _isDisposed;
|
private bool _isDisposed;
|
||||||
|
|
Loading…
Reference in New Issue