Example #1
0
        private ProgConfig loadConfigIfPresent()
        {
            XmlSerializer ser = new XmlSerializer(typeof(ProgConfig));

            string     cfgFile = Application.StartupPath + "\\config.xml";
            ProgConfig cfg     = new ProgConfig();

            if (File.Exists(cfgFile))
            {
                FileStream fs = new FileStream(cfgFile, FileMode.Open, FileAccess.Read);
                cfg = (ProgConfig)ser.Deserialize(fs);

                fs.Flush();
                fs.Close();
            }
            else
            {
                //create default config now
                FileStream fs = new FileStream(cfgFile, FileMode.Create, FileAccess.ReadWrite);
                ser.Serialize(fs, cfg);
                fs.Flush();
                fs.Close();
            }

            return(cfg);
        }
Example #2
0
        private void saveConfig(ProgConfig cfg)
        {
            XmlSerializer ser = new XmlSerializer(typeof(ProgConfig));

            string     cfgFile = Application.StartupPath + "\\config.xml";
            FileStream fs      = new FileStream(cfgFile, FileMode.Create, FileAccess.ReadWrite);

            ser.Serialize(fs, cfg);
            fs.Flush();
            fs.Close();
        }
Example #3
0
        public Form1()
        {
            InitializeComponent();
            progressBar1.Hide();

            GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
            gMapControl1.MapProvider     = GMap.NET.MapProviders.BingMapProvider.Instance;
            gMapControl1.ShowCenter      = true;


            gMapControl1.Overlays.Add(prev_markers);
            gMapControl1.Overlays.Add(polygons);
            gMapControl1.Overlays.Add(markers);

            heatmapTimer.Interval = 5000;
            heatmapTimer.Tick    += heatmapTimer_Tick;

            progCfg = loadConfigIfPresent();

            if (progCfg.apiKey == "")
            {
                DialogAddApiKey diag = new DialogAddApiKey();
                DialogResult    res  = diag.ShowDialog();
                if (res == System.Windows.Forms.DialogResult.OK)
                {
                    this.progCfg.apiKey = diag.apiKey;
                }
            }

            textBoxStartLat.Text  = progCfg.centerPos.Lat.ToString();
            textBoxStartLong.Text = progCfg.centerPos.Lng.ToString();

            gMapControl1.Position = new GMap.NET.PointLatLng(
                Convert.ToDouble(textBoxStartLat.Text, CultureInfo.InvariantCulture),
                Convert.ToDouble(textBoxStartLong.Text, CultureInfo.InvariantCulture));

            numericUpDown_ValueChanged(null, null);
        }