private void buttonGenerateAdjacents_Click(object sender, EventArgs e) { if (radioBtnDPPt.Checked) { ColumnFlipSequence.Visible = true; ColumnElmResponse.Visible = false; ColumnRoamers.Visible = false; ColumnGen5IVs.Visible = false; } else if (radioBtnHgSs.Checked) { ColumnFlipSequence.Visible = false; ColumnElmResponse.Visible = true; ColumnRoamers.Visible = true; ColumnGen5IVs.Visible = false; } else { ColumnFlipSequence.Visible = false; ColumnElmResponse.Visible = false; ColumnRoamers.Visible = false; ColumnGen5IVs.Visible = true; ColumnCGearAdjust.Visible = sekrit; } if (maskedTextBoxMDelay.Text == "") { maskedTextBoxMDelay.Focus(); return; } if (maskedTextBoxPDelay.Text == "") { maskedTextBoxPDelay.Focus(); return; } if (maskedTextBoxMSecond.Text == "") { maskedTextBoxMSecond.Focus(); return; } if (maskedTextBoxPSecond.Text == "") { maskedTextBoxPSecond.Focus(); return; } // Make sure that something is selected in the main // times grid and then go ahead and get that item if (dataGridViewValues.SelectedRows.Count == 0) { return; } // Load all of our +/- so we can use them to generate // or list of adjacent frames. int mDelay = int.Parse(maskedTextBoxMDelay.Text); int pDelay = int.Parse(maskedTextBoxPDelay.Text); int mSecond = int.Parse(maskedTextBoxMSecond.Text); int pSecond = int.Parse(maskedTextBoxPSecond.Text); var timeAndDelay = (TimeAndDelay)dataGridViewValues.SelectedRows[0].DataBoundItem; // From the actual time we need to build a start // time and an end time so that we can iterate DateTime startTime = timeAndDelay.Date - new TimeSpan(0, 0, mSecond); DateTime endTime = timeAndDelay.Date + new TimeSpan(0, 0, pSecond); // Figure out how many seconds there are between the times // as this is going to be the number of times that we are // going to loop, plus 1. TimeSpan span = endTime - startTime; int startDelay = timeAndDelay.Delay - mDelay; int endDelay = timeAndDelay.Delay + pDelay; // Grab our roamer information so we only have to do it one // time and can just run the code and pass the results into // the adjacents. uint rRoute = 0; uint eRoute = 0; uint lRoute = 0; // need to tryparse out all of the route values if (maskedTextBoxRRoute.Text != "") { rRoute = uint.Parse(maskedTextBoxRRoute.Text); } if (maskedTextBoxERoute.Text != "") { eRoute = uint.Parse(maskedTextBoxERoute.Text); } if (maskedTextBoxLRoute.Text != "") { lRoute = uint.Parse(maskedTextBoxLRoute.Text); } var adjacents = new List <Adjacent>(); int oddEven = timeAndDelay.Delay & 1; int minFrame; int maxFrame; int.TryParse(maskedTextBoxMinFrame.Text, out minFrame); int.TryParse(maskedTextBoxMaxFrame.Text, out maxFrame); if (minFrame == 0) { minFrame = 1; } if (maxFrame == 0) { maxFrame = 10; } if (checkBoxRoamer.Checked) { minFrame++; maxFrame++; } for (int cnt = 0; cnt <= (int)span.TotalSeconds; cnt++) { DateTime seedTime = startTime + new TimeSpan(0, 0, cnt); // Now we need to loop through all of our delay range // so that we have all of the information to create // a seed. for (int delayCnt = startDelay; delayCnt <= endDelay; delayCnt++) { if (!checkBoxOddEven.Checked || (delayCnt & 1) == oddEven) { // Create the seed an add to the collection var adjacent = new Adjacent { Delay = delayCnt, Date = seedTime, MinFrame = minFrame, MaxFrame = maxFrame + 6, Seed = ((((uint)seedTime.Month * (uint)seedTime.Day + (uint)seedTime.Minute + (uint)seedTime.Second) % 0x100) * 0x1000000) + ((uint)seedTime.Hour * 0x10000) + ((uint)seedTime.Year - 2000 + (uint)delayCnt) + // only part of the MAC Address is used ((uint)MAC_Address & 0xFFFFFF) }; adjacent.RoamerInformtion = HgSsRoamers.GetHgSsRoamerInformation( adjacent.Seed, checkBoxRPresent.Checked, checkBoxEPresent.Checked, checkBoxLPresent.Checked, rRoute, eRoute, lRoute); adjacents.Add(adjacent); } } } // Bind to the collection dataGridViewAdjacents.DataSource = adjacents; //highlight the target int target = adjacents.FindIndex(IsTarget); dataGridViewAdjacents.FirstDisplayedScrollingRowIndex = target; }
private void Generate() { if (maskedTextBoxYear.Text == "") { MessageBox.Show("You must enter a year.", "Please Enter a Year", MessageBoxButtons.OK); return; } int lockedSecond = 0; if (maskedTextBoxSeconds.Text == "" && checkBoxLockSeconds.Checked) { MessageBox.Show("You must enter a seconds value.", "Please Enter Seconds", MessageBoxButtons.OK); return; } if (checkBoxLockSeconds.Checked) { lockedSecond = int.Parse(maskedTextBoxSeconds.Text); } if (textBoxSeed.Text != "") { Seed = uint.Parse(textBoxSeed.Text, NumberStyles.HexNumber); } if (radioBtnDPPt.Checked) { labelVerificationType.Text = "Coin Flips for Seed:"; labelFlipsElmsForSeed.Text = CoinFlips.GetFlips(Seed, 15); labelRoamerRoutes.Text = ""; } else if (radioBtnHgSs.Checked) { labelVerificationType.Text = "Elm Responses for Seed:"; //labelFlipsElmsForSeed.Text = ElmResponse.GetResponses(seed, 10, 0); // Handle all of the roaming Pokemon here uint rRoute = 0; uint eRoute = 0; uint lRoute = 0; // need to tryparse out all of the route values if (maskedTextBoxRRoute.Text != "") { rRoute = uint.Parse(maskedTextBoxRRoute.Text); } if (maskedTextBoxERoute.Text != "") { eRoute = uint.Parse(maskedTextBoxERoute.Text); } if (maskedTextBoxLRoute.Text != "") { lRoute = uint.Parse(maskedTextBoxLRoute.Text); } // We need to know two things, forced advancement and the // starting route of each of the roamers the user has // shown interest in -- HgSsRoamerInformation information = HgSsRoamers.GetHgSsRoamerInformation( Seed, checkBoxRPresent.Checked, checkBoxEPresent.Checked, checkBoxLPresent.Checked, rRoute, eRoute, lRoute); // Build our roaming monster string //labelRoamerRoutes.Text = ""; string labelRoamerRoutesText = ""; bool firstDisplay = true; if (checkBoxRPresent.Checked) { labelRoamerRoutesText += "R: " + information.RCurrentRoute; firstDisplay = false; } if (checkBoxEPresent.Checked) { if (!firstDisplay) { labelRoamerRoutesText += " "; } labelRoamerRoutesText += "E: " + information.ECurrentRoute; firstDisplay = false; } if (checkBoxLPresent.Checked) { if (!firstDisplay) { labelRoamerRoutesText += " "; } labelRoamerRoutesText += "L: " + information.LCurrentRoute; firstDisplay = false; } if (!firstDisplay) { labelRoamerRoutesText += " --- "; labelRoamerRoutesText += "Frame(s) Advanced: " + information.RngCalls; } labelRoamerRoutes.Text = labelRoamerRoutesText; // Handle elm here, letting it know the foced advancement labelFlipsElmsForSeed.Text = Responses.ElmResponses(Seed, 15, information.RngCalls); } else { labelVerificationType.Text = "First 10 IVs in Seed:"; labelFlipsElmsForSeed.Text = Gen5IVs.GetIVs(Seed, 1, 10); labelRoamerRoutes.Text = ""; } // Break seed out into parts if (!radioBtnBW.Checked) { MAC_Address = 0; } uint partialmac = (uint)MAC_Address & 0xFFFFFF; uint ab = (Seed - partialmac) >> 24; uint cd = ((Seed - partialmac) & 0x00FF0000) >> 16; uint efgh = (Seed - partialmac) & 0x0000FFFF; // Get the year and the seed from the dialog // we need to get the year because we let the // user change this in the dialog // wfy this can fail if nothing entred int generateYear = int.Parse(maskedTextBoxYear.Text); // Get Delay int delay = (int)efgh + (2000 - generateYear); // Get Hour var hour = (int)cd; // We need to check here, as a user could have entered a seed // that is not possible (invalid hour) to lets warn and exit // on it. if (hour > 23) { MessageBox.Show("This seed is invalid, please verify that you have entered it correctly and try again.", "Invalid Seed", MessageBoxButtons.OK); return; } var timeAndDeleays = new List <TimeAndDelay>(); // Loop through all months for (int month = 1; month <= 12; month++) { int daysInMonth = DateTime.DaysInMonth(generateYear, month); // Loop through all days for (int day = 1; day <= daysInMonth; day++) { // Loop through all minutes for (int minute = 0; minute <= 59; minute++) { // Loop through all seconds for (int second = 0; second <= 59; second++) { if (ab == ((month * day + minute + second) % 0x100)) { if (!checkBoxLockSeconds.Checked || second == lockedSecond) { // Create Date/Time and add item to collection var timeAndDelay = new TimeAndDelay(); // Build DateTime var dateTime = new DateTime(generateYear, month, day, hour, minute, second); timeAndDelay.Date = dateTime; timeAndDelay.Delay = delay; // Add to collection timeAndDeleays.Add(timeAndDelay); } } } } } } // Do our databind to the grid here so the user // can get the time listing. dataGridViewValues.DataSource = timeAndDeleays; }