public DesktopTransportExecutor()
 {
     //get|width|height|showModel
     _commandText = new string[] { "get" };
     ShowModel = ShowModels.FollowMouse;
     defaultVideoParameters = new VideoParameters() { Width = 800, Height = 480, Quality = 30L };
 }
Пример #2
0
        public Image GetFullScreenImage(VideoParameters v)
        {
            try
            {
                System.Drawing.Image MyImage = new Bitmap((int)SystemParameters.VirtualScreenWidth, (int)SystemParameters.VirtualScreenHeight);
                CURSORINFO           pci;
                pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
                GetCursorInfo(out pci);
                Graphics g = Graphics.FromImage(MyImage);
                g.CopyFromScreen(new System.Drawing.Point(0, 0), new System.Drawing.Point(0, 0), new System.Drawing.Size((int)SystemParameters.VirtualScreenWidth, (int)SystemParameters.VirtualScreenHeight));

                System.Windows.Forms.Cursor cur = new System.Windows.Forms.Cursor(pci.hCursor);
                cur.Draw(g, new System.Drawing.Rectangle(pci.ptScreenPos.x - 10, pci.ptScreenPos.y - 10, cur.Size.Width, cur.Size.Height));


                Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);
                MyImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
                Image img = MyImage.GetThumbnailImage(v.Height, v.Width, myCallback, IntPtr.Zero);
                return(img);
            }
            catch
            {
                throw;
            }
        }
Пример #3
0
        public Image GetFullScreenImage(VideoParameters v)
        {
            try
            {
                System.Drawing.Image MyImage = new Bitmap((int)SystemParameters.VirtualScreenWidth, (int)SystemParameters.VirtualScreenHeight);
                CURSORINFO pci;
                pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
                GetCursorInfo(out pci);
                Graphics g = Graphics.FromImage(MyImage);
                g.CopyFromScreen(new System.Drawing.Point(0, 0), new System.Drawing.Point(0, 0), new System.Drawing.Size((int)SystemParameters.VirtualScreenWidth, (int)SystemParameters.VirtualScreenHeight));

                System.Windows.Forms.Cursor cur = new System.Windows.Forms.Cursor(pci.hCursor);
                cur.Draw(g, new System.Drawing.Rectangle(pci.ptScreenPos.x - 10, pci.ptScreenPos.y - 10, cur.Size.Width, cur.Size.Height));

                Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);
                MyImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
                Image img = MyImage.GetThumbnailImage(v.Height, v.Width, myCallback, IntPtr.Zero);
                return img;
            }
            catch
            {
                throw;
            }
        }
        public void Excute(AsyncParameters parameters, string cmd)
        {
            try
            {
                string[] parms = cmd.Split('|');
                if (parms != null && parms.Length > 1)
                {
                    VideoParameters = new VideoParameters();
                    foreach (string p in parms)
                    {
                        string prm = p.ToLower();
                        if (prm == "followmouse")
                        {
                            ShowModel = ShowModels.FollowMouse;
                        }
                        else if (prm == "fullscreen")
                        {
                            ShowModel = ShowModels.FullScreen;
                        }
                        else if (prm[prm.Length - 1] == 'w')
                        {
                            VideoParameters.Width = int.Parse(prm.Substring(0, prm.Length - 1));
                        }
                        else if (prm[prm.Length - 1] == 'h')
                        {
                            VideoParameters.Height = int.Parse(prm.Substring(0, prm.Length - 1));
                        }
                        else if (prm[prm.Length - 1] == 'q')
                        {
                            VideoParameters.Quality = long.Parse(prm.Substring(0, prm.Length - 1));
                        }
                    }
                }
            }
            catch { }

            VideoParameters v;
            if(VideoParameters==null||VideoParameters.Width==0||VideoParameters.Height==0)
            {
                v = defaultVideoParameters;
            }
            else
            {
                v = VideoParameters;
            }
            try
            {

                Screenshot ss = new Screenshot();
                Image img = null;
                if (ShowModel == ShowModels.FollowMouse)
                {
                    img = ss.GetRectangleScreenshot(v);
                }
                else
                {
                    img = ss.GetFullScreenImage(v);
                }

                parameters.Data = ImageProcessing.CompressedImageQuality(img, v.Quality);
                img.Dispose();
                //Console.WriteLine(parameters.Data.Length / 1024);
                parameters.Client.BeginSend(parameters.Data, 0, parameters.Data.Length, 0, new AsyncCallback(EndSend), parameters);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message+e.Source+e.StackTrace);
            }
        }
