コード例 #1
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");
        }
コード例 #2
0
        private void BuildListButton_Click(object sender, EventArgs e)
        {
            Excel excel = OpenFileAt(11);
            int planetsToBuild = (int)excel.ReadCellDouble(1, 15);

            for (int i = 1; i <= planetsToBuild; i++) //planet tally is in P column
            {
                //output.Write("Coordinates: ");
                output.Write(excel.ReadCellString(i, 2)); //coordinates
                output.Write(" | ");

                //output.Write("Planet Name: ");
                output.Write(excel.ReadCellString(i, 3)); //colony name
                output.Write(" | ");

                //output.Write("Colony Name: ");
                output.Write(excel.ReadCellString(i, 4));//Planet Name
                output.Write(" | ");

                output.Write("Zounds: ");
                output.Write(excel.ReadCellBool(i, 5));//Zoundsable
                output.Write(" | ");

                output.Write("Medium: ");
                output.Write(excel.ReadCellBool(i, 6));//Medium
                output.Write(" | ");

                output.Write("?: ");
                output.Write(excel.ReadCellBool(i, 7));//Questionable
                output.Write(" | ");

                output.Write("Decconstruct: ");
                output.Write(excel.ReadCellBool(i, 8));//Deconstruct
                output.Write(" | ");

                //output.Write("Research x/10: ");
                output.Write((int)excel.ReadCellDouble(i, 9)); //Research
                output.Write(" | ");
                output.WriteLine("");
            }
            output.Flush();
            MessageBox.Show("Build List added to output", "Message");
        }