Example #1
0
        public void LoadConfigurationSettings(string stationName)
        {
            Configuration config = GetSystemConfigObject();

            try
            {
                if (!string.IsNullOrEmpty(stationName))
                {
                    // Read and display the custom section.
                    ObservingStationsSection myStations = config.GetSection("ObservingStations") as ObservingStationsSection;

                    StationConfigElement station = null;

                    if (myStations != null)
                    {
                        for (int i = 0; i < myStations.Stations.Count; i++)
                        {
                            if (myStations.Stations[i].Name == stationName)
                            {
                                station = myStations.Stations[i];
                                break;
                            }
                        }

                        if (station == null)
                        {
                            station = new StationConfigElement(stationName, string.Empty, string.Empty, string.Empty, 300, 30, false);

                            myStations.Stations.Add(station);
                        }
                        this.OriginalLogsDirectory              = station.Logs;
                        this.OriginalScreenshotsDirectory       = station.Screenshots;
                        this.HighResolutionScreenshotsDirectory = station.HighResolutions;
                        this.CaptureSpan      = station.CaptureSpan;
                        this.ScreenshotsDelay = station.CaptureDelay;
                        this.UsePagination    = station.UsePagination;
                    }
                    else
                    {
                        UsingConfigurationCollectionAttribute.CreateCustomSection();
                    }
                }

                int temp = 0;

                if (config.AppSettings.Settings["defaultStation"] != null)
                {
                    this.DefaultStation = config.AppSettings.Settings["defaultStation"].Value.ToString();
                }

                int.TryParse(config.AppSettings.Settings["annualTopMeteorCount"].Value, out temp);
                this.AnnualTopMeteorCount = temp;
            }
            catch { }
        }
Example #2
0
        private void InitializeConfiguration()
        {
            List <string> configuredStations = UsingConfigurationCollectionAttribute.GetStationNames();

            cmbStationNames.Items.AddRange(configuredStations.ToArray());

            config = new ConfigObject(this, string.Empty);

            // Populate Config tab...
            config.LoadConfigurationSettings("Default");

            chkDefaultStation.Checked = !string.IsNullOrEmpty(config.DefaultStation);

            if (cmbStationNames.Items.Contains(config.DefaultStation))
            {
                cmbStationNames.SelectedItem = config.DefaultStation;
                config.CurrentStation        = config.DefaultStation;
            }
        }
Example #3
0
        public void SaveConfigurationSettings(string stationName)
        {
            Configuration config = GetSystemConfigObject();

            if (!string.IsNullOrEmpty(stationName) && config != null)
            {
                try
                {
                    // Read and display the custom section.
                    ObservingStationsSection myStations = config.GetSection("ObservingStations") as ObservingStationsSection;

                    if (myStations == null)
                    {
                        UsingConfigurationCollectionAttribute.CreateCustomSection();
                    }

                    // Update station-specific properties...
                    myStations.Stations.Remove(stationName);

                    StationConfigElement station = new StationConfigElement(stationName,
                                                                            this.OriginalLogsDirectory,
                                                                            this.OriginalScreenshotsDirectory,
                                                                            this.HighResolutionScreenshotsDirectory,
                                                                            this.CaptureSpan,
                                                                            this.ScreenshotsDelay,
                                                                            this.UsePagination);

                    myStations.Stations.Add(station);

                    // Process the common properties...
                    if (config.AppSettings.Settings["defaultStation"] != null)
                    {
                        config.AppSettings.Settings["defaultStation"].Value = this.DefaultStation;
                    }

                    config.AppSettings.Settings["annualTopMeteorCount"].Value = this.AnnualTopMeteorCount.ToString();

                    config.Save(ConfigurationSaveMode.Full);
                }
                catch { }
            }
        }