示例#1
0
        /// <summary>
        /// 接收到命令
        /// </summary>
        /// <param name="msg"></param>
        public void webCient_OnMessage(object sender, Remote_Client_fubao.Model.Entity.Message msg)
        {
            try
            {
                //var transferStr = Encoding.UTF8.GetString(msg.Data).ToLower();
                var transferStr = Encoding.UTF8.GetString(msg.Data);
                var transferArr = transferStr.Split('\\');
                if (transferArr.Count() > 0)
                {
                    if (transferArr[0] == "chanjetservice")
                    {
                        TrueOrFalse trueOrFalse = new TrueOrFalse(transferArr[1]);
                        trueOrFalse.ShowDialog();
                        if (trueOrFalse.Accept)
                        {
                            _isHelp  = true;
                            _isClose = false;
                            _remote  = msg.Sender;
                            _mCleint.SendRemoteConnect(msg.Accepter, msg.Sender, true);
                            _isSend    = true;
                            lastBitmap = null;
                            Interlocked.Increment(ref sendCount);
                            if (sendCount < 2)
                            {
                                SendImage();
                            }
                            SendImageKeep();
                        }
                        else
                        {
                            _mCleint.SendRemoteConnect(msg.Accepter, msg.Sender, false);
                            return;
                        }
                    }
                    else
                    {
                        if (_isHelp)
                        {
                            var transferArr2 = transferStr.Split(new string[] { ":" }, StringSplitOptions.None);
                            var command      = transferArr2[0];
                            var dataStr      = transferArr2[1];
                            switch (command)
                            {
                            case "mousemove"://鼠标移动
                                string[] localString      = dataStr.Split('@');
                                int      localX           = int.Parse(localString[0]);
                                int      localY           = int.Parse(localString[1]);
                                int      remoteFormHeight = int.Parse(localString[2]);
                                double   rate             = ((double)Screen.PrimaryScreen.Bounds.Height) / remoteFormHeight;
                                _MouseAndKeyHelper.SetCursorPosition((int)(localX * rate), (int)(localY * rate));
                                break;

                            case "mousedown"://鼠标键的按下
                                if (dataStr == "left")
                                {
                                    _MouseAndKeyHelper.MouseDown(MouseAndKeyHelper.ClickOnWhat.LeftMouse);
                                }
                                else if (dataStr == "middle")
                                {
                                    _MouseAndKeyHelper.MouseDown(MouseAndKeyHelper.ClickOnWhat.MiddleMouse);
                                }
                                else if (dataStr == "right")
                                {
                                    _MouseAndKeyHelper.MouseDown(MouseAndKeyHelper.ClickOnWhat.RightMouse);
                                }
                                break;

                            case "mouseup"://鼠标键的抬起
                                if (dataStr == "left")
                                {
                                    _MouseAndKeyHelper.MouseUp(MouseAndKeyHelper.ClickOnWhat.LeftMouse);
                                }
                                else if (dataStr == "middle")
                                {
                                    _MouseAndKeyHelper.MouseUp(MouseAndKeyHelper.ClickOnWhat.MiddleMouse);
                                }
                                else if (dataStr == "right")
                                {
                                    _MouseAndKeyHelper.MouseUp(MouseAndKeyHelper.ClickOnWhat.RightMouse);
                                }
                                break;

                            case "keypress"://键盘键的按下即抬起
                                string[] arry = dataStr.Split('&');
                                if (arry.Length <= 1)
                                {
                                    int keyValue = int.Parse(dataStr);
                                    MouseAndKeyHelper.VirtualKeys virtualKey = (MouseAndKeyHelper.VirtualKeys)(Enum.ToObject(typeof(MouseAndKeyHelper.VirtualKeys), keyValue));
                                    _MouseAndKeyHelper.KeyPress(virtualKey);
                                }
                                else
                                {
                                    List <MouseAndKeyHelper.VirtualKeys> list = new List <MouseAndKeyHelper.VirtualKeys>();
                                    foreach (var str in arry)
                                    {
                                        int Value = int.Parse(str);
                                        MouseAndKeyHelper.VirtualKeys virtualKey = (MouseAndKeyHelper.VirtualKeys)(Enum.ToObject(typeof(MouseAndKeyHelper.VirtualKeys), Value));
                                        list.Add(virtualKey);
                                    }
                                    _MouseAndKeyHelper.KeyPress(list);
                                }
                                break;

                            case "mousewheel"://鼠标滚轮的滚动
                                int delta = int.Parse(dataStr);
                                _MouseAndKeyHelper.MouseWheel(delta);
                                break;

                            default:
                                break;
                            }


                            if (transferStr == "helpcommand")
                            {
                            }
                            if (transferStr == "stopremotehelp")
                            {
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
示例#2
0
        /// <summary>
        /// 接收到命令
        /// </summary>
        /// <param name="msg"></param>
        private void webCient_OnMessage(object sender, GFF.Model.Entity.Message msg)
        {
            Task.Factory.StartNew(() =>
            {
                try
                {
                    var transferStr = Encoding.UTF8.GetString(msg.Data).ToLower();

                    if (transferStr == "wenlirdp")
                    {
                        OnConnected?.Invoke();
                        SendImage();
                    }
                    else
                    {
                        if (this._isHelp)
                        {
                            var transferArr = transferStr.Split(new string[] { ":" }, StringSplitOptions.None);
                            var command     = transferArr[0];
                            var dataStr     = transferArr[1];
                            switch (command)
                            {
                            case "mousemove":    //鼠标移动
                                string[] localString = dataStr.Split('@');
                                int localX           = int.Parse(localString[0]);
                                int localY           = int.Parse(localString[1]);
                                int remoteFormHeight = int.Parse(localString[2]);
                                double rate          = ((double)Screen.AllScreens[0].Bounds.Height) / remoteFormHeight;
                                _MouseAndKeyHelper.SetCursorPosition((int)(localX * rate), (int)(localY * rate));
                                break;

                            case "mousedown":    //鼠标键的按下
                                if (dataStr == "left")
                                {
                                    _MouseAndKeyHelper.MouseDown(MouseAndKeyHelper.ClickOnWhat.LeftMouse);
                                }
                                else if (dataStr == "middle")
                                {
                                    _MouseAndKeyHelper.MouseDown(MouseAndKeyHelper.ClickOnWhat.MiddleMouse);
                                }
                                else if (dataStr == "right")
                                {
                                    _MouseAndKeyHelper.MouseDown(MouseAndKeyHelper.ClickOnWhat.RightMouse);
                                }
                                break;

                            case "mouseup":    //鼠标键的抬起
                                if (dataStr == "left")
                                {
                                    _MouseAndKeyHelper.MouseUp(MouseAndKeyHelper.ClickOnWhat.LeftMouse);
                                }
                                else if (dataStr == "middle")
                                {
                                    _MouseAndKeyHelper.MouseUp(MouseAndKeyHelper.ClickOnWhat.MiddleMouse);
                                }
                                else if (dataStr == "right")
                                {
                                    _MouseAndKeyHelper.MouseUp(MouseAndKeyHelper.ClickOnWhat.RightMouse);
                                }
                                break;

                            case "keypress":    //键盘键的按下即抬起
                                int keyValue = int.Parse(dataStr);
                                MouseAndKeyHelper.VirtualKeys virtualKey = (MouseAndKeyHelper.VirtualKeys)(Enum.ToObject(typeof(MouseAndKeyHelper.VirtualKeys), keyValue));
                                _MouseAndKeyHelper.KeyPress(virtualKey);
                                break;

                            case "mousewheel":    //鼠标滚轮的滚动
                                int delta = int.Parse(dataStr);
                                _MouseAndKeyHelper.MouseWheel(delta);
                                break;

                            default:
                                break;
                            }
                        }
                        if (transferStr == "helpcommand")
                        {
                            this._isHelp = true;
                        }
                        if (transferStr == "stopremotehelp")
                        {
                            this._isHelp = false;
                            _mCleint.Dispose();
                        }
                    }
                }
                catch { }
            });
        }