- Timestamp:
- 04/19/11 12:37:16 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/histogram/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/System.Drawing/Font2XmlSerializer.cs
r6022 r6027 22 22 using System; 23 23 using System.Drawing; 24 using System.Globalization;25 24 26 25 namespace HeuristicLab.Persistence.Default.Xml.Primitive { … … 28 27 29 28 public override XmlString Format(Font font) { 30 if (font != null) {31 return new XmlString(font.Name32 + ";" + font.SizeInPoints.ToString(CultureInfo.InvariantCulture.NumberFormat)33 + ";" + font.Style.ToString("d")34 + ";" + font.GdiCharSet.ToString());35 }36 return new XmlString(string.Empty);29 return new XmlString(string.Format("{0};{1};{2};{3};{4};{5}", 30 font.Name, 31 Float2XmlSerializer.FormatG8(font.Size), 32 font.Style, 33 font.Unit, 34 font.GdiCharSet, 35 font.GdiVerticalFont)); 37 36 } 38 37 39 38 public override Font Parse(XmlString fontData) { 40 if (string.IsNullOrEmpty(fontData.Data)) return null;41 39 string[] tokens = fontData.Data.Split(';'); 42 if (tokens.Length < 4) return null; 43 float size = 12.0f; 44 FontStyle style = FontStyle.Regular; 45 byte gdiCharSet = 1; 46 if (!float.TryParse(tokens[1], NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out size)) 47 return null; 48 if (!Enum.TryParse(tokens[2], out style)) 49 return null; 50 if (!byte.TryParse(tokens[3], out gdiCharSet)) 51 return null; 52 53 return new Font(tokens[0], size, style, GraphicsUnit.Point, gdiCharSet); 40 return new Font( 41 tokens[0], 42 Float2XmlSerializer.ParseG8(tokens[1]), 43 (FontStyle)Enum.Parse(typeof(FontStyle), tokens[2]), 44 (GraphicsUnit)Enum.Parse(typeof(GraphicsUnit), tokens[3]), 45 byte.Parse(tokens[4]), 46 bool.Parse(tokens[5])); 54 47 } 55 48 }
Note: See TracChangeset
for help on using the changeset viewer.