2013-07-19 15:30:58 +00:00
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
|
|
using System;
|
2013-06-25 12:35:13 +00:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
|
|
2013-07-19 15:30:58 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
2013-06-25 12:35:13 +00:00
|
|
|
|
namespace CodeImp.DoomBuilder.GZBuilder.Controls
|
|
|
|
|
{
|
|
|
|
|
public partial class PairedIntControl : UserControl
|
|
|
|
|
{
|
2013-07-19 15:30:58 +00:00
|
|
|
|
#region ================== Events
|
|
|
|
|
|
|
|
|
|
public event EventHandler OnValuesChanged;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
2013-06-25 12:35:13 +00:00
|
|
|
|
private int defaultValue;
|
2013-07-19 15:30:58 +00:00
|
|
|
|
private bool blockUpdate;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Properties
|
2013-06-25 12:35:13 +00:00
|
|
|
|
|
|
|
|
|
public string Label { get { return label.Text; } set { label.Text = value; } }
|
|
|
|
|
public int DefaultValue { get { return defaultValue; } set { defaultValue = value; } }
|
|
|
|
|
public int ButtonStep { get { return (int)value1.ButtonStep; } set { value1.ButtonStep = value; value2.ButtonStep = value; } }
|
|
|
|
|
|
2013-07-19 15:30:58 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
2013-06-25 12:35:13 +00:00
|
|
|
|
public PairedIntControl() {
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetValues(int val1, int val2) {
|
2013-07-19 15:30:58 +00:00
|
|
|
|
blockUpdate = true;
|
|
|
|
|
|
2013-06-25 12:35:13 +00:00
|
|
|
|
if(!string.IsNullOrEmpty(value1.Text) && value1.Text != val1.ToString())
|
|
|
|
|
value1.Text = "";
|
|
|
|
|
else
|
|
|
|
|
value1.Text = val1.ToString();
|
|
|
|
|
|
|
|
|
|
if(!string.IsNullOrEmpty(value2.Text) && value2.Text != val2.ToString())
|
|
|
|
|
value2.Text = "";
|
|
|
|
|
else
|
|
|
|
|
value2.Text = val2.ToString();
|
2013-07-19 15:30:58 +00:00
|
|
|
|
|
|
|
|
|
blockUpdate = false;
|
2013-06-25 12:35:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int GetValue1(int original) {
|
|
|
|
|
return value1.GetResult(original);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int GetValue2(int original) {
|
|
|
|
|
return value2.GetResult(original);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void checkValues() {
|
2013-09-11 08:49:45 +00:00
|
|
|
|
bool changed = string.IsNullOrEmpty(value1.Text) || string.IsNullOrEmpty(value2.Text)
|
|
|
|
|
|| value1.GetResult(defaultValue) != defaultValue || value2.GetResult(defaultValue) != defaultValue;
|
2013-06-25 12:35:13 +00:00
|
|
|
|
label.Enabled = changed;
|
|
|
|
|
bReset.Visible = changed;
|
2013-07-19 15:30:58 +00:00
|
|
|
|
|
|
|
|
|
if(!blockUpdate && OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
|
2013-06-25 12:35:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void bReset_Click(object sender, EventArgs e) {
|
|
|
|
|
value1.Text = defaultValue.ToString();
|
|
|
|
|
value2.Text = defaultValue.ToString();
|
|
|
|
|
checkValues();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void value1_WhenTextChanged(object sender, EventArgs e) {
|
|
|
|
|
checkValues();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|