UltimateZoneBuilder/Source/Rendering/ColorSetting.cs

96 lines
2.1 KiB
C#
Raw Normal View History

2007-06-15 18:30:55 +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
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Reflection;
using System.Drawing;
2007-06-15 18:30:55 +00:00
#endregion
namespace CodeImp.DoomBuilder.Rendering
2007-06-15 18:30:55 +00:00
{
2008-01-02 21:49:43 +00:00
internal sealed class ColorSetting : IEquatable<ColorSetting>
2007-06-15 18:30:55 +00:00
{
#region ================== Constants
#endregion
#region ================== Variables
private string name;
private PixelColor color;
2007-06-15 18:30:55 +00:00
#endregion
#region ================== Properties
2007-10-20 10:02:20 +00:00
public Color Color { get { return Color.FromArgb(color.ToInt()); } set { color = PixelColor.FromColor(value); } }
public PixelColor PixelColor { get { return color; } set { color = value; } }
public string Name { get { return name; } }
2007-06-15 18:30:55 +00:00
#endregion
#region ================== Constructor / Disposer
// Constructor
public ColorSetting(string name, PixelColor color)
2007-06-15 18:30:55 +00:00
{
// Initialize
this.name = name;
this.color = color;
// We have no destructor
GC.SuppressFinalize(this);
2007-06-15 18:30:55 +00:00
}
#endregion
#region ================== Methods
2007-10-20 12:34:27 +00:00
// This returns a PixelColor with adjusted alpha
public PixelColor WithAlpha(byte a)
{
return new PixelColor(color, a);
}
// Equal?
public bool Equals(ColorSetting other)
{
return this.name == other.name;
}
// To PixelColor
public static implicit operator PixelColor(ColorSetting c)
2007-06-15 22:38:42 +00:00
{
return c.color;
2007-06-15 22:38:42 +00:00
}
2007-10-20 10:02:20 +00:00
// To Color
public static implicit operator Color(ColorSetting c)
{
return Color.FromArgb(c.color.ToInt());
}
2007-06-15 22:38:42 +00:00
2007-06-15 18:30:55 +00:00
#endregion
}
}