Beispiel #1
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox  temp      = sender as ComboBox;
            EnigmaCfg enigmaCfg = (EnigmaCfg)temp.SelectedItem;

            if (enigmaCfg != null)
            {
                string validRotors = enigmaCfg.ValidRotors;
                this.curRotors.Clear();
                foreach (Rotor rotor in this.allRotors)
                {
                    if (validRotors.Contains(rotor.IndexValue))
                    {
                        this.curRotors.Add(rotor);
                    }
                }
                string validReflectors = enigmaCfg.ValidReflector;
                this.curReflectors.Clear();
                foreach (Rotor reflector in this.allReflectors)
                {
                    if (validReflectors.Contains(reflector.IndexValue))
                    {
                        this.curReflectors.Add(reflector);
                    }
                }
                if (enigmaCfg.Plugboard == true)
                {
                    plugboard1.Enabled = true;
                }
                else
                {
                    plugboard1.Enabled = false;
                }
                if (enigmaCfg.FourRotors == true)
                {
                    label5.Enabled     = true;
                    comboBox5.Enabled  = true;
                    comboBox9.Enabled  = true;
                    comboBox14.Enabled = true;
                }
                else
                {
                    label5.Enabled     = false;
                    comboBox5.Enabled  = false;
                    comboBox9.Enabled  = false;
                    comboBox14.Enabled = false;
                }
            }
        }
Beispiel #2
0
        List <EnigmaCfg> getEnigmas()
        {
            List <EnigmaCfg> enigmaList = new List <EnigmaCfg>();
            EnigmaCfg        newCfg     = new EnigmaCfg("Enigma A", "ABC", false, false, "A", "A");

            enigmaList.Add(newCfg);
            newCfg = new EnigmaCfg("Enigma B", "ABC", false, false, "A", "A");
            enigmaList.Add(newCfg);
            newCfg = new EnigmaCfg("Enigma D", "GHI", false, false, "A", "A");
            enigmaList.Add(newCfg);
            newCfg = new EnigmaCfg("Enigma M3", "RSTUVWXY", false, true, "A", "FGH");
            enigmaList.Add(newCfg);
            newCfg = new EnigmaCfg("Enigma M4", "RSTUVWXYZ1", true, true, "A", "DEFGH");
            enigmaList.Add(newCfg);
            newCfg = new EnigmaCfg("German Railway", "DEF", false, false, "A", "B");

            enigmaList.Add(newCfg);
            return(enigmaList);
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string enigmaString = "";
            //entry disc
            EnigmaCfg temp = (EnigmaCfg)comboBox1.SelectedItem;

            enigmaString += Convert.ToString(temp.EntryDisc);
            enigmaString += " ";
            //rotors
            enigmaString += Convert.ToString(comboBox2.SelectedValue);
            enigmaString += Convert.ToString(comboBox3.SelectedValue);
            enigmaString += Convert.ToString(comboBox4.SelectedValue);
            if (comboBox5.Enabled)
            {
                enigmaString += Convert.ToString(comboBox5.SelectedValue);
            }
            enigmaString += Convert.ToString(comboBox6.SelectedValue);
            enigmaString += " ";


            //ring settings
            enigmaString += comboBox10.SelectedItem;
            enigmaString += comboBox7.SelectedItem;
            enigmaString += comboBox8.SelectedItem;
            if (comboBox9.Enabled)
            {
                enigmaString += comboBox9.SelectedItem;
            }
            enigmaString += " ";

            //message key
            enigmaString += comboBox11.SelectedItem;
            enigmaString += comboBox12.SelectedItem;
            enigmaString += comboBox13.SelectedItem;
            if (comboBox14.Enabled)
            {
                enigmaString += comboBox14.SelectedItem;
            }
            enigmaString += " ";

            //plugboard
            enigmaString += plugboard1.GetPlugboardString();

            enigmaString += " \"" + textBox1.Text + "\"";

            Process cmd = new Process();

            cmd.StartInfo.FileName               = @"..\..\..\Debug\Enigma.exe";
            cmd.StartInfo.Arguments              = enigmaString;
            cmd.StartInfo.RedirectStandardInput  = true;
            cmd.StartInfo.RedirectStandardOutput = true;
            cmd.StartInfo.CreateNoWindow         = true;

            cmd.StartInfo.UseShellExecute = false;
            cmd.Start();

            cmd.WaitForExit(2000);
            if (cmd.ExitCode == 0)
            {
                textBox2.Text = cmd.StandardOutput.ReadToEnd();
            }
            else
            {
                textBox2.Text = "Error in Engima.exe. Please check parameters.";
            }
        }