public void Remove(StationConfigElement url) { if (BaseIndexOf(url) >= 0) { BaseRemove(url.Name); } }
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 { } }
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 { } } }
public void UpdateConfigurationSettings(string stationName) { try { // Get the current configuration file. Configuration systemConfig = GetSystemConfigObject(); // Read and display the custom section. ObservingStationsSection myStations = systemConfig.GetSection("ObservingStations") as ObservingStationsSection; List <StationConfigElement> arrayOfStations = new List <StationConfigElement>(); if (myStations != null) { foreach (StationConfigElement stationElement in myStations.Stations) { if (stationElement.Name != stationName) { StationConfigElement station = new StationConfigElement(stationElement.Name, stationElement.Logs, stationElement.Screenshots, stationElement.HighResolutions, stationElement.CaptureSpan, stationElement.CaptureDelay, stationElement.UsePagination); arrayOfStations.Add(station); } } systemConfig.Sections.Remove("ObservingStations"); } // Create a custom configuration section. ObservingStationsSection myStationsSection = new ObservingStationsSection(); foreach (StationConfigElement stationElement in arrayOfStations) { myStationsSection.Stations.Add(stationElement); } // Take care to save the changes... StationConfigElement updatedStation = new StationConfigElement(stationName, this.OriginalLogsDirectory, this.OriginalScreenshotsDirectory, this.HighResolutionScreenshotsDirectory, this.CaptureSpan, this.ScreenshotsDelay, this.UsePagination); //myStations.Stations.Add(updatedStation); myStationsSection.Stations.Add(updatedStation); // Add the custom section to the application configuration file. if (systemConfig.Sections["ObservingStations"] == null) { systemConfig.Sections.Add("ObservingStations", myStationsSection); } // Save the application configuration file. myStationsSection.SectionInformation.ForceSave = true; systemConfig.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("ObservingStations"); } catch { } }
public void Add(StationConfigElement url) { BaseAdd(url); }
public int IndexOf(StationConfigElement url) { return(BaseIndexOf(url)); }
public StationsCollection() { StationConfigElement station = (StationConfigElement)CreateNewElement(); Add(station); }