コード例 #1
0
        public void WriteXml(XmlWriter _xmlWriter)
        {
            _xmlWriter.WriteElementString("Position", String.Format("{0};{1}", m_MainBackground.Rectangle.Location.X, m_MainBackground.Rectangle.Location.Y));

            _xmlWriter.WriteStartElement("Values");
            _xmlWriter.WriteElementString("Visible", (m_iVisibleTimestamp == long.MaxValue) ? "-1" : m_iVisibleTimestamp.ToString());
            _xmlWriter.WriteElementString("StartCounting", (m_iStartCountingTimestamp == long.MaxValue) ? "-1" : m_iStartCountingTimestamp.ToString());
            _xmlWriter.WriteElementString("StopCounting", (m_iStopCountingTimestamp == long.MaxValue) ? "-1" : m_iStopCountingTimestamp.ToString());
            _xmlWriter.WriteElementString("Invisible", (m_iInvisibleTimestamp == long.MaxValue) ? "-1" : m_iInvisibleTimestamp.ToString());
            _xmlWriter.WriteElementString("Countdown", m_bCountdown ? "true" : "false");

            // Spreadsheet support
            string userDuration = "0";

            if (m_iStartCountingTimestamp != long.MaxValue && m_iStopCountingTimestamp != long.MaxValue)
            {
                userDuration = m_ParentMetadata.TimeStampsToTimecode(m_iStopCountingTimestamp - m_iStartCountingTimestamp, TimeCodeFormat.Unknown, false);
            }
            _xmlWriter.WriteElementString("UserDuration", userDuration);

            // </values>
            _xmlWriter.WriteEndElement();

            // Label
            _xmlWriter.WriteStartElement("Label");
            _xmlWriter.WriteElementString("Text", m_Label);
            _xmlWriter.WriteElementString("Show", m_bShowLabel ? "true" : "false");
            _xmlWriter.WriteEndElement();

            _xmlWriter.WriteStartElement("DrawingStyle");
            m_Style.WriteXml(_xmlWriter);
            _xmlWriter.WriteEndElement();
        }
コード例 #2
0
        public void WriteXml(XmlWriter w)
        {
            w.WriteStartElement("Position");
            string userTime = m_ParentMetadata.TimeStampsToTimecode(m_Position, TimeCodeFormat.Unknown, false);

            w.WriteAttributeString("UserTime", userTime);
            w.WriteString(m_Position.ToString());
            w.WriteEndElement();

            if (!string.IsNullOrEmpty(Title))
            {
                w.WriteElementString("Title", Title);
            }

            if (!string.IsNullOrEmpty(m_CommentRtf))
            {
                w.WriteElementString("Comment", m_CommentRtf);
            }

            if (m_Drawings.Count > 0)
            {
                w.WriteStartElement("Drawings");
                foreach (AbstractDrawing drawing in m_Drawings)
                {
                    IKvaSerializable serializableDrawing = drawing as IKvaSerializable;
                    if (serializableDrawing != null)
                    {
                        // The XML name for this drawing should be stored in its [XMLType] C# attribute.
                        Type     t          = serializableDrawing.GetType();
                        object[] attributes = t.GetCustomAttributes(typeof(XmlTypeAttribute), false);

                        if (attributes.Length > 0)
                        {
                            string xmlName = ((XmlTypeAttribute)attributes[0]).TypeName;

                            w.WriteStartElement(xmlName);
                            serializableDrawing.WriteXml(w);
                            w.WriteEndElement();
                        }
                    }
                }
                w.WriteEndElement();
            }
        }