Пример #5
0
        public Image GetRectangleScreenshot(VideoParameters v)
        {
            try
            {
                int videoWidth  = (int)SystemParameters.VirtualScreenWidth;
                int videoHeight = (int)SystemParameters.VirtualScreenHeight;
                System.Drawing.Image MyImage = new Bitmap(v.Width, v.Height);
                CURSORINFO           pci;
                pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
                GetCursorInfo(out pci);
                Graphics g      = Graphics.FromImage(MyImage);
                int      px     = 0;
                int      py     = 0;
                int      wx     = videoWidth - pci.ptScreenPos.x;
                int      wy     = videoHeight - pci.ptScreenPos.y;
                int      mouseX = 0;
                int      mouseY = 0;
                if (pci.ptScreenPos.x > v.Width && wx < v.Width)
                {
                    px     = videoWidth - v.Width;
                    mouseX = pci.ptScreenPos.x - (videoWidth - v.Width);
                }
                else if (pci.ptScreenPos.x < v.Width && wx > v.Width)
                {
                    px     = 0;
                    mouseX = pci.ptScreenPos.x;
                }
                else if (pci.ptScreenPos.x - (v.Width / 2) > 0 && pci.ptScreenPos.x + (v.Width / 2) < videoWidth)
                {
                    px     = pci.ptScreenPos.x - (v.Width / 2);
                    mouseX = v.Width / 2;
                }

                if (pci.ptScreenPos.y > v.Height && wy < v.Height)
                {
                    py     = videoHeight - v.Height;
                    mouseY = pci.ptScreenPos.y - (videoHeight - v.Height);
                }
                else if (pci.ptScreenPos.y < v.Height && wy > v.Height)
                {
                    py     = 0;
                    mouseY = pci.ptScreenPos.y;
                }
                else if (pci.ptScreenPos.y - (v.Height / 2) > 0 && pci.ptScreenPos.y + (v.Height / 2) < videoHeight)
                {
                    py     = pci.ptScreenPos.y - (v.Height / 2);
                    mouseY = v.Height / 2;
                }

                g.CopyFromScreen(new System.Drawing.Point(px, py), new System.Drawing.Point(0, 0), new System.Drawing.Size(v.Width, v.Height));

                System.Windows.Forms.Cursor cur = new System.Windows.Forms.Cursor(pci.hCursor);
                cur.Draw(g, new System.Drawing.Rectangle(mouseX, mouseY, cur.Size.Width, cur.Size.Height));


                Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);
                MyImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
                Image img = MyImage.GetThumbnailImage(v.Height, v.Width, myCallback, IntPtr.Zero);
                //img.Save(@"D:\1.jpg");
                return(img);
            }
            catch
            {
                throw;
            }
        }
Пример #6
0
        public Image GetRectangleScreenshot(VideoParameters v)
        {
            try
            {
                int videoWidth = (int)SystemParameters.VirtualScreenWidth;
                int videoHeight = (int)SystemParameters.VirtualScreenHeight;
                System.Drawing.Image MyImage = new Bitmap(v.Width,v.Height );
                CURSORINFO pci;
                pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
                GetCursorInfo(out pci);
                Graphics g = Graphics.FromImage(MyImage);
                int px = 0;
                int py = 0;
                int wx= videoWidth - pci.ptScreenPos.x;
                int wy = videoHeight - pci.ptScreenPos.y;
                int mouseX=0;
                int mouseY=0;
                if(pci.ptScreenPos.x>v.Width && wx<v.Width)
                {
                    px = videoWidth - v.Width;
                    mouseX=pci.ptScreenPos.x-(videoWidth - v.Width);
                }
                else if(pci.ptScreenPos.x<v.Width && wx>v.Width)
                {
                    px = 0;
                    mouseX=pci.ptScreenPos.x;
                }
                else if(pci.ptScreenPos.x-(v.Width/2)>0 && pci.ptScreenPos.x+(v.Width/2)<videoWidth)
                {
                    px = pci.ptScreenPos.x - (v.Width / 2);
                    mouseX=v.Width/2;
                }

                if(pci.ptScreenPos.y>v.Height && wy<v.Height)
                {
                    py = videoHeight - v.Height;
                    mouseY=pci.ptScreenPos.y-(videoHeight-v.Height);
                }
                else if (pci.ptScreenPos.y < v.Height && wy > v.Height)
                {
                    py = 0;
                    mouseY=pci.ptScreenPos.y;
                }
                else if(pci.ptScreenPos.y-(v.Height/2)>0 && pci.ptScreenPos.y+(v.Height/2)<videoHeight)
                {
                    py = pci.ptScreenPos.y - (v.Height / 2);
                    mouseY=v.Height/2;
                }

                g.CopyFromScreen(new System.Drawing.Point(px, py), new System.Drawing.Point(0, 0), new System.Drawing.Size(v.Width, v.Height));

                System.Windows.Forms.Cursor cur = new System.Windows.Forms.Cursor(pci.hCursor);
                cur.Draw(g, new System.Drawing.Rectangle(mouseX,mouseY, cur.Size.Width, cur.Size.Height));

                Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);
                MyImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
                Image img = MyImage.GetThumbnailImage(v.Height, v.Width, myCallback, IntPtr.Zero);
                //img.Save(@"D:\1.jpg");
                return img;
            }
            catch
            {
                throw;
            }
        }