private async void btnAdd_Click(object sender, EventArgs e) { AddFarm dialog = new AddFarm(); var result = await dialog.ShowForm(null); if (result != DialogResult.Cancel) { refresh(); } }
public override async Task <TaskRes> Execute(Account acc) { var wb = acc.Wb.Driver; await acc.Wb.Navigate($"{acc.AccInfo.ServerUrl}/spieler.php?uid=1"); var vills = acc.Wb.Html.GetElementbyId("villages").Descendants("tr"); int addedFarms = 0; foreach (var vill in vills) { var name = vill.ChildNodes.First(x => x.HasClass("name")).InnerText; var pop = (int)Parser.RemoveNonNumeric(vill.Descendants().First(x => x.HasClass("inhabitants")).InnerHtml); if (pop > MinPop && pop < MaxPop) { var href = vill.Descendants("a").First(x => x.GetAttributeValue("href", "").StartsWith("karte.php?x=")).GetAttributeValue("href", "").Split('?')[1]; var xy = href.Split('&'); Coordinates coords = new Coordinates { x = (int)Parser.RemoveNonNumeric(xy[0].Split('=')[1]), y = (int)Parser.RemoveNonNumeric(xy[1].Split('=')[1]) }; var task = new AddFarm() { Coordinates = coords, ExecuteAt = DateTime.Now.AddMilliseconds(addedFarms), FarmListId = this.FL.Id, Troops = new List <TroopsRaw>() { new TroopsRaw() { Type = 1, Number = 10 } } //just add 10 of 1st troops }; TaskExecutor.AddTask(acc, task); addedFarms++; if (FL.NumOfFarms + addedFarms >= 100) { break; //no more slots FL slots! } } } return(TaskRes.Executed); }
private async void btnEditSelected_Click(object sender, EventArgs e) { AddFarm dialog = new AddFarm(); DataGridViewRow row = null; if (dataGridFarms.SelectedRows.Count > 0) { row = dataGridFarms.SelectedRows[0]; FarmEntity doc = (FarmEntity)row.DataBoundItem; var result = await dialog.ShowForm(doc); if (result != DialogResult.Cancel) { refresh(); } } else { MessageBox.Show("Please select a row to edit."); } }