using System.Collections.Generic; using System.Windows.Forms; using System.Drawing; using BizHawk.Client.Common; namespace BizHawk.Client.EmuHawk { public class AnalogBindPanel : UserControl { private readonly Dictionary _realConfigObject; public AnalogBindPanel(Dictionary realConfigObject, List realConfigButtons = null) { _realConfigObject = realConfigObject; LoadSettings(realConfigButtons ?? (IEnumerable)realConfigObject.Keys); } private void LoadSettings(IEnumerable buttonList) { SuspendLayout(); int x = 4; int y = 4; foreach (string buttonName in buttonList) { var ctrl = new AnalogBindControl(buttonName, _realConfigObject[buttonName]) { 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; } } } }