-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainForm.cs
156 lines (130 loc) · 4.78 KB
/
MainForm.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace TorrentCrawler
{
public partial class MainForm : Form
{
private bool anyButtonClicked;
private enum CrawlerFunction {analyzeArchive, analyzeNewest, testingFunctions};
DebugForm debugForm;
public MainForm()
{
InitializeComponent();
anyButtonClicked = false;
debugForm = new DebugForm();
Thread newThread = new Thread(() => Application.Run(debugForm));
newThread.Start();
Program.mainForm = this;
}
private void analyzeKickAssArchive_Click(object sender, EventArgs e)
{
if (!anyButtonClicked)
{
anyButtonClicked = true;
Program.debug("Starting Crawler");
Thread newThread = new Thread(new ParameterizedThreadStart(startAnalyzing));
newThread.Start(CrawlerFunction.analyzeArchive);
}
}
private void AnalyzeNewestButton_MouseClick(object sender, MouseEventArgs e)
{
if (!anyButtonClicked)
{
anyButtonClicked = true;
Program.debug("Starting Crawler");
Thread newThread = new Thread(new ParameterizedThreadStart(startAnalyzing));
newThread.Start(CrawlerFunction.analyzeNewest);
}
}
private void startAnalyzing(Object input)
{
CrawlerFunction crawlerFunction = (CrawlerFunction)input;
Crawler crawler = new Crawler();
Thread newThread = new Thread(crawler.startAnalyzingArchive); // messy
switch (crawlerFunction)
{
case CrawlerFunction.analyzeArchive:
newThread = new Thread(crawler.startAnalyzingArchive);
break;
case CrawlerFunction.analyzeNewest:
newThread = new Thread(crawler.startAnalyzingNewset);
break;
case CrawlerFunction.testingFunctions:
newThread = new Thread(crawler.startTestingFunctions);
break;
}
newThread.Start();
newThread.Join();
anyButtonClicked = false;
}
private void TestButton_MouseClick(object sender, MouseEventArgs e)
{
if (!anyButtonClicked)
{
anyButtonClicked = true;
Program.debug("Testing Crawler Functions");
Thread newThread = new Thread(new ParameterizedThreadStart(startAnalyzing));
newThread.Start(CrawlerFunction.testingFunctions);
}
}
public class ArchiveProgressBarInitializationObject
{
public int maximum;
public int current;
public ArchiveProgressBarInitializationObject(int maximum, int current)
{
this.maximum = maximum;
this.current = current;
}
}
public void initializeArchiveProgressBar(Object o)
{
ArchiveProgressBarInitializationObject init = (ArchiveProgressBarInitializationObject)o;
ArchiveProgressBar.Maximum = init.maximum;
ArchiveProgressBar.Value = init.current;
}
public void stepArchiveProgressBar()
{
ArchiveProgressBar.PerformStep();
}
public void setBlocksCompleted(int count)
{
BlocksCompletedLabel.Text = "Blocks completed until: " + count;
}
public void setInsertedFirstTime(int count)
{
TorrentsInsertedLabel.Text = "Torrents inserted for the first time: " + count;
}
public void setUpdated(int count)
{
TorrentsUpdatedLabel.Text = "Torrents updated: " + count;
}
public void setNotResponding(int count)
{
TorrentsNotRespondingLabel.Text = "Torrents that didn't respond: " + count;
}
public void setTotalTorrents(int count)
{
TotalTorrentsLabel.Text = "Total inspected Torrents: " + count;
}
public void setTimeRunning(TimeSpan time)
{
int seconds = time.Seconds;
int minutes = time.Minutes;
int hours = time.Hours;
int days = time.Days;
TimeLabel.Text = "Time Running: " + days + " days; " + hours + " hours; " + minutes + " minutes; and " + seconds + " seconds";
}
public int startingBlockGetInput()
{
return Decimal.ToInt32(StartingBlockInput.Value);
}
}
}