This repository has been archived by the owner on Aug 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form2.cs
123 lines (115 loc) · 5.33 KB
/
Form2.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using System.Collections.Specialized;
namespace PopupFinderGui
{
public partial class Form2 : Form
{
public static string[] websites = { "youtube", "facebook", "gmail", "google", "microsoft", "twitter", "wikipedia", "amazon", "instagram", "reddit", "ebay", "netflix", "apple", "walmart", "yahoo", "nytimes", "aol", "bing", "fandom", "imdb", "yelp", "craigslist", "healthline", "tripadvisor", "linkedin", "homedepot", "quora", "roblox", "zillow", "paypal" };
public static string[] extensions = { ".cc", ".pro", ".biz", ".eu", ".ru", ".info", ".uk", ".de", ".ga", ".online", ".xyz", ".org", ".net", ".com" };
public static bool gorp = false;
public static int guesses = 1000;
public static int popups = 20;
public static double timeout = 1;
public static bool nonum = false;
public Form2()
{
InitializeComponent();
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
textBox2.Enabled = true;
textBox1.Enabled = false;
}
else
{
textBox2.Enabled = false;
textBox1.Enabled = true;
}
}
private void Form2_Load(object sender, EventArgs e)
{
richTextBox1.Lines = websites;
richTextBox2.Lines = extensions;
textBox1.Text = guesses.ToString();
textBox2.Text = popups.ToString();
textBox3.Text = timeout.ToString();
checkBox1.Checked = gorp;
checkBox2.Checked = nonum;
}
private void button1_Click(object sender, EventArgs e)
{
button1.Text = "Saving...";
button1.Enabled = false;
websites = richTextBox1.Lines;
extensions = richTextBox2.Lines;
guesses = int.Parse(textBox1.Text);
popups = int.Parse(textBox2.Text);
timeout = int.Parse(textBox3.Text);
gorp = checkBox1.Checked;
nonum = checkBox2.Checked;
var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var settings = configFile.AppSettings.Settings;
settings.Add("websites", arraytostring(websites));
settings.Add("extensions", arraytostring(extensions));
settings.Add("guesses", Convert.ToString(guesses));
settings.Add("popups", Convert.ToString(popups));
settings.Add("timeout", Convert.ToString(timeout));
settings.Add("gorp", Convert.ToString(gorp));
settings.Add("nonum", Convert.ToString(nonum));
configFile.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
this.Hide();
button1.Enabled = true;
button1.Text = "Save!";
}
private void button2_Click(object sender, EventArgs e)
{
var appSettings = ConfigurationManager.AppSettings;
richTextBox1.Text = appSettings["websites"] ?? "Not Found";
richTextBox2.Text = appSettings["extensions"] ?? "Not Found";
textBox1.Text = appSettings["guesses"] ?? "Not Found";
textBox2.Text = appSettings["popups"] ?? "Not Found";
textBox3.Text = appSettings["timeout"] ?? "Not Found";
checkBox1.Checked = Convert.ToBoolean(appSettings["gorp"] ?? "false");
checkBox2.Checked = Convert.ToBoolean(appSettings["nonum"] ?? "false");
}
private string arraytostring(string[] array)
{
StringBuilder sb = new StringBuilder();
foreach (string s in array)
{
sb.Append($"{s}\n");
}
return sb.ToString();
}
private void button3_Click(object sender, EventArgs e)
{
var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var settings = configFile.AppSettings.Settings;
settings.Clear();
configFile.Save();
ConfigurationManager.RefreshSection("appSettings");
string[] websites2 = { "youtube", "facebook", "gmail", "google", "microsoft", "twitter", "wikipedia", "amazon", "instagram", "reddit", "ebay", "netflix", "apple", "walmart", "yahoo", "nytimes", "aol", "bing", "fandom", "imdb", "yelp", "craigslist", "healthline", "tripadvisor", "linkedin", "homedepot", "quora", "roblox", "zillow", "paypal" };
richTextBox1.Text = arraytostring(websites2);
string[] extensions2 = { ".cc", ".pro", ".biz", ".eu", ".ru", ".info", ".uk", ".de", ".ga", ".online", ".xyz", ".org", ".net", ".com" };
richTextBox2.Text = arraytostring(extensions2);
textBox1.Text = "1000";
textBox2.Text = "20";
textBox3.Text = "1";
checkBox1.Checked = false;
checkBox2.Checked = false;
this.Refresh();
}
}
}