using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing; using BizHawk.Client.Common; namespace BizHawk.Client.EmuHawk { class AnalogBindPanel : UserControl { Dictionary RealConfigObject; public AnalogBindPanel(Dictionary RealConfigObject, List RealConfigButtons = null) :base() { this.RealConfigObject = RealConfigObject; LoadSettings(RealConfigButtons ?? (IEnumerable)RealConfigObject.Keys); } void LoadSettings(IEnumerable ButtonList) { SuspendLayout(); int x = 4; int y = 4; foreach (string ButtonName in ButtonList) { var ctrl = new AnalogBindControl(ButtonName, RealConfigObject[ButtonName]); ctrl.Location = new Point(x, y); y += ctrl.Height + 4; Controls.Add(ctrl); } ResumeLayout(); } /// /// save to config /// /// if non-null, save to possibly different config object than originally initialized from public void Save(Dictionary SaveConfigObject = null) { var saveto = SaveConfigObject ?? RealConfigObject; foreach (Control c in Controls) { var abc = (AnalogBindControl)c; saveto[abc.ButtonName] = abc.Bind; } } } }