private void ImportRouteScannerOptions(RouteScannerOptions options) { txtRunMaxJumps.Text = options.RunMaxJumps.ToString(); txtRouteMaxStops.Text = options.RouteMaxStops.ToString(); txtMinProfitPerUnit.Text = options.MinProfitPerUnit.ToString(); txtMinRouteScore.Text = options.MinRouteScore.ToString(); txtScoreWeightPerRun.Text = options.ScoreWeightPerRun.ToString(); txtScoreWeightPerDuplicateTrade.Text = options.ScoreWeightPerDuplicateTrade.ToString(); cbSingleRoutePerStartSystem.Checked = options.SingleRoutePerStartSystem; cbAllowSameStopBuySell.Checked = options.AllowSameStopBuySell; txtStartSystems.Text = string.Join(STARTSYSTEMS_DELIM.ToString(), options.StartSystems); var mapBoundsSb = new StringBuilder(); foreach (var bound in options.MapBounds) { mapBoundsSb.Append($"{bound.Key},{bound.Value}"); } txtMapBounds.Text = mapBoundsSb.ToString(); }
public ScanWorker(IEnumerable <string> defFiles, RouteScannerOptions options) { _defFiles = defFiles; _options = options; }
private RouteScannerOptions ExportRouteScannerOptions() { var options = new RouteScannerOptions(); options.RunMaxJumps = ParseIntField("RunMaxJumps", txtRunMaxJumps.Text); options.RouteMaxStops = ParseIntField("RouteMaxStops", txtRouteMaxStops.Text); options.MinProfitPerUnit = ParseIntField("MinProfitPerUnit", txtMinProfitPerUnit.Text); options.MinRouteScore = ParseIntField("MinRouteScore", txtMinRouteScore.Text); options.ScoreWeightPerRun = ParseIntField("ScoreWeightPerRun", txtScoreWeightPerRun.Text); options.ScoreWeightPerDuplicateTrade = ParseIntField("ScoreWeightPerDuplicateTrade", txtScoreWeightPerDuplicateTrade.Text); options.StartSystems.Clear(); var startSystemsArr = txtStartSystems.Text.Split(STARTSYSTEMS_DELIM); foreach (var startSystem in startSystemsArr) { var startSystemName = startSystem.Trim().ToLower(); if (!string.IsNullOrEmpty(startSystemName)) { options.StartSystems.Add(startSystemName); } } options.SingleRoutePerStartSystem = cbSingleRoutePerStartSystem.Checked; options.AllowSameStopBuySell = cbAllowSameStopBuySell.Checked; options.MapBounds.Clear(); var mapBoundsArr = txtMapBounds.Text.Split(MAPBOUNDS_LINE_DELIM); foreach (var mapBoundLine in mapBoundsArr) { if (string.IsNullOrEmpty(mapBoundLine.Trim())) { continue; // Skip empty line } var errMsg = $"Couldn't read map bound line '{mapBoundLine}'"; var mapBoundSplit = mapBoundLine.Split(MAPBOUND_PARM_DELIM); if (mapBoundSplit.Length != 2) { throw new ArgumentOutOfRangeException("mapBoundLine", errMsg); } var mapBoundSystem = mapBoundSplit[0].Trim(); if (string.IsNullOrEmpty(mapBoundSplit[0].Trim())) { throw new ArgumentOutOfRangeException("mapBoundSystem", errMsg); } int mapBoundRange; if (!int.TryParse(mapBoundSplit[1].Trim(), out mapBoundRange)) { throw new ArgumentOutOfRangeException("mapBoundRange", errMsg); } if (mapBoundRange < 0) { mapBoundRange = 0; } // Save it options.MapBounds.Add(mapBoundSystem, mapBoundRange); } return(options); }