hello all,
i keep getting an "Index is out of bounds of array" error on line # 574 which is:
label.Font = new Font(fontNameFields[0], Single.Parse(fontNameFields[1]));
... The following text file i am parsing contains this exact information:
Label
"hi tyler"
23, 76
Arial,12.5
...I can successfully parse all the other info (just not the very last line), and the code i have is:
MatchCollection lines = Regex.Matches(File.ReadAllText(Path), @"(.+?)\r\n""([^""]+)""\r\n(\d+), (\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 cfont = match.Groups[5].Value;
string color = match.Groups[6].Value;
Console.WriteLine("{0}, \"{1}\", {2}, {3}, {4}, {5}", control, text, x, y, cfont, color);
switch (control)
{
case "Label":
Label label = new Label();
label.Text = text;
label.AutoSize = true;
label.IsAccessible = true;
label.MouseClick += new MouseEventHandler(label_MouseClick);
label.MouseDoubleClick += new MouseEventHandler(label_MouseDoubleClick);
label.MouseDown += new MouseEventHandler(label_MouseDown);
label.MouseMove += new MouseEventHandler(label_MouseMove);
label.MouseUp += new MouseEventHandler(label_MouseUp);
label.Location = new Point(x, y);
canvas.Controls.Add(label);
String fontName = cfont;
String[] fontNameFields = fontName.Split(',');
label.Font = new Font(fontNameFields[0], Single.Parse(fontNameFields[1]));
...i think there may be something wrong with the regex that gets the font stuff... i dont know, but it just won't work, can somebody please help?
For a history of this problem, see: http://stackoverflow.com/questions/1519477/parsing-font-info-and-converting-it-to-system-drawing-font/1519491#1519491