Ejemplo n.º 1
0
 public static void LoadFile(string fileName)
 {
     XmlSerializer serializer = new XmlSerializer(typeof(ProgramSettings));
     Stream file = new FileStream(fileName, FileMode.Open, FileAccess.Read);
     Program.Settings = (ProgramSettings)serializer.Deserialize(file);
     file.Close();
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Settings = new ProgramSettings();

            //System.Threading.Thread.Sleep(30000);

            Parameters parameters = new Parameters();
            try
            {
                CommandLineParser.ParseArguments(parameters, args);
            }
            catch (Exception) { }

            if (parameters.Help)
            {
                using (HelpForm helpForm = new HelpForm())
                {
                    helpForm.ShowDialog();
                    return;
                }
            }

            bool fileLoaded = false;
            if (!string.IsNullOrEmpty(parameters.LoadFile))
            {
                try
                {
                    LoadFile(parameters.LoadFile);
                    fileLoaded = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Invalid settings file.\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            if (!string.IsNullOrEmpty(parameters.Resolution))
            {
                Regex Validator = new Regex("^\\d*x\\d*$");       // Digits x digits - Width x Height
                if (Validator.IsMatch(parameters.Resolution))
                {
                    int W = Int32.Parse(parameters.Resolution.Substring(0, parameters.Resolution.IndexOf('x')));
                    int H = Int32.Parse(parameters.Resolution.Substring(parameters.Resolution.IndexOf('x') + 1, parameters.Resolution.Length - parameters.Resolution.IndexOf('x') - 1));
                    ForcedResolution = new System.Drawing.Size(W, H);
                }
            }

            if (fileLoaded && parameters.Silent)
            {
                SetWallpaper(null);
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Settings = new ProgramSettings();

            //System.Threading.Thread.Sleep(30000);

            Parameters parameters = new Parameters();

            try
            {
                CommandLineParser.ParseArguments(parameters, args);
            }
            catch (Exception) { }

            if (parameters.Help)
            {
                using (HelpForm helpForm = new HelpForm())
                {
                    helpForm.ShowDialog();
                    return;
                }
            }

            bool fileLoaded = false;

            if (!string.IsNullOrEmpty(parameters.LoadFile))
            {
                try
                {
                    LoadFile(parameters.LoadFile);
                    fileLoaded = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Invalid settings file.\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            if (!string.IsNullOrEmpty(parameters.Resolution))
            {
                Regex Validator = new Regex("^\\d*x\\d*$");       // Digits x digits - Width x Height
                if (Validator.IsMatch(parameters.Resolution))
                {
                    int W = Int32.Parse(parameters.Resolution.Substring(0, parameters.Resolution.IndexOf('x')));
                    int H = Int32.Parse(parameters.Resolution.Substring(parameters.Resolution.IndexOf('x') + 1, parameters.Resolution.Length - parameters.Resolution.IndexOf('x') - 1));
                    ForcedResolution = new System.Drawing.Size(W, H);
                }
            }

            if (fileLoaded && parameters.Silent)
            {
                SetWallpaper(null);
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());
            }
        }