using System;
using System.IO;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace Icarus.Logic {
    /// <summary>
    /// Tests the writing and loading funcitonality of the 
    /// XML system for the Icarus Game Engine.
    /// </summary>
    public class XMLTester {

        /// <summary>
        /// Creates a level, writes it to "TestWrite.xml", then opens dialog 
        /// to load an xml level file, then writes that file to "TestLoadRewrite.xml"
        /// </summary>
        public static void Main() {
            Level level = new Level();
            LevelWriter lw = new LevelWriter();
            lw.WriteLevelXML(level, "TestWrite.xml");

            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter=  "XML Files (*.xml)|*.xml";
            if(DialogResult.Cancel == ofd.ShowDialog()) {
                return;
            }
            String PathXMLFile = Path.GetFullPath(ofd.FileName);
            LevelLoader loader = LevelLoader.Instance;
            Level loadedLevel = loader.LoadLevelXML(PathXMLFile);

            lw.WriteLevelXML(loadedLevel, "TestLoadRewrite.xml");
        }
    }
}
