private void exportShip(object sender, RoutedEventArgs e) { Ship ship = (Ship)((Button)e.Source).DataContext; EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); // Coriolis is the default export target string uri = ship.CoriolisUri(); // Support EDShipyard as well. if (eddiConfiguration.exporttarget == "EDShipyard") { uri = ship.EDShipyardUri(); } Logging.Debug("Export target is " + eddiConfiguration.exporttarget + ", URI is " + uri); // URI can be very long so we can't use a simple Process.Start(), as that fails try { ProcessStartInfo proc = new ProcessStartInfo(Net.GetDefaultBrowserPath(), uri) { UseShellExecute = false }; Process.Start(proc); } catch (Exception ex) { Logging.Error("Failed: ", ex); try { // Last-gasp attempt if we have a shorter URL if (uri.Length < 2048) { Process.Start(uri); } else { Logging.Error("Failed to find a way of opening URL \"" + uri + "\""); } } catch (Exception) { // Nothing to do } } }
public ConfigurationWindow() { InitializeComponent(); shipData.ItemsSource = shipMonitor().shipyard; EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); string exportTarget = eddiConfiguration.exporttarget; // handle migration if (exportTarget == "EDShipyard") { exportTarget = "EDSY"; eddiConfiguration.exporttarget = exportTarget; eddiConfiguration.ToFile(); } Logging.Debug("Export target from configuration: " + exportTarget); exportComboBox.Text = exportTarget ?? "Coriolis"; }
public MainWindow() { InitializeComponent(); // Configured the EDDI tab EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); eddiHomeSystemText.Text = eddiConfiguration.HomeSystem; eddiHomeStationText.Text = eddiConfiguration.HomeStation; eddiInsuranceDecimal.Value = eddiConfiguration.Insurance; debug = eddiConfiguration.Debug; // Configure the Companion App tab CompanionAppCredentials companionAppCredentials = CompanionAppCredentials.FromFile(); // See if the credentials work companionAppService = new CompanionAppService(debug); try { commander = companionAppService.Profile(); setUpCompanionAppComplete("Your connection to the companion app is operational, Commander " + commander.Name); } catch (Exception ex) { if (companionAppService.CurrentState == CompanionAppService.State.NEEDS_LOGIN) { // Fall back to stage 1 setUpCompanionAppStage1(); } else if (companionAppService.CurrentState == CompanionAppService.State.NEEDS_CONFIRMATION) { // Fall back to stage 2 setUpCompanionAppStage2(); } } if (commander != null) { setShipyardFromConfiguration(); } // Configure the NetLog tab NetLogConfiguration netLogConfiguration = NetLogConfiguration.FromFile(); netLogPathTextBox.Text = netLogConfiguration.path; // Configure the EDSM tab StarMapConfiguration starMapConfiguration = StarMapConfiguration.FromFile(); edsmApiKeyTextBox.Text = starMapConfiguration.apiKey; edsmCommanderNameTextBox.Text = starMapConfiguration.commanderName; // Configure the Text-to-speech tab SpeechServiceConfiguration speechServiceConfiguration = SpeechServiceConfiguration.FromFile(); List <String> speechOptions = new List <String>(); speechOptions.Add("Windows TTS default"); try { using (SpeechSynthesizer synth = new SpeechSynthesizer()) { foreach (InstalledVoice voice in synth.GetInstalledVoices()) { if (voice.Enabled) { speechOptions.Add(voice.VoiceInfo.Name); } } } ttsVoiceDropDown.ItemsSource = speechOptions; ttsVoiceDropDown.Text = speechServiceConfiguration.StandardVoice == null ? "Windows TTS default" : speechServiceConfiguration.StandardVoice; } catch (Exception e) { using (System.IO.StreamWriter errLog = new System.IO.StreamWriter(Environment.GetEnvironmentVariable("AppData") + @"\EDDI\speech.log", true)) { errLog.WriteLine("" + System.Threading.Thread.CurrentThread.ManagedThreadId + ": Caught exception " + e); } } ttsVolumeSlider.Value = speechServiceConfiguration.Volume; ttsRateSlider.Value = speechServiceConfiguration.Rate; ttsEffectsLevelSlider.Value = speechServiceConfiguration.EffectsLevel; ttsDistortCheckbox.IsChecked = speechServiceConfiguration.DistortOnDamage; ttsTestShipDropDown.ItemsSource = ShipDefinitions.ShipModels; ttsTestShipDropDown.Text = "Adder"; }