private void ButtonTcpConnectClicked(string address) { TcpManager.Connect(address); if (!TcpManager.Connected) { return; } NetManager.Stream = TcpManager.GetStream(); NetManager.Client = TcpManager.GetClient(); InitializeComponent_MousePage(); AccelerometerStart(SensorSpeed.Fastest); }
private void InitializeComponent_MousePage() { SetContentView(Resource.Layout.MousePage); var seekBarSensitivity = FindViewById <SeekBar>(Resource.Id.seekBar); seekBarSensitivity.ProgressChanged += (sender, e) => { Sensitivity = e.Progress; }; var buttonLeft = FindViewById <ImageButton>(Resource.Id.mouseButtonLeft); buttonLeft.Touch += (sender, e) => { switch (e.Event.Action) { case MotionEventActions.Up: NetManager.Send(NetManager.Command.LeftUp, ""); break; case MotionEventActions.Down: NetManager.Send(NetManager.Command.LeftDown, ""); break; } }; var buttonRight = FindViewById <ImageButton>(Resource.Id.mouseButtonRight); buttonRight.Touch += (sender, e) => { switch (e.Event.Action) { case MotionEventActions.Up: NetManager.Send(NetManager.Command.RightUp, ""); break; case MotionEventActions.Down: NetManager.Send(NetManager.Command.RightDown, ""); break; } }; var buttonExit = FindViewById <ImageButton>(Resource.Id.mouseButtonExit); buttonExit.Click += delegate { AccelerometerStop(); NetManager.Send(NetManager.Command.ConnectClose, ""); Sensitivity = 0; TcpManager.Disconnect(); InitializeComponent_HomePage(); }; }
protected override void OnDestroy() { base.OnDestroy(); try { AccelerometerStop(); NetManager.Send(NetManager.Command.ConnectClose, ""); TcpManager.Disconnect(); } catch { // ignored } }