示例#1
0
        internal void SendMouseMoveEvent(IRemoteDesktopClientInternal service, MouseMoveServiceEventArgs e)
        {
            Area area = mVisibleArea;

            if (LOGGER.IsDebugEnabled)
            {
                LOGGER.Debug(string.Format("REMOTE_CLIENT, service sent mouse move data. X: {0}, Y: {1}, CursorId: {2}. Current area, StartX: {3}, EndX: {4}, StartY: {5}, EndY: {6}", e.Position.X.ToString(), e.Position.Y.ToString(), e.CursorId, area.StartX.ToString(), area.EndX.ToString(), area.StartY.ToString(), area.EndY.ToString()));
            }

            if (area.StartX <= e.Position.X && area.EndX >= e.Position.X &&
                area.StartY <= e.Position.Y && area.EndY >= e.Position.Y)
            {
                if (service.LastMousePosX != e.Position.X || service.LastMousePosY != e.Position.Y || !service.LastCursorId.Equals(e.CursorId))
                {
                    service.LastMousePosX = e.Position.X;
                    service.LastMousePosY = e.Position.Y;
                    service.LastCursorId  = e.CursorId;

                    DrawMouse();
                }
                //else
                //{
                //    LOGGER.Debug("REMOTE_CLIENT, no mouse drawn #1.");
                //}
            }
            else
            {
                //LOGGER.Debug("REMOTE_CLIENT, no mouse drawn #2.");
                service.LastMousePosX = e.Position.X;
                service.LastMousePosY = e.Position.Y;
                service.LastCursorId  = e.CursorId;
            }
        }
示例#2
0
        private void Event_KeyUp(object sender, KeyEventArgs e)
        {
            ListSpecialized <EventHandler <SubscribedKeyPressEventArgs> > subscribeds = null;
            KeysSubscription k = new KeysSubscription(e.KeyCode, e.Alt, e.Control, e.Shift);

            lock (mKeysSubscriptions)
            {
                if (mKeysSubscriptions.ContainsKey(k))
                {
                    subscribeds = new ListSpecialized <EventHandler <SubscribedKeyPressEventArgs> >(mKeysSubscriptions[k]);
                }
            }

            if (subscribeds != null)
            {
                SubscribedKeyPressEventArgs arg = new SubscribedKeyPressEventArgs(k);
                foreach (EventHandler <SubscribedKeyPressEventArgs> handler in subscribeds)
                {
                    Raiser.CallDelegatorBySync(handler, new object[] { this, arg });
                }
            }
            else
            {
                IRemoteDesktopClientInternal proxy = mProxy;
                if (proxy != null && proxy.IsActive)
                {
                    try
                    {
                        proxy.ClientSendKeyEvent(new KeyboardEventArgs(KeyboardEventTypeEnum.Up, e.KeyCode));
                    }
                    catch (Exception) { }
                }
                //LogKeyEvent(sender, "KEY-UP", e);
            }
        }
示例#3
0
        private void DrawMouse()
        {
            if (LOGGER.IsDebugEnabled)
            {
                LOGGER.Debug("REMOTE_CLIENT, draw mouse to the surface.");
            }

            if (this.InvokeRequired)
            {
                Action d = new Action(DrawMouse);
                ((RemoteDesktopWinFormsControl)d.Target).Invoke(d);
                return;
            }

            IRemoteDesktopClientInternal proxy = mProxy;
            Bitmap background = mRemoteDesktopImage.Clone() as Bitmap;

            if (proxy != null && !string.IsNullOrEmpty(proxy.LastCursorId))
            {
                using (Graphics g = Graphics.FromImage(background))
                {
                    Cursor    c            = mCursorWithIds[proxy.LastCursorId];
                    Rectangle cursorBounds = new Rectangle(new Point(proxy.LastMousePosX, proxy.LastMousePosY), c.Size);
                    c.Draw(g, cursorBounds);
                }
            }
            pbClient.Image = background;
        }
示例#4
0
 internal void SendDesktopImageClip(IRemoteDesktopClientInternal service, DesktopImageClipArgs e)
 {
     if (LOGGER.IsDebugEnabled)
     {
         LOGGER.Debug(string.Format("REMOTE_CLIENT, service sent desktop clip refresh. X: {0}, Y: {1}. Size: {2}", e.Location.X.ToString(), e.Location.Y.ToString(), e.ImageData.Length.ToString()));
     }
     DrawDesktopClip(e);
 }
