Exemplo n.º 1
0
        /// <summary>
        /// 快捷键注册按键
        /// </summary>
        /// <param name="code"></param>
        public void ShortcutkeyHandRegister()
        {
            string temp = ClassStatic.GetConfigSoftware("copy");

            ClassStatic.ShortcutKeys tempkey = GetShortcutKey(temp, ClassHotKey.KeyModifiers.Ctrl, Keys.C);
            if (tempkey.key1 != ClassHotKey.KeyModifiers.Ctrl || tempkey.key2 != Keys.C)
            {
                ClassHotKey.RegisterHotKey(Handle, ClassStatic.ShortcutKey.Copy, tempkey.key1, tempkey.key2);
            }

            temp    = ClassStatic.GetConfigSoftware("paste");
            tempkey = GetShortcutKey(temp, ClassHotKey.KeyModifiers.Ctrl, Keys.V);
            if (tempkey.key1 != ClassHotKey.KeyModifiers.Ctrl || tempkey.key2 != Keys.V)
            {
                ClassHotKey.RegisterHotKey(Handle, ClassStatic.ShortcutKey.Paste, tempkey.key1, tempkey.key2);
            }

            temp    = ClassStatic.GetConfigSoftware("screenshot");
            tempkey = GetShortcutKey(temp, ClassHotKey.KeyModifiers.Ctrl, Keys.P);
            ClassHotKey.RegisterHotKey(Handle, ClassStatic.ShortcutKey.Screenshot, tempkey.key1, tempkey.key2);

            temp    = ClassStatic.GetConfigSoftware("color");
            tempkey = GetShortcutKey(temp, ClassHotKey.KeyModifiers.Ctrl, Keys.L);
            ClassHotKey.RegisterHotKey(Handle, ClassStatic.ShortcutKey.Color, tempkey.key1, tempkey.key2);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 解析连接开启
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Parsing_CheckedChanged(object sender, EventArgs e)
 {
     if (ClassStatic.GetConfigSoftware("parse") != Parsing.Checked.ToString())
     {
         ClassStatic.SetConfigSoftware("parse", Parsing.Checked.ToString());
         Action <bool, byte[]>  action     = new Action <bool, byte[]>(SettingChange_Callback);
         ClassStatic.ClientData clientData = new ClassStatic.ClientData("parse", Parsing.Checked.ToString());
         ClassStatic.tcpClient.Send(220, ClassStatic.SetClientDataByte(clientData), action);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 上线信息响应回调处理
        /// </summary>
        /// <param name="state"></param>
        /// <param name="data"></param>
        private void SendMyOnline_Callback(bool state, byte[] data)
        {
            this.Invoke(new Action(() => {
                if (state)
                {
                    ClassStatic.UserLoginSuccess resultData = ClassStatic.GetLoginSuccessData(data);
                    if (resultData != null && resultData.ret == "true")
                    {
                        ClassStatic.isLogined = true;
                        ClassStatic.bind      = resultData.bind;

                        if (ClassStatic.GetConfigSoftware("turnOn") == "")
                        {
                            ClassStatic.SetConfigSoftware("turnOn", "False");
                        }
                        if (ClassStatic.GetConfigSoftware("parse") == "")
                        {
                            ClassStatic.SetConfigSoftware("parse", resultData.parse);
                        }
                        if (ClassStatic.GetConfigSoftware("copy") == "")
                        {
                            ClassStatic.SetConfigSoftware("copy", resultData.copy);
                        }
                        if (ClassStatic.GetConfigSoftware("paste") == "")
                        {
                            ClassStatic.SetConfigSoftware("paste", resultData.paste);
                        }
                        if (ClassStatic.GetConfigSoftware("screenshot") == "")
                        {
                            ClassStatic.SetConfigSoftware("screenshot", resultData.screenshot);
                        }
                        if (ClassStatic.GetConfigSoftware("color") == "")
                        {
                            ClassStatic.SetConfigSoftware("color", resultData.color);
                        }

                        FormLogin.formLogin.Close();
                        return;
                    }
                }
                ClassStatic.account = "";
                LabelTipShow("登录失败,请稍后再试", true);
            }));
        }
Exemplo n.º 4
0
        private void buttonFinish_Click(object sender, EventArgs e)
        {
            // 定义一个临时图层
            Image    temp     = (Image)canvasImage.Clone();
            Graphics graphics = Graphics.FromImage(temp);

            foreach (DrawShape drawShape in drawShapeList)
            {
                DrawShapeOnGraphics(graphics, drawShape);
            }
            graphics.Dispose();
            int   w     = cropBoxRectangle.Width;
            int   h     = cropBoxRectangle.Height;
            Image temp2 = new Bitmap(w, h);

            graphics = Graphics.FromImage(temp2);
            graphics.DrawImage(temp, new Rectangle(0, 0, w, h), cropBoxRectangle, GraphicsUnit.Pixel);
            graphics.Dispose();
            string path = ClassStatic.GetConfigSoftware("cachePath");

            if (Directory.Exists(path) == false)
            {
                path = System.Environment.CurrentDirectory + "\\cache";
                Directory.CreateDirectory(path);
                ClassStatic.SetConfigSoftware("cachePath", path);
            }

            path = path + "\\" + DateTime.Now.ToString("yyyy-MM-dd.HHmmss") + ".png";
            temp2.Save(path);
            StringCollection file = new StringCollection();

            file.Add(path);
            Clipboard.SetFileDropList(file);
            temp.Dispose();
            temp2.Dispose();
            this.Close();
        }
Exemplo n.º 5
0
        public void InitializeControl()
        {
            if (ClassStatic.GetConfigSoftware("cachePath") == "")
            {
                ClassStatic.SetConfigSoftware("cachePath", System.Environment.CurrentDirectory + "\\cache");
            }
            string path = ClassStatic.GetConfigSoftware("cachePath");

            if (Directory.Exists(path) == false)
            {
                path = System.Environment.CurrentDirectory + "\\cache";
                Directory.CreateDirectory(path);
                ClassStatic.SetConfigSoftware("cachePath", path);
            }

            cachePath.Text = path;

            if (ClassStatic.bind != "")
            {
                textBindNumber.Text = ClassStatic.bind;
                buttonBindQQ.Text   = "解除绑定";
            }
            else
            {
                textBindNumber.Text = "等待绑定";
                buttonBindQQ.Text   = "绑定QQ";
            }

            turnOn.Checked  = (ClassStatic.GetConfigSoftware("turnOn") == "True");
            Parsing.Checked = (ClassStatic.GetConfigSoftware("parse") == "True");

            textCopy.Text       = ClassStatic.GetConfigSoftware("copy");
            textPaste.Text      = ClassStatic.GetConfigSoftware("paste");
            textScreenshot.Text = ClassStatic.GetConfigSoftware("screenshot");
            textColor.Text      = ClassStatic.GetConfigSoftware("color");
        }
Exemplo n.º 6
0
        /// <summary>
        /// 远程发送剪贴板中含有文字
        /// </summary>
        /// <param name="state"></param>
        /// <param name="data"></param>
        public void OnOtherDriveClipboardDataTextHandler(int state, byte[] data)
        {
            if (state == 221)
            {
                this.Invoke(new Action(() => {
                    ClassStatic.isRemoteClipboardData = 2;
                    Clipboard.SetText(ClassStatic.GetString(data));
                }));
            }
            if (state == 222)
            {
                this.Invoke(new Action(() => {
                    Bitmap bmp  = new Bitmap(Clipboard.GetImage());
                    string path = ClassStatic.GetConfigSoftware("cachePath");
                    if (Directory.Exists(path) == false)
                    {
                        path = System.Environment.CurrentDirectory + "\\cache";
                        Directory.CreateDirectory(path);
                        ClassStatic.SetConfigSoftware("cachePath", path);
                    }
                    path += "\\img";
                    if (Directory.Exists(path) == false)
                    {
                        Directory.CreateDirectory(path);
                    }

                    path += "\\" + DateTime.Now.ToString("yyyy-MM-dd.HHmmss") + ".png";
                    bmp.Save(path, Clipboard.GetImage().RawFormat);
                    StringCollection file = new StringCollection();
                    file.Add(path);
                    ClassStatic.isRemoteClipboardData = 2;
                    Clipboard.SetFileDropList(file);
                    bmp.Dispose();
                }));
            }
            if (state == 223)
            {
                string fileName = "";

                try
                {
                    int lenth = Convert.ToInt32(ClassStatic.GetString(data.Skip(1).Take(data[0]).ToArray()));
                    data     = data.Skip(data[0] + 1).ToArray();
                    fileName = ClassStatic.GetString(data.Take(lenth).ToArray());
                    data     = data.Skip(lenth).ToArray();
                }
                catch
                {
                }

                if (fileName != "")
                {
                    this.Invoke(new Action(() => {
                        string path = ClassStatic.GetConfigSoftware("cachePath");
                        if (Directory.Exists(path) == false)
                        {
                            path = System.Environment.CurrentDirectory + "\\cache";
                            Directory.CreateDirectory(path);
                            ClassStatic.SetConfigSoftware("cachePath", path);
                        }
                        path += "\\" + fileName;

                        System.Diagnostics.Debug.WriteLine(path);
                        FileStream fs = new FileStream(path, FileMode.Create);

                        System.Diagnostics.Debug.WriteLine(data.Length);
                        fs.Write(data, 0, data.Length);
                        fs.Close();

                        StringCollection file = new StringCollection();
                        file.Add(path);
                        ClassStatic.isRemoteClipboardData = 2;
                        Clipboard.SetFileDropList(file);
                        System.Diagnostics.Debug.WriteLine(Clipboard.GetFileDropList().Count);
                    }));
                }
            }
            if (state == 238)
            {
                this.Invoke(new Action(() =>
                {
                    FormMain.formMain.deviceList.InitializeDeviceList();
                }));
            }
        }
Exemplo n.º 7
0
        /// <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--;
                }
            }
        }