示例#1
0
        public override void TransitionTo()
        {
            base.TransitionTo();

            haveUserName = false;
            myName       = "";

            // Try to connect to the server
            if (!Game.multiplayer.Connect(hostname, port))
            {
                Game.game.screenManager.TransitionScreen("MainMenu");
                return;
            }

            // Prompt for a username
            while (myName.Equals(""))
            {
                SimpleInput si = new SimpleInput("Enter Username:"******"Please type your desired username.");
                si.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
                System.Windows.Forms.DialogResult result = si.ShowDialog(null);

                myName = si.res;
            }

            haveUserName = true;
            Game.multiplayer.LogIn(myName);
            playerArea.AddPlayer(Game.multiplayer.getPID(), myName);

            start = -1;
        }
示例#2
0
        private void btnDecrypt_Click(object sender, EventArgs e)
        {
            switch (criptareToolStripMenuItem.Text)
            {
            case "Greek":
                SimpleInput simpleInput = new SimpleInput();
                if (simpleInput.ShowDialog() == DialogResult.OK)
                {
                    txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.GREEK, new object[] { simpleInput.txtKey.Text });
                }
                break;

            case "Caesar":
                simpleInput = new SimpleInput();
                if (simpleInput.ShowDialog() == DialogResult.OK)
                {
                    txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.CAESAR, new object[] { simpleInput.txtKey.Text });
                }
                break;

            case "Playfair":
                simpleInput = new SimpleInput();
                if (simpleInput.ShowDialog() == DialogResult.OK)
                {
                    txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.PLAYFAIR, new object[] { simpleInput.txtKey.Text });
                }
                break;

            case "ADFGVX":
                DoubleInput doubleInput = new DoubleInput();
                if (doubleInput.ShowDialog() == DialogResult.OK)
                {
                    txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.ADFGVX, new object[] { doubleInput.txtKey1.Text, doubleInput.txtKey2.Text });
                }
                break;

            case "Homophonic":
                txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.HOMOPHONIC, new object[] { });
                break;

            case "Enigma":
                simpleInput = new SimpleInput();
                if (simpleInput.ShowDialog() == DialogResult.OK)
                {
                    txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.ENIGMA, new object[] { simpleInput.txtKey.Text });
                }
                break;

            // TODO: add message for DES
            case "RSA":
                MessageBox.Show("In the next dialog, select number of bits for the key.");
                simpleInput = new SimpleInput();
                if (simpleInput.ShowDialog() == DialogResult.OK)
                {
                    txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.RSA, new object[] { simpleInput.txtKey.Text });
                }
                break;

            default:
                MessageBox.Show("Select encryption mode from menu.");
                break;
            }
        }