Example #1
0
        /// <summary>
        /// Handles whenever the sharer moves his mouse and sends his mouse data to the server.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MouseMonitor_MouseMovedWithinSharedWindow(object sender, MouseMonitor.MouseArgs e)
        {
            CollabPacket.Packet mouseDataPacket = new CollabPacket.Packet
            {
                MousePacket = new CollabPacket.MousePacket
                {
                    X = e.X,
                    Y = e.Y
                },
                User = Globals.User,
                ShareID = ShareID,
                Message = "MOUSE_MOVE"
            };

            Globals.Client.WriteData(CollabPacket.ClassSerializer.SerializeClass(mouseDataPacket));
        }
Example #2
0
        private void UpdateImage(object sender, EventArgs e, IntPtr windowHandle)
        {
            // Let the CPU do other tasks
            Thread.Sleep(0);

            // Here it's basically determining if we want to use the Alternate capture method (PrinWindow)
            // We ONLY want to use that method on Vista+ machines wtih DWM COMP enabled! Otherwise it behaves
            // crazy!

            // Commented out alt capture method for now because I havent implemented sending only the data that's changed with it yet.
            Capture.ImageData imageData =
                ( /*UseAltMethod ? Globals.Capture.CaptureWindowVista(windowHandle, _imageFormat) :*/
                    _capture.CaptureWindow(windowHandle));

            if (imageData.Data != null)
            {
                var imagesToSend = _capture.SplitImage(imageData.BoundingBox, imageData.Data);
                Globals.DebugConsole.Log("Sending " + imagesToSend.Count + " images.");

                foreach (var i in imagesToSend)
                {
                    // Send the Image data over the wire
                    CollabPacket.Packet buildImagePacket = new CollabPacket.Packet
                    {
                        ImageData = i.Value,
                        BoundingBox = new CollabPacket.BoundingBox
                        {
                            Top = i.Key.Top,
                            Left = i.Key.Left,
                            Bottom = i.Key.Bottom,
                            Right = i.Key.Right
                        },
                        Message = "I",
                        //User = Globals.User,
                        ShareID = ShareID,
                        WindowRect = imageData.WindowRect
                    };

                    Globals.Client.WriteData(CollabPacket.ClassSerializer.SerializeClass(buildImagePacket));
                }
            }

            GC.Collect();
        }
Example #3
0
        public void SendShareRequest(IntPtr hWnd, int targetUserID)
        {
            WindowHandle = hWnd;

            Globals.DebugConsole.Log(String.Format("Requesting to share hWnd={0} with UserID={1}...",
                                                   hWnd,
                                                   targetUserID));

            WindowTitle = WinApi.User32.GetWindowTitle(hWnd);

            // Create the Share Request packet and send it to server
            CollabPacket.Packet shareRequestPacket = new CollabPacket.Packet
            {
                User = Globals.User,
                ShareID = Globals.User.UserID,
                Message = string.Format("SHARE_REQUEST|{0}|{1}|{2}", targetUserID, WindowTitle, hWnd)
            };

            Globals.Client.WriteData(CollabPacket.ClassSerializer.SerializeClass(shareRequestPacket));
        }
Example #4
0
        /// <summary>
        /// Handles a new share session initialization
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Client_ShareStarted(object sender, Client.ShareEventArgs e)
        {
            CollabPacket.ShareInfo sInfo = new CollabPacket.ShareInfo
                {
                    ShareID = e.Packet.ShareID,
                    Sharer = e.Packet.User,
                    WindowTitle = e.Packet.WindowTitle
                };

            if (e.Packet.ShareID != null) ShareID = (int) e.Packet.ShareID;

            _dispatcher.Invoke(new Action(() =>
                {
                    ShareWindow = new Share(sInfo);
                    ShareWindow.Show();
                    ShareWindow.Focus();
                }));

            CollabPacket.Packet joinedShare = new CollabPacket.Packet
            {
                ShareID = sInfo.ShareID,
                Message = "JOIN_SHARE",
                User = Globals.User
            };

            Globals.Client.WriteData(CollabPacket.ClassSerializer.SerializeClass(joinedShare));
        }
Example #5
0
        private void Window_MouseMove(object sender, MouseEventArgs e)
        {
            CollabPacket.Packet mouseDataPacket = new CollabPacket.Packet
            {
                MousePacket = new CollabPacket.MousePacket
                {
                    X = e.GetPosition(this).X,
                    Y = e.GetPosition(this).Y,
                },
                User = Globals.User,

                Message = "MOUSE_MOVE"
            };

            Globals.Client.WriteData(CollabPacket.ClassSerializer.SerializeClass(mouseDataPacket));
        }
Example #6
0
        private void Window_MouseDown_1(object sender, MouseButtonEventArgs e)
        {
            CollabPacket.Packet mouseDataPacket = new CollabPacket.Packet
                {
                    MouseControls = new CollabPacket.MouseControls
                        {
                            X = (int) (e.GetPosition(this).X + _windowRect.Left),
                            Y = (int) (e.GetPosition(this).Y + _windowRect.Top),
                            IsRightClick = e.RightButton == MouseButtonState.Pressed
                        },

                    User = Globals.User,
                    Message = "MOUSE_CLICK",
                };

            Globals.Client.WriteData(CollabPacket.ClassSerializer.SerializeClass(mouseDataPacket));
        }
Example #7
0
        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            CollabPacket.Packet kbDataPacket = new CollabPacket.Packet
            {
                User = Globals.User,
                KeyboardData = new CollabPacket.KeyboardData
                {
                    Char = KeyInterop.VirtualKeyFromKey(e.Key)
                },
                Message = "KB"
            };

            Globals.Client.WriteData(CollabPacket.ClassSerializer.SerializeClass(kbDataPacket));
        }
Example #8
0
        public void Login(string username, string password)
        {
            CollabPacket.Packet loginPacket = new CollabPacket.Packet
                {
                    Message = string.Format("LOGIN|{0}|{1}", username, password)
                };

            WriteData(CollabPacket.ClassSerializer.SerializeClass(loginPacket));
        }
Example #9
0
        private void OnLoad(object sender, RoutedEventArgs e)
        {
            // 1. Populate the form control information with data read in from the Globals.User object
            LblProfileName.Content = Globals.User.FirstName + " " + Globals.User.LastName;
            LblStatusBox.Text = Globals.User.Status;
            UpdateProfilePicture(Globals.User.ProfileURL);

            // 2. Request list of currently online friends
            Globals.DebugConsole.Log("Sending REQUEST_FRIENDS to server...");
            CollabPacket.Packet requestFriends = new CollabPacket.Packet {Message = "REQUEST_FRIENDS", User = Globals.User};
            Globals.Client.WriteData(CollabPacket.ClassSerializer.SerializeClass(requestFriends));

            // 3. Bind to some friend events
            Globals.Client.FriendOnline += Client_FriendOnline;
            Globals.Client.FriendOffline += Client_FriendOffline;
            Globals.Client.FriendDataReceived += Client_FriendDataReceived;

            // 4. TODO: Send updated device information
        }