BizHawk/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPad.cs

79 lines
1.6 KiB
C#
Raw Normal View History

2014-06-22 13:58:12 +00:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Emulation.Common;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
{
2014-06-22 15:05:37 +00:00
public partial class VirtualPad : UserControl, IVirtualPad
2014-06-22 13:58:12 +00:00
{
private PadSchema _schema;
2014-06-22 15:05:37 +00:00
public VirtualPad(PadSchema schema)
2014-06-22 13:58:12 +00:00
{
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
BorderStyle = BorderStyle.Fixed3D;
InitializeComponent();
_schema = schema;
}
private void VirtualPadControl_Load(object sender, EventArgs e)
{
Size = _schema.DefaultSize;
foreach (var button in _schema.Buttons)
{
switch (button.Type)
{
case PadSchema.PadInputType.Boolean:
2014-06-22 15:43:45 +00:00
Controls.Add(new VirtualPadButton
2014-06-22 13:58:12 +00:00
{
Name = button.Name,
Text = button.DisplayName,
2014-06-22 15:43:45 +00:00
Location = button.Location,
2014-06-22 13:58:12 +00:00
Image = button.Icon
2014-06-22 15:43:45 +00:00
});
2014-06-22 13:58:12 +00:00
break;
2014-06-22 15:43:45 +00:00
case PadSchema.PadInputType.AnalogStick:
2014-06-22 16:30:24 +00:00
Controls.Add(new AnalogStickPanel
2014-06-22 15:43:45 +00:00
{
Name = button.Name,
Location = button.Location
});
2014-06-22 13:58:12 +00:00
break;
}
}
}
public void Clear()
{
Controls
2014-06-22 15:05:37 +00:00
.OfType<IVirtualPadControl>()
2014-06-22 13:58:12 +00:00
.ToList()
.ForEach(c => {
2014-06-22 15:05:37 +00:00
c.Clear();
2014-06-22 13:58:12 +00:00
});
}
public IController Get()
{
return Global.MovieSession.MovieControllerInstance();
}
public void Set(IController controller)
{
}
}
}