コード例 #1
0
        void sendOverMouseEvent(MouseEventMessage msg)
        {
            string jsonMsg = JsonConvert.SerializeObject(msg, Formatting.Indented);

            if (isWSConnected)
            {
                wsClient.Send(jsonMsg);
            }
        }
コード例 #2
0
        private void imgHMIBkg_MouseMove(object sender, MouseEventArgs e)
        {
            System.Windows.Point mouseP    = getMouseLocationOnImage(e);
            System.Windows.Point relMouseP = new System.Windows.Point(mouseP.X / imgHMIBkg.Source.Width, mouseP.Y / imgHMIBkg.Source.Height);
            //update local cursor position in minimap
            minimapController.UpdateLocalCursorPos(relMouseP.X, relMouseP.Y);
            //lbldebugText.Content = String.Format("Local mouse Pos: ({0},{1})", relMouseP.X, relMouseP.Y);
            MouseEventMessage mouseEventMsg = new MouseEventMessage();

            mouseEventMsg.UserID  = userID;
            mouseEventMsg.RelPosX = (float)relMouseP.X;
            mouseEventMsg.RelPosY = (float)relMouseP.Y;
            //at the moment, by the default the focused area is the entire HMI screen, if focus on a smaller area, this needs to be changed
            mouseEventMsg.FocusAreaTop    = 0;
            mouseEventMsg.FocusAreaLeft   = 0;
            mouseEventMsg.FocusAreaRight  = 0.5f;
            mouseEventMsg.FocusAreaBottom = 0.5f;
            sendOverMouseEvent(mouseEventMsg);
            //UpdateMinimap();
        }
コード例 #3
0
 private void WsClient_OnMessage(object sender, WebSocketSharp.MessageEventArgs e)
 {
     if (e.IsText)
     {
         string            msgText       = e.Data;
         MouseEventMessage mouseEventMsg = JsonConvert.DeserializeObject <MouseEventMessage>(msgText);
         //store latest remote mouse event for further processing if needed
         latestRemoteMouseEvent = mouseEventMsg;
         //update remote mouse cursor in minimap
         minimapController.UpdateRemoteCursorPos(mouseEventMsg.RelPosX, mouseEventMsg.RelPosY);
         //test display the received message to check the result
         Action displayReceivedMsg = delegate
         {
             lbldebugText.Content = string.Format("RemotePos: ({0}, {1})", mouseEventMsg.RelPosX, mouseEventMsg.RelPosY);
         };
         lbldebugText.Dispatcher.Invoke(displayReceivedMsg);
         //update focus area & cursor location of remote user into hmiScreenController & tooltipController
         tooltipRemoteUser.UpdateRemoteFocusAndCursor(new RectangleF(latestRemoteMouseEvent.FocusAreaLeft, latestRemoteMouseEvent.FocusAreaTop,
                                                                     latestRemoteMouseEvent.FocusAreaRight - latestRemoteMouseEvent.FocusAreaLeft,
                                                                     latestRemoteMouseEvent.FocusAreaBottom - latestRemoteMouseEvent.FocusAreaTop),
                                                      new PointF(mouseEventMsg.RelPosX, mouseEventMsg.RelPosY));
         hmiScreenController.UpdateRemoteCursorRelPos(latestRemoteMouseEvent.RelPosX, latestRemoteMouseEvent.RelPosY);
     }
 }