Browse Source

Fixed SD2-779: XML form's font ignored

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1330 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
c662b4083d
  1. 13
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/XmlDesignerGenerator.cs
  2. 18
      src/Main/Base/Project/Src/Gui/XmlForms/Lib/XmlLoader.cs

13
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/XmlDesignerGenerator.cs

@ -156,12 +156,15 @@ namespace ICSharpCode.FormsDesigner @@ -156,12 +156,15 @@ namespace ICSharpCode.FormsDesigner
}
} else if (pd.ShouldSerializeValue(o) && pd.IsBrowsable) {
XmlAttribute valueAttribute = doc.CreateAttribute("value");
if (propertyValue is Font) {
Font f = (Font)propertyValue;
propertyValue = new Font(f.FontFamily, (float)Math.Round(f.Size));
}
valueAttribute.InnerText = propertyValue == null ? null : propertyValue.ToString();
if (propertyValue == null) {
valueAttribute.InnerText = null;
} else if (propertyValue is Color) {
valueAttribute.InnerText = propertyValue.ToString();
} else {
TypeConverter typeConv = TypeDescriptor.GetConverter(pd.PropertyType);
valueAttribute.InnerText = typeConv.ConvertToInvariantString(propertyValue);
}
childEl.Attributes.Append(valueAttribute);
childNodes.Insert(0, childEl);
}

18
src/Main/Base/Project/Src/Gui/XmlForms/Lib/XmlLoader.cs

@ -40,7 +40,6 @@ namespace ICSharpCode.SharpDevelop.Gui.XmlForms @@ -40,7 +40,6 @@ namespace ICSharpCode.SharpDevelop.Gui.XmlForms
IObjectCreator objectCreator = new DefaultObjectCreator();
IPropertyValueCreator propertyValueCreator = null;
readonly static Regex fontRegex = new Regex(@"Name=(\.+)\,\s+Size=(\d+)");
readonly static Regex propertySet = new Regex(@"(?<Property>[\w]+)\s*=\s*(?<Value>[\w\d]+)", RegexOptions.Compiled);
/// <summary>
@ -298,23 +297,10 @@ namespace ICSharpCode.SharpDevelop.Gui.XmlForms @@ -298,23 +297,10 @@ namespace ICSharpCode.SharpDevelop.Gui.XmlForms
} else {
propertyInfo.SetValue(o, Color.FromName(color), null);
}
} else if (propertyInfo.PropertyType == typeof(Font)) {
Match m = fontRegex.Match(val);
if (m.Success) {
propertyInfo.SetValue(o, new Font(m.Groups[0].Value, Int32.Parse(m.Groups[1].Value)), null);
} else {
// set some default font here
propertyInfo.SetValue(o, SystemInformation.MenuFont, null);
}
} else if (propertyInfo.PropertyType == typeof(System.Windows.Forms.Cursor)) {
string[] cursor = val.Split('[', ']', ' ', ':');
PropertyInfo cursorProperty = typeof(System.Windows.Forms.Cursors).GetProperty(cursor[3]);
if (cursorProperty != null) {
propertyInfo.SetValue(o, cursorProperty.GetValue(null, null), null);
}
} else {
if (val.Length > 0) {
propertyInfo.SetValue(o, Convert.ChangeType(val, propertyInfo.PropertyType), null);
TypeConverter conv = TypeDescriptor.GetConverter(propertyInfo.PropertyType);
propertyInfo.SetValue(o, conv.ConvertFromInvariantString(val), null);
}
}
} catch (Exception e) {

Loading…
Cancel
Save