Beispiel #1
0
        public frmMain()
        {
            InitializeComponent();
            Icon = Properties.Resources._1462723114_timer;
            horseCount.Maximum = decimal.MaxValue;

            if (File.Exists(_jsonFile))
            {
                var content = File.ReadAllText(_jsonFile);
                _appInfo =
                 JsonConvert.DeserializeObject<ApplicationInformation>(content);
                _appInfo.FromFile = true;
                horseCount.Text = _appInfo.HorseCount;
            }
            else
            {
                _appInfo = new ApplicationInformation();
                _appInfo.FromFile = false;
            }
            PopulateSpots();
        }
Beispiel #2
0
 private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (_appInfo == null) return;
     if (string.IsNullOrEmpty(_jsonFile)) return;
     try
     {
         _appInfo = new ApplicationInformation();
         _appInfo.HorseCount = horseCount.Text;
         foreach (HorseSpot spot in flowLayoutPanel1.Controls)
         {
             _appInfo.SpotsInformation.Add(spot.GetSpotInfo());
         }
         File.WriteAllText(_jsonFile, JsonConvert.SerializeObject(_appInfo, Formatting.Indented));
     }
     catch (Exception) { e.Cancel = false; }
 }