C
CGuy
Hi,
I am currently developing a C# code generator which works as follows.
1. A form is described using an XAML like XML grammar
e.g: <Form Name="frmTest" Size="100,100" Location="10,20">
<TextBox Name="FirstName" Location = "25,25"/>
.........
2. A C# application parses the above configuration file and generates C#
code for the layout of the form as well as it's child controls.
Almost everything works fine except for a few things.
1. Control properties that represent a color (properties which are of type
System.Drawing.Color) - these don't work well (right now I use a hack).
My basic code loigic is that I read a given control node from the config
file (e.g: <TextBox Name="FirstName" Location = "25,25"/>), process each
attribute (which represents a propety of the object), and format the
attribute value as per the type of the property.
My question is - how can I generate the following code
this.textBox1.BackColor = System.Drawing.Color.Blue;
from the config file that has
<TextBox Name="textBox1" BackColor="Blue"/>
Also, how can I generate the following code
this.textBox1.BackColor = System.Drawing.Color.FromArgb(10,10,10,10);
from the config file that has
<TextBox Name="textBox1" BackColor="10,10,10,10"/>
Note the difference - one is named color and the other is not.
Please help.
CGuy
I am currently developing a C# code generator which works as follows.
1. A form is described using an XAML like XML grammar
e.g: <Form Name="frmTest" Size="100,100" Location="10,20">
<TextBox Name="FirstName" Location = "25,25"/>
.........
2. A C# application parses the above configuration file and generates C#
code for the layout of the form as well as it's child controls.
Almost everything works fine except for a few things.
1. Control properties that represent a color (properties which are of type
System.Drawing.Color) - these don't work well (right now I use a hack).
My basic code loigic is that I read a given control node from the config
file (e.g: <TextBox Name="FirstName" Location = "25,25"/>), process each
attribute (which represents a propety of the object), and format the
attribute value as per the type of the property.
My question is - how can I generate the following code
this.textBox1.BackColor = System.Drawing.Color.Blue;
from the config file that has
<TextBox Name="textBox1" BackColor="Blue"/>
Also, how can I generate the following code
this.textBox1.BackColor = System.Drawing.Color.FromArgb(10,10,10,10);
from the config file that has
<TextBox Name="textBox1" BackColor="10,10,10,10"/>
Note the difference - one is named color and the other is not.
Please help.
CGuy