-
Notifications
You must be signed in to change notification settings - Fork 3
/
bulkAdd.cs
96 lines (87 loc) · 2.78 KB
/
bulkAdd.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ALL_LEGIT
{
public partial class bulkAdd : Form
{
public bulkAdd()
{
InitializeComponent();
this.TopMost = true;
}
private void bulkAddBox_KeyDown(object sender, KeyEventArgs e)
{
}
private void cancelBulkAdd_Click(object sender, EventArgs e)
{
this.Hide();
bulkAddBox.Clear();
}
private void BulkAddConfirm_Click(object sender, EventArgs e)
{
string lineList = "";
if (bulkAddBox.Text.Trim().Length > 0)
{
bool first = true;
foreach (var line in bulkAddBox.Text.Split('\n'))
{
if (!first && !line.EndsWith("\n"))
lineList += "\n";
if (first)
first = false;
lineList += line.Trim();
}
Clipboard.Clear();
Program.form.DoAsyncConversion(lineList);
bulkAddBox.Clear();
this.Hide();
}
else
{
MessageBox.Show("Add lines to bulk add box or click cancel!");
}
}
private void bulkAddBox_Enter(object sender, EventArgs e)
{
if (bulkAddBox.Text.Contains("Paste multiple magnets/DDL links seperated by NEW LINES to add them all at once!"))
{
bulkAddBox.Clear();
}
}
private void bulkAddBox_TextChanged(object sender, EventArgs e)
{
if (bulkAddBox.Text.EndsWith("\n") || bulkAddBox.Text.Trim().Length == 0 || bulkAddBox.Text.EndsWith("\n\n"))
{
return;
}
bulkAddBox.AppendText("\n");
bulkAddBox.SelectionStart = bulkAddBox.Text.Length;
bulkAddBox.SelectionLength = 0;
int count = 0;
foreach (string line in bulkAddBox.Text.Split('\n'))
{
if (line.Equals(Clipboard.GetText()))
{
count++;
}
}
if (count > 1)
{
string newtext = "";
newtext = bulkAddBox.Text.Replace(Clipboard.GetText() + "\n", "");
newtext += $"{Clipboard.GetText()}\n";
bulkAddBox.Text = newtext;
bulkAddBox.SelectionStart = bulkAddBox.Text.Length;
bulkAddBox.SelectionLength = 0;
}
}
}
}