-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
77 lines (67 loc) · 2.21 KB
/
Form1.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
using System;
using System.Windows.Forms;
namespace CssScraper
{
public partial class Form1 : Form
{
private HTMLClassExtractor scrapper;
public Form1()
{
InitializeComponent();
Init();
}
private void Init()
{
scrapper = new HTMLClassExtractor();
}
private void BrowseBtn_Click(object sender, EventArgs e)
{
FileDialog fd = new OpenFileDialog();
fd.ShowDialog();
userFilePath.Text = fd.FileName.ToString();
}
private void ScrapeBtn_Click(object sender, EventArgs e)
{
if (userFilePath.Text.ToString() != "")
{
scrapper.setInputFile(userFilePath.Text);
resultsTextBox.ResetText();
wordsCount.Text += scrapper.ExtractClasses().Count.ToString();
foreach (string words in scrapper.ExtractClasses())
{
resultsTextBox.Text += (words + "\n");
}
}
else
{
MessageBox.Show("Error : Please select the html file first.", "Error");
}
}
private void DiscardBtn_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void SaveBtn_Click(object sender, EventArgs e)
{
if (resultsTextBox.Text.ToString() != "")
{
FileDialog fd = new SaveFileDialog();
fd.ShowDialog();
string saveFilePath = fd.FileName.ToString();
try
{
System.IO.File.WriteAllText(saveFilePath, resultsTextBox.Text);
MessageBox.Show("Succes : Succesfuly created the file.", "Succes");
}
catch (Exception exc)
{
MessageBox.Show("Error : " + exc.Message, "Error");
}
}
else
{
MessageBox.Show("Error : Please scrap the classes first.", "Error");
}
}
}
}