internal void SendMouseMoveEvent(IRemoteDesktopClientInternal service, MouseMoveServiceEventArgs e) { Area area = mVisibleArea; if (LOGGER.IsDebugEnabled) { LOGGER.Debug(string.Format("REMOTE_CLIENT, service sent mouse move data. X: {0}, Y: {1}, CursorId: {2}. Current area, StartX: {3}, EndX: {4}, StartY: {5}, EndY: {6}", e.Position.X.ToString(), e.Position.Y.ToString(), e.CursorId, area.StartX.ToString(), area.EndX.ToString(), area.StartY.ToString(), area.EndY.ToString())); } if (area.StartX <= e.Position.X && area.EndX >= e.Position.X && area.StartY <= e.Position.Y && area.EndY >= e.Position.Y) { if (service.LastMousePosX != e.Position.X || service.LastMousePosY != e.Position.Y || !service.LastCursorId.Equals(e.CursorId)) { service.LastMousePosX = e.Position.X; service.LastMousePosY = e.Position.Y; service.LastCursorId = e.CursorId; DrawMouse(); } //else //{ // LOGGER.Debug("REMOTE_CLIENT, no mouse drawn #1."); //} } else { //LOGGER.Debug("REMOTE_CLIENT, no mouse drawn #2."); service.LastMousePosX = e.Position.X; service.LastMousePosY = e.Position.Y; service.LastCursorId = e.CursorId; } }
/// <summary> /// Starts the event pump. /// </summary> /// <exception cref="System.InvalidOperationException"> /// Client was not connected. /// or /// Client was not authenticated. /// </exception> public void StartEventPump() { if (!IsConnected) { throw new InvalidOperationException("Client was not connected."); } if (!IsAuthenticated) { throw new InvalidOperationException("Client was not authenticated."); } if (this.InvokeRequired) { Action d = new Action(StartEventPump); ((RemoteDesktopWinFormsControl)d.Target).Invoke(d); return; } // innentől UI thread if (mProxy != null && !mProxy.IsActive) { mVisibleArea = GetVisibleArea(); mProxy.IsActive = true; mProxy.ClientSubscribeForDesktop(mVisibleArea); MouseMoveServiceEventArgs mouseData = mProxy.ClientStartEventPump(); mProxy.LastCursorId = mouseData.CursorId; mProxy.LastMousePosX = mouseData.Position.X; mProxy.LastMousePosY = mouseData.Position.Y; ClipboardEventManager.Instance.EventClipboardChanged += new EventHandler <Native.Hooks.ClipboardChangedEventArgs>(ClipboardChangedEventHandler); ClipboardEventManager.Instance.Start(); DrawMouse(); if (mServiceConfig.AcceptKeyboardAndMouseInputs) { SubscribeEvents(); mMouseMoveThread = new Thread(new ThreadStart(MouseMoveMain)); mMouseMoveThread.IsBackground = true; mMouseMoveThread.Name = "MouseMoveSenderClient"; mMouseMoveThread.Start(); } } }