public static Dictionary <string, LSLKeyWord> Parse() { Dictionary <string, LSLKeyWord> ret = new Dictionary <string, LSLKeyWord>(); Color currentColor = Color.Black; bool valid = false; string section = string.Empty; foreach (String line in Properties.Resources.lsl_keywords.Split('\n')) { Match m; string l = line.Trim(); // Skip comments if (l.StartsWith("#")) { continue; } // Looking for line like [word 0, .3, .5] if ((m = sectionRegex.Match(l)).Success) { section = m.Groups[1].Value; if (section == "word") { valid = true; float r = float.Parse(m.Groups[2].Value, System.Globalization.CultureInfo.InvariantCulture); float g = float.Parse(m.Groups[3].Value, System.Globalization.CultureInfo.InvariantCulture); float b = float.Parse(m.Groups[4].Value, System.Globalization.CultureInfo.InvariantCulture); currentColor = Color.FromArgb((int)(r * 255), (int)(g * 255), (int)(b * 255)); } else { valid = false; } continue; } if ((m = keyWordRegex.Match(l)).Success) { LSLKeyWord kw = new LSLKeyWord { KeyWord = m.Groups[1].Value, ToolTip = m.Groups[3].Value.Replace(@"\n", "\n"), Color = currentColor }; if (valid) { ret.Add(kw.KeyWord, kw); } } } return(ret); }
public static Dictionary<string, LSLKeyWord> Parse() { Dictionary<string, LSLKeyWord> ret = new Dictionary<string, LSLKeyWord>(); Color currentColor = Color.Black; bool valid = false; string section = string.Empty; foreach (String line in Properties.Resources.lsl_keywords.Split('\n')) { Match m; string l = line.Trim(); // Skip comments if (l.StartsWith("#")) { continue; } // Looking for line like [word 0, .3, .5] if ((m = sectionRegex.Match(l)).Success) { section = m.Groups[1].Value; if (section == "word") { valid = true; float r = float.Parse(m.Groups[2].Value, System.Globalization.CultureInfo.InvariantCulture); float g = float.Parse(m.Groups[3].Value, System.Globalization.CultureInfo.InvariantCulture); float b = float.Parse(m.Groups[4].Value, System.Globalization.CultureInfo.InvariantCulture); currentColor = Color.FromArgb((int)(r * 255), (int)(g * 255), (int)(b * 255)); } else { valid = false; } continue; } if ((m = keyWordRegex.Match(l)).Success) { LSLKeyWord kw = new LSLKeyWord(); kw.KeyWord = m.Groups[1].Value; kw.ToolTip = m.Groups[3].Value.Replace(@"\n", "\n"); kw.Color = currentColor; if (valid) { ret.Add(kw.KeyWord, kw); } continue; } } return ret; }