2013-07-19 15:30:58 +00:00
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
|
|
using System;
|
2014-12-03 23:15:26 +00:00
|
|
|
|
using System.Globalization;
|
2013-06-25 12:35:13 +00:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
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;
|
2015-01-05 14:56:44 +00:00
|
|
|
|
private bool changed;
|
2013-07-19 15:30:58 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Properties
|
2013-06-25 12:35:13 +00:00
|
|
|
|
|
2015-01-05 14:56:44 +00:00
|
|
|
|
public bool NonDefaultValue { get { return changed; } }
|
2013-06-25 12:35:13 +00:00
|
|
|
|
public int DefaultValue { get { return defaultValue; } set { defaultValue = value; } }
|
2014-01-20 08:47:49 +00:00
|
|
|
|
public int ButtonStep { get { return value1.ButtonStep; } set { value1.ButtonStep = value; value2.ButtonStep = value; } }
|
2015-03-23 14:21:32 +00:00
|
|
|
|
public float ButtonStepBig { get { return value1.ButtonStepBig; } set { value1.ButtonStepBig = value; value2.ButtonStepBig = value; } }
|
|
|
|
|
public float ButtonStepSmall { get { return value1.ButtonStepSmall; } set { value1.ButtonStepSmall = value; value2.ButtonStepSmall = value; } }
|
|
|
|
|
public bool ButtonStepsUseModifierKeys { get { return value1.ButtonStepsUseModifierKeys; } set { value1.ButtonStepsUseModifierKeys = value; value2.ButtonStepsUseModifierKeys = value; } }
|
2013-06-25 12:35:13 +00:00
|
|
|
|
|
2013-07-19 15:30:58 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public PairedIntControl()
|
|
|
|
|
{
|
2013-06-25 12:35:13 +00:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public void SetValues(int val1, int val2, bool first)
|
|
|
|
|
{
|
2013-07-19 15:30:58 +00:00
|
|
|
|
blockUpdate = true;
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if (first)
|
|
|
|
|
{
|
|
|
|
|
value1.Text = val1.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
value2.Text = val2.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(value1.Text) && value1.Text != val1.ToString(CultureInfo.InvariantCulture))
|
2014-01-20 08:47:49 +00:00
|
|
|
|
value1.Text = string.Empty;
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(value2.Text) && value2.Text != val2.ToString(CultureInfo.InvariantCulture))
|
2014-01-20 08:47:49 +00:00
|
|
|
|
value2.Text = string.Empty;
|
|
|
|
|
}
|
2013-07-19 15:30:58 +00:00
|
|
|
|
|
|
|
|
|
blockUpdate = false;
|
2013-06-25 12:35:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public int GetValue1(int original)
|
|
|
|
|
{
|
2013-06-25 12:35:13 +00:00
|
|
|
|
return value1.GetResult(original);
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public int GetValue2(int original)
|
|
|
|
|
{
|
2013-06-25 12:35:13 +00:00
|
|
|
|
return value2.GetResult(original);
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
private void CheckValues()
|
|
|
|
|
{
|
2015-01-05 14:56:44 +00:00
|
|
|
|
changed = string.IsNullOrEmpty(value1.Text) || string.IsNullOrEmpty(value2.Text)
|
2015-07-26 23:18:13 +00:00
|
|
|
|
|| value1.GetResult(defaultValue, 0) != defaultValue || value2.GetResult(defaultValue, 0) != defaultValue;
|
2013-06-25 12:35:13 +00:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
private void bReset_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
value1.Text = defaultValue.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
value2.Text = defaultValue.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
CheckValues();
|
2013-06-25 12:35:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
private void value1_WhenTextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CheckValues();
|
2013-06-25 12:35:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|