/// <summary> /// 開始する /// </summary> public async void Begin() { this.isOver = false; // FFXIVプラグインのバージョンをチェックする FFXIVPlugin.Instance.ActPluginAttachedCallback = () => { var ver = FFXIVPlugin.Instance.ActPlugin.GetType().Assembly.GetName().Version; if (ver.Major >= 2) { WPFHelper.InvokeAsync(() => { ModernMessageBox.ShowDialog( "This Hojoring not supported FFXIV_ACT_Plugin v2 or later." + Environment.NewLine + "You should update to Hojoring v7 or later.", "Attention", MessageBoxButton.OK); }); } }; // FFXIVのスキャンを開始する // FFXIVプラグインへのアクセスを開始する await Task.Run(() => FFXIVPlugin.Instance.Start( Settings.Default.LogPollSleepInterval, Settings.Default.FFXIVLocale)); // ログバッファを生成する this.LogBuffer = new LogBuffer(); await Task.Run(() => { // テーブルコンパイラを開始する TableCompiler.Instance.Begin(); // サウンドコントローラを開始する SoundController.Instance.Begin(); }); // Overlayの更新スレッドを開始する this.BeginOverlaysThread(); // ログ監視タイマを開始する this.detectLogsWorker = new ThreadWorker( () => this.DetectLogsCore(), 0, nameof(this.detectLogsWorker)); // Backgroudスレッドを開始する this.backgroudWorker = new System.Timers.Timer(); this.backgroudWorker.AutoReset = true; this.backgroudWorker.Interval = 5000; this.backgroudWorker.Elapsed += (s, e) => { this.BackgroundCore(); }; this.detectLogsWorker.Run(); this.backgroudWorker.Start(); }
private void DisplayContentMessage(string message, string title) { var contentBox = new ModernMessageBox { Title = title, Content = message }; contentBox.ShowDialog(); }
private void DisplayErrorMessage(string message) { var errorBox = new ModernMessageBox { Title = "Error", Content = "Error: " + message }; errorBox.ShowDialog(); }
public MainWindow() { ConfigsSystem.Check_Start.Check(); var MyIni = new IniFile(PathFinding.CONFIGFILE); InitializeComponent(); this.MouseLeftButtonDown += delegate { DragMove(); }; string privatecy = MyIni.Read("PrivatePolicy", "System"); priv = Boolean.Parse(privatecy); string music = MyIni.Read("Music", "Audio"); string Discordss = MyIni.Read("DiscordRPC", "System").ToString(); string AutoLogin = MyIni.Read("AutoLogin", "System").ToString(); bool Discord = Boolean.Parse(Discordss); bool AutoLogins = Boolean.Parse(AutoLogin); priv2 = Boolean.Parse(music); if (!priv) { var msg = new ModernMessageBox(welcome(), "Azusa Password Manager", ModernMessageboxIcons.Info, "Okay") { Button1Key = Key.D1, CheckboxText = "Okey", CheckboxVisibility = Visibility.Visible, }; msg.ShowDialog(); if (msg.CheckboxChecked == true) { MyIni.Write("PrivatePolicy", "true", "System"); } else { System.Environment.Exit(1); } } if (priv2) { BackgroundSysteme.MusicSysteme.play(true); } if (Discord) { DiscordRPC.Discord_Stages.login(); } if (AutoLogins) { Algorythmen.Auth_Class_System.password_crypt = sugar + MeisXOR.XORConverter.MeiXORDecrypt(MyIni.Read("PSW2", "PasswortFileSystem").ToString(), pw) + pepper; Algorythmen.Auth_Class_System.salt_key = MeisXOR.XORConverter.MeiXORDecrypt(MyIni.Read("PIN", "PasswortFileSystem").ToString(), pw); UI_Management.ControlScreen data = new UI_Management.ControlScreen(); data.Show(); this.Close(); } rename(); }
private void Rename(ShortcutInfo shortcutInfo) { var msg = new ModernMessageBox("请设置一个用于显示的别名", "设置显示名", ModernMessageboxIcons.Question, "确定", "取消") { TextBoxText = shortcutInfo.FileRenameDisp, TextBoxVisibility = Visibility.Visible, }; msg.Owner = MessageBoxHelper.GlobalParentWindow; msg.ShowDialog(); if (msg.Result == ModernMessageboxResult.Button1) { shortcutInfo.FileRename = msg.TextBoxText; } }
public static bool IsValidPluginLoadOrder() { lock (LockObject) { if (isCheckedLoadOrder) { return(isLastValidPluginLoadOrder); } var isExistsXIVPlugin = false; foreach (var plugin in ActGlobals.oFormActMain.ActPlugins) { if (plugin.pluginFile.Name.ContainsIgnoreCase("FFXIV_ACT_Plugin")) { isExistsXIVPlugin = true; } if (plugin.pluginFile.Name.ContainsIgnoreCase("ACT.SpecialSpellTimer") || plugin.pluginFile.Name.ContainsIgnoreCase("ACT.TTSYukkuri") || plugin.pluginFile.Name.ContainsIgnoreCase("ACT.UltraScouter")) { isLastValidPluginLoadOrder = isExistsXIVPlugin; break; } } isCheckedLoadOrder = true; } if (!isLastValidPluginLoadOrder) { WPFHelper.InvokeAsync(() => { ModernMessageBox.ShowDialog( "Plugin load order is wrong.\n" + "Please load FFXIV_ACT_Plugin before Hojoring.\n\n" + "ex.\n" + "1. FFXIV_ACT_Plugin\n" + "2. ACT.TTSYukkuri\n" + "3. ACT.SpecialSpellTimer\n" + "4. ACT.UltraScouter\n", "Plugin Load Error"); }); } return(isLastValidPluginLoadOrder); }
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { var msg = new ModernMessageBox("The quick brown fox jumps over the lazy dog.\n", "hello world", ModernMessageboxIcons.Info, "CSharp", "Java", "Python") { Button1Key = Key.D1, Button2Key = Key.D2, Button3Key = Key.D3, CheckboxText = "Don't show this again", CheckboxVisibility = Visibility.Visible, TextBoxText = "some staff", TextBoxVisibility = Visibility.Visible, }; msg.ShowDialog(); QModernMessageBox.None(msg.TextBoxText, "TextBoxText"); QModernMessageBox.None(msg.CheckboxChecked.ToString(), "CheckboxChecked"); }
/// <summary> /// 後片付けをする /// </summary> public void DeInitPluginCore() { try { // 付加情報オーバーレイを閉じる LPSView.CloseLPS(); POSView.ClosePOS(); PluginMainWorker.Instance.End(); PluginMainWorker.Free(); TimelineController.Free(); this.RemoveSwitchVisibleButton(); this.PluginStatusLabel.Text = "Plugin Exited"; // 設定ファイルを保存する TimelineSettings.Save(); Settings.Default.Save(); Logger.Write("Plugin Exited."); } catch (Exception ex) { ActGlobals.oFormActMain.WriteExceptionLog( ex, "Plugin deinit error."); Logger.Write("Plugin deinit error.", ex); if (this.PluginStatusLabel != null) { this.PluginStatusLabel.Text = "Plugin Exit Error"; } ModernMessageBox.ShowDialog( "Plugin deinit error !", "ACT.SpecialSpellTimer", System.Windows.MessageBoxButton.OK, ex); } Logger.DeInit(); }
public static bool IsAvailableWindows() { const string prompt1 = "Unsupported Operating System."; const string prompt2 = "Windows 10 or Later is Required."; var result = false; if (IsWindows10Later) { result = true; } else { if (Config.Instance.SupportWin7) { result = true; if (!shownWindowsIsOld) { shownWindowsIsOld = true; Logger.Warn($"{prompt1} {prompt2}"); Logger.Warn($"Support Win7 manualy, but you'd better update to Windows 10. https://www.microsoft.com/software-download/windows10"); } } else { if (!shownWindowsIsOld) { shownWindowsIsOld = true; Logger.Error($"{prompt1} {prompt2}"); WPFHelper.BeginInvoke( () => ModernMessageBox.ShowDialog( $"{prompt1}\n{prompt2}", "ACT.Hojoring"), DispatcherPriority.Normal); } } } return(result); }
/// <summary> /// ハンドルされない例外ハンドラ /// </summary> /// <param name="sender">sender</param> /// <param name="e">イベント引数</param> private static void OnDispatcherUnhandledException( object sender, DispatcherUnhandledExceptionEventArgs e) { try { AppLog.DefaultLogger.Fatal( e.Exception, "Unhandled Exception"); InvokeAsync(() => ModernMessageBox.ShowDialog( "Fatal Error.\nUnhandled Exception.", "Fatal Error", MessageBoxButton.OK, e.Exception)); e.Handled = true; } catch (Exception) { } }
public Task <FFXIVReaderStartingResult> WaitForReaderToStartedAsync( TabPage baseTabPage) => Task.Run(() => { var result = new FFXIVReaderStartingResult(); lock (this) { // 旧の単独DLL版が存在したら念のため削除する var dll = Path.Combine( Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "FFXIV_MemoryReader.dll"); if (File.Exists(dll)) { var message = new StringBuilder(); try { File.Delete(dll); message.Clear(); message.AppendLine($@"""FFXIV_MemoryReader.dll"" was deleted."); message.AppendLine($@"Please, restart ACT."); WPFHelper.BeginInvoke(() => ModernMessageBox.ShowDialog( message.ToString(), "Warning", MessageBoxButton.OK)); } catch (Exception) { } if (File.Exists(dll)) { message.Clear(); message.AppendLine($@"""FFXIV_MemoryReader.dll"" is exists yet."); message.AppendLine($@"You should delete ""FFXIV_MemoryReader.dll""."); message.AppendLine(); message.AppendLine("Path:"); message.AppendLine(dll); WPFHelper.BeginInvoke(() => ModernMessageBox.ShowDialog( message.ToString(), "Warning", MessageBoxButton.OK)); } } if (this.MemoryPlugin != null) { result.Status = FFXIVReaderStartingStatus.AlreadyStarted; return(result); } var succeeded = false; WPFHelper.Invoke(() => { var parentTabControl = baseTabPage.Parent as TabControl; if (parentTabControl == null) { return; } var memoryReaderTabPage = new TabPage(); var dummyLabel = new Label(); parentTabControl.TabPages.Add(memoryReaderTabPage); this.tab = parentTabControl; this.tabPage = memoryReaderTabPage; try { this.MemoryPlugin = new MemoryPlugin(); this.MemoryPlugin.InitPlugin(memoryReaderTabPage, dummyLabel); succeeded = dummyLabel.Text.ContainsIgnoreCase("Started"); if (succeeded) { result.Status = FFXIVReaderStartingStatus.Started; } else { result.Status = FFXIVReaderStartingStatus.Error; result.Message = "Error occurred initializing FFXIV_MemoryReader."; this.MemoryPlugin?.DeInitPlugin(); this.MemoryPlugin = null; } } catch (Exception ex) { result.Status = FFXIVReaderStartingStatus.Error; result.Message = "Fatal error occurred initializing FFXIV_MemoryReader."; result.Exception = ex; ModernMessageBox.ShowDialog( result.Message, "Fatal Error", MessageBoxButton.OK, ex); } }, DispatcherPriority.Normal); this.IsAvailable = succeeded; } return(result); });
public void InitPluginCore( TabPage pluginScreenSpace, Label pluginStatusText) { this.PluginStatusLabel = pluginStatusText; AppLog.LoadConfiguration(AppLog.HojoringConfig); this.AppLogger.Trace(Assembly.GetExecutingAssembly().GetName().ToString() + " start."); try { Logger.Init(); Logger.Write("Plugin Start."); pluginScreenSpace.Text = "SPESPE"; // .NET Frameworkのバージョンを確認する if (!UpdateChecker.IsAvailableDotNet()) { return; } // 設定ファイルを読み込む Settings.Default.Load(); Settings.Default.ApplyRenderMode(); // 最小化する? if (Settings.Default.IsMinimizeOnStart) { ActGlobals.oFormActMain.WindowState = FormWindowState.Minimized; Application.DoEvents(); } // HojoringのSplashを表示する WPFHelper.Start(); UpdateChecker.ShowSplash(); // アップデートを確認する Task.Run(() => { this.Update(); }); // 自身の場所を格納しておく var plugin = ActGlobals.oFormActMain.PluginGetSelfData(this.PluginRoot); if (plugin != null) { this.Location = plugin.pluginFile.DirectoryName; } // 設定ファイルを読み込む SpellPanelTable.Instance.Load(); SpellTable.Instance.Load(); TickerTable.Instance.Load(); TagTable.Instance.Load(); // 設定ファイルのバックアップを作成する SpellPanelTable.Instance.Backup(); SpellTable.Instance.Backup(); TickerTable.Instance.Backup(); TagTable.Instance.Backup(); // TTS辞書を読み込む TTSDictionary.Instance.Load(); // 設定Panelを追加する var baseView = new BaseView(pluginScreenSpace.Font); pluginScreenSpace.Controls.Add(new ElementHost() { Child = baseView, Dock = DockStyle.Fill, Font = pluginScreenSpace.Font, }); // 本体を開始する PluginMainWorker.Instance.Begin(); TimelineController.Init(); // 付加情報オーバーレイを表示する LPSView.ShowLPS(); POSView.ShowPOS(); this.SetSwitchVisibleButton(); this.PluginStatusLabel.Text = "Plugin Started"; Logger.Write("Plugin Started."); } catch (Exception ex) { ActGlobals.oFormActMain.WriteExceptionLog( ex, "Plugin init error."); Logger.Write("Plugin init error.", ex); if (this.PluginStatusLabel != null) { this.PluginStatusLabel.Text = "Plugin Initialize Error"; } ModernMessageBox.ShowDialog( "Plugin init error !", "ACT.SpecialSpellTimer", System.Windows.MessageBoxButton.OK, ex); } }
public void InitPlugin( IActPluginV1 plugin, TabPage pluginScreenSpace, Label pluginStatusText) { // タイトルをセットする pluginScreenSpace.Text = "YUKKURI"; EnvironmentMigrater.Migrate(); MasterFilePublisher.Publish(); WPFHelper.Start(); WPFHelper.BeginInvoke(async() => { AppLog.LoadConfiguration(AppLog.HojoringConfig); this.Logger?.Trace(Assembly.GetExecutingAssembly().GetName().ToString() + " start."); try { EnvironmentHelper.GarbageLogs(); EnvironmentHelper.StartActivator(() => { ConfigBaseView.Instance.SetActivationStatus(false); this.DeInitPlugin(); }); this.Logger.Trace("[YUKKURI] Start InitPlugin"); this.PluginStatusLabel = pluginStatusText; var pluginInfo = ActGlobals.oFormActMain.PluginGetSelfData(plugin); if (pluginInfo != null) { this.PluginDirectory = pluginInfo.pluginFile.DirectoryName; } // .NET FrameworkとOSのバージョンを確認する if (!UpdateChecker.IsAvailableDotNet() || !UpdateChecker.IsAvailableWindows()) { NotSupportedView.AddAndShow(pluginScreenSpace); return; } // 設定ファイルを読み込む // TP廃止につき無効化する Settings.Default.Load(); Settings.Default.StatusAlertSettings.EnabledTPAlert = false; // 漢字変換を初期化する KanjiTranslator.Default.Initialize(); // TTSキャッシュの移行とGarbageを行う await Task.Run(() => { this.MigrateTTSCache(); this.GarbageTTSCache(); }); // HojoringのSplashを表示する WPFHelper.Start(); UpdateChecker.ShowSplash(); await Task.Run(() => { // TTSサーバを開始する TTSServerController.Start(); // TTSを初期化する SpeechController.Default.Initialize(); // FF14監視スレッドを初期化する FFXIVWatcher.Initialize(); }); // 設定Panelを追加する pluginScreenSpace.Controls.Add(new ElementHost() { Child = new ConfigBaseView(), Dock = DockStyle.Fill, }); // TTSメソッドを置き換える this.StartReplaceTTSMethodTimer(); await Task.Run(() => { // DISCORD BOT クライアントを初期化する DiscordClientModel.Model.Initialize(); // AutoJoinがONならば接続する if (Settings.Default.DiscordSettings.AutoJoin) { DiscordClientModel.Model.Connect(true); } }); await Task.Run(() => { // VOICEROIDを起動する if (SpeechController.Default is VoiceroidSpeechController ctrl) { ctrl.Start(); } }); // Bridgeにメソッドを登録する PlayBridge.Instance.SetBothDelegate((message, isSync, volume) => this.Speak(message, PlayDevices.Both, isSync, volume)); PlayBridge.Instance.SetMainDeviceDelegate((message, isSync, volume) => this.Speak(message, PlayDevices.Main, isSync, volume)); PlayBridge.Instance.SetSubDeviceDelegate((message, isSync, volume) => this.Speak(message, PlayDevices.Sub, isSync, volume)); PlayBridge.Instance.SetSyncStatusDelegate(() => Settings.Default.Player == WavePlayerTypes.WASAPIBuffered); // テキストコマンドの購読を登録する this.SubscribeTextCommands(); // サウンドデバイスを初期化する SoundPlayerWrapper.Init(); SoundPlayerWrapper.LoadTTSCache(); PluginStatusLabel.Text = "Plugin Started"; this.Logger.Trace("[YUKKURI] End InitPlugin"); // 共通ビューを追加する CommonViewHelper.Instance.AddCommonView( pluginScreenSpace.Parent as TabControl); // アップデートを確認する await Task.Run(() => this.Update()); } catch (Exception ex) { this.Logger.Error(ex, "InitPlugin error."); ModernMessageBox.ShowDialog( "Plugin init error !", "ACT.TTSYukkuri", System.Windows.MessageBoxButton.OK, ex); // TTSをゆっくりに戻す Settings.Default.TTS = TTSType.Yukkuri; Settings.Default.Save(); } }); }
public void InitPluginCore( TabPage pluginScreenSpace, Label pluginStatusText) { // タイトルをセットする pluginScreenSpace.Text = "SPESPE"; EnvironmentMigrater.Migrate(); MasterFilePublisher.Publish(); WPFHelper.Start(); WPFHelper.BeginInvoke(async() => { AppLog.LoadConfiguration(AppLog.HojoringConfig); this.AppLogger?.Trace(Assembly.GetExecutingAssembly().GetName().ToString() + " start."); try { this.PluginStatusLabel = pluginStatusText; if (!EnvironmentHelper.IsValidPluginLoadOrder()) { pluginStatusText.Text = "Plugin Initialize Error"; return; } EnvironmentHelper.GarbageLogs(); EnvironmentHelper.StartActivator(() => { BaseView.Instance.SetActivationStatus(false); this.DeInitPluginCore(); }); Logger.Init(); Logger.Write("[SPESPE] Start InitPlugin"); // .NET FrameworkとOSのバージョンを確認する if (!UpdateChecker.IsAvailableDotNet() || !UpdateChecker.IsAvailableWindows()) { NotSupportedView.AddAndShow(pluginScreenSpace); return; } // メイン設定ファイルを読み込む Settings.Default.Load(); Settings.Default.ApplyRenderMode(); Settings.Default.StartAutoSave(); // 最小化する? if (Settings.Default.IsMinimizeOnStart) { ActGlobals.oFormActMain.WindowState = FormWindowState.Minimized; } // HojoringのSplashを表示する UpdateChecker.ShowSplash(); // 自身の場所を格納しておく var plugin = ActGlobals.oFormActMain.PluginGetSelfData(this.PluginRoot); if (plugin != null) { this.Location = plugin.pluginFile.DirectoryName; } // 設定ファイルを読み込む SpellPanelTable.Instance.Load(); SpellTable.Instance.Load(); TickerTable.Instance.Load(); TagTable.Instance.Load(); // 設定ファイルをバックアップする await EnvironmentHelper.BackupFilesAsync( Settings.Default.FileName, SpellPanelTable.Instance.DefaultFile, SpellTable.Instance.DefaultFile, TickerTable.Instance.DefaultFile, TagTable.Instance.DefaultFile, FFXIV.Framework.Config.FileName); TTSDictionary.Instance.Load(); // 設定Panelを追加する var baseView = new BaseView(pluginScreenSpace.Font); pluginScreenSpace.Controls.Add(new ElementHost() { Child = baseView, Dock = DockStyle.Fill, Font = pluginScreenSpace.Font, }); EnvironmentHelper.WaitInitActDone(); // 本体を開始する PluginMainWorker.Instance.Begin(); TimelineController.Init(); // 付加情報オーバーレイを表示する LPSView.ShowLPS(); POSView.ShowPOS(); this.SetSwitchVisibleButton(); this.PluginStatusLabel.Text = "Plugin Started"; Logger.Write("[SPESPE] End InitPlugin"); // 共通ビューを追加する CommonViewHelper.Instance.AddCommonView( pluginScreenSpace.Parent as TabControl); this.isLoaded = true; // アップデートを確認する await Task.Run(() => this.Update()); } catch (Exception ex) { Logger.Write("InitPlugin error.", ex); if (this.PluginStatusLabel != null) { this.PluginStatusLabel.Text = "Plugin Initialize Error"; } ModernMessageBox.ShowDialog( "Plugin init error !", "ACT.SpecialSpellTimer", System.Windows.MessageBoxButton.OK, ex); } }); }
public void InitPlugin( IActPluginV1 plugin, TabPage pluginScreenSpace, Label pluginStatusText) { // タイトルをセットする pluginScreenSpace.Text = "YUKKURI"; WPFHelper.Start(); WPFHelper.BeginInvoke(async() => { // FFXIV_MemoryReaderを先にロードさせる await FFXIVReader.Instance.WaitForReaderToStartedAsync(); AppLog.LoadConfiguration(AppLog.HojoringConfig); this.Logger.Trace(Assembly.GetExecutingAssembly().GetName().ToString() + " start."); try { this.Logger.Trace("[YUKKURI] Start InitPlugin"); this.PluginStatusLabel = pluginStatusText; var pluginInfo = ActGlobals.oFormActMain.PluginGetSelfData(plugin); if (pluginInfo != null) { this.PluginDirectory = pluginInfo.pluginFile.DirectoryName; } // .NET FrameworkとOSのバージョンを確認する if (!UpdateChecker.IsAvailableDotNet() || !UpdateChecker.IsAvailableWindows()) { NotSupportedView.AddAndShow(pluginScreenSpace); return; } // 設定ファイルを読み込む Settings.Default.Load(); // 漢字変換を初期化する KanjiTranslator.Default.Initialize(); // TTSのキャッシュを移行する await Task.Run(() => this.MigrateTTSCache()); // HojoringのSplashを表示する WPFHelper.Start(); UpdateChecker.ShowSplash(); await Task.Run(() => { // TTSサーバを開始する TTSServerController.Start(); // TTSを初期化する SpeechController.Default.Initialize(); // FF14監視スレッドを初期化する FFXIVWatcher.Initialize(); }); // 設定Panelを追加する pluginScreenSpace.Controls.Add(new ElementHost() { Child = new ConfigBaseView(), Dock = DockStyle.Fill, }); // TTSメソッドを置き換える this.StartReplaceTTSMethodTimer(); await Task.Run(() => { // Discordに接続する DiscordClientModel.Model.Initialize(); DiscordClientModel.Model.Connect(true); }); await Task.Run(() => { // VOICEROIDを起動する if (SpeechController.Default is VoiceroidSpeechController ctrl) { ctrl.Start(); } }); // Bridgeにメソッドを登録する PlayBridge.Instance.SetBothDelegate((message, isSync) => this.Speak(message, PlayDevices.Both, isSync)); PlayBridge.Instance.SetMainDeviceDelegate((message, isSync) => this.Speak(message, PlayDevices.Main, isSync)); PlayBridge.Instance.SetSubDeviceDelegate((message, isSync) => this.Speak(message, PlayDevices.Sub, isSync)); PlayBridge.Instance.SetSyncStatusDelegate(() => Settings.Default.Player == WavePlayerTypes.WASAPIBuffered); // サウンドデバイスを初期化する SoundPlayerWrapper.Init(); PluginStatusLabel.Text = "Plugin Started"; this.Logger.Trace("[YUKKURI] End InitPlugin"); // アップデートを確認する await Task.Run(() => this.Update()); } catch (Exception ex) { this.Logger.Error(ex, "InitPlugin error."); ModernMessageBox.ShowDialog( "Plugin init error !", "ACT.TTSYukkuri", System.Windows.MessageBoxButton.OK, ex); // TTSをゆっくりに戻す Settings.Default.TTS = TTSType.Yukkuri; Settings.Default.Save(); } }); }
private async void ExecuteGetVoicesCommand() { if (string.IsNullOrEmpty(this.Config.AccessKey) || string.IsNullOrEmpty(this.Config.SecretKey)) { ModernMessageBox.ShowDialog( "Enter your access key and secret key.", "ACT.Hojoring"); return; } var endpoint = this.Config.Endpoint; var chain = new CredentialProfileStoreChain(); var hash = (this.Config.Region + this.Config.AccessKey + this.Config.SecretKey).GetHashCode().ToString("X4"); var profileName = $"polly_profile_{hash}"; AWSCredentials awsCredentials; if (!chain.TryGetAWSCredentials( profileName, out awsCredentials)) { var options = new CredentialProfileOptions { AccessKey = this.Config.AccessKey, SecretKey = this.Config.SecretKey, }; var profile = new CredentialProfile(profileName, options); profile.Region = endpoint; chain.RegisterProfile(profile); chain.TryGetAWSCredentials( profileName, out awsCredentials); } if (awsCredentials == null) { return; } var voice = this.Config.Voice; using (var pc = new AmazonPollyClient( awsCredentials, endpoint)) { var res = await pc.DescribeVoicesAsync(new DescribeVoicesRequest()); if (res == null || res.HttpStatusCode != HttpStatusCode.OK) { ModernMessageBox.ShowDialog( "Voices update is failed.", "ACT.Hojoring"); return; } this.Voices.Clear(); this.Config.Voice = string.Empty; foreach (var v in from x in res.Voices orderby x.LanguageCode.ToString(), x.Gender.ToString(), x.Name select x) { this.Voices.Add( new PollyConfigs.PollyVoice { Name = $"{v.Id.Value} ({v.LanguageCode}, {v.Gender})", Value = v.Id }); } } if (this.Voices.Any(x => x.Value == voice)) { this.Config.Voice = voice; } Settings.Default.Save(); ModernMessageBox.ShowDialog( "Voices update is completed.", "ACT.Hojoring"); }