public Animatroller.Framework.PhysicalDevice.DigitalInput AddDigitalInput_FlipFlop(DigitalInput2 logicalDevice, bool showOutput)
{
var control = new CheckBox();
control.Text = logicalDevice.Name;
control.Size = new System.Drawing.Size(80, 60);
control.ImageAlign = ContentAlignment.TopLeft;
var indicator = new Animatroller.Simulator.Control.Bulb.LedBulb();
indicator.On = false;
indicator.Size = new System.Drawing.Size(12, 12);
indicator.Left = 0;
indicator.Top = 0;
var imageOff = new Bitmap(12, 12);
indicator.DrawToBitmap(imageOff, new Rectangle(0, 0, 12, 12));
var imageOn = new Bitmap(12, 12);
indicator.On = true;
indicator.DrawToBitmap(imageOn, new Rectangle(0, 0, 12, 12));
flowLayoutPanelLights.Controls.Add(control);
var device = new Animatroller.Framework.PhysicalDevice.DigitalInput();
control.CheckedChanged += (sender, e) =>
{
device.Trigger((sender as CheckBox).Checked);
};
device.Connect(logicalDevice);
control.Checked = logicalDevice.Value;
logicalDevice.Output
.ObserveOn(SynchronizationContext.Current)
.Subscribe(x =>
{
control.Checked = x;
if (showOutput)
control.Image = x ? imageOn : imageOff;
});
return device;
}