2012-08-14 20:10:59 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Windows
|
|
|
|
|
{
|
|
|
|
|
public partial class FlagsForm : DelayedForm
|
|
|
|
|
{
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
2013-03-18 13:52:27 +00:00
|
|
|
|
//private bool setup;
|
2012-08-14 20:10:59 +00:00
|
|
|
|
private string value;
|
|
|
|
|
private IDictionary<string, string> flagdefs;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
|
|
public string Value { get { return value; } }
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
|
|
public FlagsForm()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Setup from EnumList
|
|
|
|
|
public void Setup(string value, IDictionary<string, string> inflags)
|
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
|
//setup = true;
|
2012-08-14 20:10:59 +00:00
|
|
|
|
this.value = value;
|
|
|
|
|
flagdefs = inflags;
|
|
|
|
|
|
|
|
|
|
// Fill flags list
|
|
|
|
|
foreach (KeyValuePair<string, string> tf in flagdefs)
|
|
|
|
|
flags.Add(tf.Value, tf.Key);
|
|
|
|
|
|
|
|
|
|
// Parse the value string and check the boxes if necessary
|
|
|
|
|
if (value.Trim() != "")
|
|
|
|
|
{
|
|
|
|
|
foreach (string s in value.Split(','))
|
|
|
|
|
{
|
|
|
|
|
string str = s.Trim();
|
|
|
|
|
|
|
|
|
|
// Make sure the given flag actually exists
|
|
|
|
|
if(!flagdefs.ContainsKey(str))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
foreach (CheckBox c in flags.Checkboxes)
|
|
|
|
|
{
|
|
|
|
|
if (c.Text == flagdefs[str])
|
|
|
|
|
c.Checked = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-18 13:52:27 +00:00
|
|
|
|
//setup = false;
|
2012-08-14 20:10:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This shows the dialog
|
|
|
|
|
// Returns the flags or the same flags when cancelled
|
|
|
|
|
public static string ShowDialog(IWin32Window owner, string value, IDictionary<string, string> inflags)
|
|
|
|
|
{
|
|
|
|
|
string result = value;
|
|
|
|
|
FlagsForm f = new FlagsForm();
|
|
|
|
|
f.Setup(value, inflags);
|
|
|
|
|
if (f.ShowDialog(owner) == DialogResult.OK) result = f.Value;
|
|
|
|
|
f.Dispose();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private void LinedefFlagsForm_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void apply_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
value = "";
|
|
|
|
|
|
|
|
|
|
foreach (CheckBox c in flags.Checkboxes)
|
|
|
|
|
{
|
|
|
|
|
if(c.Checked == false) continue;
|
|
|
|
|
|
|
|
|
|
foreach (KeyValuePair<string, string> lf in flagdefs)
|
|
|
|
|
{
|
|
|
|
|
if (lf.Value == c.Text)
|
|
|
|
|
{
|
|
|
|
|
if (value != "") value += ",";
|
|
|
|
|
value += lf.Key.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DialogResult = DialogResult.OK;
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Close
|
|
|
|
|
DialogResult = DialogResult.Cancel;
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|