using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Mesen.GUI.Config; using Mesen.GUI.Controls; using System.Drawing.Imaging; namespace Mesen.GUI.Forms.Config { public partial class ctrlStandardController : BaseInputConfigControl { public ctrlStandardController() { InitializeComponent(); if(IsDesignMode) { return; } picBackground.Resize += picBackground_Resize; UpdateBackground(); } public int PortNumber { get; set; } private void picBackground_Resize(object sender, EventArgs e) { this.BeginInvoke((Action)(()=> UpdateBackground())); } public void UpdateBackground() { float xFactor = picBackground.Width / 614f; float yFactor = picBackground.Height / 279f; Bitmap bitmap = new Bitmap(picBackground.Width, picBackground.Height, PixelFormat.Format32bppPArgb); using(Graphics g = Graphics.FromImage(bitmap)) { g.ScaleTransform(xFactor, yFactor); using(Pen pen = new Pen(Color.LightGray, 2f)) { g.DrawRectangle(pen, 1, 1, 614 - 2, 279 - 2); g.DrawEllipse(pen, 15, 70, 170, 170); g.FillEllipse(Brushes.WhiteSmoke, 375, 48, 225, 225); } } picBackground.Image = bitmap; } public override void Initialize(KeyMapping mappings) { InitButton(btnA, mappings.A); InitButton(btnB, mappings.B); InitButton(btnStart, mappings.Start); InitButton(btnSelect, mappings.Select); InitButton(btnUp, mappings.Up); InitButton(btnDown, mappings.Down); InitButton(btnLeft, mappings.Left); InitButton(btnRight, mappings.Right); InitButton(btnX, mappings.X); InitButton(btnY, mappings.Y); InitButton(btnL, mappings.L); InitButton(btnR, mappings.R); InitButton(btnTurboR, mappings.TurboR); InitButton(btnTurboL, mappings.TurboL); InitButton(btnTurboA, mappings.TurboA); InitButton(btnTurboB, mappings.TurboB); InitButton(btnTurboX, mappings.TurboX); InitButton(btnTurboY, mappings.TurboY); this.OnChange(); } public override void UpdateKeyMappings(ref KeyMapping mappings) { mappings.A = (UInt32)btnA.Tag; mappings.B = (UInt32)btnB.Tag; mappings.Start = (UInt32)btnStart.Tag; mappings.Select = (UInt32)btnSelect.Tag; mappings.Up = (UInt32)btnUp.Tag; mappings.Down = (UInt32)btnDown.Tag; mappings.Left = (UInt32)btnLeft.Tag; mappings.Right = (UInt32)btnRight.Tag; mappings.X = (UInt32)btnX.Tag; mappings.Y = (UInt32)btnY.Tag; mappings.L = (UInt32)btnL.Tag; mappings.R = (UInt32)btnR.Tag; mappings.TurboA = (UInt32)btnTurboA.Tag; mappings.TurboB = (UInt32)btnTurboB.Tag; mappings.TurboX = (UInt32)btnTurboX.Tag; mappings.TurboY = (UInt32)btnTurboY.Tag; mappings.TurboL = (UInt32)btnTurboL.Tag; mappings.TurboR = (UInt32)btnTurboR.Tag; } } }