-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetUsersControl.cs
259 lines (216 loc) · 8.78 KB
/
GetUsersControl.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using System.IO;
using System.Text.RegularExpressions;
namespace Retweet_Done
{
public partial class GetUsersControl : UserControl
{
String path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/Motab3 Company/Retweet Swap/";
public GetUsersControl()
{
InitializeComponent();
}
private void getlistbtn_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(url.Text))
{
msg.Visible = true;
msg.Text = "يرجى وضع رابط القائمة المراد سحبها";
log.Visible = true;
log.Text = "يجري الان التعرف على القائمة ...";
}
else
if (url.Text.StartsWith(@"https://twitter.com"))
{
weblist.Navigate(new Uri(url.Text + "/members"));
msg.Visible = true; msg.Text = "يجري العمل الان";
url.Enabled = false;
getlistbtn.Enabled = false;
stopbtn.Enabled = true;
}
else { msg.Visible = true; msg.Text = "يرجى وضع رابط القائمة المراد سحبها بشكل صحيح"; }
}
private void weblist_DocumentCompleted_1(object sender, WebBrowserDocumentCompletedEventArgs e)
{
get.Start();
}
private void get_Tick_1(object sender, EventArgs e)
{
}
private void bunifuFlatButton3_Click_1(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(uerslist.Text))
{
MessageBox.Show("لا يوجد حسابات لحفظها !");
}
else
{
XmlTextWriter writer = new XmlTextWriter(path + "/lists/" + listname.Text + ".xml", Encoding.UTF8);
writer.WriteStartDocument();
writer.WriteStartElement("SAVED");
writer.WriteStartElement("TITLE");
writer.WriteEndElement(); //TITLE
foreach (string item in uerslist.Items)
{
writer.WriteStartElement("ITEM");
writer.WriteString(item);
writer.WriteEndElement(); //ITEM
}
writer.WriteEndElement(); //SAVED
writer.WriteEndDocument();
writer.Close();
uerslist.Items.Clear();
listname.Text = "";
string[] files = Directory.GetFiles(path + "lists/", "*.xml", SearchOption.AllDirectories);
var namesOnly = files.Select(f => Path.GetFileNameWithoutExtension(f)).ToArray();
label3.Text = "0";
MessageBox.Show("تم الحفظ بنجاح");
msg.Text = "تم الحفظ بنجاح";
}
}
private void stopbtn_Click(object sender, EventArgs e)
{
get.Stop();
getmore.Stop();
url.Enabled = true;
getlistbtn.Enabled = true;
stopbtn.Enabled = false;
}
private void bunifuFlatButton2_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(uerslist.Text))
{
msg.Visible = true;
msg.Text = "حدد عنصر لحذفه";
MessageBox.Show("حدد عنصر لحذفه !");
}
else
{
object item = uerslist.SelectedItem;
uerslist.Items.Remove(item);
}
}
private void bunifuFlatButton4_Click(object sender, EventArgs e)
{
DialogResult dialogResult = MessageBox.Show("سوف تخسر جميع البيانات ، هل انت متأكد ؟ ", "!انتبه", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
uerslist.Items.Clear();
}
else if (dialogResult == DialogResult.No)
{
}
}
private void getmore_Tick(object sender, EventArgs e)
{
getmore.Stop();
Point scrollPoint = new Point(50, 100000);
weblist.Document.Window.ScrollTo(scrollPoint);
get.Start();
}
private void url_Click(object sender, EventArgs e)
{
if (url.Text == "ضع هنا رابط القائمة") { url.Text = ""; }
}
private void listname_Click(object sender, EventArgs e)
{
if (listname.Text == "ضع اسم القائمة هنا") { listname.Text = ""; }
}
private void get_Tick(object sender, EventArgs e)
{
get.Stop();
uerslist.Items.Clear();
foreach (HtmlElement el in weblist.Document.GetElementsByTagName("ul"))
if (el.GetAttribute("className") == "stats")
{
numb.Text = el.InnerText;
string usernumber = el.InnerText;
int indexOfSteam = usernumber.IndexOf("Subscribers");
if (indexOfSteam >= 0)
{
usernumber = usernumber.Remove(indexOfSteam);
usernumber = Regex.Replace(usernumber, "[^0-9]+", string.Empty);
cp2.MaxValue = Convert.ToInt32(usernumber);
}
}
foreach (HtmlElement el in weblist.Document.GetElementsByTagName("div"))
if (el.GetAttribute("className") == "account js-actionable-user js-profile-popup-actionable ")
{
uerslist.Items.Add(el.GetAttribute("data-screen-name"));
// label10.Visible = false;
label3.Text = uerslist.Items.Count.ToString();
uerslist.SelectedIndex = 0;
cp2.Value = uerslist.Items.Count;
if (uerslist.Items.Count == cp2.MaxValue)
{
get.Stop();
getmore.Stop();
url.Enabled = true;
getlistbtn.Enabled = true;
stopbtn.Enabled = false;
msg.Text = "تم جلب القائمة بشكل كامل";
}
else { getmore.Start(); }
}
else
{
int n = Convert.ToInt32(cp2.MaxValue);
if (n == 0)
{
msg.Text = "هناك خطأ ما لا توجد نتيجة!";
url.Enabled = true;
getlistbtn.Enabled = true;
stopbtn.Enabled = false;
}
}
}
private void GetUsersControl_Load(object sender, EventArgs e)
{
Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Motab3 Company"));
Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/Motab3 Company/", "Retweet Swap", "lists"));
}
private void bunifuImageButton2_Click(object sender, EventArgs e)
{
this.Hide();
}
private void getlistbtnb_Click(object sender, EventArgs e)
{
OpenFileDialog f = new OpenFileDialog();
if (f.ShowDialog() == DialogResult.OK)
{
uerslist.Items.Clear();
List<string> lines = new List<string>();
using (StreamReader r = new StreamReader(f.OpenFile()))
{
string line;
while ((line = r.ReadLine()) != null)
{
uerslist.Items.Add(line);
uerslist.SelectedIndex = 0;
}
}
}
}
private void bunifuFlatButton1_Click(object sender, EventArgs e)
{
var saveFile = new SaveFileDialog();
saveFile.Filter = "Text (*.txt)|*.txt";
if (saveFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
using (var sw = new StreamWriter(saveFile.FileName, false))
foreach (var item in uerslist.Items)
sw.Write(item.ToString() + Environment.NewLine);
MessageBox.Show("تم الحفظ بنجاح");
}
}
}
}