private static void OnClientAccepted(ClientBase client) { if (ClientAccepted != null) { ClientAccepted(Listener, new ServerEventArgs { Client = client }); } }
public static void RemoveClient(ClientBase client) { Clients.Remove(client); if (ClientRemoved != null) { ClientRemoved(Listener, new ServerEventArgs { Client = client }); } }
private void ForwardMouseEvent(MouseInput e, ClientBase clientBase) { MouseInput L_e = new MouseInput(); L_e.IsAbsolute = true; L_e.MouseData = e.MouseData; L_e.Point = L_e_Point; L_e.Time = e.Time; L_e.WindowDesktopHandle = clientBase.WindowDesktopHandle; L_e.WindowStationHandle = clientBase.WindowStationHandle; L_e.WindowHandle = clientBase.WindowHandle; L_e.WM = e.WM; clientBase.Dispatch(L_e); }
private static void InputToClient(KeyboardInput e, ClientBase client) { // this method basically applies CAS settings and calls ForwardEventToClient byte cas = 0; var clientSettings = Mubox.Configuration.MuboxConfigSection.Default.Profiles.ActiveProfile.ActiveClient; if (clientSettings != null) { if (clientSettings.Name.Equals(client.DisplayName, StringComparison.InvariantCultureIgnoreCase)) { Mubox.Configuration.KeySetting keySetting; if (clientSettings.Keys.TryGetKeySetting((WinAPI.VK)e.VK, out keySetting) && keySetting.EnableNoModActiveClient) { cas = (byte)e.CAS; e.CAS = (WinAPI.CAS)0; } } } ForwardEventToClient(e, client); if (cas != 0) { e.CAS = (WinAPI.CAS)cas; } }
private static WinAPI.Windows.RECT GetScreenRelativeClientRect(ClientBase item) { if (item.CachedScreenFromClientRectExpiry.Ticks < DateTime.Now.Ticks) { WinAPI.Windows.RECT calcRect; WinAPI.Windows.RECT clientRect; WinAPI.Windows.GetWindowRect(item.WindowHandle, out calcRect); WinAPI.Windows.GetClientRect(item.WindowHandle, out clientRect); int borderOffset = ((calcRect.Width - clientRect.Width) / 2); calcRect.Left += borderOffset; calcRect.Bottom -= borderOffset; calcRect.Top = calcRect.Bottom - clientRect.Height; item.CachedScreenFromClientRect = calcRect; item.CachedScreenFromClientRectExpiry = DateTime.Now.AddSeconds(3); } return item.CachedScreenFromClientRect; }
private static void ForwardEventToClient(KeyboardInput e, ClientBase clientBase) { try { e.WindowStationHandle = clientBase.WindowStationHandle; e.WindowDesktopHandle = clientBase.WindowDesktopHandle; e.WindowHandle = clientBase.WindowHandle; clientBase.Dispatch(e); } catch (Exception ex) { Mubox.Control.Network.Server.RemoveClient(clientBase); ex.Log(); } }
private void TrackMousePositionClientRelative(MouseInput e, ClientBase activeClient, ClientBase[] clients) { ClientBase clientForCoordinateNormalization = activeClient; if (clientForCoordinateNormalization == null || !clientForCoordinateNormalization.IsLocalAddress || !IsMouseInClientArea(e, GetScreenRelativeClientRect(clientForCoordinateNormalization))) { // look for a local client which the mouse coordinates "belong to" and re-assign "clientForCoordinateNormalization" clientForCoordinateNormalization = null; foreach (var item in clients) { if (item.IsLocalAddress && IsMouseInClientArea(e, GetScreenRelativeClientRect(item))) { clientForCoordinateNormalization = item; break; } } } if (clientForCoordinateNormalization != null) { // track client-relative position this.L_e_Point = new Point( Math.Ceiling((double)(e.Point.X - clientForCoordinateNormalization.CachedScreenFromClientRect.Left) * (65536.0 / (double)clientForCoordinateNormalization.CachedScreenFromClientRect.Width)), Math.Ceiling((double)(e.Point.Y - clientForCoordinateNormalization.CachedScreenFromClientRect.Top) * (65536.0 / (double)clientForCoordinateNormalization.CachedScreenFromClientRect.Height))); } }