public void Start() { mouseMonitor?.Dispose(); CancelHighlightOnMove(); highlightOnMoveCts = new CancellationTokenSource(); switch (clientSession.Agent.Type) { case AgentType.iOS: coordinateMapper = new iOSSimulatorCoordinateMapper(clientSession.Agent.Identity); break; case AgentType.Android: coordinateMapper = new MacAndroidCoordinateMapper(clientSession.Agent.Identity); break; default: coordinateMapper = new MacCoordinateMapper(); break; } mouseMonitor = new MouseMonitor(); mouseMonitor.MouseMoved += MouseMonitor_MouseMoved; mouseMonitor.MouseUp += MouseMonitor_MouseUp; }
async void MouseMonitor_MouseUp(CGPoint point) { mouseMonitor.Dispose(); mouseMonitor = null; HighlightEnded?.Invoke(this, EventArgs.Empty); try { // Since everything's async, it's possible for the move handler's HighlightView call // to hit after this, causing the view to stay highlighted. So we cancel. CancelHighlightOnMove(); await HighlightView(point, andSelect : true); } catch (Exception e) { Log.Error(TAG, e); } }