public NameValueCollection ToCollection()
        {
            var settings = new NameValueCollection()
            {
                ["cacheMemoryLimitMegabytes"]     = MemoryLimitMegabytes.ToString(),
                ["physicalMemoryLimitPercentage"] = PhysicalMemoryLimitPercentage.ToString(),
                ["pollingInterval"] = PollingInterval.ToString(@"hh\:mm\:ss", CultureInfo.InvariantCulture),
            };

            return(settings);
        }
Esempio n. 2
0
        /// <summary>Stores advanced settings to <see cref="ConfigurationManager"/></summary>
        public static void Store()
        {
            ConfigurationManager.AppSettings["COMPort"]          = ComPort;
            ConfigurationManager.AppSettings["BaudRate"]         = BaudRate.ToString();
            ConfigurationManager.AppSettings["UseWindowsDriver"] = UseWindowsDriver ? "true" : "false";
            ConfigurationManager.AppSettings["PollingInterval"]  = PollingInterval.ToString(System.Globalization.CultureInfo.InvariantCulture);
            ConfigurationManager.AppSettings["LogToTextBox"]     = LogToTextBox ? "true" : "false";
            ConfigurationManager.AppSettings["LogToFile"]        = LogToLogFile ? "true" : "false";
            switch (LogFormat)
            {
            case LogFormat.KML:
                ConfigurationManager.AppSettings["LogFormat"] = "KML";
                break;

            case LogFormat.CSV:
                ConfigurationManager.AppSettings["LogFormat"] = "CSV";
                break;

            default:
                ConfigurationManager.AppSettings["LogFormat"] = "GPX";
                break;
            }

            switch (TrackType)
            {
            case TrackType.Track: ConfigurationManager.AppSettings["TrackType"] = "Track"; break;

            default: ConfigurationManager.AppSettings["TrackType"] = "Points"; break;
            }
            ConfigurationManager.AppSettings["LogAltitude"]     = LogAltitude ? "true" : "false";
            ConfigurationManager.AppSettings["LogFileLocation"] = LogFileLocation;

            ConfigurationManager.AppSettings["UseGPSTime"]          = UseGpsTime ? "true" : "false";
            ConfigurationManager.AppSettings["StatusBar"]           = StatusBar ? "true" : "false";
            ConfigurationManager.AppSettings["MaxLogLength"]        = MaxLogLength.ToString(System.Globalization.CultureInfo.InvariantCulture);
            ConfigurationManager.AppSettings["AltitudeCorrection"]  = AltitudeCorrection.ToString(System.Globalization.CultureInfo.InvariantCulture);
            ConfigurationManager.AppSettings["StartImmediatelly"]   = StartImmediatelly ? "true" : "false";
            ConfigurationManager.AppSettings["KMLNameFormat"]       = KmlNameFormat;
            ConfigurationManager.AppSettings["KMLDescFormat"]       = KmlDescFormat;
            ConfigurationManager.AppSettings["KMLLineColor"]        = KmlLineColor.ToArgb().ToString(System.Globalization.CultureInfo.InvariantCulture);
            ConfigurationManager.AppSettings["MinimalDistance"]     = MinimalDistance.ToString(System.Globalization.CultureInfo.InvariantCulture);
            ConfigurationManager.AppSettings["TextLogFormat"]       = TextLogFormat;
            ConfigurationManager.AppSettings["InvalidPositionsMax"] = InvalidPositionsMax.ToString(System.Globalization.CultureInfo.InvariantCulture);
            ConfigurationManager.AppSettings["NMEALog"]             = NmeaLog ? "true" : "false";
            ConfigurationManager.AppSettings["SeaLevelAltitude"]    = SeaLevelAltitude ? "true" : "false";
            ConfigurationManager.AppSettings["InfoPane"]            = InfoPane ? "true" : "false";
            ConfigurationManager.AppSettings["BeepTimer"]           = BeepTimer.ToString(System.Globalization.CultureInfo.InvariantCulture);
            ConfigurationManager.AppSettings["KeepAwake"]           = KeepAwakeList == null ? "" : string.Join(" ", KeepAwakeList);
            ConfigurationManager.AppSettings["SpeedUnit"]           = SpeedUnit.ToString();
            ConfigurationManager.AppSettings["DistanceUnit"]        = DistanceUnit.ToString();
            ConfigurationManager.AppSettings["ElevationUnit"]       = ElevationUnit.ToString();
            ConfigurationManager.AppSettings["CSVSeparator"]        = CsvSeparator.ToString();
            ConfigurationManager.AppSettings["CSVTextQualifier"]    = CsvTextQualifier.ToString();
            ConfigurationManager.AppSettings["CSVNewLine"]          = CsvNewLine;
            ConfigurationManager.AppSettings["CSVQualifierUsage"]   = ((int)CsvQualifierUsage).ToString(System.Globalization.CultureInfo.InvariantCulture);
            ConfigurationManager.AppSettings["CSVHeader"]           = CsvHeader;
            ConfigurationManager.AppSettings["CSVFields"]           = CsvFields;
            ConfigurationManager.AppSettings["CSVDateFormat"]       = CsvDateFormat;
            ConfigurationManager.AppSettings["CSVUTC"]   = CsvUtc ? "true" : "false";
            ConfigurationManager.AppSettings["Language"] = Language;
            ConfigurationManager.AppSettings["MainFormBottomEmptySpace"] = MainFormBottomEmptySpace.ToString(System.Globalization.CultureInfo.InvariantCulture);
        }