예제 #1
0
        void Client_FriendDataReceived(object sender, Client.FriendReceivedEventArgs e)
        {
            // TODO: Add them to the appropriate online/offline list.
            if (e.IsOnline)
            {
                // Add them to the Online list
                Globals.DebugConsole.Log(
                    string.Format("Populating friends list with: {0} {1} ({2}) - ONLINE.",
                              e.Packet.User.FirstName,
                              e.Packet.User.LastName,
                              e.Packet.User.Username));

            }
            else
            {
                // Add them to the offline listGlobals.DebugConsole.Log(
                Globals.DebugConsole.Log(
                    string.Format("Populating friends list with: {0} {1} ({2}) - OFFLINE.",
                              e.Packet.User.FirstName,
                              e.Packet.User.LastName,
                              e.Packet.User.Username));

            }

            // TEMPORARY: Add them to the general list for now.
            Dispatcher.Invoke(new Action(() =>
                UserFriendsList.AddFriend(
                    null,
                    (e.Packet.User.FirstName + " " + e.Packet.User.LastName),
                    e.Packet.User.Status,
                    e.Packet.User.UserID,
                    e.IsOnline))
            );
        }
예제 #2
0
        private void Client_FriendOffline(object sender, Client.DataReceivedEventArgs e)
        {
            Globals.DebugConsole.Log("A user went OFFLINE: " + e.Packet.User.Username);

            Dispatcher.Invoke(new Action(() =>
                                         UserFriendsList.UpdateFriendOnlineStatus(e.Packet.User.UserID, false)
                                  ));
        }
예제 #3
0
        void Client_BadLogin(object sender, Client.DataReceivedEventArgs e)
        {
            Globals.DebugConsole.Log("Bad login.");

            MessageBox.Show("Bad username or password. Please try again.", "Login error",
                            MessageBoxButton.OK,
                            MessageBoxImage.Error);

            Dispatcher.Invoke(new Action(() =>
            {
                BtnLogin.IsEnabled = true;
                BtnLogin.Content = "Login";
            }));
        }
예제 #4
0
        void Client_LoggedIn(object sender, Client.DataReceivedEventArgs e)
        {
            CollabPacket.Packet p = e.Packet;

            Globals.DebugConsole.Log(string.Format("Logged in successfully as {0} {1} ({2})",
                                                   p.User.FirstName,
                                                   p.User.LastName,
                                                   p.User.Username));

            // Set Global Users Object
            Globals.User = p.User;

            // Show the main window and close the login window
            Dispatcher.Invoke(new Action(() =>
                {
                    new MainWindow().Show();
                    Close();
                }));
        }
예제 #5
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));
        }
예제 #6
0
        void Client_MouseDataReceived(object sender, Client.ShareEventArgs e)
        {
            int fromUserID = e.Packet.User.UserID;
            double xPos = e.Packet.MousePacket.X;
            double yPos = e.Packet.MousePacket.Y;

            if(ShareWindow!=null)
                ShareWindow.MoveMouse(fromUserID, xPos, yPos);
            if(MouseWindow!=null)
                MouseWindow.MoveMouse(fromUserID, new Point((int)xPos, (int)yPos));
        }
예제 #7
0
        void Client_MouseClickReceived(object sender, Client.ShareEventArgs e)
        {
            // Send virtual click to point
            if (MouseWindow != null)
            {
                // TODO: Capture current mouse location
                //       Move to click point, send click

                WinApi.User32.POINT currentPosition = new WinApi.User32.POINT();
                WinApi.User32.GetCursorPos(out currentPosition);

                WinApi.User32.SetCursorPos(
                    (e.Packet.MouseControls.X),
                    (e.Packet.MouseControls.Y)
                    );

                Globals.DebugConsole.Log("Sending mouse click to " + (e.Packet.MouseControls.X) + "x" +(e.Packet.MouseControls.Y));

                if (e.Packet.MouseControls.IsRightClick)
                {
                    WinApi.mouse_event(WinApi.MOUSEEVENTF_RIGHTDOWN | WinApi.MOUSEEVENTF_RIGHTUP, (uint)(e.Packet.MouseControls.X), (uint)(e.Packet.MouseControls.Y), 0, 0);
                }
                else
                {
                    WinApi.mouse_event(WinApi.MOUSEEVENTF_LEFTDOWN | WinApi.MOUSEEVENTF_LEFTUP, (uint)(e.Packet.MouseControls.X), (uint)(e.Packet.MouseControls.Y), 0, 0);
                }

                WinApi.User32.SetCursorPos(
                    currentPosition.X,
                    currentPosition.Y
                    );

                // Move back to origin
            }
        }
예제 #8
0
 void Client_KeyboardDataReceived(object sender, Client.ShareEventArgs e)
 {
     if (MouseWindow != null)
     {
         Globals.DebugConsole.Log("Simulating key press of key value: " + e.Packet.KeyboardData.Char);
         InputSimulator.SimulateKeyPress((WindowsInput.VirtualKeyCode)e.Packet.KeyboardData.Char);
     }
 }
예제 #9
0
 void Client_ImageReceived(object sender, Client.ShareEventArgs e)
 {
     ShareWindow.UpdateImage(e.Packet);
 }
예제 #10
0
 private void Client_ClientJoinedShare(object sender, Client.ShareEventArgs e)
 {
     if (MouseWindow == null)
         StartShareSession(e);
     else
     {
         MouseWindow.Add(e.Packet.User.UserID,
                         e.Packet.User.FirstName + " " + e.Packet.User.LastName.Substring(0, 1));
     }
 }
예제 #11
0
        /// <summary>
        /// This function is called by the Sharer whenever he wants to start a share session on the server.
        /// </summary>
        /// <param name="windowHandle"></param>
        public void StartShareSession(Client.ShareEventArgs e)
        {
            // Start mousemonitor
            MouseMonitor = new MouseMonitor(WindowHandle, 10);
            MouseMonitor.MouseMovedWithinSharedWindow += MouseMonitor_MouseMovedWithinSharedWindow;
            MouseMonitor.Start();

            //// Start Overlay
            //Thread mThread = new Thread(() =>
            //    {
            //        MouseWindow = new MouseDisplay();
            //        MouseMonitor.SharedWindowChanged += MouseWindow.SharedWindowChanged;
            //        MouseWindow.Add(e.Packet.User.UserID,
            //                        e.Packet.User.FirstName + " " + e.Packet.User.LastName.Substring(0, 1));

            //        MouseWindow.Show();

            //        while (true)
            //        {
            //            Thread.Sleep(9999999);
            //        }
            //    });

            //mThread.SetApartmentState(ApartmentState.STA);
            //mThread.Start();
            ////mThread.Join();

            _dispatcher.BeginInvoke(new Action(() =>
                {
                    MouseWindow = new MouseDisplay();
                    MouseMonitor.SharedWindowChanged += MouseWindow.SharedWindowChanged;
                    MouseWindow.Add(e.Packet.User.UserID,
                                    e.Packet.User.FirstName + " " + e.Packet.User.LastName.Substring(0, 1));

                    MouseWindow.Show();
                }));

            // Start capure timer
            StartShare();
        }