[Monodevelop-patches-list] r462 - trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Sun Jan 11 21:06:52 EST 2004
Author: benm
Date: 2004-01-11 21:06:52 -0500 (Sun, 11 Jan 2004)
New Revision: 462
Modified:
trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/HighlightColor.cs
Log:
dont call string.split so much
Modified: trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/HighlightColor.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/HighlightColor.cs 2004-01-12 02:06:10 UTC (rev 461)
+++ trunk/MonoDevelop/src/Libraries/ICSharpCode.TextEditor/src/Document/HighlightingStrategy/HighlightColor.cs 2004-01-12 02:06:52 UTC (rev 462)
@@ -24,9 +24,11 @@
{
bool systemColor = false;
string systemColorName = null;
+ double systemColorFactor = 1.0;
bool systemBgColor = false;
- string systemBgColorName = null;
+ string systemBgColorName = null;
+ double systemBgColorFactor = 1.0;
Color color;
Color backgroundcolor = System.Drawing.Color.WhiteSmoke;
@@ -75,7 +77,7 @@
if (!systemBgColor) {
return backgroundcolor;
}
- return ParseColorString(systemBgColorName);
+ return ParseColorString(systemBgColorName, systemBgColorFactor);
}
}
@@ -87,7 +89,7 @@
if (!systemColor) {
return color;
}
- return ParseColorString(systemColorName);
+ return ParseColorString(systemColorName, systemColorFactor);
}
}
@@ -103,17 +105,11 @@
}
}
- Color ParseColorString(string colorName)
+ Color ParseColorString(string colorName, double factor)
{
- string[] cNames = colorName.Split('*');
- Color c = Color.FromName (cNames [0]);
+ Color c = Color.FromName (colorName);
+ c = Color.FromArgb((int)((double)c.R * factor), (int)((double)c.G * factor), (int)((double)c.B * factor));
- if (cNames.Length == 2) {
- // hack : can't figure out how to parse doubles with '.' (culture info might set the '.' to ',')
- double factor = Double.Parse(cNames[1]) / 100;
- c = Color.FromArgb((int)((double)c.R * factor), (int)((double)c.G * factor), (int)((double)c.B * factor));
- }
-
return c;
}
@@ -136,8 +132,11 @@
if (c[0] == '#') {
color = ParseColor(c);
} else if (c.StartsWith("SystemColors.")) {
- systemColor = true;
- systemColorName = c.Substring("SystemColors.".Length);
+ systemColor = true;
+ string [] cNames = c.Substring ("SystemColors.".Length).Split('*');
+ systemColorName = cNames [0];
+ // hack : can't figure out how to parse doubles with '.' (culture info might set the '.' to ',')
+ if (cNames.Length == 2) systemColorFactor = Double.Parse(cNames[1]) / 100;
} else {
color = (Color)(Color.GetType()).InvokeMember(c, BindingFlags.GetProperty, null, Color, new object[0]);
}
@@ -151,8 +150,11 @@
if (c[0] == '#') {
backgroundcolor = ParseColor(c);
} else if (c.StartsWith("SystemColors.")) {
- systemBgColor = true;
- systemBgColorName = c.Substring("SystemColors.".Length);
+ systemBgColor = true;
+ string [] cNames = c.Substring ("SystemColors.".Length).Split('*');
+ systemBgColorName = cNames [0];
+ // hack : can't figure out how to parse doubles with '.' (culture info might set the '.' to ',')
+ if (cNames.Length == 2) systemBgColorFactor = Double.Parse(cNames[1]) / 100;
} else {
backgroundcolor = (Color)(Color.GetType()).InvokeMember(c, BindingFlags.GetProperty, null, Color, new object[0]);
}
@@ -183,8 +185,11 @@
if (c[0] == '#') {
color = ParseColor(c);
} else if (c.StartsWith("SystemColors.")) {
- systemColor = true;
- systemColorName = c.Substring("SystemColors.".Length);
+ systemColor = true;
+ string [] cNames = c.Substring ("SystemColors.".Length).Split('*');
+ systemColorName = cNames [0];
+ // hack : can't figure out how to parse doubles with '.' (culture info might set the '.' to ',')
+ if (cNames.Length == 2) systemColorFactor = Double.Parse(cNames[1]) / 100;
} else {
color = (Color)(Color.GetType()).InvokeMember(c, BindingFlags.GetProperty, null, Color, new object[0]);
}
@@ -197,8 +202,12 @@
if (c[0] == '#') {
backgroundcolor = ParseColor(c);
} else if (c.StartsWith("SystemColors.")) {
- systemBgColor = true;
- systemBgColorName = c.Substring("SystemColors.".Length);
+ systemBgColor = true;
+ string [] cNames = c.Substring ("SystemColors.".Length).Split('*');
+ systemBgColorName = cNames [0];
+ // hack : can't figure out how to parse doubles with '.' (culture info might set the '.' to ',')
+ if (cNames.Length == 2) systemBgColorFactor = Double.Parse(cNames[1]) / 100;
+
} else {
backgroundcolor = (Color)(Color.GetType()).InvokeMember(c, BindingFlags.GetProperty, null, Color, new object[0]);
}
@@ -241,10 +250,16 @@
hasBackground = true;
this.systemColor = true;
- systemColorName = systemColor;
+ string [] cNames = systemColor.Split('*');
+ systemColorName = cNames [0];
+ // hack : can't figure out how to parse doubles with '.' (culture info might set the '.' to ',')
+ if (cNames.Length == 2) systemColorFactor = Double.Parse(cNames[1]) / 100;
systemBgColor = true;
- systemBgColorName = systemBackgroundColor;
+ cNames = systemBackgroundColor.Split('*');
+ systemBgColorName = cNames [0];
+ // hack : can't figure out how to parse doubles with '.' (culture info might set the '.' to ',')
+ if (cNames.Length == 2) systemBgColorFactor = Double.Parse(cNames[1]) / 100;
this.bold = bold;
this.italic = italic;
More information about the Monodevelop-patches-list
mailing list