101 lines
3.3 KiB
C#
101 lines
3.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
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>();
|
|
ColorIndx["black"] = 1;
|
|
ColorIndx["blue"] = 2;
|
|
ColorIndx["green"] = 3;
|
|
ColorIndx["cyan"] = 4;
|
|
ColorIndx["red"] = 5;
|
|
ColorIndx["magenta"] = 6;
|
|
ColorIndx["brown"] = 7;
|
|
ColorIndx["lightgray"] = 8;
|
|
ColorIndx["darkgray"] = 9;
|
|
ColorIndx["lightblue"] = 10;
|
|
ColorIndx["lightgreen"] = 11;
|
|
ColorIndx["lightcyan"] = 12;
|
|
ColorIndx["lightred"] = 13;
|
|
ColorIndx["lightmagenta"] = 14;
|
|
ColorIndx["yellow"] = 15;
|
|
ColorIndx["white"] = 16;
|
|
ColorIndx["ro"] = 17;
|
|
ColorIndx["trans"] = 18;
|
|
ColorIndx["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)
|
|
{
|
|
Dictionary<string, int> ColorIndx = new Dictionary<string, int>();
|
|
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
|
|
ColorRtf["black"] = "\\red0\\green0\\blue0;";
|
|
ColorRtf["blue"] = "\\red0\\green0\\blue255;";
|
|
ColorRtf["green"] = "\\red0\\green155\\blue12;";
|
|
ColorRtf["cyan"] = "\\red0\\green136\\blue159;";
|
|
ColorRtf["red"] = "\\red255\\green0\\blue0;";
|
|
ColorRtf["magenta"] = "\\red202\\green28\\blue175;";
|
|
ColorRtf["brown"] = "\\red128\\green64\\blue0;";
|
|
ColorRtf["lightgray"] = "\\red100\\green100\\blue100;";
|
|
ColorRtf["darkgray"] = "\\red10\\green10\\blue10;";
|
|
ColorRtf["lightblue"] = "\\red0\\green0\\blue255;";
|
|
ColorRtf["lightgreen"] = "\\red0\\green255\\blue0;";
|
|
ColorRtf["lightcyan"] = "\\red0\\green0\\blue255;";
|
|
ColorRtf["lightred"] = "\\red209\\green29\\blue183;";
|
|
ColorRtf["lightmagenta"] = "\\red255\\green0\\blue255;";
|
|
ColorRtf["yellow"] = "\\red255\\green0\\blue0;";
|
|
ColorRtf["white"] = "\\red128\\green128\\blue128;";
|
|
ColorRtf["ro"] = "\\red255\\green128\\blue0;";
|
|
ColorRtf["trans"] = "\\red255\\green128\\blue0;";
|
|
ColorRtf["editbackground"] = "\\red192\\green192\\blue192;";
|
|
}
|
|
return ColorRtf[color];
|
|
}
|
|
#endregion
|
|
}
|
|
}
|