Example #1
0
 protected override void OnShown(EventArgs e)
 {
     base.OnShown(e);
     ProfileID = Program.Config.DefaultProfileID;
     LoadProfile(ProfileID);
     launcher = loadLauncher();
     LoadData(true);
 }
Example #2
0
        public void Write()
        {
            try
            {
                XmlSerializer serializer;
                FileInfo      destFile;

                switch (Config)
                {
                case UOSReader.ConfigType.Profile:
                    XML.Profile.Profile profile = CfgFile as XML.Profile.Profile;
                    serializer = new XmlSerializer(typeof(XML.Profile.Profile));
                    destFile   = Program.profiles[ProfileID];

                    if (File.Exists(destFile.FullName + ".backup"))
                    {
                        File.Delete(destFile.FullName + ".backup");
                    }

                    destFile.CopyTo(destFile.FullName + ".backup");
                    using (FileStream fstream = destFile.OpenWrite())
                    {
                        serializer.Serialize(fstream, profile);
                    }
                    break;

                case UOSReader.ConfigType.Launcher:
                    XML.Launcher.Launcher launcher = CfgFile as XML.Launcher.Launcher;
                    serializer = new XmlSerializer(typeof(XML.Launcher.Launcher));
                    destFile   = new FileInfo(new DirectoryInfo(Program.Config.UOSPath).Parent.FullName + @"\launcher.xml");

                    if (File.Exists(destFile.FullName + ".backup"))
                    {
                        File.Delete(destFile.FullName + ".backup");
                    }

                    destFile.CopyTo(destFile.FullName + ".backup");
                    using (FileStream fstream = destFile.OpenWrite())
                    {
                        serializer.Serialize(fstream, launcher);
                        fstream.Flush();
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Program.CMSG(ex);
            }
        }