cleanup PresentationPanel.cs

This commit is contained in:
adelikat 2019-11-30 10:46:05 -06:00
parent 2d65d2b66a
commit d2ff9b6ff0
1 changed files with 15 additions and 24 deletions

View File

@ -1,17 +1,9 @@
using System;
using System.Drawing;
using sd=System.Drawing;
using sysdrawingfont=System.Drawing.Font;
using sysdrawing2d=System.Drawing.Drawing2D;
using System.IO;
using System.Threading;
using System.Drawing;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Bizware.BizwareGL;
using OpenTK.Graphics.OpenGL;
namespace BizHawk.Client.EmuHawk
{
/// <summary>
@ -23,23 +15,25 @@ namespace BizHawk.Client.EmuHawk
{
GL = GlobalWin.GL;
GraphicsControl = new GraphicsControl(GL);
GraphicsControl.Dock = DockStyle.Fill;
GraphicsControl.BackColor = Color.Black;
GraphicsControl = new GraphicsControl(GL)
{
Dock = DockStyle.Fill,
BackColor = Color.Black
};
//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 += (o, e) => HandleFullscreenToggle(o, e);
// 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) => GlobalWin.MainForm.MainForm_MouseClick(o, e);
GraphicsControl.MouseMove += (o, e) => GlobalWin.MainForm.MainForm_MouseMove(o, e);
GraphicsControl.MouseWheel += (o, e) => GlobalWin.MainForm.MainForm_MouseWheel(o, e);
}
bool IsDisposed = false;
private bool _isDisposed;
public void Dispose()
{
if (IsDisposed) return;
IsDisposed = true;
if (_isDisposed) return;
_isDisposed = true;
GraphicsControl.Dispose();
}
@ -47,14 +41,14 @@ namespace BizHawk.Client.EmuHawk
IGL GL;
public GraphicsControl GraphicsControl;
public Control Control { get { return GraphicsControl; } }
public Control Control => GraphicsControl;
public static implicit operator Control(PresentationPanel self) { return self.GraphicsControl; }
private void HandleFullscreenToggle(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
//allow suppression of the toggle.. but if shift is pressed, always do the toggle
// allow suppression of the toggle.. but if shift is pressed, always do the toggle
bool allowSuppress = Control.ModifierKeys != Keys.Shift;
if (Global.Config.DispChrome_AllowDoubleClickFullscreen || !allowSuppress)
{
@ -65,11 +59,8 @@ namespace BizHawk.Client.EmuHawk
public bool Resized { get; set; }
public Size NativeSize { get { return GraphicsControl.ClientSize; } }
public Size NativeSize => GraphicsControl.ClientSize;
}
public interface IBlitterFont { }
}