Ejemplo n.º 1
0
        public JPGCorruptForm()
        {
            InitializeComponent();
            this.DoubleBuffered = true;
            this.Invalidate();

            _settingsFileName = Program.ExecutablePath() + "\\" + Program.AppName() + ".settings";

            toolStripLabelCurrent.Text = "";

            // Retrieve settings
            try
            {
                _settings = Settings.DeserializeFromXML(_settingsFileName);
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Failure reading settings file: " + ex.ToString(), "ERROR");
                MessageBox.Show("Failure reading settings file: " + ex.Message);
            }

            Loop = _settings.Loop;
            Trace.WriteLine(String.Format("Loop = {0}", Loop.ToString()));

            try
            {
                // These two properties actually try to load the file data
                Trace.WriteLine(String.Format("Trying _settings.TextFile: {0}", _settings.TextFile));
                CurrentTextFile = _settings.TextFile;
                Trace.WriteLine(String.Format("Trying _settings.ImageFile: {0}", _settings.ImageFile));
                CurrentImageFile = _settings.ImageFile;
            }
            catch (FileNotFoundException)
            {
                Trace.WriteLine("File not found. Ignoring exception");
                // Ignore if the files aren't found during app load.
            }

            if (_settings.AutoStart)
            {
                FullScreen = _settings.FullScreen;
                Trace.WriteLine(String.Format("FullScreen = {0}", FullScreen.ToString()));
                Go();
            }
        }
Ejemplo n.º 2
0
 public static void SerializeToXML(String file, Settings settings)
 {
     Trace.WriteLine("SerializeToXML()");
     XmlSerializer serializer = new XmlSerializer(typeof(Settings));
     TextWriter textWriter = new StreamWriter(file);
     serializer.Serialize(textWriter, settings);
     textWriter.Close();
 }