Ejemplo n.º 1
0
        public void ProcessMethod()
        {
            ServerProtocol protocol = new ServerProtocol();
            while (_ThreadRunning == true)
            {
                if (CredentialsStorage.Username != null)
                {
                    if (CredentialsStorage.Username.Length > 1)
                    {
                        // Check on the server
                        string clipBoardText = protocol.GetTextFromClipboard(CredentialsStorage.Username, CredentialsStorage.Password, CredentialsStorage.LastNumber);
                        try
                        {
                            SyncItem item = JSONHelper.Deserialize<SyncItem>(clipBoardText);

                            CredentialsStorage.LastNumber = item.SyncID;
                            CredentialsStorage.ClipboardData = item.ClipboardData;
                        }
                        catch { }

                    }
                }

                Thread.Sleep(1000 * 2);
            }
        }
Ejemplo n.º 2
0
 private void button_login_Click(object sender, EventArgs e)
 {
     if (this.textBox_Username.Text.Length > 1)
     {
         //Login
         if (this.textBox_Password.Text == this.textBox_Password_repeat.Text)
         {
             this.labelIncorrectPassword.Visible = false;
             ServerProtocol protocol = new ServerProtocol();
             if (protocol.ServerRegistration(this.textBox_Username.Text, this.textBox_Password.Text) == true)
             {
                 this.label_error.Visible = false;
                 protocol.ServerLogin(this.textBox_Username.Text, this.textBox_Password.Text);
                 CredentialsStorage.Username = this.textBox_Username.Text;
                 CredentialsStorage.Password = this.textBox_Password.Text;
                 this.Hide();
             }
             else
             {
                 this.label_error.Visible = true;
             }
         }
         else
         {
             this.labelIncorrectPassword.Visible = true;
         }
     }
 }
Ejemplo n.º 3
0
        public void ProcessMethod()
        {
            ServerProtocol protocol = new ServerProtocol();

            while (_ThreadRunning == true)
            {
                if (CredentialsStorage.Username != null)
                {
                    if (CredentialsStorage.Username.Length > 1)
                    {
                        // Check on the server
                        string clipBoardText = protocol.GetTextFromClipboard(CredentialsStorage.Username, CredentialsStorage.Password, CredentialsStorage.LastNumber);
                        try
                        {
                            SyncItem item = JSONHelper.Deserialize <SyncItem>(clipBoardText);

                            CredentialsStorage.LastNumber    = item.SyncID;
                            CredentialsStorage.ClipboardData = item.ClipboardData;
                        }
                        catch { }
                    }
                }

                Thread.Sleep(1000 * 2);
            }
        }
Ejemplo n.º 4
0
 private void button_login_Click(object sender, EventArgs e)
 {
     if (this.textBox_Username.Text.Length > 1)
     {
         //Login
         if (this.textBox_Password.Text == this.textBox_Password_repeat.Text)
         {
             this.labelIncorrectPassword.Visible = false;
             ServerProtocol protocol = new ServerProtocol();
             if (protocol.ServerRegistration(this.textBox_Username.Text, this.textBox_Password.Text) == true)
             {
                 this.label_error.Visible = false;
                 protocol.ServerLogin(this.textBox_Username.Text, this.textBox_Password.Text);
                 CredentialsStorage.Username = this.textBox_Username.Text;
                 CredentialsStorage.Password = this.textBox_Password.Text;
                 this.Hide();
             }
             else
             {
                 this.label_error.Visible = true;
             }
         }
         else
         {
             this.labelIncorrectPassword.Visible = true;
         }
     }
 }
Ejemplo n.º 5
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?
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
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?
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private void button_login_Click(object sender, EventArgs e)
        {
            this.button_login.Enabled = false;

            if (this.menuItemLogin.Text == "Logout")
            {
                this.menuItemLogin.Text     = "Login";
                CredentialsStorage.Username = "";
                CredentialsStorage.Password = "";

                _clipboardProcess.Stop();

                this.button_login.Enabled = true;
                return;
            }
            CredentialsStorage.Username = textBox_Username.Text;
            CredentialsStorage.Password = textBox_Password.Text;

            ServerProtocol server  = new ServerProtocol();
            bool           bReturn = server.ServerLogin(CredentialsStorage.Username, CredentialsStorage.Password);

            if (bReturn == true)
            {
                this.labelIncorrectPassword.Visible = false;
                this.Hide();

                this.menuItemLogin.Text = "Logout";

                _clipboardProcess.Start();
            }

            else
            {
                this.labelIncorrectPassword.Visible = true;
                _clipboardProcess.Stop();
            }

            this.button_login.Enabled = true;
        }
Ejemplo n.º 8
0
        private void button_login_Click(object sender, EventArgs e)
        {
            this.button_login.Enabled = false;

            if (this.menuItemLogin.Text == "Logout")
            {
                this.menuItemLogin.Text = "Login";
                CredentialsStorage.Username = "";
                CredentialsStorage.Password = "";

                _clipboardProcess.Stop();

                this.button_login.Enabled = true;
                return;
            }
            CredentialsStorage.Username = textBox_Username.Text;
            CredentialsStorage.Password = textBox_Password.Text;

            ServerProtocol server = new ServerProtocol();
            bool bReturn = server.ServerLogin(CredentialsStorage.Username, CredentialsStorage.Password);

            if (bReturn == true)
            {
                this.labelIncorrectPassword.Visible = false;
                this.Hide();

                this.menuItemLogin.Text = "Logout";

                _clipboardProcess.Start();
            }

            else
            {
                this.labelIncorrectPassword.Visible = true;
                _clipboardProcess.Stop();
            }

            this.button_login.Enabled = true;
        }