private void userPic_Click(object sender, EventArgs e) { CatchScreen cs = new CatchScreen(); cs.getImgs(); }
public void sendDesktop() { CatchScreen cs = new CatchScreen(); ImgCompara imgCompara = new ImgCompara(); //新开线程处理被控端的桌面数据; while (isCtrl && isLogining && mySocket.isConn) { //TimeSpan ts1 = new TimeSpan(DateTime.Now.Ticks); List<ImgEntity> deskList = cs.getImgs(); List<ImgEntity> changes = imgCompara.compress(deskList); if (changes.Count > 0) { //TimeSpan ts2 = new TimeSpan(DateTime.Now.Ticks) //Console.WriteLine("chang count = " + changes.Count); using (MemoryStream ms = new MemoryStream()) { BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(ms, changes); Byte[] imgBuffer = new Byte[ms.Length]; ms.Seek(0, SeekOrigin.Begin); ms.Read(imgBuffer, 0, (Int32)ms.Length); Console.WriteLine("send lenth = " + imgBuffer.Length); mySocket.sent((byte)MyConfig.REQ_TYPE_DESKTOP_SWITCH, MyConfig.PROTOCOL_HEAD_HAS_TOKEN, mySocket.token, imgBuffer); } if (changes.Count >= (MyConfig.INT_BLOCK_X_COUNT * MyConfig.INT_BLOCK_Y_COUNT * 2 / 3)) { //超过2/3的时候,切换低频率 Thread.Sleep(MyConfig.INT_DESKTOP_REFLUSH_FREQUENCY_LOW); } else if (changes.Count >= (MyConfig.INT_BLOCK_X_COUNT * MyConfig.INT_BLOCK_Y_COUNT * 1 / 3)) { //数据变化1/3到2/3之间,则切换为中频 Thread.Sleep(MyConfig.INT_DESKTOP_REFLUSH_FREQUENCY_NORMAL); } else { //低于1/3数据变换,则切换为高频 Thread.Sleep(MyConfig.INT_DESKTOP_REFLUSH_FREQUENCY_HIGHT); } } else { //没有数据变换,则休眠1秒 Thread.Sleep(MyConfig.INT_DESKTOP_REFLUSH_FREQUENCY_SLEEP); } } // Console.WriteLine("退出数据发送, isctrl:" + isCtrl + " isLogin:"******" isconn:" + mySocket.isConn); }