internal void Save(XmlWriter writer) { writer.WriteStartElement("fullScreenViewer"); ResizerConverter rsConv = new ResizerConverter(); writer.WriteStartElement("resizer"); writer.WriteAttributeString("value", (string)rsConv.ConvertTo(null, null, resizer, typeof(string))); writer.WriteEndElement(); EnumConverter ipConv = new EnumConverter(typeof(InterpolationMode)); writer.WriteStartElement("interpolationMode"); writer.WriteAttributeString("value", ipConv.ConvertToString(interpolationMode)); writer.WriteEndElement(); ColorConverter colorConv = new ColorConverter(); writer.WriteStartElement("backColor"); writer.WriteAttributeString("value", colorConv.ConvertToString(backColor)); writer.WriteEndElement(); writer.WriteEndElement(); }
public static FullScreenViewerSettings Load(XmlDocument document) { Resizer resizer; InterpolationMode interpolationMode; Color backColor; ResizerConverter rsConv = new ResizerConverter(); XmlElement resizerElem = document.SelectSingleNode("settings/fullScreenViewer/resizer") as XmlElement; if (resizerElem != null) { try { resizer = (Resizer)rsConv.ConvertFrom(null, null, resizerElem.GetAttribute("value")); } catch { resizer = DefaultResizer; } } else { resizer = DefaultResizer; } EnumConverter ipConv = new EnumConverter(typeof(InterpolationMode)); XmlElement ipmodeElem = document.SelectSingleNode("settings/fullScreenViewer/interpolationMode") as XmlElement; if (ipmodeElem != null) { try { interpolationMode = (InterpolationMode)ipConv.ConvertFromString(ipmodeElem.GetAttribute("value")); } catch { interpolationMode = DefaultInterpolationMode; } } else { interpolationMode = DefaultInterpolationMode; } ColorConverter colorConv = new ColorConverter(); XmlElement bcolorElem = document.SelectSingleNode("settings/fullScreenViewer/backColor") as XmlElement; if (bcolorElem != null) { try { backColor = (Color)colorConv.ConvertFromString(bcolorElem.GetAttribute("value")); } catch { backColor = DefaultBackColor; } } else { backColor = DefaultBackColor; } return new FullScreenViewerSettings(resizer, interpolationMode, backColor); }