/// <summary>
 /// 模式更改到勿扰
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void toolStripMenuItemtoolStripMenuItemNoData_Click(object sender, EventArgs e)
 {
     if (ClassStatic.tcpClient.IsConnected && ClassStatic.onlineStatus != 1)
     {
         if (ClassStatic.isLogined)
         {
             this.Invoke(new Action(() => {
                 ClassStatic.onlineStatus              = 1;
                 statusOnlineControl1.Status           = 1;
                 deviceList.controlDeviceMyself.Status = 1;
                 notifyIcon1.Icon             = Properties.Resources.RemoteClipboardRed;
                 Action <bool, byte[]> action = new Action <bool, byte[]>(MenuItemChangeState_Callback);
                 ClassStatic.tcpClient.Send(203, ClassStatic.GetBytes("勿扰"), action);
             }));
         }
     }
 }
Example #2
0
        /// <summary>
        /// 刷新设备列表
        /// </summary>
        public void InitializeDeviceList()
        {
            DeviceOnlineCount = 1;
            flowLayoutPanelList.Controls.Clear();
            controlDeviceOnline.Clear();
            controlDeviceOffline.Clear();

            controlDeviceMyself.Title    = System.Net.Dns.GetHostName();
            controlDeviceMyself.Mac      = ClassStatic.GetMacByNetworkInterface();
            controlDeviceMyself.Status   = ClassStatic.onlineStatus;
            controlDeviceMyself.Oneself  = true;
            controlDeviceMyself.Portrait = ClassStatic.portraitPid;

            flowLayoutPanelList.Controls.Add(controlDeviceMyself);

            // 获取设备列表
            Action <bool, byte[]> action = new Action <bool, byte[]>(GetDeviceList_Callback);

            ClassStatic.tcpClient.Send(200, ClassStatic.GetBytes("获取设备列表"), action);
        }
        /// <summary>
        /// 剪贴板内容改变事件
        /// </summary>
        private void DisplayClipboardData()
        {
            if (ClassStatic.isLogined)
            {
                if (ClassStatic.isRemoteClipboardData < 1)
                {
                    if (Clipboard.ContainsImage())
                    {
                        Action <bool, byte[]> action = new Action <bool, byte[]>(ClipboardData_Callback);
                        ClassStatic.tcpClient.Send(222, ClassStatic.GetByteImage(Clipboard.GetImage()), action);
                    }
                    if (Clipboard.ContainsText())
                    {
                        if (ClassStatic.GetConfigSoftware("parse") == "True")
                        {
                            string          url  = Clipboard.GetText();
                            string          path = ClassStatic.GetConfigSoftware("cachePath");
                            MatchCollection mc   = Regex.Matches(url, @"^http://(.*?)\.\w+$");
                            if (mc.Count > 0)
                            {
                                string filename = "";
                                try
                                {
                                    Uri uri = new Uri(url);
                                    filename = System.Web.HttpUtility.UrlDecode(uri.Segments.Last());
                                }
                                catch {}
                                if (filename != "")
                                {
                                    path += "\\" + filename;
                                    FormDownload temp = new FormDownload(url, path);
                                    temp.Show();
                                }
                            }
                        }
                        Action <bool, byte[]> action = new Action <bool, byte[]>(ClipboardData_Callback);
                        ClassStatic.tcpClient.Send(221, ClassStatic.GetBytes(Clipboard.GetText()), action);
                    }
                    if (Clipboard.ContainsFileDropList())
                    {
                        if (Clipboard.GetFileDropList().Count == 1)
                        {
                            string file = Clipboard.GetFileDropList()[0];
                            if (File.Exists(file) == true)
                            {
                                byte[] buffur = { };
                                using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read))
                                {
                                    try
                                    {
                                        buffur = new byte[fs.Length];
                                        fs.Read(buffur, 0, (int)fs.Length);
                                    }
                                    catch (Exception ex)
                                    {
                                        throw ex;
                                    }
                                }
                                string fileName = Path.GetFileName(file);
                                Action <bool, byte[]> action = new Action <bool, byte[]>(ClipboardData_Callback);

                                List <byte> byteSource = new List <byte>();

                                byte[] fileNameByte      = ClassStatic.GetBytes(fileName);
                                byte[] fileNameByteLenth = ClassStatic.GetBytes(fileNameByte.Length.ToString());
                                byteSource.AddRange(new byte[] { Convert.ToByte(fileNameByteLenth.Length) });
                                byteSource.AddRange(fileNameByteLenth);
                                byteSource.AddRange(fileNameByte);
                                byteSource.AddRange(buffur);

                                ClassStatic.tcpClient.Send(223, byteSource.ToArray(), action);
                            }
                        }
                    }
                }
                else
                {
                    ClassStatic.isRemoteClipboardData--;
                }
            }
        }