示例#5
0
        private void pbClient_MouseEnter(object sender, EventArgs e)
        {
            // amikor belép a területre, át kell rajzolni a helyi Cursor-t
            IRemoteDesktopClientInternal proxy = mProxy;

            if (proxy != null && proxy.IsActive && !string.IsNullOrEmpty(proxy.LastCursorId))
            {
                Cursor.Current = mCursorWithIds[proxy.LastCursorId];
            }
        }
示例#6
0
 public void Disconnect()
 {
     if (mProxy != null)
     {
         mProxy.Dispose();
         Proxy_Disconnected(null, null);
         mProxy = null;
         DrawInitialBlackBackground();
     }
 }
示例#7
0
        private void pbClient_MouseMove(object sender, MouseEventArgs e)
        {
            IRemoteDesktopClientInternal proxy = mProxy;

            if (proxy != null && proxy.IsActive)
            {
                proxy.LastMousePosX = e.Location.X;
                proxy.LastMousePosY = e.Location.Y;
                mClientMouseMove    = true;
            }
            //LogMouseEvent("PB-MOVE", e);
        }
示例#8
0
 internal void SendClipboardContent(IRemoteDesktopClientInternal service, Forge.RemoteDesktop.Contracts.ClipboardChangedEventArgs e)
 {
     if (LOGGER.IsDebugEnabled)
     {
         LOGGER.Debug(string.Format("REMOTE_CLIENT, service sent clipboard content. Text: {0}", e.Text));
     }
     if (string.Compare(service.ClipboardContent, e.Text) != 0)
     {
         service.ClipboardContent = e.Text;
         SetClipboardContentFromClient(e.Text);
     }
 }
示例#9
0
        private void pbClient_MouseUp(object sender, MouseEventArgs e)
        {
            IRemoteDesktopClientInternal proxy = mProxy;

            if (proxy != null && proxy.IsActive)
            {
                try
                {
                    proxy.ClientSendMouseButtonEvent(new MouseButtonEventArgs(MouseButtonEventTypeEnum.Up, e.Button, e.Location));
                }
                catch (Exception) { }
            }
            //LogMouseEvent("PB-UP", e);
        }
示例#10
0
        private void RemoteDesktopWinFormsControl_ClientSizeChanged(object sender, EventArgs e)
        {
            IRemoteDesktopClientInternal proxy = mProxy;

            if (proxy != null && proxy.IsActive)
            {
                mVisibleArea = GetVisibleArea();
                try
                {
                    proxy.ClientSubscribeForDesktop(mVisibleArea);
                }
                catch (Exception) { }
            }

            //Console.WriteLine(string.Format("FORM, new client size: {0}, {1}; Pos: {2}, {3}, HScroll: {4}, VScroll: {5}", this.ClientSize.Width.ToString(), this.ClientSize.Height.ToString(), this.AutoScrollPosition.X.ToString(), this.AutoScrollPosition.Y.ToString(), this.HorizontalScroll.Value.ToString(), this.VerticalScroll.Value.ToString()));
            //LogVisibleArea();
        }
示例#11
0
        private void RemoteDesktopWinFormsControl_Scroll(object sender, ScrollEventArgs e)
        {
            IRemoteDesktopClientInternal proxy = mProxy;

            if (proxy != null && proxy.IsActive)
            {
                mVisibleArea = GetVisibleArea();
                try
                {
                    proxy.ClientSubscribeForDesktop(mVisibleArea);
                }
                catch (Exception) { }
            }

            //Console.WriteLine(string.Format("SCROLL, Type: {0}, OldValue: {1}, NewValue: {2}, Orientation: {3}", e.Type.ToString(), e.OldValue.ToString(), e.NewValue.ToString(), e.ScrollOrientation.ToString()));
            //LogVisibleArea();
        }
示例#12
0
        private void ClipboardChangedEventHandler(object sender, Native.Hooks.ClipboardChangedEventArgs e)
        {
            IRemoteDesktopClientInternal proxy = mProxy;

            if (proxy != null && proxy.IsActive && e.ContainsText())
            {
                string text = e.GetText();
                if (string.Compare(text, proxy.ClipboardContent) != 0)
                {
                    try
                    {
                        proxy.ClientSendClipboardContent(new Contracts.ClipboardChangedEventArgs(text));
                    }
                    catch (Exception) { }
                    proxy.ClipboardContent = text;
                }
            }
        }
