private void SetProfile(ResearcherProfile profile) { if (profile.Custom.Length != 7) { MessageBox.Show("Corrupt profile detected"); return; } if (profile.Type != ResearcherProfile.RNGType.Custom) { radioButtonCommon.Checked = true; comboBoxRNG.SelectedIndex = (int) profile.Type; } else { radioButtonCustom.Checked = true; textBoxMult.Text = profile.CustomM; textBoxAdd.Text = profile.CustomA; checkBox64bit.Checked = profile.Is64Bit; } maskedTextBoxMaxFrames.Text = profile.MaxResults.ToString(); textBoxSeed.Text = profile.Seed; //todo: automoate this comboBoxLValue1.SelectedIndex = (int) profile.Custom[0].Type; comboBoxOperator1.SelectedIndex = (int) profile.Custom[0].Operation; textBoxRValue1.Text = profile.Custom[0].Operand; checkBoxCustom1Hex.Checked = profile.Custom[0].isHex; comboBoxLValue2.SelectedIndex = (int) profile.Custom[1].Type; comboBoxOperator2.SelectedIndex = (int) profile.Custom[1].Operation; textBoxRValue2.Text = profile.Custom[1].Operand; checkBoxCustom2Hex.Checked = profile.Custom[1].isHex; comboBoxRValue2.SelectedIndex = (int) profile.Custom[1].RelOperand; comboBoxLValue3.SelectedIndex = (int) profile.Custom[2].Type; comboBoxOperator3.SelectedIndex = (int) profile.Custom[2].Operation; textBoxRValue3.Text = profile.Custom[2].Operand; checkBoxCustom3Hex.Checked = profile.Custom[2].isHex; comboBoxRValue3.SelectedIndex = (int) profile.Custom[2].RelOperand; comboBoxLValue4.SelectedIndex = (int) profile.Custom[3].Type; comboBoxOperator4.SelectedIndex = (int) profile.Custom[3].Operation; textBoxRValue4.Text = profile.Custom[3].Operand; checkBoxCustom4Hex.Checked = profile.Custom[3].isHex; comboBoxRValue4.SelectedIndex = (int) profile.Custom[3].RelOperand; comboBoxLValue5.SelectedIndex = (int) profile.Custom[4].Type; comboBoxOperator5.SelectedIndex = (int) profile.Custom[4].Operation; textBoxRValue5.Text = profile.Custom[4].Operand; checkBoxCustom5Hex.Checked = profile.Custom[4].isHex; comboBoxRValue5.SelectedIndex = (int) profile.Custom[4].RelOperand; comboBoxLValue6.SelectedIndex = (int) profile.Custom[5].Type; comboBoxOperator6.SelectedIndex = (int) profile.Custom[5].Operation; textBoxRValue6.Text = profile.Custom[5].Operand; checkBoxCustom6Hex.Checked = profile.Custom[5].isHex; comboBoxRValue6.SelectedIndex = (int) profile.Custom[5].RelOperand; comboBoxLValue7.SelectedIndex = (int) profile.Custom[6].Type; comboBoxOperator7.SelectedIndex = (int) profile.Custom[6].Operation; textBoxRValue7.Text = profile.Custom[6].Operand; checkBoxCustom7Hex.Checked = profile.Custom[6].isHex; comboBoxRValue7.SelectedIndex = (int) profile.Custom[6].RelOperand; }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { var profile = new ResearcherProfile {MaxResults = 1000, Custom = new CustomResearcher[7]}; for (int i = 0; i < 7; ++i) profile.Custom[i] = new CustomResearcher(); SetProfile(profile); }
private void SaveProfile(ResearcherProfile profile, string fileName) { var serializer = new XmlSerializer(typeof (ResearcherProfile)); TextWriter textWriter = new StreamWriter(fileName); serializer.Serialize(textWriter, profile); textWriter.Close(); }
private ResearcherProfile GetProfile() { var profile = new ResearcherProfile(); if (radioButtonCommon.Checked) { profile.Type = (ResearcherProfile.RNGType) comboBoxRNG.SelectedIndex; } else { profile.Type = ResearcherProfile.RNGType.Custom; profile.CustomM = textBoxMult.Text; profile.CustomA = textBoxAdd.Text; profile.Is64Bit = checkBox64bit.Checked; } profile.MaxResults = Int32.Parse(maskedTextBoxMaxFrames.Text); profile.Seed = textBoxSeed.Text; profile.Custom = new CustomResearcher[7]; for (int i = 0; i < 7; ++i) profile.Custom[i] = new CustomResearcher(); profile.Custom[0].Type = (CustomResearcher.ValueType) comboBoxLValue1.SelectedIndex; profile.Custom[0].Operation = (CustomResearcher.Operator) comboBoxOperator1.SelectedIndex; profile.Custom[0].Operand = textBoxRValue1.Text; profile.Custom[0].isHex = checkBoxCustom1Hex.Checked; profile.Custom[1].Type = (CustomResearcher.ValueType) comboBoxLValue2.SelectedIndex; profile.Custom[1].Operation = (CustomResearcher.Operator) comboBoxOperator2.SelectedIndex; profile.Custom[1].Operand = textBoxRValue2.Text; profile.Custom[1].isHex = checkBoxCustom2Hex.Checked; profile.Custom[1].RelOperand = (CustomResearcher.RelativeOperand) comboBoxRValue2.SelectedIndex; profile.Custom[2].Type = (CustomResearcher.ValueType) comboBoxLValue3.SelectedIndex; profile.Custom[2].Operation = (CustomResearcher.Operator) comboBoxOperator3.SelectedIndex; profile.Custom[2].Operand = textBoxRValue3.Text; profile.Custom[2].isHex = checkBoxCustom3Hex.Checked; profile.Custom[2].RelOperand = (CustomResearcher.RelativeOperand) comboBoxRValue3.SelectedIndex; profile.Custom[3].Type = (CustomResearcher.ValueType) comboBoxLValue4.SelectedIndex; profile.Custom[3].Operation = (CustomResearcher.Operator) comboBoxOperator4.SelectedIndex; profile.Custom[3].Operand = textBoxRValue4.Text; profile.Custom[3].isHex = checkBoxCustom4Hex.Checked; profile.Custom[3].RelOperand = (CustomResearcher.RelativeOperand) comboBoxRValue4.SelectedIndex; profile.Custom[4].Type = (CustomResearcher.ValueType) comboBoxLValue5.SelectedIndex; profile.Custom[4].Operation = (CustomResearcher.Operator) comboBoxOperator5.SelectedIndex; profile.Custom[4].Operand = textBoxRValue5.Text; profile.Custom[4].isHex = checkBoxCustom5Hex.Checked; profile.Custom[4].RelOperand = (CustomResearcher.RelativeOperand) comboBoxRValue5.SelectedIndex; profile.Custom[5].Type = (CustomResearcher.ValueType) comboBoxLValue6.SelectedIndex; profile.Custom[5].Operation = (CustomResearcher.Operator) comboBoxOperator6.SelectedIndex; profile.Custom[5].Operand = textBoxRValue6.Text; profile.Custom[5].isHex = checkBoxCustom6Hex.Checked; profile.Custom[5].RelOperand = (CustomResearcher.RelativeOperand) comboBoxRValue6.SelectedIndex; profile.Custom[6].Type = (CustomResearcher.ValueType) comboBoxLValue7.SelectedIndex; profile.Custom[6].Operation = (CustomResearcher.Operator) comboBoxOperator7.SelectedIndex; profile.Custom[6].Operand = textBoxRValue7.Text; profile.Custom[6].isHex = checkBoxCustom7Hex.Checked; profile.Custom[6].RelOperand = (CustomResearcher.RelativeOperand) comboBoxRValue7.SelectedIndex; return profile; }