/
MainForm.cs
1622 lines (1361 loc) · 55 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
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Net;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.IO;
using OpenQA.Selenium;
using System.Threading;
using System.Reflection;
//using AutoItX3Lib;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using Excel_12 = Microsoft.Office.Interop.Excel;
namespace KSTN_Facebook_Tool
{
public partial class MainForm : Form
{
#region SMALL STUFFS
// Disable WebBrowser Sounds
const int FEATURE_DISABLE_NAVIGATION_SOUNDS = 21;
const int SET_FEATURE_ON_PROCESS = 0x00000002;
[DllImport("urlmon.dll")]
[PreserveSig]
[return: MarshalAs(UnmanagedType.Error)]
static extern int CoInternetSetFeatureEnabled(
int FeatureEntry,
[MarshalAs(UnmanagedType.U4)] int dwFlags,
bool fEnable);
static void DisableClickSounds()
{
CoInternetSetFeatureEnabled(
FEATURE_DISABLE_NAVIGATION_SOUNDS,
SET_FEATURE_ON_PROCESS,
true);
}
private const int CS_DROPSHADOW = 0x00020000;
protected override CreateParams CreateParams
{
get
{
CreateParams parameters = base.CreateParams;
if (OSFeature.IsPresent(SystemParameter.DropShadow))
{
parameters.ClassStyle = parameters.ClassStyle | CS_DROPSHADOW;
}
return parameters;
}
}
private void pbClose_MouseHover(object sender, EventArgs e)
{
pbClose.Image = System.Drawing.Bitmap.FromFile("close2.png");
pbClose.BackColor = Color.OrangeRed;
}
private void pbClose_MouseLeave(object sender, EventArgs e)
{
pbClose.Image = System.Drawing.Bitmap.FromFile("close1.png");
pbClose.BackColor = Color.White;
}
private void pbClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void pbMinimize_MouseHover(object sender, EventArgs e)
{
pbMinimize.Image = System.Drawing.Bitmap.FromFile("min2.png");
pbMinimize.BackColor = Color.Silver;
}
private void pbMinimize_MouseLeave(object sender, EventArgs e)
{
pbMinimize.Image = System.Drawing.Bitmap.FromFile("min1.png");
pbMinimize.BackColor = Color.White;
}
private void pbMinimize_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
#endregion
SeleniumControl SE;
//public AutoItX3 autoIt = new AutoItX3();
private String CHAT_URL = "http://ipostfb.com/chatlog.php";
#region GENERAL MAINFORM
public MainForm()
{
InitializeComponent();
DisableClickSounds();
}
private void MainForm_Shown(object sender, EventArgs e)
{
Program.loadingForm = new LoadingForm();
SE = new SeleniumControl();
txtUser.Focus();
txtUser.Text = Properties.Settings.Default.user;
txtPass.Text = Properties.Settings.Default.pass;
cbGroupReload.Checked = Properties.Settings.Default.group_reload;
ChatRefresh();
dgGroups.Rows.Add("Đăng nhập để sử dụng", "", "", 0);
Rectangle rect = dgGroups.GetCellDisplayRectangle(3, -1, true);
rect.Y = 3;
rect.X = rect.Location.X + (rect.Width / 5);
CheckBox checkboxHeader = new CheckBox();
checkboxHeader.Name = "cbGroupHeader";
checkboxHeader.Checked = true;
//datagridview[0, 0].ToolTipText = "sdfsdf";
checkboxHeader.Size = new Size(18, 18);
checkboxHeader.Location = rect.Location;
checkboxHeader.CheckedChanged += new EventHandler(cbGroupHeader_CheckedChanged);
dgGroups.Controls.Add(checkboxHeader);
pbAvatar.ErrorImage = pbAvatar.Image;
txtFanpageSeeder.Text = string.Join("\r\n", Properties.Settings.Default.comments.Split(','));
}
private void cbGroupHeader_CheckedChanged(object sender, EventArgs e)
{
var headerBox = (CheckBox)sender;
var b = headerBox.Checked;
if (dgGroups.Rows.Count == 0) return;
foreach (DataGridViewRow row in dgGroups.Rows)
{
DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells[3];
chk.Value = b ? 1 : 0;
}
groups_to_xml();
}
private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
{
Program.loadingForm.RequestStop();
SE.quit();
}
private void btnLogin_Click(object sender, EventArgs e)
{
if (btnLogin.Text == "Đăng nhập")
{
txtUser.Enabled = false;
txtPass.Enabled = false;
PictureBox loading = new PictureBox();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoadingForm));
loading.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
loading.Size = new System.Drawing.Size(172, 107);
loading.Location = new Point(200, 50);
loading.BackColor = Color.Transparent;
loading.Name = "group_loading_gif";
dgGroups.Controls.Add(loading);
loading.BringToFront();
SE.FBLogin(txtUser.Text, txtPass.Text);
if (cbRemember.Checked)
{
Properties.Settings.Default.user = txtUser.Text;
Properties.Settings.Default.Save();
Properties.Settings.Default.pass = txtPass.Text;
Properties.Settings.Default.Save();
}
else
{
Properties.Settings.Default.user = "";
Properties.Settings.Default.Save();
Properties.Settings.Default.pass = "";
Properties.Settings.Default.Save();
}
}
else
{
if (!SE.ready)
{
MessageBox.Show("Chương trình đang thực hiện 1 tác vụ, không thể đăng xuất!");
return;
}
btnLogin.Enabled = false;
SE.Logout();
}
}
private void lblViewProfile_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start(lblViewProfile.Text);
}
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (TabControl1.SelectedTab == TabControl1.TabPages["tabPageInvite"])
{
dgGroups.Parent = GroupBoxInvite;
dgGroups.Height = 310;
}
else if (TabControl1.SelectedTab == TabControl1.TabPages["tabPagePost"])
{
dgGroups.Parent = groupBox4;
dgGroups.Height = 160;
}
else if (TabControl1.SelectedTab == TabControl1.TabPages["tabPageFanpage"] || TabControl1.SelectedTab == TabControl1.TabPages["tabPageComment"])
{
fanpage_init();
}
else if (TabControl1.SelectedTab == TabControl1.TabPages["tabPageEvents"])
{
events_init();
}
else if (TabControl1.SelectedTab == TabControl1.TabPages["tabPageScraper"])
{
Dictionary<string, string> relationships = new Dictionary<string, string>();
relationships.Add("-- Chọn mối quan hệ --", "");
relationships.Add("Độc thân", "single");
relationships.Add("Đang hẹn hò", "engaged");
relationships.Add("Đã đính hôn", "married");
relationships.Add("Đang có quan hệ kết hợp dân sự", "in-civil-union");
relationships.Add("Đang có quan hệ chung sống", "in-domestic-partnership");
relationships.Add("Đang trong một mối quan hệ mở", "in-open-relationship");
relationships.Add("Có mối quan hệ phức tạp", "its-complicated");
relationships.Add("Đã ly thân", "separated");
relationships.Add("Đã ly hôn", "divorced");
relationships.Add("Góa", "widowed");
cbGraphSearchRelationship.DataSource = new BindingSource(relationships, null);
cbGraphSearchRelationship.DisplayMember = "Key";
cbGraphSearchRelationship.ValueMember = "Value";
Dictionary<string, string> genders = new Dictionary<string, string>();
genders.Add("-- Chọn giới tính --", "");
genders.Add("Nam", "males");
genders.Add("Nữ", "females");
cbGraphSearchGender.DataSource = new BindingSource(genders, null);
cbGraphSearchGender.DisplayMember = "Key";
cbGraphSearchGender.ValueMember = "Value";
Dictionary<string, string> locations = new Dictionary<string, string>();
locations.Add("-- Chọn địa điểm --", "");
locations.Add("Hà Nội", "653678611405322");
locations.Add("Sài Gòn", "108458769184495");
locations.Add("Hải Phòng", "106480866055537");
locations.Add("Đà Nẵng", "108680672485750");
locations.Add("Cần Thơ", "200647606648129");
locations.Add("Huế", "218845041469665");
locations.Add("Bắc Ninh", "218692191496704");
locations.Add("Bắc Giang", "123356831042645");
locations.Add("Bắc Kạn", "203910742994900");
locations.Add("Bà Rịa-Vũng Tàu", "230834780261698");
cbGraphSearchLocation.DataSource = new BindingSource(locations, null);
cbGraphSearchLocation.DisplayMember = "Key";
cbGraphSearchLocation.ValueMember = "Value";
}
}
private void btnToggle_Click(object sender, EventArgs e)
{
if (SE.driver == null)
{
MessageBox.Show("Trình duyệt chưa được khởi tạo!");
btnToggle.Checked = false;
}
else
{
SE.Toggle();
}
}
private void btnPauseAll_Click(object sender, EventArgs e)
{
SE.pause = true;
btnPauseAll.Enabled = false;
}
#endregion
#region TAB AUTOPOST
private void btnBrowse1_Click(object sender, EventArgs e)
{
var fDialog = new System.Windows.Forms.OpenFileDialog();
fDialog.Title = "Open Arial Bitmap File";
fDialog.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png";
//fDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
DialogResult result = fDialog.ShowDialog(); // Show the dialog.
if (result == DialogResult.OK) // Test result.
{
string file = fDialog.FileName;
txtBrowse1.Text = file;
}
else
{
txtBrowse1.Text = "";
}
}
private void btnBrowse2_Click(object sender, EventArgs e)
{
var fDialog = new System.Windows.Forms.OpenFileDialog();
fDialog.Title = "Open Arial Bitmap File";
fDialog.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png";
//fDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
DialogResult result = fDialog.ShowDialog(); // Show the dialog.
if (result == DialogResult.OK) // Test result.
{
string file = fDialog.FileName;
txtBrowse2.Text = file;
}
else
{
txtBrowse2.Text = "";
}
}
private void btnBrowse3_Click(object sender, EventArgs e)
{
var fDialog = new System.Windows.Forms.OpenFileDialog();
fDialog.Title = "Open Arial Bitmap File";
fDialog.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png";
//fDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
DialogResult result = fDialog.ShowDialog(); // Show the dialog.
if (result == DialogResult.OK) // Test result.
{
string file = fDialog.FileName;
txtBrowse3.Text = file;
}
else
{
txtBrowse3.Text = "";
}
}
private void btnPost_Click(object sender, EventArgs e)
{
if (txtBrowse1.Text == "" && txtBrowse2.Text == "" && txtBrowse3.Text == "" && txtContent.Text == "")
{
MessageBox.Show("Điền nội dung trước khi post bài!");
return;
}
int delay;
if (!int.TryParse(txtDelay.Text, out delay) || delay < 0)
{
MessageBox.Show("Số giây Delay: số nguyên không nhỏ hơn 0");
return;
}
if (SE.ready == false)
{
MessageBox.Show("Chương trình đang thực hiện 1 tác vụ khác");
return;
}
btnPost.Enabled = false;
txtContent.Enabled = false;
txtDelay.Enabled = false;
txtBrowse1.Enabled = false;
txtBrowse2.Enabled = false;
txtBrowse3.Enabled = false;
btnBrowse1.Enabled = false;
btnBrowse2.Enabled = false;
btnBrowse3.Enabled = false;
dgGroups.Enabled = false;
SE.AutoPost();
}
private void btnGroupExport_Click(object sender, EventArgs e)
{
SaveFileDialog saveFile = new SaveFileDialog();
saveFile.Filter = "TXT files (*.txt)|*.txt";
saveFile.FileName = "GROUPS.txt";
saveFile.ShowDialog();
using (StreamWriter sw = new StreamWriter(saveFile.FileName, false))
{
if (dgGroups.Rows.Count > 0)
{
foreach (DataGridViewRow row in dgGroups.Rows)
{
sw.WriteLine(SE.RemoveSpecialCharacters(row.Cells[1].Value.ToString()) + "");
}
}
else
{
sw.WriteLine("No group found.");
}
sw.Close();
}
}
private void btnPostResultExport_Click(object sender, EventArgs e)
{
SaveFileDialog saveFile = new SaveFileDialog();
saveFile.Filter = "TXT files (*.txt)|*.txt";
saveFile.FileName = "POSTS.txt";
saveFile.ShowDialog();
using (StreamWriter sw = new StreamWriter(saveFile.FileName, false))
{
if (dgPostResult.Rows.Count > 0)
{
foreach (DataGridViewRow row in dgPostResult.Rows)
{
sw.WriteLine(row.Cells[1].Value + "");
}
}
else
{
sw.WriteLine("Không tìm thấy bài đăng nào cả.");
}
sw.Close();
}
}
private void btnPostClearGroups_Click(object sender, EventArgs e)
{
dgGroups.Rows.Clear();
}
private void cbGroupReload_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.group_reload = cbGroupReload.Checked;
Properties.Settings.Default.Save();
}
private void btnGroupJoinFromFile_Click(object sender, EventArgs e)
{
var fDialog = new System.Windows.Forms.OpenFileDialog();
fDialog.Title = "Open Groups File";
fDialog.Filter = "TXT Files (*.txt) | *.txt";
DialogResult result = fDialog.ShowDialog(); // Show the dialog.
if (result == DialogResult.OK) // Test result.
{
string file = fDialog.FileName;
txtGroupJoinFromFile.Text = file;
MessageBox.Show("Import File có thể gây treo chương trình trong vài giây! Nhấn OK để tiếp tục.");
int counter = 0;
string line;
// Read the file and display it line by line.
System.IO.StreamReader fileStr = new System.IO.StreamReader(file);
while ((line = fileStr.ReadLine()) != null)
{
string[] _line = new string[] { "", line, "" };
dgGroupSearch.Rows.Insert(0, _line);
counter++;
}
fileStr.Close();
MessageBox.Show("Đọc thành công: " + counter + " nhóm");
}
else
{
txtGroupJoinFromFile.Text = "";
}
}
private void btnGroupImport_Click(object sender, EventArgs e)
{
var fDialog = new System.Windows.Forms.OpenFileDialog();
fDialog.Title = "Open Groups File";
fDialog.Filter = "TXT Files (*.txt) | *.txt";
DialogResult result = fDialog.ShowDialog(); // Show the dialog.
if (result == DialogResult.OK) // Test result.
{
string file = fDialog.FileName;
MessageBox.Show("Import File có thể gây treo chương trình trong vài giây! Nhấn OK để tiếp tục.");
int counter = 0;
string line;
// Read the file and display it line by line.
System.IO.StreamReader fileStr = new System.IO.StreamReader(file);
while ((line = fileStr.ReadLine()) != null)
{
string[] _line = new string[] { "", line, "" };
dgGroups.Rows.Insert(0, _line);
counter++;
}
fileStr.Close();
MessageBox.Show("Đọc thành công: " + counter + " nhóm");
}
}
private void btnGroupImportFriends_Click(object sender, EventArgs e)
{
if (!SE.ready)
{
MessageBox.Show("Chương trình đang thực hiện 1 tác vụ khác!");
return;
}
btnGroupImportFriends.Enabled = false;
SE.GroupImportFriends();
}
private void btnPostImportGroups_Click(object sender, EventArgs e)
{
if (SE.ready == false)
{
MessageBox.Show("Chương trình đang thực hiện 1 tác vụ khác");
return;
}
dgGroups.Rows.Clear();
SE.getGroups();
}
public void groups_to_xml()
{
if (SE.user_id == "") return;
try
{
//Create a datatable to store XML data
DataTable dt = new DataTable();
foreach (DataGridViewColumn col in dgGroups.Columns)
{
dt.Columns.Add(col.HeaderText);
}
foreach (DataGridViewRow row in dgGroups.Rows)
{
DataRow dRow = dt.NewRow();
foreach (DataGridViewCell cell in row.Cells)
{
dRow[cell.ColumnIndex] = cell.Value;
}
dt.Rows.Add(dRow);
}
DataSet DS = new DataSet();
DS.Tables.Add(dt);
if (SE.user_id_img != "")
DS.WriteXml(SE.RemoveSpecialCharacters(SE.user_id_img) + "_groups.xml");
}
catch { }
//catch (Exception ex) { MessageBox.Show(ex + ""); }
}
private void dgGroups_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
var senderGrid = (DataGridView)sender;
if (senderGrid.Columns[e.ColumnIndex] is DataGridViewCheckBoxColumn && e.RowIndex >= 0)
{
dgGroups.CommitEdit(DataGridViewDataErrorContexts.Commit);
groups_to_xml();
}
}
#endregion
#region TAB AUTOJOIN
private void btnGroupJoin_Click(object sender, EventArgs e)
{
if (dgGroupSearch.Rows.Count == 0)
{
MessageBox.Show("Chưa có nhóm nào trong List!");
return;
}
if (SE.ready == false)
{
MessageBox.Show("Chương trình đang thực hiện 1 tác vụ khác");
return;
}
int delay;
if (!int.TryParse(txtJoinDelay.Text, out delay) || delay < 0)
{
MessageBox.Show("Số giây Delay: số nguyên không nhỏ hơn 0");
return;
}
btnGroupJoin.Enabled = false;
txtJoinDelay.Enabled = false;
SE.AutoJoin();
}
private void btnGroupSearch_Click(object sender, EventArgs e)
{
if (txtGroupSearch.Text == "")
{
MessageBox.Show("Điền từ khóa tìm kiếm!");
return;
}
int min;
if (!int.TryParse(txtGroupSearchMin.Text, out min))
{
MessageBox.Show("Số lượng thành viên tối thiểu???");
}
if (SE.ready == false)
{
MessageBox.Show("Chương trình đang thực hiện 1 tác vụ khác");
return;
}
txtGroupSearch.Enabled = false;
txtGroupSearchMin.Enabled = false;
btnGroupSearch.Enabled = false;
dgGroupSearch.Rows.Clear();
SE.GroupSearch();
}
#endregion
#region TAB AUTOINVITE
private void btnInvite_Click(object sender, EventArgs e)
{
if (txtInviteName.Text == "")
{
MessageBox.Show("Điền tên muốn mời trước khi bắt đầu Auto!");
return;
}
int delay;
if (!int.TryParse(txtInviteDelay.Text, out delay) || delay < 0)
{
MessageBox.Show("Số giây Delay: số nguyên không nhỏ hơn 0");
return;
}
if (SE.ready == false)
{
MessageBox.Show("Chương trình đang thực hiện 1 tác vụ khác");
return;
}
txtInviteDelay.Enabled = false;
txtInviteName.Enabled = false;
btnInvite.Enabled = false;
SE.AutoInvite();
}
#endregion
#region TAB AUTOCOMMENT
private void btnCommentBrowse_Click(object sender, EventArgs e)
{
dgCommentBrowse.Rows.Clear();
var fDialog = new System.Windows.Forms.OpenFileDialog();
fDialog.Title = "Open Post IDS File";
fDialog.Filter = "TXT Files (*.txt) | *.txt";
DialogResult result = fDialog.ShowDialog(); // Show the dialog.
if (result == DialogResult.OK) // Test result.
{
string file = fDialog.FileName;
txtCommentBrowse.Text = file;
MessageBox.Show("Import File có thể gây treo chương trình trong vài giây! Nhấn OK để tiếp tục.");
int counter = 0;
string line;
// Read the file and display it line by line.
System.IO.StreamReader fileStr = new System.IO.StreamReader(file);
while ((line = fileStr.ReadLine()) != null)
{
dgCommentBrowse.Rows.Insert(0, line);
counter++;
}
fileStr.Close();
MessageBox.Show("Đọc thành công: " + counter + " bài đăng");
}
else
{
txtCommentBrowse.Text = "";
}
}
private void btnCommentImportComment_Click(object sender, EventArgs e)
{
if (SE.ready == false)
{
MessageBox.Show("Chương trình đang thực hiện 1 tác vụ khác");
return;
}
int delay;
if (!int.TryParse(txtCommentDelay.Text, out delay) || delay < 0)
{
MessageBox.Show("Số giây Delay: số nguyên không nhỏ hơn 0");
return;
}
if (txtComment.Text == "")
{
MessageBox.Show("Không được bỏ trống nội dung bình luận");
return;
}
txtComment.Enabled = false;
txtCommentDelay.Enabled = false;
btnCommentBrowse.Enabled = false;
btnCommentImportComment.Enabled = false;
dgCommentBrowse.Enabled = false;
SE.AutoComment2();
}
private void btnCommentScan_Click(object sender, EventArgs e)
{
if (SE.ready == false)
{
MessageBox.Show("Chương trình đang thực hiện 1 tác vụ khác");
return;
}
btnCommentScan.Enabled = false;
SE.AutoCommentScan();
}
#endregion
#region TAB EVENTS
private async void events_init()
{
if (SE.events.Count > 0) return;
await SE.getEvents();
if (SE.events.Count > 0)
{
cbEvents.Items.Clear();
foreach (string event_title in SE.events.Keys)
{
cbEvents.Items.Add(event_title);
}
cbEvents.SelectedIndex = 0;
cbEvents.Enabled = true;
}
else
{
cbEvents.Items.Add("Bạn không có Sự kiện nào cả!");
cbEvents.SelectedIndex = 0;
cbEvents.Enabled = false;
}
}
private void btnEventReload_Click(object sender, EventArgs e)
{
if (SE.ready == false)
{
MessageBox.Show("Chương trình đang thực hiện 1 tác vụ khác");
return;
}
SE.events.Clear();
events_init();
}
private void btnEventInviteFriends_Click(object sender, EventArgs e)
{
if (SE.ready == false)
{
MessageBox.Show("Chương trình đang thực hiện 1 tác vụ khác");
return;
}
btnEventInviteFriends.Enabled = false;
SE.EventsInviteFriends();
}
#endregion
#region TAB PM
private void btnPMImportFriends_Click(object sender, EventArgs e)
{
if (!SE.ready)
{
MessageBox.Show("Chương trình đang thực hiện 1 tác vụ khác!");
return;
}
btnPMImportFriends.Enabled = false;
SE.ImportFriendList();
}
private void btnPMImportGroup_Click(object sender, EventArgs e)
{
if (!SE.ready)
{
MessageBox.Show("Chương trình đang thực hiện 1 tác vụ khác!");
return;
}
if (txtPMImportGroup.Text == "")
{
MessageBox.Show("Điền URL nhóm!");
return;
}
txtPMImportGroup.Enabled = false;
btnPMImportGroup.Enabled = false;
SE.ImportGroupMembers(txtPMImportGroup.Text);
}
private void btnPMImportProfile_Click(object sender, EventArgs e)
{
if (!SE.ready)
{
MessageBox.Show("Chương trình đang thực hiện 1 tác vụ khác!");
return;
}
if (txtPMImportProfile.Text == "")
{
MessageBox.Show("Điền URL Profile!");
return;
}
txtPMImportProfile.Enabled = false;
btnPMImportProfile.Enabled = false;
SE.ImportProfileFriends(txtPMImportProfile.Text);
}
private void btnPMImportFile_Click(object sender, EventArgs e)
{
var fDialog = new System.Windows.Forms.OpenFileDialog();
fDialog.Title = "Open UID File";
fDialog.Filter = "TXT Files (*.txt) | *.txt";
//fDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
DialogResult result = fDialog.ShowDialog(); // Show the dialog.
if (result == DialogResult.OK) // Test result.
{
string file = fDialog.FileName;
txtPMImportFile.Text = file;
MessageBox.Show("Import File có thể gây treo chương trình trong vài giây! Nhấn OK để tiếp tục.");
int counter = 0;
string line;
// Read the file and display it line by line.
System.IO.StreamReader fileStr = new System.IO.StreamReader(file);
while ((line = fileStr.ReadLine()) != null)
{
dgUID.Rows.Insert(0, "", line);
counter++;
}
fileStr.Close();
MessageBox.Show("Đọc thành công: " + counter + " Profile");
}
else
{
txtPMImportFile.Text = "";
}
}
private void btnPMClear_Click(object sender, EventArgs e)
{
dgUID.Rows.Clear();
}
private void btnPMExport_Click(object sender, EventArgs e)
{
SaveFileDialog saveFile = new SaveFileDialog();
saveFile.Filter = "TXT files (*.txt)|*.txt";
saveFile.FileName = "UID.txt";
saveFile.ShowDialog();
using (StreamWriter sw = new StreamWriter(saveFile.FileName, false))
{
if (dgUID.Rows.Count > 0)
{
foreach (DataGridViewRow row in dgUID.Rows)
{
sw.WriteLine(row.Cells[1].Value + "");
}
}
else
{
sw.WriteLine("No group found.");
}
sw.Close();
}
}
private void btnPMExportXLS_Click(object sender, EventArgs e)
{
UIDToCSV(dgUID);
}
public static void ExportDataGridViewTo_Excel12(DataGridView myDataGridViewQuantity)
{
Excel_12.Application oExcel_12 = null; //Excel_12 Application
Excel_12.Workbook oBook = null; // Excel_12 Workbook
Excel_12.Sheets oSheetsColl = null; // Excel_12 Worksheets collection
Excel_12.Worksheet oSheet = null; // Excel_12 Worksheet
Excel_12.Range oRange = null; // Cell or Range in worksheet
Object oMissing = System.Reflection.Missing.Value;
// Create an instance of Excel_12.
oExcel_12 = new Excel_12.Application();
// Make Excel_12 visible to the user.
oExcel_12.Visible = true;
// Set the UserControl property so Excel_12 won't shut down.
oExcel_12.UserControl = true;
// System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US");
//object file = File_Name;
//object missing = System.Reflection.Missing.Value;
// Add a workbook.
oBook = oExcel_12.Workbooks.Add(oMissing);
// Get worksheets collection
oSheetsColl = oExcel_12.Worksheets;
// Get Worksheet "Sheet1"
oSheet = (Excel_12.Worksheet)oSheetsColl.get_Item("Sheet1");
oSheet.Name = "Danh sách UID";
// Export titles
for (int j = 0; j < myDataGridViewQuantity.Columns.Count; j++)
{
oRange = (Excel_12.Range)oSheet.Cells[1, j + 1];
oRange.Value2 = myDataGridViewQuantity.Columns[j].HeaderText;
}
// Export data
for (int i = 0; i < myDataGridViewQuantity.Rows.Count; i++)
{
for (int j = 0; j < myDataGridViewQuantity.Columns.Count; j++)
{
oRange = (Excel_12.Range)oSheet.Cells[i + 2, j + 1];
try
{
oRange.Value2 = myDataGridViewQuantity[j, i].Value;
}
catch { }