Ejemplo n.º 1
0
        /// <summary>
        /// Populate the list of available ships and set the current selection
        /// and set the appropriate values.
        /// </summary>
        /// <param name="refreshList">Set to true to refresh the drop down list.</param>
        public void SetShipList(bool refreshList = false)
        {
            if (refreshList)
            {
                validConfigs            = SetAvailableShips();
                altConfigBox.DataSource = null;
                altConfigBox.DataSource = validConfigs;
            }

            TDSettings settings = MainForm.settingsRef;

            SharpConfig.Configuration config = SharpConfig.Configuration.LoadFromFile(configFile);

            if (string.IsNullOrEmpty(settings.LastUsedConfig))
            {
                settings.LastUsedConfig = "Default";
            }

            bool hasSection = config.FirstOrDefault(x => x.Name == settings.LastUsedConfig) != null;

            if (hasSection)
            {
                settings.Capacity  = GetConfigSetting(config, settings.LastUsedConfig, "Capacity");
                settings.Insurance = GetConfigSetting(config, settings.LastUsedConfig, "Insurance");
                settings.LadenLY   = GetConfigSetting(config, settings.LastUsedConfig, "LadenLY");
                settings.Padsizes  = config[settings.LastUsedConfig]["Padsizes"].StringValue;
                settings.UnladenLY = GetConfigSetting(config, settings.LastUsedConfig, "UnladenLY");
            }
            else
            {
                settings.Capacity  = 1;
                settings.Insurance = 0;
                settings.LadenLY   = 1;
                settings.Padsizes  = "?";
                settings.UnladenLY = 1;
            }

            altConfigBox.SelectedIndex
                = !string.IsNullOrEmpty(settings.LastUsedConfig)
               ? altConfigBox.FindStringExact(settings.LastUsedConfig)
               : 0;

            capacityBox.Value  = settings.Capacity;
            insuranceBox.Value = Math.Max(settings.Insurance, insuranceBox.Minimum);
            ladenLYBox.Value   = Math.Max(settings.LadenLY, ladenLYBox.Minimum);
            padSizeBox.Text    = settings.Padsizes;
            unladenLYBox.Value = Math.Max(settings.UnladenLY, unladenLYBox.Minimum);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Copy the values from the setting boxes to the settings obejct.
        /// </summary>
        private void CopyValuesToSettings()
        {
            TDSettings settings = MainForm.settingsRef;

            settings.DisableNetLogs        = overrideDisableNetLogs.Checked;
            settings.DoNotUpdate           = overrideDoNotUpdate.Checked;
            settings.CopySystemToClipboard = !overrideCopySystemToClipboard.Checked;

            settings.PythonPath = pythonPathBox.Text;
            settings.NetLogPath = txtNetLogsPath.Text;

            settings.ExtraRunParams = extraRunParameters.Text;
            settings.Locale         = txtLocale.Text;

            settings.RebuyPercentage = rebuyPercentage.Value;

            settings.Quiet        = !chkQuiet.Checked;
            settings.Verbosity    = verbosityComboBox.SelectedIndex;
            settings.TestSystems  = testSystemsCheckBox.Checked;
            settings.ShowProgress = chkProgress.Checked;
            settings.Summary      = chkSummary.Checked;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Copy the values from the setting boxes to the settings obejct.
        /// </summary>
        private void CopyValuesToSettings()
        {
            TDSettings settings = MainForm.settingsRef;

            settings.DisableNetLogs        = this.overrideDisableNetLogs.Checked;
            settings.DoNotUpdate           = this.overrideDoNotUpdate.Checked;
            settings.CopySystemToClipboard = !this.overrideCopySystemToClipboard.Checked;

            settings.PythonPath = this.pythonPathBox.Text;
            settings.TDPath     = this.tdPathBox.Text;
            settings.EdcePath   = this.edcePathBox.Text;
            settings.NetLogPath = this.netLogsPathBox.Text;

            settings.ExtraRunParams = this.extraRunParameters.Text;

            settings.RebuyPercentage = this.rebuyPercentage.Value;

            settings.Quiet        = !this.chkQuiet.Checked;
            settings.Verbosity    = this.verbosityComboBox.SelectedIndex;
            settings.TestSystems  = this.testSystemsCheckBox.Checked;
            settings.ShowProgress = this.chkProgress.Checked;
            settings.Summary      = this.chkSummary.Checked;
        }
Ejemplo n.º 4
0
 public void Reset(TDSettings instance)
 {
     // go through and reset all accessors in instance
     instance.AbovePrice            = 0;
     instance.Age                   = 0;
     instance.AvailableShips        = string.Empty;
     instance.Avoid                 = string.Empty;
     instance.BelowPrice            = 0;
     instance.Capacity              = 0;
     instance.CmdrName              = string.Empty;
     instance.CopySystemToClipboard = false;
     instance.Corrections           = false;
     instance.Credits               = 0;
     instance.CSVSelect             = 0;
     instance.Demand                = 0;
     instance.DisableNetLogs        = false;
     instance.DoNotUpdate           = false;
     instance.EdcePath              = string.Empty;
     instance.ExtraRunParams        = string.Empty;
     instance.GPT                   = 0;
     instance.HasUpdated            = false;
     instance.Hops                  = 0;
     instance.ImportPath            = string.Empty;
     instance.Insurance             = 0;
     instance.Jumps                 = 0;
     instance.LadenLY               = 0;
     instance.LastUsedConfig        = string.Empty;
     instance.Limit                 = 0;
     instance.LocalNoPlanet         = false;
     instance.LocationChild         = string.Empty;
     instance.LocationParent        = string.Empty;
     instance.Loop                  = false;
     instance.LoopInt               = 0;
     instance.LSPenalty             = 0;
     instance.Margin                = 0;
     instance.MarkedStations        = string.Empty;
     instance.MaxGPT                = 0;
     instance.MaxLSDistance         = 0;
     instance.MiniModeOnTop         = false;
     instance.NetLogPath            = string.Empty;
     instance.Padsizes              = string.Empty;
     instance.Planetary             = string.Empty;
     instance.PruneHops             = 0;
     instance.PruneScore            = 0;
     instance.PythonPath            = string.Empty;
     instance.Quiet                 = false;
     instance.RebuyPercentage       = 5;
     instance.RouteNoPlanet         = false;
     instance.ShowJumps             = false;
     instance.ShowProgress          = false;
     instance.SizeChild             = string.Empty;
     instance.SizeParent            = string.Empty;
     instance.Stock                 = 0;
     instance.Summary               = false;
     instance.Supply                = 0;
     instance.TDPath                = string.Empty;
     instance.TestSystems           = false;
     instance.Towards               = false;
     instance.TreeViewFont          = string.Empty;
     instance.Unique                = false;
     instance.UnladenLY             = 0;
     instance.UploadPath            = string.Empty;
     instance.Verbosity             = 0;
     instance.Via                   = string.Empty;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Save the settings to the ini file.
        /// </summary>
        public static void SaveSettingsToIniFile()
        {
            Configuration config
                = CheckIfFileOpens(configFile)
                ? Configuration.LoadFromFile(configFile)
                : new Configuration();

            TDSettings settings = MainForm.settingsRef;

            Section configSection = config["App"];

            // Settgins used for trade route calculation.
            configSection["AbovePrice"].DecimalValue    = settings.AbovePrice;
            configSection["Age"].DecimalValue           = settings.Age;
            configSection["Avoid"].StringValue          = settings.Avoid ?? string.Empty;
            configSection["BelowPrice"].DecimalValue    = settings.BelowPrice;
            configSection["Corrections"].BoolValue      = settings.Corrections;
            configSection["CSVSelect"].DecimalValue     = settings.CSVSelect;
            configSection["Demand"].DecimalValue        = settings.Demand;
            configSection["ExtraRunParams"].StringValue = settings.ExtraRunParams ?? string.Empty;
            configSection["GPT"].DecimalValue           = settings.GPT;
            configSection["Hops"].DecimalValue          = settings.Hops;
            configSection["Jumps"].DecimalValue         = settings.Jumps;
            configSection["Limit"].DecimalValue         = settings.Limit;
            configSection["LocalNoPlanet"].BoolValue    = settings.LocalNoPlanet;
            configSection["Loop"].BoolValue             = settings.Loop;
            configSection["LoopInt"].DecimalValue       = settings.LoopInt;
            configSection["LSPenalty"].DecimalValue     = settings.LSPenalty;
            configSection["Margin"].DecimalValue        = settings.Margin;
            configSection["MarkedStations"].StringValue = settings.MarkedStations ?? string.Empty;
            configSection["MaxGPT"].DecimalValue        = settings.MaxGPT;
            configSection["MaxLSDistance"].DecimalValue = settings.MaxLSDistance;
            configSection["Planetary"].StringValue      = settings.Planetary ?? string.Empty;
            configSection["PruneHops"].DecimalValue     = settings.PruneHops;
            configSection["PruneScore"].DecimalValue    = settings.PruneScore;
            configSection["RouteNoPlanet"].BoolValue    = settings.RouteNoPlanet;
            configSection["RouteStations"].BoolValue    = settings.RouteStations;
            configSection["ShowJumps"].BoolValue        = settings.ShowJumps;
            configSection["ShowProgress"].BoolValue     = settings.ShowProgress;
            configSection["Stock"].DecimalValue         = settings.Stock;
            configSection["Summary"].BoolValue          = settings.Summary;
            configSection["Supply"].DecimalValue        = settings.Supply;
            configSection["Towards"].BoolValue          = settings.Towards;
            configSection["Unique"].BoolValue           = settings.Unique;
            configSection["Verbosity"].DecimalValue     = settings.Verbosity;
            configSection["Via"].StringValue            = settings.Via ?? string.Empty;

            // Commander settings
            configSection = config["Commander"];

            configSection["CmdrName"].StringValue         = settings.CmdrName ?? string.Empty;
            configSection["Credits"].DecimalValue         = settings.Credits;
            configSection["RebuyPercentage"].DecimalValue = settings.RebuyPercentage;

            // TD Helper system settings.
            configSection = config["System"];

            configSection["AvailableShips"].StringValue      = settings.AvailableShips ?? string.Empty;
            configSection["CopySystemToClipboard"].BoolValue = settings.CopySystemToClipboard;
            configSection["DisableNetLogs"].BoolValue        = settings.DisableNetLogs;
            configSection["DoNotUpdate"].BoolValue           = settings.DoNotUpdate;
            configSection["EdcePath"].StringValue            = settings.EdcePath ?? string.Empty;
            configSection["HasUpdated"].BoolValue            = settings.HasUpdated;
            configSection["ImportPath"].StringValue          = settings.ImportPath ?? string.Empty;
            configSection["LastUsedConfig"].StringValue      = settings.LastUsedConfig ?? string.Empty;
            configSection["LocationChild"].StringValue       = settings.LocationChild ?? string.Empty;
            configSection["LocationParent"].StringValue      = settings.LocationParent ?? string.Empty;
            configSection["MiniModeOnTop"].BoolValue         = settings.MiniModeOnTop;
            configSection["NetLogPath"].StringValue          = settings.NetLogPath ?? string.Empty;
            configSection["PythonPath"].StringValue          = settings.PythonPath ?? string.Empty;
            configSection["Quiet"].BoolValue          = settings.Quiet;
            configSection["SizeChild"].StringValue    = settings.SizeChild ?? string.Empty;
            configSection["SizeParent"].StringValue   = settings.SizeParent ?? string.Empty;
            configSection["TDPath"].StringValue       = settings.TDPath ?? string.Empty;
            configSection["TestSystems"].BoolValue    = settings.TestSystems;
            configSection["TreeViewFont"].StringValue = settings.TreeViewFont ?? string.Empty;
            configSection["UploadPath"].StringValue   = settings.UploadPath ?? string.Empty;

            // Update the current ship if required.
            if (!string.IsNullOrEmpty(settings.LastUsedConfig))
            {
                string sectionName = settings.LastUsedConfig;

                bool hasSection = config.FirstOrDefault(x => x.Name == sectionName) != null;

                if (hasSection)
                {
                    if (config[sectionName]["Capacity"].DecimalValue != settings.Capacity)
                    {
                        config[sectionName]["Capacity"].DecimalValue = settings.Capacity;
                    }

                    if (config[sectionName]["LadenLY"].DecimalValue != settings.LadenLY)
                    {
                        config[sectionName]["LadenLY"].DecimalValue = settings.LadenLY;
                    }

                    if (config[sectionName]["Padsizes"].StringValue != settings.Padsizes)
                    {
                        config[sectionName]["Padsizes"].StringValue = settings.Padsizes;
                    }

                    if (config[sectionName]["UnladenLY"].DecimalValue != settings.UnladenLY)
                    {
                        config[sectionName]["UnladenLY"].DecimalValue = settings.UnladenLY;
                    }
                }
                else
                {
                    config[sectionName]["Capacity"].DecimalValue  = settings.Capacity;
                    config[sectionName]["LadenLY"].DecimalValue   = settings.LadenLY;
                    config[sectionName]["Padsizes"].StringValue   = settings.Padsizes;
                    config[sectionName]["UnladenLY"].DecimalValue = settings.UnladenLY;
                }
            }

            config.SaveToFile(configFile);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Load the setting from the inin file.
        /// </summary>
        public static void LoadSettingsFromIniFile()
        {
            if (CheckIfFileOpens(configFile))
            {
                Configuration config   = Configuration.LoadFromFile(configFile);
                TDSettings    settings = MainForm.settingsRef;

                Section configSection = config["App"];

                settings.AbovePrice     = SectionHasKey(configSection, "AbovePrice") ? configSection["AbovePrice"].DecimalValue : 0;
                settings.Age            = SectionHasKey(configSection, "Age") ? configSection["Age"].DecimalValue : 0;
                settings.Avoid          = SectionHasKey(configSection, "Avoid") ? configSection["Avoid"].StringValue : string.Empty;
                settings.BelowPrice     = SectionHasKey(configSection, "BelowPrice") ? configSection["BelowPrice"].DecimalValue : 0;
                settings.Corrections    = SectionHasKey(configSection, "Corrections") ? configSection["Corrections"].BoolValue : false;
                settings.CSVSelect      = SectionHasKey(configSection, "CSVSelect") ? configSection["CSVSelect"].DecimalValue : 0;
                settings.Demand         = SectionHasKey(configSection, "Demand") ? configSection["Demand"].DecimalValue : 0;
                settings.ExtraRunParams = SectionHasKey(configSection, "ExtraRunParams") ? configSection["ExtraRunParams"].StringValue : string.Empty;
                settings.GPT            = SectionHasKey(configSection, "GPT") ? configSection["GPT"].DecimalValue : 0;
                settings.Hops           = SectionHasKey(configSection, "Hops") ? configSection["Hops"].DecimalValue : 0;
                settings.Jumps          = SectionHasKey(configSection, "Jumps") ? configSection["Jumps"].DecimalValue : 0;
                settings.Limit          = SectionHasKey(configSection, "Limit") ? configSection["Limit"].DecimalValue : 0;
                settings.LocalNoPlanet  = SectionHasKey(configSection, "LocalNoPlanet") ? configSection["LocalNoPlanet"].BoolValue : false;
                settings.Loop           = SectionHasKey(configSection, "Loop") ? configSection["Loop"].BoolValue : false;
                settings.LoopInt        = SectionHasKey(configSection, "LoopInt") ? configSection["LoopInt"].DecimalValue : 0;
                settings.LSPenalty      = SectionHasKey(configSection, "LSPenalty") ? configSection["LSPenalty"].DecimalValue : 0;
                settings.Margin         = SectionHasKey(configSection, "Margin") ? configSection["Margin"].DecimalValue : 0;
                settings.MarkedStations = SectionHasKey(configSection, "MarkedStations") ? configSection["MarkedStations"].StringValue : string.Empty;
                settings.MaxGPT         = SectionHasKey(configSection, "MaxGPT") ? configSection["MaxGPT"].DecimalValue : 0;
                settings.MaxLSDistance  = SectionHasKey(configSection, "MaxLSDistance") ? configSection["MaxLSDistance"].DecimalValue : 0;
                settings.Planetary      = SectionHasKey(configSection, "Planetary") ? configSection["Planetary"].StringValue : string.Empty;
                settings.PruneHops      = SectionHasKey(configSection, "PruneHops") ? configSection["PruneHops"].DecimalValue : 0;
                settings.PruneScore     = SectionHasKey(configSection, "PruneScore") ? configSection["PruneScore"].DecimalValue : 0;
                settings.RouteNoPlanet  = SectionHasKey(configSection, "RouteNoPlanet") ? configSection["RouteNoPlanet"].BoolValue : false;
                settings.RouteStations  = SectionHasKey(configSection, "RouteStations") ? configSection["RouteStations"].BoolValue : false;
                settings.ShowJumps      = SectionHasKey(configSection, "ShowJumps") ? configSection["ShowJumps"].BoolValue : false;
                settings.ShowProgress   = SectionHasKey(configSection, "ShowProgress") ? configSection["ShowProgress"].BoolValue : false;
                settings.Stock          = SectionHasKey(configSection, "Stock") ? configSection["Stock"].DecimalValue : 0;
                settings.Summary        = SectionHasKey(configSection, "Summary") ? configSection["Summary"].BoolValue : false;
                settings.Supply         = SectionHasKey(configSection, "Supply") ? configSection["Supply"].DecimalValue : 0;
                settings.Towards        = SectionHasKey(configSection, "Towards") ? configSection["Towards"].BoolValue : false;
                settings.Unique         = SectionHasKey(configSection, "Unique") ? configSection["Unique"].BoolValue : false;
                settings.Verbosity      = SectionHasKey(configSection, "Verbosity") ? configSection["Verbosity"].DecimalValue : 0;
                settings.Via            = SectionHasKey(configSection, "Via") ? configSection["Via"].StringValue : string.Empty;
                // Commander settings
                configSection = config["Commander"];

                settings.CmdrName        = SectionHasKey(configSection, "CmdrName") ? configSection["CmdrName"].StringValue : string.Empty;
                settings.Credits         = SectionHasKey(configSection, "Credits") ? configSection["Credits"].DecimalValue : 0;
                settings.RebuyPercentage = SectionHasKey(configSection, "RebuyPercentage") ? configSection["RebuyPercentage"].DecimalValue : 0;

                // TD Helper system settings.
                configSection = config["System"];

                settings.AvailableShips        = SectionHasKey(configSection, "AvailableShips") ? configSection["AvailableShips"].StringValue : string.Empty;
                settings.CopySystemToClipboard = SectionHasKey(configSection, "CopySystemToClipboard") ? configSection["CopySystemToClipboard"].BoolValue : false;
                settings.DisableNetLogs        = SectionHasKey(configSection, "DisableNetLogs") ? configSection["DisableNetLogs"].BoolValue : false;
                settings.DoNotUpdate           = SectionHasKey(configSection, "DoNotUpdate") ? configSection["DoNotUpdate"].BoolValue : false;
                settings.EdcePath       = SectionHasKey(configSection, "EdcePath") ? configSection["EdcePath"].StringValue : string.Empty;
                settings.HasUpdated     = SectionHasKey(configSection, "HasUpdated") ? configSection["HasUpdated"].BoolValue : false;
                settings.ImportPath     = SectionHasKey(configSection, "ImportPath") ? configSection["ImportPath"].StringValue : string.Empty;
                settings.LastUsedConfig = SectionHasKey(configSection, "LastUsedConfig") ? configSection["LastUsedConfig"].StringValue : string.Empty;
                settings.LocationChild  = SectionHasKey(configSection, "LocationChild") ? configSection["LocationChild"].StringValue : string.Empty;
                settings.LocationParent = SectionHasKey(configSection, "LocationParent") ? configSection["LocationParent"].StringValue : string.Empty;
                settings.MiniModeOnTop  = SectionHasKey(configSection, "MiniModeOnTop") ? configSection["MiniModeOnTop"].BoolValue : false;
                settings.NetLogPath     = SectionHasKey(configSection, "NetLogPath") ? configSection["NetLogPath"].StringValue : string.Empty;
                settings.PythonPath     = SectionHasKey(configSection, "PythonPath") ? configSection["PythonPath"].StringValue : string.Empty;
                settings.Quiet          = SectionHasKey(configSection, "Quiet") ? configSection["Quiet"].BoolValue : false;
                settings.SizeChild      = SectionHasKey(configSection, "SizeChild") ? configSection["SizeChild"].StringValue : string.Empty;
                settings.SizeParent     = SectionHasKey(configSection, "SizeParent") ? configSection["SizeParent"].StringValue : string.Empty;
                settings.TDPath         = SectionHasKey(configSection, "TDPath") ? configSection["TDPath"].StringValue : string.Empty;
                settings.TestSystems    = SectionHasKey(configSection, "TestSystems") ? configSection["TestSystems"].BoolValue : false;
                settings.TreeViewFont   = SectionHasKey(configSection, "TreeViewFont") ? configSection["TreeViewFont"].StringValue : string.Empty;
                settings.UploadPath     = SectionHasKey(configSection, "UploadPath") ? configSection["UploadPath"].StringValue : string.Empty;

                if (string.IsNullOrEmpty(settings.AvailableShips))
                {
                    settings.AvailableShips = "Default";
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Save the settings to the ini file.
        /// </summary>
        public static void SaveSettingsToIniFile()
        {
            SharpConfig.Configuration config = GetConfigurationObject();

            TDSettings settings = settingsRef;

            SharpConfig.Section configSection = config["App"];

            // Settgins used for trade route calculation.
            configSection["Age"].DecimalValue            = settings.Age;
            configSection["Avoid"].StringValue           = settings.Avoid ?? string.Empty;
            configSection["BlackMarket"].BoolValue       = settings.BlackMarket;
            configSection["Direct"].BoolValue            = settings.Direct;
            configSection["Demand"].DecimalValue         = settings.Demand;
            configSection["EndJumps"].DecimalValue       = settings.EndJumps;
            configSection["ExtraRunParams"].StringValue  = settings.ExtraRunParams ?? string.Empty;
            configSection["GPT"].DecimalValue            = settings.GPT;
            configSection["Hops"].DecimalValue           = settings.Hops;
            configSection["IncludeInsurance"].BoolValue  = settings.IncludeInsurance;
            configSection["Jumps"].DecimalValue          = settings.Jumps;
            configSection["Limit"].DecimalValue          = settings.Limit;
            configSection["Loop"].BoolValue              = settings.Loop;
            configSection["LoopInt"].DecimalValue        = settings.LoopInt;
            configSection["LSPenalty"].DecimalValue      = settings.LSPenalty;
            configSection["Margin"].DecimalValue         = settings.Margin;
            configSection["MarkedStations"].StringValue  = settings.MarkedStations ?? string.Empty;
            configSection["MaxGPT"].DecimalValue         = settings.MaxGPT;
            configSection["MaxLSDistance"].DecimalValue  = settings.MaxLSDistance;
            configSection["NumberOfRoutes"].DecimalValue = settings.NumberOfRoutes;
            configSection["Planetary"].StringValue       = settings.Planetary ?? string.Empty;
            configSection["PruneHops"].DecimalValue      = settings.PruneHops;
            configSection["PruneScore"].DecimalValue     = settings.PruneScore;
            configSection["Shorten"].BoolValue           = settings.Shorten;
            configSection["ShowJumps"].BoolValue         = settings.ShowJumps;
            configSection["ShowProgress"].BoolValue      = settings.ShowProgress;
            configSection["StartJumps"].DecimalValue     = settings.StartJumps;
            configSection["Stock"].DecimalValue          = settings.Stock;
            configSection["Summary"].BoolValue           = settings.Summary;
            configSection["Towards"].BoolValue           = settings.Towards;
            configSection["Unique"].BoolValue            = settings.Unique;
            configSection["Verbosity"].DecimalValue      = settings.Verbosity;
            configSection["Via"].StringValue             = settings.Via ?? string.Empty;

            // Commander settings
            configSection = config["Commander"];

            configSection["CmdrName"].StringValue         = settings.CmdrName ?? string.Empty;
            configSection["Credits"].DecimalValue         = settings.Credits;
            configSection["RebuyPercentage"].DecimalValue = settings.RebuyPercentage;

            // TD Helper system settings.
            configSection = config["System"];

            configSection["AvailableShips"].StringValue      = settings.AvailableShips ?? string.Empty;
            configSection["CopySystemToClipboard"].BoolValue = settings.CopySystemToClipboard;
            configSection["DisableNetLogs"].BoolValue        = settings.DisableNetLogs;
            configSection["DoNotUpdate"].BoolValue           = settings.DoNotUpdate;
            configSection["HasUpdated"].BoolValue            = settings.HasUpdated;
            configSection["ImportPath"].StringValue          = settings.ImportPath ?? string.Empty;
            configSection["LastUsedConfig"].StringValue      = settings.LastUsedConfig ?? string.Empty;
            configSection["Locale"].StringValue         = settings.Locale ?? string.Empty;
            configSection["LocationChild"].StringValue  = settings.LocationChild ?? string.Empty;
            configSection["LocationParent"].StringValue = settings.LocationParent ?? string.Empty;
            configSection["MiniModeOnTop"].BoolValue    = settings.MiniModeOnTop;
            configSection["NetLogPath"].StringValue     = settings.NetLogPath ?? string.Empty;
            configSection["PythonPath"].StringValue     = settings.PythonPath ?? string.Empty;
            configSection["Quiet"].BoolValue            = settings.Quiet;
            configSection["SizeChild"].StringValue      = settings.SizeChild ?? string.Empty;
            configSection["SizeParent"].StringValue     = settings.SizeParent ?? string.Empty;
            configSection["TDVersion"].StringValue      = settings.TDVersion ?? string.Empty;
            configSection["TestSystems"].BoolValue      = settings.TestSystems;
            configSection["TimeOut"].IntValue           = settings.TimeOut;
            configSection["TreeViewFont"].StringValue   = settings.TreeViewFont ?? string.Empty;
            configSection["UploadPath"].StringValue     = settings.UploadPath ?? string.Empty;

            configSection = config["EDDBlink"];

            configSection["SkipVend"].BoolValue = settings.SkipVend;
            configSection["Solo"].BoolValue     = settings.Solo;

            // Update the current ship if required.
            if (!string.IsNullOrEmpty(settings.LastUsedConfig))
            {
                string sectionName = settings.LastUsedConfig;

                bool hasSection = config.FirstOrDefault(x => x.Name == sectionName) != null;

                if (hasSection)
                {
                    if (config[sectionName]["Capacity"].DecimalValue != settings.Capacity)
                    {
                        config[sectionName]["Capacity"].DecimalValue = settings.Capacity;
                    }

                    if (config[sectionName]["LadenLY"].DecimalValue != settings.LadenLY)
                    {
                        config[sectionName]["LadenLY"].DecimalValue = settings.LadenLY;
                    }

                    if (config[sectionName]["Padsizes"].StringValue != settings.Padsizes)
                    {
                        config[sectionName]["Padsizes"].StringValue = settings.Padsizes;
                    }

                    if (config[sectionName]["UnladenLY"].DecimalValue != settings.UnladenLY)
                    {
                        config[sectionName]["UnladenLY"].DecimalValue = settings.UnladenLY;
                    }
                }
                else
                {
                    config[sectionName]["Capacity"].DecimalValue  = settings.Capacity;
                    config[sectionName]["LadenLY"].DecimalValue   = settings.LadenLY;
                    config[sectionName]["Padsizes"].StringValue   = settings.Padsizes;
                    config[sectionName]["UnladenLY"].DecimalValue = settings.UnladenLY;
                }
            }

            config.SaveToFile(configFile);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Load the setting from the inin file.
        /// </summary>
        public static void LoadSettingsFromIniFile()
        {
            if (CheckIfFileOpens(configFile))
            {
                SharpConfig.Configuration config = GetConfigurationObject();
                TDSettings settings = settingsRef;

                SharpConfig.Section configSection = config["App"];

                settings.Age              = GetDecimalSetting(configSection, "Age");
                settings.Avoid            = GetStringSetting(configSection, "Avoid");
                settings.Demand           = GetDecimalSetting(configSection, "Demand");
                settings.EndJumps         = GetDecimalSetting(configSection, "EndJumps");
                settings.ExtraRunParams   = GetStringSetting(configSection, "ExtraRunParams");
                settings.GPT              = GetDecimalSetting(configSection, "GPT");
                settings.Hops             = GetDecimalSetting(configSection, "Hops");
                settings.IncludeInsurance = GetBooleanSetting(configSection, "IncludeInsurance", true);
                settings.Jumps            = GetDecimalSetting(configSection, "Jumps");
                settings.Limit            = GetDecimalSetting(configSection, "Limit");
                settings.Loop             = GetBooleanSetting(configSection, "Loop");
                settings.LoopInt          = GetDecimalSetting(configSection, "LoopInt");
                settings.LSPenalty        = GetDecimalSetting(configSection, "LSPenalty", 12.5M);
                settings.Margin           = GetDecimalSetting(configSection, "Margin");
                settings.MarkedStations   = GetStringSetting(configSection, "MarkedStations");
                settings.MaxGPT           = GetDecimalSetting(configSection, "MaxGPT");
                settings.MaxLSDistance    = GetDecimalSetting(configSection, "MaxLSDistance");
                settings.Planetary        = GetStringSetting(configSection, "Planetary");
                settings.PruneHops        = GetDecimalSetting(configSection, "PruneHops");
                settings.PruneScore       = GetDecimalSetting(configSection, "PruneScore");
                settings.NumberOfRoutes   = GetDecimalSetting(configSection, "NumberOfRoutes");
                settings.ShowJumps        = GetBooleanSetting(configSection, "ShowJumps");
                settings.ShowProgress     = GetBooleanSetting(configSection, "ShowProgress");
                settings.StartJumps       = GetDecimalSetting(configSection, "startJumps");
                settings.Stock            = GetDecimalSetting(configSection, "Stock");
                settings.Summary          = GetBooleanSetting(configSection, "Summary");
                settings.Towards          = GetBooleanSetting(configSection, "Towards");
                settings.Unique           = GetBooleanSetting(configSection, "Unique");
                settings.Verbosity        = GetDecimalSetting(configSection, "Verbosity");
                settings.Via              = GetStringSetting(configSection, "Via");

                // Commander settings
                configSection = config["Commander"];

                settings.CmdrName        = GetStringSetting(configSection, "CmdrName");
                settings.Credits         = GetDecimalSetting(configSection, "Credits", 100M);
                settings.RebuyPercentage = GetDecimalSetting(configSection, "RebuyPercentage");

                // TD Helper system settings.
                configSection = config["System"];

                settings.AvailableShips        = GetStringSetting(configSection, "AvailableShips");
                settings.CopySystemToClipboard = GetBooleanSetting(configSection, "CopySystemToClipboard");
                settings.DisableNetLogs        = GetBooleanSetting(configSection, "DisableNetLogs");
                settings.DoNotUpdate           = GetBooleanSetting(configSection, "DoNotUpdate");
                settings.HasUpdated            = GetBooleanSetting(configSection, "HasUpdated");
                settings.ImportPath            = GetStringSetting(configSection, "ImportPath");
                settings.Locale         = GetStringSetting(configSection, "Locale");
                settings.LastUsedConfig = GetStringSetting(configSection, "LastUsedConfig");
                settings.LocationChild  = GetStringSetting(configSection, "LocationChild");
                settings.LocationParent = GetStringSetting(configSection, "LocationParent");
                settings.MiniModeOnTop  = GetBooleanSetting(configSection, "MiniModeOnTop");
                settings.NetLogPath     = GetStringSetting(configSection, "NetLogPath");
                settings.PythonPath     = GetStringSetting(configSection, "PythonPath");
                settings.Quiet          = GetBooleanSetting(configSection, "Quiet");
                settings.SizeChild      = GetStringSetting(configSection, "SizeChild");
                settings.SizeParent     = GetStringSetting(configSection, "SizeParent");
                settings.TDVersion      = GetStringSetting(configSection, "TDVersion");
                settings.TestSystems    = GetBooleanSetting(configSection, "TestSystems");
                settings.TimeOut        = GetIntegerSetting(configSection, "TimeOut");
                settings.TreeViewFont   = GetStringSetting(configSection, "TreeViewFont");
                settings.UploadPath     = GetStringSetting(configSection, "UploadPath");

                // EDDBlink settings
                configSection = config["EDDBlink"];

                settings.SkipVend = GetBooleanSetting(configSection, "SkipVend");
                settings.Solo     = GetBooleanSetting(configSection, "Solo");

                // Update settings if required.
                if (string.IsNullOrEmpty(settings.Locale))
                {
                    // Set the locale to British Engish.
                    settings.Locale = "en-gb";
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Populate the list of available ships and set the current selection
        /// and set the appropriate values.
        /// </summary>
        /// <param name="refreshList">Set to true to refresh the drop down list.</param>
        public void SetShipList(bool refreshList = false)
        {
            if (refreshList)
            {
                validConfigs = SetAvailableShips();

                cboCommandersShips.Items.Clear();
                cboCommandersShips.ClearSeparators();

                foreach (ComboBoxItem item in validConfigs)
                {
                    cboCommandersShips.Add(item);
                }

                int index = ((ShipSection)ConfigurationManager.GetSection("ships"))
                            .ShipSettings
                            .Cast <ShipConfig>()
                            .Count();

                if (index < cboCommandersShips.Items.Count)
                {
                    cboCommandersShips.SetSeparator(cboCommandersShips.Items.Count - index);
                }
            }

            TDSettings settings = settingsRef;

            SharpConfig.Configuration config = GetConfigurationObject();
            string shipType = string.Empty;

            bool hasSection = config.FirstOrDefault(x => x.Name == settings.LastUsedConfig) != null;

            if (hasSection)
            {
                settings.Capacity  = GetConfigSetting(config, settings.LastUsedConfig, "Capacity");
                settings.Insurance = GetConfigSetting(config, settings.LastUsedConfig, "Insurance");
                settings.LadenLY   = GetConfigSetting(config, settings.LastUsedConfig, "LadenLY");
                settings.Padsizes  = ContainsPadSizes(config[settings.LastUsedConfig]["Padsizes"].StringValue);
                settings.UnladenLY = GetConfigSetting(config, settings.LastUsedConfig, "UnladenLY");
                shipType           = config[settings.LastUsedConfig]["ShipType"].StringValue;
            }
            else
            {
                settings.Capacity  = 1;
                settings.Insurance = 0;
                settings.LadenLY   = 1;
                settings.Padsizes  = string.Empty;
                settings.UnladenLY = 1;
            }

            cboCommandersShips.SelectedIndex
                = !string.IsNullOrEmpty(settings.LastUsedConfig)
               ? cboCommandersShips.FindStringExact(GetShipNameFromConfigSection(settings.LastUsedConfig))
               : 0;

            if (!string.IsNullOrEmpty(shipType))
            {
                ShipConfig ship = ((ShipSection)ConfigurationManager.GetSection("ships"))
                                  .ShipSettings.Cast <ShipConfig>()
                                  .FirstOrDefault(x => x.ShipType == shipType);

                if (ship != null &&
                    decimal.TryParse(ship.MaxCapacity, out decimal maxCapacity))
                {
                    numRouteOptionsShipCapacity.Maximum = maxCapacity;
                }
            }

            numRouteOptionsShipCapacity.Value = settings.Capacity;
            numShipInsurance.Value            = Math.Max(settings.Insurance, numShipInsurance.Minimum);
            numLadenLy.Value   = Math.Max(settings.LadenLY, numLadenLy.Minimum);
            txtPadSize.Text    = settings.Padsizes;
            numUnladenLy.Value = Math.Max(settings.UnladenLY, numUnladenLy.Minimum);
            numRouteOptionsShipCapacity.Maximum = Decimal.MaxValue;
        }