public override void Initialize() { this.Model.RestartTickerCallback = () => WPFHelper.InvokeAsync( this.BeginAnimation, DispatcherPriority.Normal); this.Config.PropertyChanged += (_, e) => { switch (e.PropertyName) { case nameof(this.Config.Visible): if (this.Config.Visible) { this.Model.StartSync(); } else { this.Model.StopSync(); } break; case nameof(this.Config.TestMode): if (this.Config.TestMode) { this.BeginAnimation(); } break; } }; if (this.Config.Visible) { this.Model.StartSync(); } }
private async void ReplaceButton() { if (this.SwitchVisibleButton != null && !this.SwitchVisibleButton.IsDisposed && this.SwitchVisibleButton.IsHandleCreated) { var leftButton = ( from Control x in ActGlobals.oFormActMain.Controls where !x.Equals(this.SwitchVisibleButton) && ( x is Button || x is CheckBox ) orderby x.Left select x).FirstOrDefault(); var location = leftButton != null ? new Point(leftButton.Left - this.SwitchVisibleButton.Width - 1, 0) : new Point(ActGlobals.oFormActMain.Width - 533, 0); await WPFHelper.InvokeAsync(() => { if (this.SwitchVisibleButton != null) { this.SwitchVisibleButton.Location = location; } }); } }
private async void XMLPasteOnClick(object sender, RoutedEventArgs e) { var text = string.Empty; await WPFHelper.InvokeAsync(() => { for (int i = 0; i < 10; i++) { try { var obj = Clipboard.GetDataObject(); if (obj != null && obj.GetDataPresent(DataFormats.Text)) { text = (string)obj.GetData(DataFormats.Text); } break; } catch (Exception ex) when(ex is InvalidOperationException || ex is COMException) { Thread.Sleep(5); } } }); if (!string.IsNullOrEmpty(text)) { this.XMLEditor.Text = text; CommonSounds.Instance.PlayAsterisk(); } }
/// <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(); }
/// <summary> /// すべての設定を保存する /// </summary> public async void SaveSettingsAsync() => await WPFHelper.InvokeAsync(() => { SpellPanelTable.Instance.Save(); SpellTable.Instance.Save(); TickerTable.Instance.Save(); TagTable.Instance.Save(); TimelineSettings.Save(); Settings.Default.Save(); }, DispatcherPriority.Background);
private async void TriggersTreeViewOnSelectedItemChanged( object sender, RoutedPropertyChangedEventArgs <object> e) { var treeView = sender as TreeView; if (treeView.IsLoaded) { await WPFHelper.InvokeAsync(() => this.ShowContent(e.NewValue)); } }
/// <summary> /// 表示切り替えボタン(スペスペボタン)の状態を切り替える /// </summary> /// <param name="visible"> /// 切り替える状態</param> public async void ChangeSwitchVisibleButton( bool visible) { await Task.Run(() => { this.SwitchOverlay(visible); }); await WPFHelper.InvokeAsync(() => { this.ChangeButtonColor(); }, DispatcherPriority.Normal); }
private async void BeginAnimation() { await Task.Delay(TimeSpan.FromSeconds(Settings.Instance.MPTicker.Offset)); this.IsVisibleSyncIndicator = true; (this.View as MPTickerView)?.BeginAnimation(); await Task.Run(async() => { await Task.Delay(1200); await WPFHelper.InvokeAsync(() => this.IsVisibleSyncIndicator = false); }); }
private async void XMLCopyOnClick(object sender, RoutedEventArgs e) => await WPFHelper.InvokeAsync(() => { for (int i = 0; i < 10; i++) { try { Clipboard.SetDataObject(this.XMLEditor.Text); CommonSounds.Instance.PlayAsterisk(); break; } catch (Exception ex) when(ex is InvalidOperationException || ex is COMException) { Thread.Sleep(5); } } });
public TriggerTesterView() { this.InitializeComponent(); this.SetLocale(Settings.Default.UILocale); this.LoadConfigViewResources(); // ウィンドウのスタート位置を決める this.WindowStartupLocation = WindowStartupLocation.CenterScreen; this.MouseLeftButtonDown += (x, y) => this.DragMove(); this.Loaded += async(x, y) => { await WPFHelper.InvokeAsync(() => { this.MessageLabel.Content = "Loading, Please wait..."; this.MessageLabel.Visibility = Visibility.Visible; }, DispatcherPriority.Normal); // シミュレーションモードをONにする PluginMainWorker.Instance.InSimulation = true; TableCompiler.Instance.InSimulation = true; await Task.Delay(TimeSpan.FromSeconds(0.5)); await WPFHelper.BeginInvoke(() => { this.MessageLabel.Content = string.Empty; this.MessageLabel.Visibility = Visibility.Collapsed; }, DispatcherPriority.ApplicationIdle); }; this.CloseButton.Click += (x, y) => { this.testTimer.Stop(); this.Close(); }; this.Closed += (x, y) => { PluginMainWorker.Instance.InSimulation = false; TableCompiler.Instance.InSimulation = false; this.ClearTestCondition(); }; this.testTimer.Tick += this.TestTimer_Tick; this.RunButton.Click += async(x, y) => { // インスタンススペルを消去する SpellTable.Instance.RemoveInstanceSpellsAll(); await Task.Run(() => { lock (this) { this.testTimer.Stop(); this.isPause = false; foreach (var log in this.Logs) { log.IsDone = false; } this.prevTestTimestamp = DateTime.Now; this.TestTime = TimeSpan.Zero; this.testTimer.Start(); } }); }; this.PauseButton.Click += (x, y) => { this.isPause = !this.isPause; this.PauseButton.Content = this.isPause ? "Resume" : "Pause"; }; this.StopButton.Click += async(x, y) => { await Task.Run(() => { lock (this) { this.testTimer.Stop(); foreach (var log in this.Logs) { log.IsDone = false; } this.prevTestTimestamp = DateTime.MinValue; } PluginMainWorker.Instance.InSimulation = false; ChatLogWorker.Instance?.Write(true); }); // インスタンススペルを消去する SpellTable.Instance.RemoveInstanceSpellsAll(); }; this.OpenButton.Click += (x, y) => { var result = this.openFileDialog.ShowDialog(ActGlobals.oFormActMain); if (result != System.Windows.Forms.DialogResult.OK) { return; } this.LogFile = this.openFileDialog.FileName; this.LoadLog(); }; this.ApplyButton.Click += async(x, y) => { await WPFHelper.InvokeAsync(() => { this.MessageLabel.Content = "Loading, Please wait..."; this.MessageLabel.Visibility = Visibility.Visible; }, DispatcherPriority.Normal); await Task.Run(() => { // インスタンススペルを消去する SpellTable.Instance.RemoveInstanceSpellsAll(); // テスト条件を適用する this.ApplyTestCondition(); }); ModernMessageBox.ShowDialog( "Test Condition was applied.", "Trigger Simulator"); await Task.Delay(TimeSpan.FromSeconds(0.5)); await WPFHelper.BeginInvoke(() => { this.MessageLabel.Content = string.Empty; this.MessageLabel.Visibility = Visibility.Collapsed; }, DispatcherPriority.ApplicationIdle); }; this.ClearButton.Click += async(x, y) => { await WPFHelper.InvokeAsync(() => { this.MessageLabel.Content = "Loading, Please wait..."; this.MessageLabel.Visibility = Visibility.Visible; }, DispatcherPriority.Normal); await Task.Run(() => { // インスタンススペルを消去する SpellTable.Instance.RemoveInstanceSpellsAll(); // テスト条件を解除する this.ClearTestCondition(); }); ModernMessageBox.ShowDialog( "Test Condition was cleard.", "Trigger Simulator"); await Task.Delay(TimeSpan.FromSeconds(0.5)); await WPFHelper.BeginInvoke(() => { this.MessageLabel.Content = string.Empty; this.MessageLabel.Visibility = Visibility.Collapsed; }, DispatcherPriority.ApplicationIdle); }; // AddLogLine this.AddLogLineButton.Click += async(x, y) => await this.AddLogLineAsync(); this.AddLogLineTextBox.KeyDown += async(x, y) => { if (y.Key == Key.Enter) { if (!string.IsNullOrEmpty(this.AddLogLineTextBox.Text)) { this.LogLine = this.AddLogLineTextBox.Text; } await this.AddLogLineAsync(); } }; }