Ejemplo n.º 1
0
        private void buttonSearchFlips_Click(object sender, EventArgs e)
        {
            dataGridViewAdjacents.MultiSelect = false;
            if (radioBtnDPPt.Checked)
            {
                var adjacents = (List<Adjacent>) dataGridViewAdjacents.DataSource;
                var searchFlips = new SearchFlips(adjacents);
                if (searchFlips.ShowDialog() == DialogResult.OK)
                {
                    if (searchFlips.Possible.Count > 0)
                    {
                        dataGridViewAdjacents.ClearSelection();
                        dataGridViewAdjacents.MultiSelect = true;
                        int target = adjacents.FindIndex(IsTarget);
                        int closest = 0;
                        foreach (Adjacent adjacent in searchFlips.Possible)
                        {
                            int index = adjacents.IndexOf(adjacent);
                            dataGridViewAdjacents.Rows[index].Selected = true;

                            //store the closest one to the target
                            if (Math.Abs(target - closest) > Math.Abs(index - target))
                                closest = index;
                        }
                        //select the closest
                        dataGridViewAdjacents.FirstDisplayedScrollingRowIndex = closest;
                        //dataGridViewAdjacents.MultiSelect = false;
                    }
                    else
                        MessageBox.Show("No match was found for your flips.", "No Match", MessageBoxButtons.OK);
                }
            } // if (radioBtnDPPt.Checked)

            if (radioBtnHgSs.Checked)
            {
                //  We need to bring up the special searcher for roamers and/or
                //  elm flips.  Also need to figure out how we are going to search
                var adjacents = (List<Adjacent>) dataGridViewAdjacents.DataSource;

                var searchElm = new SearchElm(adjacents);
                if (adjacents != null && searchElm.ShowDialog() == DialogResult.OK)
                {
                    if (searchElm.Possible.Count > 0)
                    {
                        dataGridViewAdjacents.ClearSelection();
                        dataGridViewAdjacents.MultiSelect = true;
                        int target = adjacents.FindIndex(IsTarget);
                        int closest = 0;
                        foreach (Adjacent adjacent in searchElm.Possible)
                        {
                            int index = adjacents.IndexOf(adjacent);
                            dataGridViewAdjacents.Rows[index].Selected = true;

                            //store the closest one to the target
                            if (Math.Abs(target - closest) > Math.Abs(index - target))
                                closest = index;
                        }
                        //select the closest
                        dataGridViewAdjacents.FirstDisplayedScrollingRowIndex = closest;
                        //dataGridViewAdjacents.MultiSelect = false;
                    }
                    else
                        MessageBox.Show("No match was found for your Elm responses.", "No Match",
                                        MessageBoxButtons.OK);
                }
            } // if (radioBtnHgSs.Checked)

            if (radioBtnBW.Checked)
            {
                var searchIVs = new SearchIVs(checkBoxRoamer.Checked);

                if (searchIVs.ShowDialog() == DialogResult.OK)
                {
                    var adjacents = (List<Adjacent>) dataGridViewAdjacents.DataSource;

                    if (adjacents != null)
                    {
                        int cnt = 0;

                        bool found = false;

                        foreach (Adjacent adjacent in adjacents)
                        {
                            if (adjacent.IVs.Contains(searchIVs.ReturnIVs))
                            {
                                dataGridViewAdjacents.FirstDisplayedScrollingRowIndex = cnt;
                                dataGridViewAdjacents.Rows[cnt].Selected = true;

                                found = true;

                                break;
                            }

                            cnt++;
                        }

                        if (!found)
                            MessageBox.Show("No match was found for your IVs.", "No Match", MessageBoxButtons.OK);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var searchFlips = new SearchFlips();

            if (searchFlips.ShowDialog() == DialogResult.OK)
            {
                //  Going to pull out the collection and then iterate looking
                //  for the first instance of a match.

                if (iframesEggIVs != null)
                {
                    int cnt = 0;

                    foreach (IFrameBreeding frame in iframesEggIVs)
                    {
                        if (frame.Flips == searchFlips.ReturnFlips)
                        {
                            dataGridViewEggIVValues.FirstDisplayedScrollingRowIndex = cnt;
                            dataGridViewEggIVValues.Rows[cnt].Selected = true;

                            break;
                        }

                        cnt++;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void buttonSearchFlips_Click(object sender, EventArgs e)
        {
            dataGridViewAdjacents.MultiSelect = false;
            if (radioBtnDPPt.Checked)
            {
                var adjacents   = (List <Adjacent>)dataGridViewAdjacents.DataSource;
                var searchFlips = new SearchFlips(adjacents);
                if (searchFlips.ShowDialog() == DialogResult.OK)
                {
                    if (searchFlips.Possible.Count > 0)
                    {
                        dataGridViewAdjacents.ClearSelection();
                        dataGridViewAdjacents.MultiSelect = true;
                        int target  = adjacents.FindIndex(IsTarget);
                        int closest = 0;
                        foreach (Adjacent adjacent in searchFlips.Possible)
                        {
                            int index = adjacents.IndexOf(adjacent);
                            dataGridViewAdjacents.Rows[index].Selected = true;

                            //store the closest one to the target
                            if (Math.Abs(target - closest) > Math.Abs(index - target))
                            {
                                closest = index;
                            }
                        }
                        //select the closest
                        dataGridViewAdjacents.FirstDisplayedScrollingRowIndex = closest;
                        //dataGridViewAdjacents.MultiSelect = false;
                    }
                    else
                    {
                        MessageBox.Show("No match was found for your flips.", "No Match", MessageBoxButtons.OK);
                    }
                }
            } // if (radioBtnDPPt.Checked)

            if (radioBtnHgSs.Checked)
            {
                //  We need to bring up the special searcher for roamers and/or
                //  elm flips.  Also need to figure out how we are going to search
                var adjacents = (List <Adjacent>)dataGridViewAdjacents.DataSource;

                var searchElm = new SearchElm(adjacents);
                if (adjacents != null && searchElm.ShowDialog() == DialogResult.OK)
                {
                    if (searchElm.Possible.Count > 0)
                    {
                        dataGridViewAdjacents.ClearSelection();
                        dataGridViewAdjacents.MultiSelect = true;
                        int target  = adjacents.FindIndex(IsTarget);
                        int closest = 0;
                        foreach (Adjacent adjacent in searchElm.Possible)
                        {
                            int index = adjacents.IndexOf(adjacent);
                            dataGridViewAdjacents.Rows[index].Selected = true;

                            //store the closest one to the target
                            if (Math.Abs(target - closest) > Math.Abs(index - target))
                            {
                                closest = index;
                            }
                        }
                        //select the closest
                        dataGridViewAdjacents.FirstDisplayedScrollingRowIndex = closest;
                        //dataGridViewAdjacents.MultiSelect = false;
                    }
                    else
                    {
                        MessageBox.Show("No match was found for your Elm responses.", "No Match",
                                        MessageBoxButtons.OK);
                    }
                }
            } // if (radioBtnHgSs.Checked)

            if (radioBtnBW.Checked)
            {
                var searchIVs = new SearchIVs(checkBoxRoamer.Checked);

                if (searchIVs.ShowDialog() == DialogResult.OK)
                {
                    var adjacents = (List <Adjacent>)dataGridViewAdjacents.DataSource;

                    if (adjacents != null)
                    {
                        int cnt = 0;

                        bool found = false;

                        foreach (Adjacent adjacent in adjacents)
                        {
                            if (adjacent.IVs.Contains(searchIVs.ReturnIVs))
                            {
                                dataGridViewAdjacents.FirstDisplayedScrollingRowIndex = cnt;
                                dataGridViewAdjacents.Rows[cnt].Selected = true;

                                found = true;

                                break;
                            }

                            cnt++;
                        }

                        if (!found)
                        {
                            MessageBox.Show("No match was found for your IVs.", "No Match", MessageBoxButtons.OK);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void searchCoinFlipsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var searchFips = new SearchFlips();

            if (searchFips.ShowDialog() == DialogResult.OK)
            {
                int startIndex = 0;

                if (dataGridViewValues.SelectedRows[0] != null)
                {
                    startIndex = dataGridViewValues.SelectedRows[0].Index;
                }

                //  Grab a raw list of the frames, since this is the quick way to
                //  actual search them. Using the grid itself is easier, but slow
                var frames = (List<Frame>) dataGridViewValues.DataSource;

                bool found = true;
                int nextFrame = 0;

                //  Iterate through, looking for a set of matches, need
                //  to figure out the base way to do this one cleanly.
                for (int cnt = startIndex; cnt <= frames.Count - 10; cnt++)
                {
                    found = true;

                    for (int searchCnt = 0; searchCnt <= 9; searchCnt++)
                    {
                        if (frames[cnt + searchCnt].Coin.Substring(0, 1) != searchFips.ReturnArray[searchCnt])
                        {
                            found = false;
                            break;
                        }
                    }

                    if (found)
                    {
                        nextFrame = cnt + 10;

                        //  We need to cheat if we are the absolute last
                        //  item found, as we cant highlight the one after
                        if (nextFrame >= frames.Count)
                            nextFrame = frames.Count - 1;

                        break;
                    }
                }

                if (found)
                {
                    dataGridViewValues.FirstDisplayedScrollingRowIndex = nextFrame;
                    dataGridViewValues.Rows[nextFrame].Selected = true;
                }
                else
                {
                    MessageBox.Show("No matches found for the sequence of responses entered.", "No Match Found",
                                    MessageBoxButtons.OK);
                }
            }
        }