Exemplo n.º 1
0
        public void Save()
        {
            XmlSerializer serializer = new XmlSerializer(typeof(ActiveScenario));
            string        filename   = CCOWUtils.GetActiveScenarioFilename();

            using (TextWriter writer = new StreamWriter(filename))
            {
                try
                {
                    serializer.Serialize(writer, this);
                    writer.Close();
                }
                catch { }
            }
        }
Exemplo n.º 2
0
        public static ActiveScenario Load()
        {
            XmlSerializer  serializer = new XmlSerializer(typeof(ActiveScenario));
            string         filename   = CCOWUtils.GetActiveScenarioFilename();
            ActiveScenario settings   = null;

            if (File.Exists(filename))
            {
                settings = Deserialize <ActiveScenario>(filename);
            }

            if (settings == null)
            {
                settings          = new ActiveScenario();
                settings.Filename = Application.StartupPath + @"\P1_Default.scn";
            }

            if (!string.IsNullOrEmpty(settings.Filename))
            {
                settings.Scenario = Deserialize <Scenario>(settings.Filename);
            }

            return(settings);
        }