Esempio n. 1
0
        }     //ConnectionWindow

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try {
                IPAddress.Parse(this.IP_TextBox.Text);

                this.connectionSettings.IP = this.IP_TextBox.Text;
            }//try
            catch {
                MessageBox.Show("Error IP Parse", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }//catch

            if (this.Port_TextBox.Text.Length == 0)
            {
                MessageBox.Show("Port is Empty", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }//if

            int port = 0;

            try {
                port = int.Parse(this.Port_TextBox.Text);
            }//try
            catch {
                MessageBox.Show("Error Port Parse", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }//catch


            if (port > 65535)
            {
                MessageBox.Show("Port Max Value = 65535", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }//if
            else if (port == 0)
            {
                MessageBox.Show("Port Min Value = 1", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }//else if

            this.connectionSettings.Port = port;

            string NickName = this.NickName_TextBox.Text;

            if (NickName.Trim().Length == 0)
            {
                MessageBox.Show("NickName should not be empty!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }//if

            NickName = NickName.Replace(" ", "");

            if (this.connectionSettings.RandomSend == false)
            {
                if (this.Video_Send_Port_TextBox.Text.Length == 0)
                {
                    MessageBox.Show("Video Send Port is Empty", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                    return;
                }//if

                try {
                    port = int.Parse(this.Video_Send_Port_TextBox.Text);
                }//try
                catch {
                    MessageBox.Show("Error Video Send Port Parse", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                    return;
                }//catch

                if (port > 65535)
                {
                    MessageBox.Show("Video Send Port Max Value = 65535", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                    return;
                }//if
                else if (port == 0)
                {
                    MessageBox.Show("Video Send Port Min Value = 1", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                    return;
                }//else if

                this.connectionSettings.VideoSendPort = port;

                if (this.Audio_Send_Port_TextBox.Text.Length == 0)
                {
                    MessageBox.Show("Audio Send Port is Empty", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                    return;
                }//if

                try {
                    port = int.Parse(this.Audio_Send_Port_TextBox.Text);
                }//try
                catch {
                    MessageBox.Show("Error Audio Send Port Parse", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                    return;
                }//catch

                if (port > 65535)
                {
                    MessageBox.Show("Audio Send Port Max Value = 65535", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                    return;
                }//if
                else if (port == 0)
                {
                    MessageBox.Show("Audio Send Port Min Value = 1", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                    return;
                }//else if

                this.connectionSettings.AudioSendPort = port;
            }//if

            this.connectionSettings.ServerPassword = EncryptionString.Encrypt(this.Password_PasswordBox.Password);

            this.connectionSettings.NickName = NickName;

            try {
                ConnectionSettings.SerializeJSON(this.connectionSettings, FName);
            }//try
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }//catch

            this.DialogResult = true;
        }//Button_Click
Esempio n. 2
0
        public void TestEncryptString()
        {
            String result = e.Encrypt("Hello World");

            Assert.AreEqual("0a4d55a8d778e5022fab701977c5d840bbc486d0", result);
        }