private void Form2_Load(object sender, EventArgs e) { Random rnd = new Random(); int RandomFactNum = rnd.Next(0, RandomFactList.FactArray.Length); BlackListView = treeView1; RandomFactText.Text = RandomFactList.FactArray[RandomFactNum]; WebMethods.XmlReader(); }
private void RemoveFromBlacklist(object sender, MouseEventArgs e) { TreeNode treeNode = BlackListView.SelectedNode; if (BlackListView.SelectedNode.Tag == null) { WebMethods.XmlRemove(treeNode).ContinueWith(res => { if (res.Result) { BlackListView.Invoke(new Action(() => BlackListView.Nodes.Remove(treeNode))); } }); } else { MessageBox.Show("You cannot remove a category!"); } }
private async void Button1_Click(object sender, EventArgs e) { string site = blacklistSiteTextBox.Text; string category = selectedCategory.Text; string tagName = tagNameInput.Text; await Database.BlacklistWebsiteAsync(tagName, category, site).ContinueWith(task => { string result = task.Result; bool res = Boolean.Parse(result.ToString()); if (res) { MessageBox.Show("You Blacklisted '" + site + "' under the category " + category); tagNameInput.Invoke(new Action(() => tagNameInput.Text = "Enter TagName Here")); blacklistSiteTextBox.Invoke(new Action(() => blacklistSiteTextBox.Text = "Enter URL Here")); } else { MessageBox.Show("An error occurred, '" + site + "' was not added to the blacklist."); } }); WebMethods.XmlReader(); }