-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddTorrentFileForm.cs
More file actions
129 lines (113 loc) · 4.15 KB
/
AddTorrentFileForm.cs
File metadata and controls
129 lines (113 loc) · 4.15 KB
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
using System;
using System.Windows.Forms;
namespace Torrent
{
public partial class AddTorrentFileForm : Form
{
public AddTorrentFileForm()
{
InitializeComponent();
}
public string GetAddTorrentFilePath()
{
return addTorrentFilePathTxt.Text;
}
public string GetSaveFilePath()
{
return saveFilePathTxt.Text;
}
public int GetMaxUploadSpeed()
{
return maxUploadSpeed;
}
public int GetMaxDownloadSpeed()
{
return maxDownloadSpeed;
}
public bool GetUnlimitedDownloadSpeed()
{
return unlimitedDownloadSpeed;
}
public bool GetUnlimitedUploadSpeed()
{
return unlimitedUploadSpeed;
}
int maxUploadSpeed;
int maxDownloadSpeed;
bool unlimitedDownloadSpeed;
bool unlimitedUploadSpeed;
#region Events
private void pAddTorrent_Load(object sender, EventArgs e)
{
addTorrentFilePathTxt.Text = SettingsForm.defaultSettings.defaultTorrentPath;
saveFilePathTxt.Text = SettingsForm.defaultSettings.defaultSavePath;
unlimitedDownloadSpeed = SettingsForm.defaultSettings.unlimitedDownloadSpeed;
unlimitedUploadSpeed = SettingsForm.defaultSettings.unlimitedUploadSpeed;
if (SettingsForm.defaultSettings.unlimitedDownloadSpeed == true)
{
downloadSpeedSelector.Enabled = false;
unlimitedDownSpeedBox.Checked = true;
unlimitedDownSpeedBox.Visible = true;
}
else
downloadSpeedSelector.Value = SettingsForm.defaultSettings.defaultMaxDownloadSpeed;
if (SettingsForm.defaultSettings.unlimitedUploadSpeed == true)
{
uploadSpeedSelector.Enabled = false;
unlimitedUpSpeedBox.Checked = true;
unlimitedUpSpeedBox.Visible = true;
}
else
uploadSpeedSelector.Value = SettingsForm.defaultSettings.defaultMaxUploadSpeed;
}
private void addFileBtn_Click(object sender, EventArgs e)
{
//Opens file browser
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Torrents (*.torrent)|*.torrent|All Files (*.*)|*.*"; //<--- Don't touch this piece of shit filter
ofd.RestoreDirectory = true;
DialogResult dr = ofd.ShowDialog();
string torrentFile = string.Empty;
if (dr == DialogResult.OK)
{
torrentFile = ofd.FileName;
}
addTorrentFilePathTxt.Text = torrentFile;
}
private void saveFolderBtn_Click(object sender, EventArgs e)
{
//Opens file browser
FolderBrowserDialog fbd = new FolderBrowserDialog();
DialogResult dr = fbd.ShowDialog();
string saveFilePath = string.Empty;
if (dr == DialogResult.OK)
{
saveFilePath = fbd.SelectedPath;
}
saveFilePathTxt.Text = saveFilePath;
}
private void unlimitedDownSpeedBox_CheckedChanged(object sender, EventArgs e)
{
if (unlimitedDownSpeedBox.Checked == true)
downloadSpeedSelector.Enabled = false;
else
downloadSpeedSelector.Enabled = true;
}
private void unlimitedUpSpeedBox_CheckedChanged(object sender, EventArgs e)
{
if (unlimitedUpSpeedBox.Checked == true)
uploadSpeedSelector.Enabled = false;
else
uploadSpeedSelector.Enabled = true;
}
private void addTorrentBtn_Click(object sender, EventArgs e)
{
maxUploadSpeed = Convert.ToInt32(uploadSpeedSelector.Value);
maxDownloadSpeed = Convert.ToInt32(downloadSpeedSelector.Value);
unlimitedDownloadSpeed = unlimitedDownSpeedBox.Checked;
unlimitedUploadSpeed = unlimitedUpSpeedBox.Checked;
this.Close();
}
#endregion
}
}