Example #1
0
 public void OpenFromFile(string fileName)
 {
     Visible = false;
     try
     {
         Controls.Clear();
         XmlReader reader = XmlReader.Create((Stream) new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read));
         reader.Read();
         if (!reader.IsStartElement("Root"))
         {
             throw new ApplicationException("An Invalid file format was selected.");
         }
         while (reader.Read())
         {
             if (reader.IsStartElement() && reader.HasAttributes)
             {
                 if (reader.Name == "Slide")
                 {
                     SlideControl slide = CreateSlide();
                     Controls.SetChildIndex((Control)slide, 0);
                     slide.ReadFromXML(reader);
                 }
                 else if (reader.Name == "Font")
                 {
                     string attribute = reader.GetAttribute("Name");
                     if (attribute == "SongFont")
                     {
                         SongFont.ReadFromXML(reader);
                     }
                     else if (attribute == "IndicatorFont")
                     {
                         IndicatorFont.ReadFromXML(reader);
                     }
                     else if (attribute == "MessageFont")
                     {
                         MessageFont.ReadFromXML(reader);
                     }
                 }
             }
         }
         reader.Close();
         IsDirty = false;
     }
     finally
     {
         Visible = true;
     }
 }
Example #2
0
        public void SaveToFile(string fileName)
        {
            XmlWriter writer = XmlWriter.Create(fileName);

            writer.WriteStartElement("Root");
            writer.WriteStartElement("Slides");
            for (int index = Controls.Count - 1; index >= 0; --index)
            {
                ((SlideControl)Controls[index]).WriteToXML(writer);
            }
            writer.WriteEndElement();
            writer.WriteStartElement("Fonts");
            SongFont.WriteToXML(writer, "SongFont");
            IndicatorFont.WriteToXML(writer, "IndicatorFont");
            MessageFont.WriteToXML(writer, "MessageFont");
            writer.WriteEndElement();
            writer.WriteEndElement();
            writer.Close();
            IsDirty = false;
        }