BizHawk/BizHawk.Client.EmuHawk/tools/BasicBot/BotControlsRow.cs

52 lines
1.2 KiB
C#
Raw Normal View History

2015-08-27 12:19:36 +00:00
using System;
using System.Windows.Forms;
namespace BizHawk.Client.EmuHawk
{
public partial class BotControlsRow : UserControl
{
private bool _programmaticallyChangingValues;
2015-08-27 12:19:36 +00:00
public BotControlsRow()
{
InitializeComponent();
}
2015-09-07 00:37:46 +00:00
public Action ProbabilityChangedCallback { get; set; }
2015-08-27 12:19:36 +00:00
public string ButtonName
{
2019-12-22 19:58:00 +00:00
get => ButtonNameLabel.Text;
set => ButtonNameLabel.Text = value;
2015-08-27 12:19:36 +00:00
}
public double Probability
{
2019-12-22 19:58:00 +00:00
get => (double)ProbabilityUpDown.Value;
set => ProbabilityUpDown.Value = (decimal)value;
2015-08-27 12:19:36 +00:00
}
private void ProbabilityUpDown_ValueChanged(object sender, EventArgs e)
{
2016-01-31 02:28:49 +00:00
if (!_programmaticallyChangingValues)
{
_programmaticallyChangingValues = true;
ProbabilitySlider.Value = (int)ProbabilityUpDown.Value;
2019-12-22 19:58:00 +00:00
ProbabilityChangedCallback?.Invoke();
2016-01-31 02:28:49 +00:00
_programmaticallyChangingValues = false;
}
}
private void ProbabilitySlider_ValueChanged(object sender, EventArgs e)
{
2016-01-31 02:28:49 +00:00
if (!_programmaticallyChangingValues)
{
_programmaticallyChangingValues = true;
ProbabilityUpDown.Value = ProbabilitySlider.Value;
2019-12-22 19:58:00 +00:00
ProbabilityChangedCallback?.Invoke();
2016-01-31 02:28:49 +00:00
_programmaticallyChangingValues = false;
}
}
2015-08-27 12:19:36 +00:00
}
}