101 lines
3.8 KiB
C#
101 lines
3.8 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace VEPROMS.CSLA.Library
|
|
{
|
|
public static class ColorTab
|
|
{
|
|
private static Dictionary<string, int> ColorIndx = null;
|
|
// This dictionary takes a color name and converts it to the rtf string:
|
|
private static Dictionary<string, string> ColorRtf = null;
|
|
public enum E_Colors : int
|
|
{
|
|
black = 1, blue, green, cyan, red, magenta, brown, lightgray, darkgray, lightblue, lightgreen,
|
|
lightcyan, lightred, lightmagenta, yellow, white, ro, editbackground
|
|
}
|
|
#region ColorIndex
|
|
// Do I need this anymore.... I was using it when entire color table was in the rtf box.
|
|
public static int GetIndex(string color)
|
|
{
|
|
// if the dictionary hasn't been set yet,
|
|
if (ColorIndx==null)
|
|
{
|
|
ColorIndx = new Dictionary<string, int>
|
|
{
|
|
["black"] = 1,
|
|
["blue"] = 2,
|
|
["green"] = 3,
|
|
["cyan"] = 4,
|
|
["red"] = 5,
|
|
["magenta"] = 6,
|
|
["brown"] = 7,
|
|
["lightgray"] = 8,
|
|
["darkgray"] = 9,
|
|
["lightblue"] = 10,
|
|
["lightgreen"] = 11,
|
|
["lightcyan"] = 12,
|
|
["lightred"] = 13,
|
|
["lightmagenta"] = 14,
|
|
["yellow"] = 15,
|
|
["white"] = 16,
|
|
["ro"] = 17,
|
|
["trans"] = 18,
|
|
["editbackground"] = 19
|
|
};
|
|
}
|
|
return ColorIndx[color];
|
|
}
|
|
#endregion
|
|
#region ColorRtf
|
|
// This gets the rtf color table string for the input color.
|
|
public static string GetTableString(string color)
|
|
{
|
|
if (ColorRtf == null)
|
|
{
|
|
ColorRtf = new Dictionary<string, string>
|
|
{
|
|
// color table, from 16-bit code, is defined as (in order):
|
|
// black=0,0,0
|
|
// blue=0,0,255
|
|
// green=0,155,12
|
|
// cyan=0,136,159
|
|
// red=255,0,0
|
|
// magenta=202,28,175
|
|
// brown=128,64,0
|
|
// lightgray=0,0,0
|
|
// darkgray=0,0,0
|
|
// lightblue=0,0,255
|
|
// lightgreen=0,255,0
|
|
// lightcyan=0,0,255
|
|
// lightred=209,29,183
|
|
// lightmagenta=255,0,255
|
|
// yellow=255,0,0
|
|
// white=128,128,128
|
|
// ro=255,128,0
|
|
// editbackground=192,192,192
|
|
["black"] = "\\red0\\green0\\blue0;",
|
|
["blue"] = "\\red0\\green0\\blue255;",
|
|
["green"] = "\\red0\\green155\\blue12;",
|
|
["cyan"] = "\\red0\\green136\\blue159;",
|
|
["red"] = "\\red255\\green0\\blue0;",
|
|
["magenta"] = "\\red202\\green28\\blue175;",
|
|
["brown"] = "\\red128\\green64\\blue0;",
|
|
["lightgray"] = "\\red100\\green100\\blue100;",
|
|
["darkgray"] = "\\red10\\green10\\blue10;",
|
|
["lightblue"] = "\\red0\\green0\\blue255;",
|
|
["lightgreen"] = "\\red0\\green255\\blue0;",
|
|
["lightcyan"] = "\\red0\\green0\\blue255;",
|
|
["lightred"] = "\\red209\\green29\\blue183;",
|
|
["lightmagenta"] = "\\red255\\green0\\blue255;",
|
|
["yellow"] = "\\red255\\green0\\blue0;",
|
|
["white"] = "\\red128\\green128\\blue128;",
|
|
["ro"] = "\\red255\\green128\\blue0;",
|
|
["trans"] = "\\red255\\green128\\blue0;",
|
|
["editbackground"] = "\\red192\\green192\\blue192;"
|
|
};
|
|
}
|
|
return ColorRtf[color];
|
|
}
|
|
#endregion
|
|
}
|
|
}
|