示例#13
0
        private void DrawDesktopClip(DesktopImageClipArgs e)
        {
            if (this.InvokeRequired)
            {
                DrawDesktopClipHandler d = new DrawDesktopClipHandler(DrawDesktopClip);
                try
                {
                    ((RemoteDesktopWinFormsControl)d.Target).Invoke(d, e);
                }
                catch (Exception) { }
                return;
            }

            using (MemoryStream ms = new MemoryStream(e.ImageData))
            {
                ms.Position = 0;
                using (Bitmap clip = Bitmap.FromStream(ms) as Bitmap)
                {
                    using (Graphics g = Graphics.FromImage(mRemoteDesktopImage))
                    {
                        g.DrawImage(clip, e.Location);
                    }
                }
                ms.SetLength(0);
            }

            // egérnek látszódnia kell a felületen?
            IRemoteDesktopClientInternal proxy = mProxy;

            if (proxy != null &&
                proxy.LastMousePosX >= mVisibleArea.StartX && proxy.LastMousePosX <= mVisibleArea.EndX &&
                proxy.LastMousePosY >= mVisibleArea.StartY && proxy.LastMousePosY <= mVisibleArea.EndY)
            {
                // egér berajzolása a felületre
                DrawMouse();
            }
            else
            {
                pbClient.Image = mRemoteDesktopImage;
            }
        }
示例#14
0
        private void Event_KeyDown(object sender, KeyEventArgs e)
        {
            bool skipKeyEvent = false;

            lock (mKeysSubscriptions)
            {
                skipKeyEvent = mKeysSubscriptions.ContainsKey(new KeysSubscription(e.KeyCode, e.Alt, e.Control, e.Shift));
            }

            if (!skipKeyEvent)
            {
                IRemoteDesktopClientInternal proxy = mProxy;
                if (proxy != null && proxy.IsActive)
                {
                    try
                    {
                        proxy.ClientSendKeyEvent(new KeyboardEventArgs(KeyboardEventTypeEnum.Down, e.KeyCode));
                    }
                    catch (Exception) { }
                }
                //LogKeyEvent(sender, "KEY-DOWN", e);
            }
        }
示例#15
0
        private void MouseMoveMain()
        {
            if (LOGGER.IsDebugEnabled)
            {
                LOGGER.Debug("REMOTE_CLIENT, mouse move sender thread started.");
            }
            IRemoteDesktopClientInternal proxy = mProxy;

            if (proxy != null)
            {
                int lastX = proxy.LastMousePosX;
                int lastY = proxy.LastMousePosY;
                while (proxy.IsActive)
                {
                    try
                    {
                        mMouseMoveWaitEvent.WaitOne(Forge.RemoteDesktop.Client.Configuration.Settings.MouseMoveSendInterval);
                        if (mClientMouseMove)
                        {
                            if (lastX != proxy.LastMousePosX || lastY != proxy.LastMousePosY)
                            {
                                lastX            = proxy.LastMousePosX;
                                lastY            = proxy.LastMousePosY;
                                mClientMouseMove = false;
                                proxy.ClientSendMouseMoveEvent(new MouseMoveEventArgs(new Point(proxy.LastMousePosX, proxy.LastMousePosY)));
                                DrawMouse();
                            }
                        }
                    }
                    catch (Exception) { }
                }
            }
            if (LOGGER.IsDebugEnabled)
            {
                LOGGER.Debug("REMOTE_CLIENT, mouse move sender thread stopped.");
            }
        }
示例#16
0
        public void Connect(string channelId, AddressEndPoint endPoint)
        {
            DoDisposeCheck();
            if (string.IsNullOrEmpty(channelId))
            {
                ThrowHelper.ThrowArgumentNullException("channelId");
            }
            if (endPoint == null)
            {
                ThrowHelper.ThrowArgumentNullException("endPoint");
            }

            Disconnect();

            ProxyFactory <IRemoteDesktop> factory = new ProxyFactory <IRemoteDesktop>(channelId, endPoint);

            lock (mLockEventObject)
            {
                mProxy       = (IRemoteDesktopClientInternal)factory.CreateProxy();
                mProxy.Owner = this;
                Raiser.CallDelegatorBySync(EventConnectionStateChange, new object[] { this, new ConnectionStateChangeEventArgs(true) });
                mProxy.Disconnected += new EventHandler <DisconnectEventArgs>(Proxy_Disconnected);
            }
        }