Ejemplo n.º 1
0
        public static ConfigXml Load(FileInfo fileInfo)
        {
            try
            {
                if (fileInfo == null)
                {
                    throw new ApplicationException();
                }
                if (!fileInfo.Exists)
                {
                    throw new ApplicationException();
                }

                ConfigXml     cfg        = null;
                XmlSerializer serializer = new XmlSerializer(typeof(ConfigXml));
                using (TextReader reader = new StreamReader(fileInfo.FullName, System.Text.Encoding.Unicode))
                {
                    cfg = serializer.Deserialize(reader) as ConfigXml;
                    reader.Close();
                }

                if (cfg == null)
                {
                    throw new ApplicationException();
                }

                return(cfg);
            }
            catch
            {
                var cfg = new ConfigXml();
                cfg.Save(fileInfo);
                return(cfg);
            }
        }
Ejemplo n.º 2
0
        private void SaveSettings()
        {
            var config = new ConfigXml();

            config.FirstNumber = (int)this.numFirst.Value;
            config.LastNumber  = (int)this.numLast.Value;
            config.LastMission = string.IsNullOrWhiteSpace(this._LastFilename) ? "" : this._LastFilename;
            config.PositionX   = this.Location.X;
            config.PositionY   = this.Location.Y;
            config.Save(ConfigXml.Filename);
        }
Ejemplo n.º 3
0
        private void LoadSettings()
        {
            var config = ConfigXml.Load(ConfigXml.Filename);

            try { this.numFirst.Value = config.FirstNumber; } catch { }
            try { this.numLast.Value = config.LastNumber; } catch { }
            try { this._LastFilename = string.IsNullOrWhiteSpace(config.LastMission) ? "" : config.LastMission; } catch { }
            try
            {
                if (config.PositionX != -1 && config.PositionY != -1)
                {
                    this.Location = new System.Drawing.Point(config.PositionX, config.PositionY);
                }
            }
            catch { }
        }