コード例 #1
0
        public static CompanionAppCredentials Load()
        {
            /*
             * if (filename == null)
             * {
             * filename = Constants.DATA_DIR + @"\credentials.json";
             * }
             *
             * CompanionAppCredentials credentials = new CompanionAppCredentials();
             * try
             * {
             * string credentialsData = File.ReadAllText(filename);
             * credentials = JsonConvert.DeserializeObject<CompanionAppCredentials>(credentialsData);
             * }
             * catch {}
             *
             * credentials.dataPath = filename;
             * return credentials;
             */
            credentials = Instance();

            credentials.appId        = EdGo.Properties.Settings.Default.CompanionAppId;
            credentials.machineId    = EdGo.Properties.Settings.Default.CompanionMachineId;
            credentials.machineToken = EdGo.Properties.Settings.Default.CompanionMachineToken;


            return(credentials);
        }
コード例 #2
0
        //private string dataPath;

        /// <summary>
        /// Obtain credentials from a file.  If the file name is not supplied the the default
        /// path of Constants.Data_DIR\credentials.json is used
        /// </summary>
        public static CompanionAppCredentials Instance()
        {
            if (credentials == null)
            {
                credentials = new CompanionAppCredentials();
            }
            return(credentials);
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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";
        }
コード例 #5
0
ファイル: MainWindow.xaml.cs プロジェクト: ZeroCry/EDDI
        public MainWindow(bool fromVA = false)
        {
            InitializeComponent();

            this.fromVA = fromVA;

            // Start the EDDI instance
            EDDI.FromVA = fromVA;
            EDDI.Instance.Start();

            // Configure the EDDI tab
            setStatusInfo();

            // Need to set up the correct information in the hero text depending on from where we were started
            if (fromVA)
            {
                // Allow the EDDI VA plugin to change window state
                VaWindowStateChange = new vaWindowStateChangeDelegate(OnVaWindowStateChange);
                heroText.Text       = Properties.EddiResources.change_affect_va;
            }
            else
            {
                heroText.Text = Properties.EddiResources.if_using_va;
            }

            EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile();

            eddiHomeSystemText.Text      = eddiConfiguration.validSystem == true ? eddiConfiguration.HomeSystem : string.Empty;
            eddiHomeStationText.Text     = eddiConfiguration.validStation == true ? eddiConfiguration.HomeStation : string.Empty;
            eddiVerboseLogging.IsChecked = eddiConfiguration.Debug;
            eddiBetaProgramme.IsChecked  = eddiConfiguration.Beta;
            if (eddiConfiguration.Gender == "Female")
            {
                eddiGenderFemale.IsChecked = true;
            }
            else if (eddiConfiguration.Gender == "Male")
            {
                eddiGenderMale.IsChecked = true;
            }
            else
            {
                eddiGenderNeither.IsChecked = true;
            }

            List <LanguageDef> langs = GetAvailableLangs();

            chooseLanguageDropDown.ItemsSource       = langs;
            chooseLanguageDropDown.DisplayMemberPath = "displayName";
            chooseLanguageDropDown.SelectedItem      = langs.Find(l => l.ci.Name == Eddi.Properties.Settings.Default.OverrideCulture);
            chooseLanguageDropDown.SelectionChanged += (sender, e) =>
            {
                LanguageDef cultureDef = (LanguageDef)chooseLanguageDropDown.SelectedValue;
                Eddi.Properties.Settings.Default.OverrideCulture = cultureDef.ci.Name;
            };

            // Configure the Frontier API tab
            CompanionAppCredentials companionAppCredentials = CompanionAppCredentials.FromFile();

            companionAppEmailText.Text = companionAppCredentials.email;
            // See if the credentials work
            try
            {
                profile = CompanionAppService.Instance.Profile();
                if (profile == null)
                {
                    setUpCompanionAppComplete(Properties.EddiResources.frontier_api_temp_nok);
                }
                else
                {
                    setUpCompanionAppComplete(String.Format(Properties.EddiResources.frontier_api_ok, 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();
                }
            }

            // Configure the Text-to-speech tab
            ConfigureTTS();

            LoadMonitors(eddiConfiguration);

            LoadResponders(eddiConfiguration);

            RestoreWindowState();
            EDDI.Instance.Start();
        }
コード例 #6
0
        public MainWindow(bool fromVA = false)
        {
            InitializeComponent();

            this.fromVA = fromVA;

            // Start the EDDI instance
            EDDI.FromVA = fromVA;
            EDDI.Instance.Start();

            // Configure the EDDI tab
            setStatusInfo();

            // Need to set up the correct information in the hero text depending on from where we were started
            if (fromVA)
            {
                // Allow the EDDI VA plugin to change window state
                VaWindowStateChange = new vaWindowStateChangeDelegate(OnVaWindowStateChange);
                heroText.Text       = Properties.EddiResources.change_affect_va;
            }
            else
            {
                heroText.Text = Properties.EddiResources.if_using_va;
            }

            EDDIConfiguration eddiConfiguration = EDDIConfiguration.FromFile();

            // Setup home system & station from config file
            homeSystemDropDown.ItemsSource = new List <string> {
                eddiConfiguration.HomeSystem ?? string.Empty
            };
            homeSystemDropDown.SelectedItem = eddiConfiguration.HomeSystem ?? string.Empty;
            ConfigureHomeStationOptions(eddiConfiguration.HomeSystem);
            homeStationDropDown.SelectedItem = eddiConfiguration.HomeStation ?? Properties.MainWindow.no_station;

            eddiVerboseLogging.IsChecked = eddiConfiguration.Debug;
            eddiBetaProgramme.IsChecked  = eddiConfiguration.Beta;
            if (eddiConfiguration.Gender == "Female")
            {
                eddiGenderFemale.IsChecked = true;
            }
            else if (eddiConfiguration.Gender == "Male")
            {
                eddiGenderMale.IsChecked = true;
            }
            else
            {
                eddiGenderNeither.IsChecked = true;
            }
            eddiSquadronNameText.Text         = eddiConfiguration.SquadronName ?? string.Empty;
            eddiSquadronIDText.Text           = eddiConfiguration.SquadronID ?? string.Empty;
            squadronRankDropDown.SelectedItem = (eddiConfiguration.SquadronRank ?? SquadronRank.None).localizedName;
            ConfigureSquadronRankOptions(eddiConfiguration);

            // Setup squadron home system from config file
            squadronSystemDropDown.ItemsSource = new List <string> {
                eddiConfiguration.SquadronSystem ?? string.Empty
            };
            squadronSystemDropDown.SelectedItem = eddiConfiguration.SquadronSystem ?? string.Empty;

            squadronFactionDropDown.SelectedItem = eddiConfiguration.SquadronFaction ?? Power.None.localizedName;
            squadronPowerDropDown.SelectedItem   = (eddiConfiguration.SquadronPower ?? Power.None).localizedName;
            ConfigureSquadronPowerOptions(eddiConfiguration);

            List <LanguageDef> langs = GetAvailableLangs(); // already correctly sorted

            chooseLanguageDropDown.ItemsSource       = langs;
            chooseLanguageDropDown.DisplayMemberPath = "displayName";
            chooseLanguageDropDown.SelectedItem      = langs.Find(l => l.ci.Name == Eddi.Properties.Settings.Default.OverrideCulture);
            chooseLanguageDropDown.SelectionChanged += (sender, e) =>
            {
                LanguageDef cultureDef = (LanguageDef)chooseLanguageDropDown.SelectedItem;
                Eddi.Properties.Settings.Default.OverrideCulture = cultureDef.ci.Name;
            };

            // Configure the Frontier API tab
            CompanionAppCredentials companionAppCredentials = CompanionAppCredentials.Load();

            CompanionAppService.Instance.StateChanged += companionApiStatusChanged;

            // Configure the Text-to-speech tab
            ConfigureTTS();

            LoadAndSortTabs(eddiConfiguration);

            RestoreWindowState();
            EDDI.Instance.MainWindow = this;
            EDDI.Instance.Start();
        }
コード例 #7
0
 private void inputCode_KeyUp(object sender, KeyEventArgs e)
 {
     CompanionAppCredentials.Instance().code = inputCode.Text;
 }
コード例 #8
0
 private void input_KeyUp(object sender, KeyEventArgs e)
 {
     CompanionAppCredentials.Instance().email    = inputEmail.Text;
     CompanionAppCredentials.Instance().password = inputPassword.Text;
 }