Exemplo n.º 1
0
        static void _clipboardTimer_Tick(object sender, EventArgs e)
        {
            // reset red icon
            if (_bRedIcon == true)
            {
                _bRedIcon = false;
                CredentialsStorage.notifyIcon.Icon = new Icon("sync-image.ico");
            }

            if (CredentialsStorage.ClipboardRunning == true)
            {
                if (CredentialsStorage.Username != null)
                {
                    if (CredentialsStorage.Username.Length > 1)
                    {
                        //Check if there is something from Clipboard.
                        if (_lastText != CredentialsStorage.ClipboardData && CredentialsStorage.ClipboardData != null)
                        {
                            System.Windows.Forms.Clipboard.SetText(CredentialsStorage.ClipboardData);
                            _lastText = CredentialsStorage.ClipboardData;
                            CredentialsStorage.notifyIcon.Icon = new Icon("sync-image_red.ico");
                            _bRedIcon = true;
                        }

                        //Check if nothing new is in the clipboard.
                        if (System.Windows.Forms.Clipboard.ContainsText())
                        {
                            string sTextOnClipboard = System.Windows.Forms.Clipboard.GetText();
                            if (sTextOnClipboard != _lastText)
                            {
                                // Send to server
                                ServerProtocol protocol = new ServerProtocol();
                                lastnumber = protocol.SendTextToClipboard(CredentialsStorage.Username, CredentialsStorage.Password, sTextOnClipboard);
                                if (lastnumber > 0)
                                {
                                    //if successful
                                    _lastText = sTextOnClipboard;
                                    CredentialsStorage.LastNumber = lastnumber;

                                    //TODO maybe some feedback to the user?
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        static void _clipboardTimer_Tick(object sender, EventArgs e)
        {
            // reset red icon
            if (_bRedIcon == true)
            {
                _bRedIcon = false;
                CredentialsStorage.notifyIcon.Icon = new Icon("sync-image.ico");
            }

            if (CredentialsStorage.ClipboardRunning == true)
            {
                if (CredentialsStorage.Username != null)
                {
                    if (CredentialsStorage.Username.Length > 1)
                    {
                        //Check if there is something from Clipboard.
                        if (_lastText != CredentialsStorage.ClipboardData && CredentialsStorage.ClipboardData != null)
                        {
                            System.Windows.Forms.Clipboard.SetText(CredentialsStorage.ClipboardData);
                            _lastText = CredentialsStorage.ClipboardData;
                            CredentialsStorage.notifyIcon.Icon = new Icon("sync-image_red.ico");
                            _bRedIcon = true;
                        }

                        //Check if nothing new is in the clipboard.
                        if (System.Windows.Forms.Clipboard.ContainsText())
                        {
                            string sTextOnClipboard = System.Windows.Forms.Clipboard.GetText();
                            if (sTextOnClipboard != _lastText)
                            {
                                // Send to server
                                ServerProtocol protocol = new ServerProtocol();
                                lastnumber = protocol.SendTextToClipboard(CredentialsStorage.Username, CredentialsStorage.Password, sTextOnClipboard);
                                if (lastnumber > 0)
                                {
                                    //if successful
                                    _lastText = sTextOnClipboard;
                                    CredentialsStorage.LastNumber = lastnumber;

                                    //TODO maybe some feedback to the user?
                                }
                            }
                        }
                    }
                }
            }
        }