Code Generation

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top