public SearchAgent(Logger logger, WagahighOperator wagahighOperator, SearchDirector searchDirector, CancellationToken cancellationToken) { this._logger = logger; this._wagahighOperator = wagahighOperator; this._searchDirector = searchDirector; this._cancellationToken = cancellationToken; }
private async void TimerTick(object sender, EventArgs e) { if (this._connection == null) { return; } try { await this.UpdateScreen(); } catch (Exception ex) { if (Debugger.IsAttached) { Debugger.Break(); } this._connection = null; MessageBox.Show(this, ex.ToString(), "エラー", MessageBoxButton.OK, MessageBoxImage.Error); } // CanExecute 更新チェック CommandManager.InvalidateRequerySuggested(); }
private async Task UpdateCursorImage() { if (this._connection == null) { return; } try { var source = this.imgCursor.Source as WriteableBitmap; bool createNewBitmap; var img = await this._connection.GetCursorImageAsync(); this._cursorImage?.Dispose(); this._cursorImage = img; createNewBitmap = source == null || source.PixelWidth != img.Width || source.PixelHeight != img.Height; if (createNewBitmap) { source = new WriteableBitmap(img.Width, img.Height, 96, 96, PixelFormats.Pbgra32, null); } source.Lock(); try { CopyPixels(img, source.BackBuffer, source.BackBufferStride * source.PixelHeight); source.AddDirtyRect(new Int32Rect(0, 0, source.PixelWidth, source.PixelHeight)); } finally { source.Unlock(); } if (createNewBitmap) { this.imgCursor.Source = source; } } catch (Exception ex) { if (Debugger.IsAttached) { Debugger.Break(); } this._connection = null; MessageBox.Show(this, ex.ToString(), "エラー", MessageBoxButton.OK, MessageBoxImage.Error); } }
private async void SendClickEvent() { if (this._connection == null) { return; } try { await this._connection.MouseClickAsync(); } catch (Exception ex) { if (Debugger.IsAttached) { Debugger.Break(); } this._connection = null; MessageBox.Show(this, ex.ToString(), "エラー", MessageBoxButton.OK, MessageBoxImage.Error); } }
public GrpcToaServer(string host, int port, WagahighOperator wagahighOperator) : base(host, port, typeof(ToaMagicOnionService)) { this._wagahighOperator = wagahighOperator; }
private async void btnConnect_Click(object sender, RoutedEventArgs e) { if (this._logSubscription != null) { this._logSubscription.Dispose(); this._logSubscription = null; } if (this._connection != null) { this._connection.Dispose(); this._connection = null; } var host = this.txtRemoteAddr.Text; int port; try { var colonIndex = host.LastIndexOf(':'); if (colonIndex >= 0) { port = int.Parse(host.Substring(colonIndex + 1)); host = host.Remove(colonIndex); } else { port = GrpcToaServer.DefaultPort; } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "接続先エラー", MessageBoxButton.OK, MessageBoxImage.Error); return; } this.btnConnect.IsEnabled = false; try { var conn = new GrpcRemoteWagahighOperator(host, port); this._connection = conn; await conn.ConnectAsync(); this._logSubscription = conn.LogStream .ObserveOn(this.Dispatcher) .Subscribe( this.OnNextLog, ex => { if (Debugger.IsAttached) { Debugger.Break(); } MessageBox.Show(this, ex.ToString(), "ログエラー", MessageBoxButton.OK, MessageBoxImage.Error); }, () => MessageBox.Show(this, "ログストリームが終了しました。", "ログエラー", MessageBoxButton.OK, MessageBoxImage.Error) ); } catch (Exception ex) { if (Debugger.IsAttached) { Debugger.Break(); } MessageBox.Show(this, ex.ToString(), "接続失敗", MessageBoxButton.OK, MessageBoxImage.Error); return; } finally { this.btnConnect.IsEnabled = true; } if (this._timer == null) { // 0.1 秒ごとに画面を更新 this._timer = new DispatcherTimer( new TimeSpan(100 * TimeSpan.TicksPerMillisecond), DispatcherPriority.Normal, this.TimerTick, this.Dispatcher ); } }