private void UpdateLogDirectory(object sender, EventArgs e) { try { var newWatcher = new LogWatcher(LogDirectoryTextBox.Text); newWatcher.OnSystemChanged += StarSystemChanged; if (logWatcher != null) { logWatcher.ShutDown(); } logWatcher = newWatcher; logDirectoryNote.Text = "Watcher updated"; } catch (Exception exc) { MessageBox.Show("Could not watch log directory:\n" + exc, "F**k!", MessageBoxButtons.OK); } }
private void MainForm_Load(object sender, EventArgs e) { // Setup bindings ComputeButton.Click += ComputeRareGoodsDistances; PathButton.Click += ComputePath; RouteButton.Click += ComputeRoute; // Rare tab RareResults.ItemSelectionChanged += SetNewDestination; RareResults.Columns.Add("System", 100); RareResults.Columns.Add("Station", 150); RareResults.Columns.Add("Commodity", 200); RareResults.Columns.Add("Dist.", 60); RareResults.Columns.Add("Station Dist.", 60); RareResults.Columns.Add("Last Known Price", 50); RareResults.Columns.Add("Station Allegiance", 90); RareResults.ColumnClick += SortRareGoodsResults; // Path tab PathResults.ItemSelectionChanged += SetCurrentLocation; PathResults.Columns.Add("System", 150); PathResults.Columns.Add("#", 30); PathResults.Columns.Add("Jump Dist.", 60); PathResults.Columns.Add("Travelled", 60); PathResults.Columns.Add("Dist. To Target", 60); // Route tab RouteResults.ItemSelectionChanged += SetCurrentRouteStop; RouteResults.Columns.Add("System", 100); RouteResults.Columns.Add("#", 30); RouteResults.Columns.Add("Station", 150); RouteResults.Columns.Add("Station Dist.", 60); RouteResults.Columns.Add("Commodity", 150); RouteResults.Columns.Add("Dist. To Prev", 60); RouteResults.Columns.Add("Good to Sell", 150); RouteResults.Columns.Add("Dist. To Sellee", 60); this.FormClosing += OnExit; // Load previous settings Settings settings; if (!LocalData <Settings> .LoadLocalData("Settings.xml", out settings)) { settings = new Settings(); } MaxJumpDistance.Text = settings.JumpDistance; CurrentSystem.Text = settings.CurrentSystem; DestinationSystem.Text = settings.DestinationSystem; JumpsPerLeg.Text = settings.JumpsPerLeg; MaxJumps.Text = settings.MaxJumps; IdealSellDistance.Text = settings.IdealSellDistance; SaveButton.Click += FullSaveRoute; LoadButton.Click += FullLoadRoute; RareGoodSelector.DrawItem += DrawRaresComboBox; BlacklistButton.Click += Blacklist; UnblacklistButton.Click += Unblacklist; LogDirectoryTextBox.Text = settings.LogDirectory; ReadDirectionsCheckBox.Checked = settings.ReadDirections; MaxDistanceUpDown.Value = settings.MaxStationDistanceValue; MaxDistanceCheckBox.Checked = settings.MaxStationDistanceEnabled; IgnoreUnknownStationDistanceCheckBox.Checked = settings.IgnoreUnknownStationDistance; blacklist = settings.Blacklist; speechSynthesizer = new SpeechSynthesizer(); speechSynthesizer.SetOutputToDefaultAudioDevice(); speechSynthesizer.Rate = -2; // Load spaaaace galaxy = new Galaxy(); UpdateSystems(); // Start tracking the player. logWatcher = new LogWatcher(settings.LogDirectory); logWatcher.OnSystemChanged += StarSystemChanged; // Load the rare cache, and notify the user if we're using hardcoded data. RareData.GetRares(); if (RareData.UsingHardcoded()) { MessageBox.Show("Using hard-coded rare data, which is incomplete. Use an updated " + "Rares.xml to get better routes and avoid this.", "Bummer.", MessageBoxButtons.OK); } currentRoute = null; }