Пример #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);
                    }
                }
            }
        }
Пример #2
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);
                        }
                    }
                }
            }
        }