well, the title pretty much says it all.
here's a little info: i have a text file, and inside that textfile contains:
Label
"this text will be associated with the Text property of the label once the label has been added to the Panel Control at runtime."
20, 45
Trebuchet MS
14.0
explanation of the above the above file may have only one label-info, or it may have a thousand of them. here's how it works:
Control
Text Property
Locatoin
Font Name
Font Size
...Now, all is well if i leave out the font information from the file. but as soon as i modified my regex to suit for the font name and font size, my program no longer adds the control to the Panel at runtime. there are no debugging errors or ugly squigly lines either. It just doesn't show anything.
So, my guess is the last part of the regex that tries to match font information/ can somebody please help me understand/solve this problem?
the code i have is:
public partial class Form1 : Form
{
private void FillCanvas()
{
canvas.Controls.Clear();
canvas.Visible = true;
canvas.BringToFront();
txt.Visible = false;
MatchCollection lines = Regex.Matches(File.ReadAllText(Path), @"(.+?)\r\n""([^""]+)""\r\n(\d+), (\d+)\r\n""(\w*)\r\n" +
@"(\d+)");
foreach (Match match in lines)
{
string control = match.Groups[1].Value;
string text = match.Groups[2].Value;
int x = Int32.Parse(match.Groups[3].Value);
int y = Int32.Parse(match.Groups[4].Value);
string fname = match.Groups[6].Value;
float fsize = float.Parse(match.Groups[7].Value);
switch (control)
{
case "Label":
Label label = new Label();
label.Text = text;
label.AutoSize = true;
label.IsAccessible = true;
label.Font = new Font(fname, fsize);
label.MouseMove += new MouseEventHandler(label_MouseMove);
label.MouseDown += new MouseEventHandler(label_MouseDown);
label.MouseUp += new MouseEventHandler(label_MouseUp);
label.Click += new EventHandler(label_Click);
label.DoubleClick += new EventHandler(label_DoubleClick);
canvas.Controls.Add(label);
ControlCount++;
label.Name = ControlCount.ToString();
label.Location = new Point(x, y);
SelectedControl = label.Name;
break;