public static string ReplacePlanetMethod(Excel excel, int sheet, int row, string newPlanetName) { if (excel.ReadCellString(row, 2).Equals("") || excel.ReadCellString(row, 2).Equals(null)) // if the box was empty { excel.WriteToCell(row, 2, newPlanetName); //planet in box excel.WriteToCell(row, 1, row.ToString()); // update number next to it if (row > excel.ReadCellDouble(1, 8)) //if the new numbeer is greater than the total { excel.WriteToCell(1, 8, row.ToString()); //update number return(newPlanetName + " added to" + " slot " + row + " on sheet " + sheet + " Totals updated to " + row); } else { return(newPlanetName + " added to" + " slot " + row + " on sheet " + sheet); } } else if (excel.ReadCellString(row, 2).Equals(newPlanetName)) { return(newPlanetName + " information updated "); } else { string oldPlanetName = excel.ReadCellString(row, 2); excel.WriteToCell(row, 2, newPlanetName); //put the planet in the box return(newPlanetName + " replaced " + oldPlanetName + " in slot " + row + " on" + " sheet " + sheet); } }
private void WriteAllPlanetInfo(int planetNum, Excel excel) { output.Write(excel.ReadCellString(planetNum, 2) + " | "); //column C //Console.WriteLine(excel.ReadCellString(planetNum, 2)); for (int i = 10; i <= 38; i++) { //Console.WriteLine(i); if (i == 11 || i == 12 || (i >= 14 && i <= 19) || (i >= 25 && i <= 37)) { var temp = excel.ReadCellDouble(planetNum, i); output.Write(temp + " | "); } else if (i == 38) { string temp = excel.ReadCellString(planetNum, i); output.Write(temp); } else { string temp = excel.ReadCellString(planetNum, i); output.Write(temp + " | "); } } output.WriteLine(""); }
private void DoubleDomeListButton_Click(object sender, EventArgs e) { Excel excel = OpenFileAt(1); output.WriteLine("Double Domes Lists: Candidates | Double Domes: "); for (int i = 2; i < Program.GetMax(); i++) { if (!string.IsNullOrEmpty(excel.ReadCellString(i, 18))) { output.Write(excel.ReadCellString(i, 18) + " | "); //Candidates } if (!string.IsNullOrEmpty(excel.ReadCellString(i, 19))) { output.Write(excel.ReadCellString(i, 19) + " | ");//double doems } if (!string.IsNullOrEmpty(excel.ReadCellString(i, 18)) || !string.IsNullOrEmpty(excel.ReadCellString(i, 19))) { output.WriteLine(""); } } output.Flush(); excel.Close(); MessageBox.Show("Double Domes list added to Output.txt", "Completed"); }
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"); }
private void ParadisesButton_Click(object sender, EventArgs e) { int.TryParse(numberTextBox.Text, out int temp); if (temp > 0) { int planetNumber = Int32.Parse(numberTextBox.Text); Excel excel = OpenFileAt(8); string planet = excel.ReadCellString(planetNumber, 2); //read row planet number column c excel.Close();//dellocate numberTextBox.Text = planet; RetrievePicture("IGP", planetNumber); } else { Excel excel = OpenFileAt(8); int planet = (int)excel.ReadCellDouble(1, 8); //amount of planets output.WriteLine("Paradises: "); for (int i = 1; i <= planet; i++) { WriteAllPlanetInfo(i, excel); } output.Flush(); excel.Close(); MessageBox.Show("Paradises added to " + outputPath, "Completed"); } }
private void RenameListsButton_Click(object sender, EventArgs e) { Excel excel = OpenFileAt(1); output.WriteLine("Rename Lists : Coordinates | Current Name | Rename "); for (int i = 2; i < Program.GetMax(); i++) { if (!string.IsNullOrEmpty(excel.ReadCellString(i, 6))) { output.Write(excel.ReadCellString(i, 6) + " | "); //location } if (!string.IsNullOrEmpty(excel.ReadCellString(i, 7))) { output.Write(excel.ReadCellString(i, 7) + " | ");//before } if (!string.IsNullOrEmpty(excel.ReadCellString(i, 8))) { output.Write("/namecolony " + excel.ReadCellString(i, 8));//after } if (!string.IsNullOrEmpty(excel.ReadCellString(i, 6)) || !string.IsNullOrEmpty(excel.ReadCellString(i, 7)) || !string.IsNullOrEmpty(excel.ReadCellString(i, 8))) { output.WriteLine(""); } } output.Flush(); excel.Close(); MessageBox.Show("Rename lists added to Output.txt", "Completed"); }
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"); }
private void NeedsDefensesButton_Click(object sender, EventArgs e) { Excel excel = OpenFileAt(1); output.WriteLine("Needs Defense List: "); for (int i = 2; i < Program.GetMax(); i++) { output.WriteLine(excel.ReadCellString(i, 14)); //needs defense column } output.Flush(); excel.Close(); MessageBox.Show("Needs Defense List added to Output.txt", "Completed"); }
public static string ReplacePlanetMethod(int sheet, int row, string newPlanetName) { Excel excel = OpenFileAt(sheet); if (excel.ReadCellString(row, 2).Equals("") || excel.ReadCellString(row, 2).Equals(null)) // if the box was empty { excel.WriteToCell(row, 2, newPlanetName); //planet in box excel.WriteToCell(row, 1, row.ToString()); // update number next to it if (row > excel.ReadCellDouble(1, 8)) //if the new numbeer is greater than the total { excel.WriteToCell(1, 8, row.ToString()); //update number excel.Close(); return(newPlanetName + " added to" + " slot " + row + " on sheet " + sheet + " Totals updated to " + row); } else { excel.Close(); return(newPlanetName + " added to" + " slot " + row + " on sheet " + sheet); } } else if (excel.ReadCellString(row, 2).Equals(newPlanetName)) { excel.Close(); return("Identitcal planet found! Nothing has been added"); } else { string oldPlanetName = excel.ReadCellString(row, 2); excel.WriteToCell(row, 2, newPlanetName); //put the planet in the box excel.Close(); return(newPlanetName + " replaced " + oldPlanetName + " in slot " + row + " on" + " sheet " + sheet); } }
public static void AddToWeakSolars(string colony, Excel totalsSheet) { for (int i = 2; i < Program.GetMax(); i++) { var box = totalsSheet.ReadCellString(i, 22); // column L if (string.IsNullOrEmpty(box)) { totalsSheet.WriteToCell(i, 22, colony); int temp = i - 1; totalsSheet.WriteToCell(i, 21, temp.ToString()); // put number in the box to the left Console.WriteLine(colony + " added to Weak Solars"); break; } } }
public static void AddToDD(string colony, Excel totalsSheet) { for (int i = 2; i < Program.GetMax(); i++) { string box = totalsSheet.ReadCellString(i, 19); if (string.IsNullOrEmpty(box)) { totalsSheet.WriteToCell(i, 19, colony); //put the colony in the slot int temp = i - 1; totalsSheet.WriteToCell(i, 17, temp.ToString()); // put number in the box to the left Console.WriteLine(colony + " added to Double Domes", "Completed"); break; } } }
/// <summary> /// add a singular planet to the needs defense list /// </summary> /// <param name="colony"></param> /// <param name="totalsSheet"></param> public static void AddToND(string colony, Excel totalsSheet) { //column 14 is Needs Defense on totals for (int i = 2; i < Program.GetMax(); i++) { string box = totalsSheet.ReadCellString(i, 14); if (string.IsNullOrEmpty(box)) { totalsSheet.WriteToCell(i, 14, colony); //put the colony in the slot int temp = i - 1; totalsSheet.WriteToCell(i, 13, temp.ToString()); // put number in the box to the left Console.WriteLine(colony + " added to Needs Defense", "Completed"); break; } } }
/// <summary> /// add a singular planet to the grow list /// </summary> /// <param name="colony"></param> /// <param name="totalsSheet"></param> public static void AddToGrow(string colony, Excel totalsSheet) { //column 11 is growing on totals for (int i = 2; i < Program.GetMax(); i++) { var box = totalsSheet.ReadCellString(i, 11); // column L if (string.IsNullOrEmpty(box)) { totalsSheet.WriteToCell(i, 11, colony); int temp = i - 1; totalsSheet.WriteToCell(i, 10, temp.ToString()); // put number in the box to the left Console.WriteLine(colony + " added to Knee Grow", "Completed"); break; } } }
/// <summary> /// Finds and outputs the planet info if the string matches /// </summary> /// <param name="find"></param> /// <param name="column"></param> private void WriteAllPlanetInfoIf(string find, int column) { for (int j = 2; j <= 10; j++) // goes through each sheet { Excel excel = OpenFileAt(j); int planet = (int)excel.ReadCellDouble(1, 8); for (int i = 1; i <= planet; i++) // goes through the planet list { if (excel.ReadCellString(planet, column).Equals(find)) { WriteAllPlanetInfo(planet, excel); } } excel.Close(); } }
private void SameSystemListButton_Click(object sender, EventArgs e) { Coordinates system = Algorithms.GetCoordinates(numberTextBox.Text); for (int j = 2; j <= 10; j++) // goes through each sheet { Excel excel = OpenFileAt(j); int planet = (int)excel.ReadCellDouble(1, 8); for (int i = 1; i <= planet; i++) // goes through the planet list { string planetName = excel.ReadCellString(i, 2); Coordinates planetCoords = Algorithms.GetCoordinates(planetName); if (system.x == planetCoords.x && system.y == planetCoords.y) { output.WriteLine(planetName); } } excel.Close(); } output.Flush(); MessageBox.Show("Colonies in the Same System to output", "Message"); }
private void VolcanicsButton_Click(object sender, EventArgs e) { int.TryParse(numberTextBox.Text, out int temp); if (temp > 0) { int planetNumber = Int32.Parse(numberTextBox.Text); Excel excel = OpenFileAt(10); string planet = excel.ReadCellString(planetNumber, 2); //read row planet number column c excel.Close();//dellocate numberTextBox.Text = planet; RetrievePicture("Vol", planetNumber); } else if (VolcanicZoundsCheckBox.Checked && VolcanicsCheckBox.Checked) //both { Excel excel = OpenFileAt(10); int planet = (int)excel.ReadCellDouble(1, 8); //amount of planets output.WriteLine("Volcanics: "); for (int i = 1; i <= planet; i++) { WriteAllPlanetInfo(i, excel); } output.Flush(); excel.Close(); MessageBox.Show("Volcanics added to " + outputPath, "Completed"); } else if (VolcanicZoundsCheckBox.Checked && !VolcanicsCheckBox.Checked) //Volcanic Zounds only { Excel excel = OpenFileAt(10); int planet = (int)excel.ReadCellDouble(2, 8); //amount of zounds output.WriteLine("Volcanic Zounds: "); for (int i = 1; i <= planet; i++) { output.WriteLine(excel.ReadCellString(i, 5)); //column F } output.Flush(); excel.Close(); MessageBox.Show("Volcanics Zounds added to " + outputPath, "Completed"); } else if (!VolcanicZoundsCheckBox.Checked && VolcanicsCheckBox.Checked) //normies only { Excel excel = OpenFileAt(10); int planet = (int)excel.ReadCellDouble(1, 8); //amount of planets output.WriteLine("Volcanic Non-Zounds: "); for (int i = 1; i <= planet; i++) { string box = excel.ReadCellString(i, 2); for (int j = 0; j < box.Length; j++)//go through string { if (box[j].Equals('.')) { if (j + 5 < box.Length && !box[j + 5].Equals('Z')) { output.WriteLine(excel.ReadCellString(i, 2)); //column C } else if (j + 3 == box.Length - 1 && !box[j - 4].Equals('.')) { output.WriteLine(excel.ReadCellString(i, 2)); //column C } } } } output.Flush(); excel.Close(); MessageBox.Show("Volcanics without Zounds added to " + outputPath, "Completed"); } else { MessageBox.Show("Nothing was selected"); } }
public static string BuildZoundsDestroy(string colonyInfo, bool resources, bool defended) { Excel excel = OpenFileAt(11); // build list StringReader reader = new StringReader(colonyInfo); string line; string planetType = null; string coordinates = null; // C string planetName = null; // D string colonyName = null; // E string discoveries = null; // K int research = -1; // J bool[] buildableHolder = new bool[4]; bool zoundsable = false; bool medium = false; bool questionable = false; bool deconstruct = false;// F , G, H, I buildableHolder[0] = zoundsable; buildableHolder[1] = medium; buildableHolder[2] = questionable; buildableHolder[3] = deconstruct; for (int i = 0; i < colonyInfo.Length; i++) { line = reader.ReadLine(); if (line != null) { if (i == 0) { colonyName = line; Console.WriteLine(line); } else if (i == 3) { string[] temp = line.Split(':'); planetType = temp[1]; planetType = RemoveSpaces(planetType); } else if (i == 4) { string[] temp = line.Split(':'); temp = temp[1].Split('('); planetName = temp[0]; coordinates = temp[1]; coordinates = "(" + coordinates; } else if (i == 40) { string[] temp = line.Split('/'); temp[0] = RemoveLetters(temp[0]); temp[0] = RemoveParenthesisColonComma(temp[0]); research = int.Parse(temp[0]); } else if (i >= 41) { discoveries = discoveries + '\n' + line; } } } bool noDuplicate = true; for (int i = 1; i <= excel.ReadCellInt(1, 15); i++) { if (planetName.Equals(excel.ReadCellString(i, 3))) { noDuplicate = false; excel.Close(); return("Duplicate Found"); } } if (research >= 1 && noDuplicate) { buildableHolder = Checkers.Buildable(discoveries, planetType); zoundsable = buildableHolder[0]; medium = buildableHolder[1]; questionable = buildableHolder[2]; deconstruct = buildableHolder[3]; int totalBuilds = excel.ReadCellInt(1, 15); totalBuilds += 1; Console.WriteLine(totalBuilds); //excel.WriteToCell(1, 15, totalBuilds.ToString()); //excel.WriteToCell(totalBuilds, 1, totalBuilds.ToString()); excel.WriteToCell(totalBuilds, 2, coordinates); excel.WriteToCell(totalBuilds, 3, planetName); excel.WriteToCell(totalBuilds, 4, colonyName); excel.WriteToCell(totalBuilds, 5, zoundsable.ToString()); excel.WriteToCell(totalBuilds, 6, medium.ToString()); excel.WriteToCell(totalBuilds, 7, questionable.ToString()); excel.WriteToCell(totalBuilds, 8, deconstruct.ToString()); excel.WriteToCell(totalBuilds, 9, research.ToString()); excel.WriteToCell(totalBuilds, 10, resources.ToString()); excel.WriteToCell(totalBuilds, 11, defended.ToString()); excel.Close(); return("build added"); } else { Console.WriteLine(colonyName + " is Not Finished Researching."); excel.Close(); return(colonyName + " is Not Finished Researching."); } }