2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
* This program is released under GNU General Public License
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
2015-04-14 11:33:57 +00:00
|
|
|
using System;
|
2009-04-19 18:07:22 +00:00
|
|
|
using System.Globalization;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Config
|
|
|
|
{
|
2015-04-14 11:33:57 +00:00
|
|
|
public class EnumItem : IComparable<EnumItem>
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
2014-12-08 21:06:08 +00:00
|
|
|
private readonly string value;
|
|
|
|
private readonly string title;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
public string Value { get { return value; } }
|
|
|
|
public string Title { get { return title; } }
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
public EnumItem(string value, string title)
|
|
|
|
{
|
|
|
|
// Initialize
|
|
|
|
this.value = value;
|
|
|
|
this.title = title;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
// String representation
|
|
|
|
public override string ToString()
|
|
|
|
{
|
|
|
|
return title;
|
|
|
|
}
|
|
|
|
|
2015-04-14 11:33:57 +00:00
|
|
|
//mxd. This compares against another activate info
|
|
|
|
public int CompareTo(EnumItem other)
|
|
|
|
{
|
|
|
|
int thisval = GetIntValue();
|
|
|
|
int otherval = other.GetIntValue();
|
|
|
|
if(thisval < otherval) return -1;
|
|
|
|
if(thisval > otherval) return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// This returns the value as int
|
|
|
|
public int GetIntValue()
|
|
|
|
{
|
|
|
|
int result;
|
2014-12-08 21:06:08 +00:00
|
|
|
return int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result) ? result : 0;
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|