Click here to Skip to main content
15,886,835 members
Home / Discussions / C#
   

C#

 
GeneralRe: Online Messages / High Scores Pin
Christian Graus15-Dec-07 13:54
protectorChristian Graus15-Dec-07 13:54 
GeneralProblem to use System.Diagnostics.ProcessWindowStyle.Hidden. Pin
hdv21215-Dec-07 11:46
hdv21215-Dec-07 11:46 
GeneralRe: Problem to use System.Diagnostics.ProcessWindowStyle.Hidden. Pin
Luc Pattyn15-Dec-07 12:26
sitebuilderLuc Pattyn15-Dec-07 12:26 
GeneralRe: Problem to use System.Diagnostics.ProcessWindowStyle.Hidden. Pin
hdv21215-Dec-07 21:11
hdv21215-Dec-07 21:11 
GeneralRe: Problem to use System.Diagnostics.ProcessWindowStyle.Hidden. Pin
Giorgi Dalakishvili16-Dec-07 4:00
mentorGiorgi Dalakishvili16-Dec-07 4:00 
GeneralRe: Problem to use System.Diagnostics.ProcessWindowStyle.Hidden. Pin
hdv21216-Dec-07 9:45
hdv21216-Dec-07 9:45 
GeneralRe: Problem to use System.Diagnostics.ProcessWindowStyle.Hidden. Pin
Giorgi Dalakishvili16-Dec-07 20:28
mentorGiorgi Dalakishvili16-Dec-07 20:28 
QuestionConstant table? Pin
Y_R15-Dec-07 10:56
Y_R15-Dec-07 10:56 
Greetings,

Mostly I use enumerations to specify a list of constants that are connected.

However, recently I needed to create a code that does the following:
Paint a line with a specific color that is set by the value of the bits in a variable.

The bits values are arranged in enumeration:
enum bits
{
Switch1 = 1,
Switch2 = 2,
Switch3 = 4,
switch4 = 8,
}

What is the best way to assign a color to each switch?



I thought of two ways:
---------------------------------------------
creating a dictionary and set its values in runtime:

Dictionary<bits, color=""> Bits_Colors = new Dictionary<bits, color="">;<br />
<br />
Bits_Colors.Add(switch1, Color.Red);<br />
Bits_Colors.Add(switch2, Color.Ivory);<br />
..</bits,></bits,>


But this solution because the dictionary is not constant and readonly would not help here.
-------------------------------------------------

Creating another enumeration for the colors and using thier names as params to Color.
<br />
enum BitsColors<br />
{<br />
  Red = 1,<br />
  Ivory = 2.<br />
  Blue = 4,<br />
  Green = 8<br />
}<br />
<br />
string name = Enum.GetNames(bits, (int) switch2 );   // name = Ivory.<br />
Color c = Color.MakeByName(name);

-----------------------------------------------------------

I wrote the code from my memory so it might be a little not working.
Sincerely yours
Y.R.

AnswerRe: Constant table? Pin
Christian Graus15-Dec-07 13:59
protectorChristian Graus15-Dec-07 13:59 
GeneralRe: Constant table? Pin
Y_R15-Dec-07 20:15
Y_R15-Dec-07 20:15 
AnswerRe: Constant table? Pin
PIEBALDconsult16-Dec-07 16:40
mvePIEBALDconsult16-Dec-07 16:40 
GeneralRe: Constant table? Pin
Y_R16-Dec-07 19:44
Y_R16-Dec-07 19:44 
GeneralRe: Constant table? Pin
PIEBALDconsult17-Dec-07 4:54
mvePIEBALDconsult17-Dec-07 4:54 
QuestionHow to load HTML file using XmlDocument class Pin
El'Cachubrey15-Dec-07 10:13
El'Cachubrey15-Dec-07 10:13 
AnswerRe: How to load HTML file using XmlDocument class Pin
Christian Graus15-Dec-07 10:34
protectorChristian Graus15-Dec-07 10:34 
AnswerRe: How to load HTML file using XmlDocument class Pin
pmarfleet15-Dec-07 10:39
pmarfleet15-Dec-07 10:39 
AnswerRe: How to load HTML file using XmlDocument class Pin
Uwe Keim15-Dec-07 10:46
sitebuilderUwe Keim15-Dec-07 10:46 
AnswerRe: How to load HTML file using XmlDocument class Pin
El'Cachubrey16-Dec-07 8:35
El'Cachubrey16-Dec-07 8:35 
Questionhow to pick some records in datagrid Pin
E_Gold15-Dec-07 9:35
E_Gold15-Dec-07 9:35 
GeneralRe: how to pick some records in datagrid Pin
Yitzchok Dev16-Dec-07 18:49
Yitzchok Dev16-Dec-07 18:49 
Generalstring replace method Pin
ahawari0915-Dec-07 9:35
ahawari0915-Dec-07 9:35 
GeneralRe: string replace method Pin
Christian Graus15-Dec-07 9:51
protectorChristian Graus15-Dec-07 9:51 
GeneralRe: string replace method Pin
ahawari0915-Dec-07 10:47
ahawari0915-Dec-07 10:47 
GeneralRe: string replace method Pin
Christian Graus15-Dec-07 14:02
protectorChristian Graus15-Dec-07 14:02 
GeneralRe: string replace method Pin
ahawari0915-Dec-07 15:45
ahawari0915-Dec-07 15:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.