Example #1
0
 // TODO exibir mensagem de erro na criação/leitura do arq de configurações
 //
 // carrega settings do arquivo padrão
 // lembrando que Program.Settings precisa ter um inicializar padrão
 public static ProgramSettings LoadFromFile()
 {
     ProgramSettings settings = new ProgramSettings();
     XmlSerializer serializer = new XmlSerializer(settings.GetType());
     StreamReader reader = new StreamReader(SETTINGS_PATH);
     settings = (ProgramSettings)serializer.Deserialize(reader);
     reader.Close();
     return settings;
 }
Example #2
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (SettingsFile.SettingsFileExists)
                Settings = SettingsFile.LoadFromFile();
            else
            {
                Settings = new ProgramSettings();
                SettingsFile.CreateAppFilesFolder();
                SettingsFile.SaveToFile(Settings);
                Directory.CreateDirectory(Settings.BackupPath);
            }

            try
            {
                args = GetActivationData(args);

                if (args != null && args.Length >= 1)
                {
                    formMenuPrincipal = new MenuPrincipal(args[0]);
                    Application.Run();
                }
                else
                {
                    formMenuPrincipal = new MenuPrincipal();
                    Application.Run(formMenuPrincipal);
                }
            }
            catch(Exception e)
            {
                string errorMessage =
                    "Erro Inesperado! \n\n" +
                    e.Message + "\n\n" +
                    "----------------------------\n\n" +
                    e.StackTrace + "\n\n";
                MessageBox.Show(errorMessage, "TeleBajaUEA", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #3
0
 public static void SaveToFile(ProgramSettings pSettings)
 {
     XmlSerializer serializer = new XmlSerializer(pSettings.GetType());
     StreamWriter writer = new StreamWriter(SETTINGS_PATH);
     serializer.Serialize(writer, pSettings);
     writer.Close();
 }