Exemplo n.º 1
0
        public static void WritePointerEvent(Stream a_stream, VncEnum.PointerEventButtonMask a_buttonMask, UInt16 a_xpos, UInt16 a_ypos)
        {
            byte[] buffer = new byte[6];
            buffer[0] = (byte)VncEnum.MessageTypeClientToServer.PointerEvent; // 5
            buffer[1] = (byte)a_buttonMask;
            Array.Copy(BigEndianBitConverter.GetBytes(a_xpos), 0, buffer, 2, 2);
            Array.Copy(BigEndianBitConverter.GetBytes(a_ypos), 0, buffer, 4, 2);

            a_stream.Write(buffer, 0, buffer.Length);
        }
Exemplo n.º 2
0
        private void mouseEvent(object sender, MouseEventArgs e)
        {
            if (m_client != null && m_client.Connected)
            {
                // If the size is too small, Numerator will be 0.
                // In this case, divide by 0, so do not do anything
                if (m_xZoom.Numerator == 0 || m_yZoom.Numerator == 0)
                {
                    return;
                }

                int xpos = (int)(e.X * m_xZoom.Denominator / m_xZoom.Numerator);
                int ypos = (int)(e.Y * m_yZoom.Denominator / m_yZoom.Numerator);

                VncEnum.PointerEventButtonMask mask = VncEnum.PointerEventButtonMask.None;
                if (e.Button == MouseButtons.Left)
                {
                    mask |= VncEnum.PointerEventButtonMask.MouseButtonLeft;
                }
                if (e.Button == MouseButtons.Middle)
                {
                    mask |= VncEnum.PointerEventButtonMask.MouseButtonMiddle;
                }
                if (e.Button == MouseButtons.Right)
                {
                    mask |= VncEnum.PointerEventButtonMask.MouseButtonRight;
                }
                if (e.Delta > 0)
                {
                    mask |= VncEnum.PointerEventButtonMask.MouseWheelUp;
                }
                if (e.Delta < 0)
                {
                    mask |= VncEnum.PointerEventButtonMask.MouseWheelDown;
                }

                // If FramebufferUpdate is not received, the screen is not updated and the mouse pointer event is not send.
                // Because there is such a scene, if you do not send the mouse pointer event for a certain time, send it.
                if ((DateTime.Now - m_lastPointerSendDt).TotalMilliseconds > 20)
                {
                    m_client.WritePointerEvent(mask, (UInt16)xpos, (UInt16)ypos);
                    m_last.Enable = false;
                }
                else
                {
                    // Since it is useless to send every time, only record it.
                    // Then, it transmits at the interval of OnPaint.
                    m_last.Enable = true;
                    m_last.Mask   = mask;
                    m_last.X      = xpos;
                    m_last.Y      = ypos;
                }
            }
        }
Exemplo n.º 3
0
        public void WritePointerEvent(VncEnum.PointerEventButtonMask a_buttonMask, UInt16 a_x, UInt16 a_y)
        {
            if (!ClientConfig.IsSendPointer)
            {
                return;
            }

            try
            {
                VncComm.WritePointerEvent(m_writeStream, a_buttonMask, a_x, a_y);
            }
            catch (Exception a_ex)
            {
                cleanupForDisconnect(a_ex);
                onDisconnected(new VncCauseEventArgs(a_ex));
            }
        }