public void TwoConsecutiveCallsWhichReturnsMessageBuffersShouldNotBeSame()
        {
            var message = new MouseDragEventMesssage(MouseEventType.Right, 56, 67, 60, 71);
            var messageBuffer1 = message.ToBytes();
            var messageBuffer2 = message.ToBytes();

            Assert.AreNotSame(messageBuffer1, messageBuffer2);
        }
        public void ShouldAbleToRetriveVariablesFromBytes()
        {
            var messageBuffer = new byte[] { 2, 56, 0, 0, 0, 67, 0, 0, 0, 60, 0, 0, 0, 71, 0, 0, 0 };

            var message = new MouseDragEventMesssage(messageBuffer);
            Assert.AreEqual(MouseEventType.Right, message.EventType);
            Assert.AreEqual(56, message.StartXPosition);
            Assert.AreEqual(67, message.StartYPosition);
            Assert.AreEqual(60, message.EndXPosition);
            Assert.AreEqual(71, message.EndYPosition);
        }
        public void ShouldAbleToBytesFromRetriveVariables()
        {
            var message = new MouseDragEventMesssage(MouseEventType.Right, 56, 67, 60, 71);
            var messageBuffer = new byte[] { 2, 56, 0, 0, 0, 67, 0, 0, 0, 60, 0, 0, 0, 71, 0, 0, 0 };
            var messageBufferToCompare = message.ToBytes();

            Assert.AreEqual(messageBuffer.Length, messageBufferToCompare.Length);

            for (var i = 0; i < messageBuffer.Length; i++)
            {
                if (messageBuffer[i] != messageBufferToCompare[i])
                    Assert.Fail("Message contents is not same");
            }
        }
Пример #4
0
 private void DoMouseDrag(RdapMessage message)
 {
     var mouseDragEventMesssage = new MouseDragEventMesssage(message.Data);
     switch (mouseDragEventMesssage.EventType)
     {
         case MouseEventType.Left:
             new MouseDrag((int) ((int)mouseDragEventMesssage.StartXPosition * desktopCapture.WidthAspectRatio),
                           (int) ((int)mouseDragEventMesssage.EndXPosition * desktopCapture.WidthAspectRatio),
                           (int) ((int)mouseDragEventMesssage.StartYPosition * desktopCapture.HeightAspectRatio),
                           (int) ((int)mouseDragEventMesssage.EndYPosition * desktopCapture.HeightAspectRatio),
                           0).Execute();
             break;
         case MouseEventType.Right:
             new MouseDrag((int) ((int)mouseDragEventMesssage.StartXPosition * desktopCapture.WidthAspectRatio),
                           (int) ((int)mouseDragEventMesssage.EndXPosition * desktopCapture.WidthAspectRatio),
                           (int) ((int)mouseDragEventMesssage.StartYPosition * desktopCapture.HeightAspectRatio),
                           (int) ((int)mouseDragEventMesssage.EndYPosition * desktopCapture.HeightAspectRatio),
                           1).Execute();
             break;
         default:
             return;
     }
 }
        private void OnMouseUp(object sender, MouseEventArgs e)
        {
            switch (e.Button)
            {
                case MouseButtons.Left:
                    dragEndMouseEventType = MouseEventType.Left;
                    break;
                case MouseButtons.Middle:
                    dragEndMouseEventType = MouseEventType.Middle;
                    break;
                case MouseButtons.Right:
                    dragEndMouseEventType = MouseEventType.Right;
                    break;
                default:
                    return;
            }

            dragEndX = e.X;
            dragEndY = e.Y;

            byte[] dataToSend;
            if (dragEndX == dragStartX && dragEndY == dragStartY)
            {
                var message = new MouseClickEventMessage(dragEndMouseEventType, (uint)e.X, (uint)e.Y);
                var messageRdap = new RdapMessage(RdapMessageType.MouseClickEventMessage, message.ToBytes());
                dataToSend = messageRdap.ToBytes();
            }
            else
            {
                var message = new MouseDragEventMesssage(dragEndMouseEventType, (uint)dragStartX, (uint)dragStartY, (uint)dragEndX, (uint)dragEndY);
                var messageRdap = new RdapMessage(RdapMessageType.MouseClickEventMessage, message.ToBytes());
                dataToSend = messageRdap.ToBytes();
            }

            if (subscriber != null)
                subscriber.Send(dataToSend, 0, dataToSend.Length);
        }