Ejemplo n.º 1
0
        private void ClearBuildsButton_Click(object sender, EventArgs e)
        {
            Excel excel = OpenFileAt(11);

            Clearer.ClearBuildList(excel);
            MessageBox.Show("Build List Cleared!", "Message");
            excel.Close();
        }
Ejemplo n.º 2
0
        private void SortBuildsButton_Click(object sender, EventArgs e)
        {
            Excel excel       = OpenFileAt(11);
            int   totalBuilds = excel.ReadCellInt(1, 15); //amount of builds num

            string[,] planets = new string[totalBuilds, 8];
            Console.WriteLine(planets.GetLength(0) + " " + planets.GetLength(1));

            for (int i = 1; i <= planets.GetLength(0); i++) //establish the array
            {
                bool tempBools = false;
                //Console.WriteLine(i);
                planets[i - 1, 0] = excel.ReadCellString(i, 2);
                planets[i - 1, 1] = excel.ReadCellString(i, 3);
                planets[i - 1, 2] = excel.ReadCellString(i, 4);

                tempBools         = excel.ReadCellBool(i, 5);
                planets[i - 1, 3] = tempBools.ToString();

                tempBools         = excel.ReadCellBool(i, 6);
                planets[i - 1, 4] = tempBools.ToString();

                tempBools         = excel.ReadCellBool(i, 7);
                planets[i - 1, 5] = tempBools.ToString();

                tempBools         = excel.ReadCellBool(i, 8);
                planets[i - 1, 6] = tempBools.ToString();

                int tempInt = excel.ReadCellInt(i, 9);
                planets[i - 1, 7] = tempInt.ToString();
            }
            //Clearer.ClearBuildList(excel);

            Coordinates origin;

            origin = Algorithms.GetCoordinates("(0,0)");

            ColonyInfo[] colInfo = Algorithms.SortPlanetsByXAndY(planets, origin, Algorithms.GetCoordinates(planets[totalBuilds - 1, 0])); //get the sorted array

            Clearer.ClearBuildList(excel);

            Console.WriteLine("This algorithm is bad its making tons of duplicates"); /*
                                                                                       * for (int i = 0; i < planets.GetLength(0); i++)
                                                                                       * {
                                                                                       * for (int j = 0; j < planets.GetLength(0); j++)
                                                                                       * {
                                                                                       * Coordinates oldList = Algorithms.GetCoordinates(planets[j, 0]);
                                                                                       * if ((colInfo[i].coords.x == oldList.x) && (colInfo[i].coords.y == oldList.y))
                                                                                       * {
                                                                                       * //Console.WriteLine(planets[i, 0] + " ");
                                                                                       * Adder.AddToBuilds(excel, planets[j, 0], planets[j, 1], planets[j, 2], planets[j, 3], planets[j, 4], planets[j, 5], planets[j, 6], planets[j, 7]);
                                                                                       * }
                                                                                       * }
                                                                                       * }
                                                                                       */
            excel.Close();
            MessageBox.Show("Build List Sorted by System", "Completed");
        }