private void ReadXml(XmlReader _xmlReader, PointF _scale, TimeStampMapper _remapTimestampCallback) { _xmlReader.ReadStartElement(); while (_xmlReader.NodeType == XmlNodeType.Element) { switch (_xmlReader.Name) { case "Position": Point p = XmlHelper.ParsePoint(_xmlReader.ReadElementContentAsString()); Point location = new Point((int)((float)p.X * _scale.X), (int)((float)p.Y * _scale.Y)); m_MainBackground.Rectangle = new Rectangle(location, Size.Empty); break; case "Values": ParseWorkingValues(_xmlReader, _remapTimestampCallback); break; case "DrawingStyle": m_Style = new DrawingStyle(_xmlReader); BindStyle(); break; case "Label": ParseLabel(_xmlReader); break; default: string unparsed = _xmlReader.ReadOuterXml(); log.DebugFormat("Unparsed content in KVA XML: {0}", unparsed); break; } } _xmlReader.ReadEndElement(); }
private void ParseWorkingValues(XmlReader _xmlReader, TimeStampMapper _remapTimestampCallback) { if (_remapTimestampCallback == null) { _xmlReader.ReadOuterXml(); return; } _xmlReader.ReadStartElement(); while (_xmlReader.NodeType == XmlNodeType.Element) { switch (_xmlReader.Name) { case "Visible": m_iVisibleTimestamp = _remapTimestampCallback(_xmlReader.ReadElementContentAsLong(), false); break; case "StartCounting": long start = _xmlReader.ReadElementContentAsLong(); m_iStartCountingTimestamp = (start == -1) ? long.MaxValue : _remapTimestampCallback(start, false); break; case "StopCounting": long stop = _xmlReader.ReadElementContentAsLong(); m_iStopCountingTimestamp = (stop == -1) ? long.MaxValue : _remapTimestampCallback(stop, false); break; case "Invisible": long hide = _xmlReader.ReadElementContentAsLong(); m_iInvisibleTimestamp = (hide == -1) ? long.MaxValue : _remapTimestampCallback(hide, false); break; case "Countdown": m_bCountdown = XmlHelper.ParseBoolean(_xmlReader.ReadElementContentAsString()); break; default: string unparsed = _xmlReader.ReadOuterXml(); log.DebugFormat("Unparsed content in KVA XML: {0}", unparsed); break; } } _xmlReader.ReadEndElement(); // Sanity check values. if (m_iVisibleTimestamp < 0) { m_iVisibleTimestamp = 0; } if (m_iStartCountingTimestamp < 0) { m_iStartCountingTimestamp = 0; } if (m_iStopCountingTimestamp < 0) { m_iStopCountingTimestamp = 0; } if (m_iInvisibleTimestamp < 0) { m_iInvisibleTimestamp = 0; } if (m_iVisibleTimestamp > m_iStartCountingTimestamp) { m_iVisibleTimestamp = m_iStartCountingTimestamp; } if (m_iStopCountingTimestamp < m_iStartCountingTimestamp) { m_iStopCountingTimestamp = long.MaxValue; } if (m_iInvisibleTimestamp < m_iStopCountingTimestamp) { m_iInvisibleTimestamp = long.MaxValue; } }
public DrawingChrono(XmlReader _xmlReader, PointF _scale, TimeStampMapper _remapTimestampCallback) : this(Point.Empty, 0, 1, ToolManager.Chrono.StylePreset.Clone()) { ReadXml(_xmlReader, _scale, _remapTimestampCallback); }