public ToFile ( string filename = null ) : void | ||
filename | string | |
Résultat | void |
// Handle changes to the editable squadron system combo box private void SquadronSystemText_TextChanged(object sender, TextChangedEventArgs e) { EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); string oldValue = eddiConfiguration.SquadronSystem; void changeHandler() { // Reset the squadron data due to selecting new squadron system if (eddiConfiguration.SquadronFaction != null) { eddiConfiguration.SquadronFaction = null; eddiConfiguration.SquadronAllegiance = Superpower.None; eddiConfiguration.SquadronPower = Power.None; eddiConfiguration.ToFile(); squadronFactionDropDown.SelectedItem = Power.None.localizedName; ConfigureSquadronFactionOptions(eddiConfiguration); squadronPowerDropDown.SelectedItem = eddiConfiguration.SquadronPower.localizedName; ConfigureSquadronPowerOptions(eddiConfiguration); EDDI.Instance.Cmdr.squadronallegiance = Superpower.None; EDDI.Instance.Cmdr.squadronpower = Power.None; eddiConfiguration.ToFile(); } } squadronSystemDropDown.TextDidChange(sender, e, oldValue, changeHandler); }
public static void ApplyAnyOverrideCulture() { string overrideCultureName = null; try { // Use Eddi.Properties.Settings if an override culture isn't set in our configuration EDDIConfiguration configuration = EDDIConfiguration.FromFile(); if (configuration.OverrideCulture is null && !string.IsNullOrEmpty(Eddi.Properties.Settings.Default.OverrideCulture)) { configuration.OverrideCulture = Eddi.Properties.Settings.Default.OverrideCulture; configuration.ToFile(); } overrideCultureName = configuration.OverrideCulture; // we are using the InvariantCulture name "" to mean user's culture CultureInfo overrideCulture = string.IsNullOrEmpty(overrideCultureName) ? null : new CultureInfo(overrideCultureName); ApplyCulture(overrideCulture); } catch { ApplyCulture(null); Debug.WriteLine("Culture [{0}] not available", overrideCultureName); } }
private void pluginenabled_Unchecked(object sender, RoutedEventArgs e) { EDDIConfiguration configuration = EDDIConfiguration.FromFile(); configuration.Plugins[pluginName] = false; configuration.ToFile(); }
private void LoadResponders(EDDIConfiguration eddiConfiguration) { foreach (EDDIResponder responder in EDDI.Instance.responders) { Logging.Debug("Adding configuration tab for " + responder.ResponderName()); PluginSkeleton skeleton = new PluginSkeleton(responder.ResponderName()); skeleton.plugindescription.Text = responder.ResponderDescription(); if (eddiConfiguration.Plugins.TryGetValue(responder.ResponderName(), out bool enabled)) { skeleton.pluginenabled.IsChecked = enabled; } else { // Default to enabled skeleton.pluginenabled.IsChecked = true; eddiConfiguration.ToFile(); } // Add responder-specific configuration items System.Windows.Controls.UserControl monitorConfiguration = responder.ConfigurationTabItem(); if (monitorConfiguration != null) { monitorConfiguration.Margin = new Thickness(10); skeleton.panel.Children.Add(monitorConfiguration); } TabItem item = new TabItem { Header = responder.LocalizedResponderName() }; item.Content = skeleton; tabControl.Items.Add(item); } }
private void verboseLoggingDisabled(object sender, RoutedEventArgs e) { EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); eddiConfiguration.Debug = eddiVerboseLogging.IsChecked.Value; eddiConfiguration.ToFile(); }
private void homeStationChanged(object sender, TextChangedEventArgs e) { EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); eddiConfiguration.HomeStation = string.IsNullOrWhiteSpace(eddiHomeStationText.Text) ? null : eddiHomeStationText.Text.Trim(); eddiConfiguration.ToFile(); }
private void isNeitherGender_Checked(object sender, RoutedEventArgs e) { EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); eddiConfiguration.Gender = "Neither"; eddiConfiguration.ToFile(); EDDI.Instance.Cmdr.gender = "Neither"; }
private void pluginenabled_Unchecked(object sender, RoutedEventArgs e) { EDDIConfiguration configuration = EDDIConfiguration.FromFile(); configuration.Plugins[pluginName] = false; configuration.ToFile(); EDDI.Instance.DisableResponder(pluginName); EDDI.Instance.DisableMonitor(pluginName); }
private void betaProgrammeDisabled(object sender, RoutedEventArgs e) { EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); eddiConfiguration.Beta = eddiBetaProgramme.IsChecked.Value; eddiConfiguration.ToFile(); // Because we have chaned to not wanting beta upgrades we need to re-check upgrade information EDDI.Instance.CheckUpgrade(); setStatusInfo(); }
private void homeStationChanged(object sender, TextChangedEventArgs e) { EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); eddiConfiguration.HomeStation = string.IsNullOrWhiteSpace(eddiHomeStationText.Text) ? null : eddiHomeStationText.Text.Trim(); eddiConfiguration = EDDI.Instance.updateHomeStation(eddiConfiguration); eddiConfiguration.ToFile(); // Update the UI for invalid results runValidation(eddiHomeStationText); }
private void eddiSquadronNameText_LostFocus(object sender, RoutedEventArgs e) { // Discard invalid results if (eddiSquadronNameText.Text == string.Empty) { EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); eddiConfiguration.SquadronName = null; eddiConfiguration.ToFile(); EDDI.Instance.Cmdr.squadronname = string.Empty; } }
private void homeStationDropDownUpdated(object sender, SelectionChangedEventArgs e) { EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); string homeStationName = homeStationDropDown.SelectedItem?.ToString(); if (eddiConfiguration.HomeStation != homeStationName) { eddiConfiguration.HomeStation = homeStationName == Properties.MainWindow.no_station ? null : homeStationName; eddiConfiguration = EDDI.Instance.updateHomeStation(eddiConfiguration); eddiConfiguration.ToFile(); } }
private void squadronIDChanged(object sender, TextChangedEventArgs e) { EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); if (eddiConfiguration.SquadronID != eddiSquadronIDText.Text) { eddiConfiguration.SquadronID = string.IsNullOrWhiteSpace(eddiSquadronIDText.Text) ? null : eddiSquadronIDText.Text.Trim(); eddiConfiguration.ToFile(); EDDI.Instance.Cmdr.squadronid = eddiConfiguration.SquadronID; } }
private void eddiHomeSystemText_LostFocus(object sender, RoutedEventArgs e) { // Discard invalid results EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); if (!eddiConfiguration.validSystem) { eddiConfiguration.HomeSystem = null; eddiHomeSystemText.Text = string.Empty; eddiConfiguration.ToFile(); } }
private void squadronPowerDropDownUpdated(object sender, SelectionChangedEventArgs e) { EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); string squadronPower = squadronPowerDropDown.SelectedItem?.ToString(); if ((eddiConfiguration.SquadronPower?.localizedName ?? "") != squadronPower) { eddiConfiguration.SquadronPower = Power.FromName(squadronPower); eddiConfiguration.ToFile(); EDDI.Instance.Cmdr.squadronpower = eddiConfiguration.SquadronPower; } }
private void squadronFactionDropDownUpdated(object sender, SelectionChangedEventArgs e) { EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); string squadronFaction = squadronFactionDropDown.SelectedItem?.ToString(); if (eddiConfiguration.SquadronFaction != squadronFaction) { eddiConfiguration.SquadronFaction = squadronFaction == "None" ? null : squadronFaction; EDDI.Instance.Cmdr.squadronfaction = eddiConfiguration.SquadronFaction; if (squadronFaction != "None") { StarSystem system = StarSystemSqLiteRepository.Instance.GetOrCreateStarSystem(eddiConfiguration.SquadronSystem, true); Faction faction = system.factions.Find(f => f.name == squadronFaction); if (eddiConfiguration.SquadronAllegiance != faction.Allegiance) { eddiConfiguration.SquadronAllegiance = faction.Allegiance; eddiConfiguration.ToFile(); EDDI.Instance.Cmdr.squadronallegiance = faction.Allegiance; squadronPowerDropDown.SelectedItem = Power.None.localizedName; ConfigureSquadronPowerOptions(eddiConfiguration); } } else { eddiConfiguration.SquadronAllegiance = Superpower.None; eddiConfiguration.ToFile(); EDDI.Instance.Cmdr.squadronallegiance = Superpower.None; squadronPowerDropDown.SelectedItem = Power.None.localizedName; ConfigureSquadronPowerOptions(eddiConfiguration); } eddiConfiguration.ToFile(); } }
private void squadronRankDropDownUpdated(object sender, SelectionChangedEventArgs e) { EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); string squadronRank = squadronRankDropDown.SelectedItem.ToString(); if (eddiConfiguration.SquadronRank.edname != squadronRank) { eddiConfiguration.SquadronRank = SquadronRank.FromName(squadronRank); eddiConfiguration.ToFile(); EDDI.Instance.Cmdr.squadronrank = eddiConfiguration.SquadronRank; } }
private void insuranceChanged(object sender, TextChangedEventArgs e) { EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); try { eddiConfiguration.Insurance = string.IsNullOrWhiteSpace(eddiInsuranceDecimal.Text) ? 5 : Convert.ToDecimal(eddiInsuranceDecimal.Text); eddiConfiguration.ToFile(); } catch { // Bad user input; ignore it } }
private void eddiSquadronIDText_LostFocus(object sender, RoutedEventArgs e) { // Discard invalid results EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); if (eddiConfiguration.SquadronID != null) { if (eddiConfiguration.SquadronID.Contains(" ") || eddiConfiguration.SquadronID.Length > 4) { eddiConfiguration.SquadronID = null; squadronSystemDropDown.Text = string.Empty; eddiConfiguration.ToFile(); } } }
private void SquadronSystemDropDown_SelectionChanged(object sender, SelectionChangedEventArgs e) { void changeHandler(string newValue) { // Update configuration to new squadron system EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); eddiConfiguration.SquadronSystem = newValue; eddiConfiguration = EDDI.Instance.updateSquadronSystem(eddiConfiguration); eddiConfiguration.ToFile(); // Update squadron faction options for new system ConfigureSquadronFactionOptions(eddiConfiguration); } squadronSystemDropDown.SelectionDidChange(changeHandler); }
// Handle changes to the editable home system combo box private void HomeSystemText_TextChanged(object sender, TextChangedEventArgs e) { EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); void changeHandler() { // Reset the home station due to selecting new home system if (eddiConfiguration.HomeStation != null) { eddiConfiguration.HomeStation = null; homeStationDropDown.SelectedItem = Properties.MainWindow.no_station; ConfigureHomeStationOptions(null); eddiConfiguration.ToFile(); } } homeSystemDropDown.TextDidChange(sender, e, eddiConfiguration.HomeSystem, changeHandler); }
private void squadronNameChanged(object sender, TextChangedEventArgs e) { EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); if (eddiConfiguration.SquadronName != eddiSquadronNameText.Text) { eddiConfiguration.SquadronName = string.IsNullOrWhiteSpace(eddiSquadronNameText.Text) ? null : eddiSquadronNameText.Text.Trim(); if (eddiConfiguration.SquadronName == null) { eddiConfiguration.SquadronID = null; eddiSquadronIDText.Text = string.Empty; squadronSystemDropDown.Text = string.Empty; } eddiConfiguration = resetSquadronRank(eddiConfiguration); eddiConfiguration.ToFile(); EDDI.Instance.Cmdr.squadronname = eddiConfiguration.SquadronName; } }
private List <TabItem> LoadMonitors(EDDIConfiguration eddiConfiguration) { List <TabItem> result = new List <TabItem>(); foreach (EDDIMonitor monitor in EDDI.Instance.monitors) { Logging.Debug("Adding configuration tab for " + monitor.MonitorName()); System.Windows.Controls.UserControl monitorConfiguration = monitor.ConfigurationTabItem(); // Only show a tab if this can be turned off or has configuration elements if (monitorConfiguration != null || !monitor.IsRequired()) { PluginSkeleton skeleton = new PluginSkeleton(monitor.MonitorName()); skeleton.plugindescription.Text = monitor.MonitorDescription(); if (eddiConfiguration.Plugins.TryGetValue(monitor.MonitorName(), out bool enabled)) { skeleton.pluginenabled.IsChecked = enabled; } else { // Default to enabled skeleton.pluginenabled.IsChecked = true; eddiConfiguration.ToFile(); } // Add monitor-specific configuration items if (monitorConfiguration != null) { skeleton.panel.Children.Add(monitorConfiguration); } TabItem item = new TabItem { Header = monitor.LocalizedMonitorName() }; item.Content = skeleton; result.Add(item); } } return(result); }
public MainWindow(bool fromVA = false) { InitializeComponent(); this.fromVA = fromVA; // Start the EDDI instance EDDI.Instance.Start(); // Configure the EDDI tab versionText.Text = Constants.EDDI_VERSION; //// Need to set up the correct information in the hero text depending on from where we were started if (fromVA) { heroText.Text = "Any changes made here will take effect automatically in VoiceAttack. You can close this window when you have finished."; } else { heroText.Text = "If you are using VoiceAttack then please close this window before you start VoiceAttack for your changes to take effect. You can access this window from VoiceAttack with the \"Configure EDDI\" command."; } EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile(); eddiHomeSystemText.Text = eddiConfiguration.HomeSystem; eddiHomeStationText.Text = eddiConfiguration.HomeStation; eddiInsuranceDecimal.Text = eddiConfiguration.Insurance.ToString(CultureInfo.InvariantCulture); eddiVerboseLogging.IsChecked = eddiConfiguration.Debug; Logging.Verbose = eddiConfiguration.Debug; // Configure the Companion App tab CompanionAppCredentials companionAppCredentials = CompanionAppCredentials.FromFile(); companionAppEmailText.Text = companionAppCredentials.email; // See if the credentials work try { profile = CompanionAppService.Instance.Profile(); if (profile == null) { setUpCompanionAppComplete("Your connection to the companion app is good but experiencing temporary issues. Your information should be available soon"); } else { setUpCompanionAppComplete("Your connection to the companion app is operational, Commander " + profile.Cmdr.name); } } catch (Exception) { if (CompanionAppService.Instance.CurrentState == CompanionAppService.State.NEEDS_LOGIN) { // Fall back to stage 1 setUpCompanionAppStage1(); } else if (CompanionAppService.Instance.CurrentState == CompanionAppService.State.NEEDS_CONFIRMATION) { // Fall back to stage 2 setUpCompanionAppStage2(); } } if (profile != null) { setShipyardFromConfiguration(); } // 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 && (!voice.VoiceInfo.Name.Contains("Microsoft Server Speech Text to Speech Voice"))) { speechOptions.Add(voice.VoiceInfo.Name); } } } ttsVoiceDropDown.ItemsSource = speechOptions; ttsVoiceDropDown.Text = speechServiceConfiguration.StandardVoice == null ? "Windows TTS default" : speechServiceConfiguration.StandardVoice; } catch (Exception e) { Logging.Warn("" + Thread.CurrentThread.ManagedThreadId + ": Caught exception " + e); } ttsVolumeSlider.Value = speechServiceConfiguration.Volume; ttsRateSlider.Value = speechServiceConfiguration.Rate; ttsEffectsLevelSlider.Value = speechServiceConfiguration.EffectsLevel; ttsDistortCheckbox.IsChecked = speechServiceConfiguration.DistortOnDamage; disableSsmlCheckbox.IsChecked = speechServiceConfiguration.DisableSsml; ttsTestShipDropDown.ItemsSource = ShipDefinitions.ShipModels; ttsTestShipDropDown.Text = "Adder"; foreach (EDDIMonitor monitor in EDDI.Instance.monitors) { Logging.Debug("Adding configuration tab for " + monitor.MonitorName()); PluginSkeleton skeleton = new PluginSkeleton(monitor.MonitorName()); skeleton.plugindescription.Text = monitor.MonitorDescription(); bool enabled; if (eddiConfiguration.Plugins.TryGetValue(monitor.MonitorName(), out enabled)) { skeleton.pluginenabled.IsChecked = enabled; } else { // Default to enabled skeleton.pluginenabled.IsChecked = true; eddiConfiguration.ToFile(); } // Add monitor-specific configuration items UserControl monitorConfiguration = monitor.ConfigurationTabItem(); if (monitorConfiguration != null) { monitorConfiguration.Margin = new Thickness(10); skeleton.panel.Children.Add(monitorConfiguration); } TabItem item = new TabItem { Header = monitor.MonitorName() }; item.Content = skeleton; tabControl.Items.Add(item); } foreach (EDDIResponder responder in EDDI.Instance.responders) { Logging.Debug("Adding configuration tab for " + responder.ResponderName()); PluginSkeleton skeleton = new PluginSkeleton(responder.ResponderName()); skeleton.plugindescription.Text = responder.ResponderDescription(); bool enabled; if (eddiConfiguration.Plugins.TryGetValue(responder.ResponderName(), out enabled)) { skeleton.pluginenabled.IsChecked = enabled; } else { // Default to enabled skeleton.pluginenabled.IsChecked = true; eddiConfiguration.ToFile(); } // Add responder-specific configuration items UserControl monitorConfiguration = responder.ConfigurationTabItem(); if (monitorConfiguration != null) { monitorConfiguration.Margin = new Thickness(10); skeleton.panel.Children.Add(monitorConfiguration); } TabItem item = new TabItem { Header = responder.ResponderName() }; item.Content = skeleton; tabControl.Items.Add(item); } EDDI.Instance.Start(); }