-
Notifications
You must be signed in to change notification settings - Fork 0
/
PluginUI.cs
1765 lines (1642 loc) · 64.8 KB
/
PluginUI.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
/*
* Created by IAP.
* User: Itzik Arzoni (itzikiap@nana.co.il)
* Date: 13/12/2005
* Time: 21:43
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.ComponentModel;
using System.Text.RegularExpressions;
using WeifenLuo.WinFormsUI;
using ScintillaNet;
using System.Windows.Forms;
using System.Collections;
using System.Text;
using System.Diagnostics;
using System.Collections.Generic;
using PluginCore;
using PluginCore.Managers;
using System.Drawing;
using FlashDevelop;
using WeifenLuo.WinFormsUI.Docking;
namespace FindReplaceEx
{
/// <summary>
/// Description of PluginUI.
/// </summary>
public class PluginUI : System.Windows.Forms.DockPanelControl
{
private System.ComponentModel.IContainer components;
// reference to the plugin interface
private PluginMain plugin;
private string lastPath;
private bool replaceShown;
private ComboBox findTxt;
private ToolTip toolTip;
private TabControl tabControl;
private TabPage optionsPage;
private CheckBox autoFeedChk;
private CheckBox autoChk;
private CheckBox openFilesChk;
private TabPage replacePage;
private Label resultsLbl;
private Button switchFindReplaceBtn;
private TextBox replaceTxt;
private Button replaceBtn;
private Button copyFindReplaceBtn;
private Button clearReplaceTxt;
private Button ofrBtn;
private TabPage filterPage;
private ComboBox filterTxt;
private Button regexHelpBtn;
private TabPage foldersPage;
private TextBox fileMaskTxt;
private CheckBox searchSubfoldersChk;
private Button browseBtn;
private ComboBox folderTxt;
private CheckBox folderFilesChk;
private RadioButton checkNoneRdo;
private RadioButton checkcCustomeRdo;
private RadioButton checkFileRdo;
private RadioButton checkSelectonRdo;
private RadioButton checkFilterRdo;
private RadioButton checkAllRdo;
private ColumnHeader at;
private ListView resultsLst;
private FolderBrowserDialog fileBrowserDlg;
private CheckBox regexpChk;
private CheckBox wholeWordChk;
private CheckBox matchCaseChk;
private ColumnHeader result;
private ColumnHeader filename;
private ColumnHeader mark;
private TabPage operationsPage;
private Button deleteBtn;
private Button bookmarkBtn;
private Button clearFilterBtn;
private CheckBox regExReplaceChk;
private Button CopyResultsBtn;
private ListViewItem currentItem;
private bool toolTipShow;
private Splitter splitter;
private Panel optionsPanel;
private bool inReplace;
private FlowLayoutPanel filterRadioFlow;
private FlowLayoutPanel findChkFlow;
private FlowLayoutPanel replacePageFlow;
private FlowLayoutPanel filterPageFlow;
private FlowLayoutPanel foldersPageFlow;
private FlowLayoutPanel operationsPageFlow;
// private bool classPathRoot;
public PluginUI(PluginMain pluginMain)
{
InitializeComponent();
// reference to the plugin interface
this.plugin = pluginMain;
toolTip.Active = true;
// switchFindReplaceBtn.Image = plugin.MainForm.GetSystemImage(10);
//resultsPanel = plugin.MainForm.FindPlugin("24df7cd8-e5f0-4171-86eb-7b2a577703ba");
}
#region Windows Forms Designer generated code
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
this.findTxt = new System.Windows.Forms.ComboBox();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.checkNoneRdo = new System.Windows.Forms.RadioButton();
this.checkcCustomeRdo = new System.Windows.Forms.RadioButton();
this.checkFileRdo = new System.Windows.Forms.RadioButton();
this.checkSelectonRdo = new System.Windows.Forms.RadioButton();
this.checkFilterRdo = new System.Windows.Forms.RadioButton();
this.folderFilesChk = new System.Windows.Forms.CheckBox();
this.browseBtn = new System.Windows.Forms.Button();
this.searchSubfoldersChk = new System.Windows.Forms.CheckBox();
this.fileMaskTxt = new System.Windows.Forms.TextBox();
this.openFilesChk = new System.Windows.Forms.CheckBox();
this.autoChk = new System.Windows.Forms.CheckBox();
this.autoFeedChk = new System.Windows.Forms.CheckBox();
this.checkAllRdo = new System.Windows.Forms.RadioButton();
this.regexHelpBtn = new System.Windows.Forms.Button();
this.regexpChk = new System.Windows.Forms.CheckBox();
this.wholeWordChk = new System.Windows.Forms.CheckBox();
this.matchCaseChk = new System.Windows.Forms.CheckBox();
this.ofrBtn = new System.Windows.Forms.Button();
this.clearReplaceTxt = new System.Windows.Forms.Button();
this.copyFindReplaceBtn = new System.Windows.Forms.Button();
this.replaceBtn = new System.Windows.Forms.Button();
this.switchFindReplaceBtn = new System.Windows.Forms.Button();
this.bookmarkBtn = new System.Windows.Forms.Button();
this.deleteBtn = new System.Windows.Forms.Button();
this.regExReplaceChk = new System.Windows.Forms.CheckBox();
this.tabControl = new System.Windows.Forms.TabControl();
this.optionsPage = new System.Windows.Forms.TabPage();
this.replacePage = new System.Windows.Forms.TabPage();
this.replaceTxt = new System.Windows.Forms.TextBox();
this.filterPage = new System.Windows.Forms.TabPage();
this.filterTxt = new System.Windows.Forms.ComboBox();
this.clearFilterBtn = new System.Windows.Forms.Button();
this.foldersPage = new System.Windows.Forms.TabPage();
this.folderTxt = new System.Windows.Forms.ComboBox();
this.operationsPage = new System.Windows.Forms.TabPage();
this.CopyResultsBtn = new System.Windows.Forms.Button();
this.resultsLbl = new System.Windows.Forms.Label();
this.at = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.resultsLst = new System.Windows.Forms.ListView();
this.mark = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.result = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.filename = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.fileBrowserDlg = new System.Windows.Forms.FolderBrowserDialog();
this.splitter = new Splitter();
this.optionsPanel = new Panel();
this.filterRadioFlow = new FlowLayoutPanel();
this.findChkFlow = new FlowLayoutPanel();
this.replacePageFlow = new FlowLayoutPanel();
this.filterPageFlow = new FlowLayoutPanel();
this.foldersPageFlow = new FlowLayoutPanel();
this.operationsPageFlow = new FlowLayoutPanel();
this.tabControl.SuspendLayout();
this.optionsPage.SuspendLayout();
this.replacePage.SuspendLayout();
this.filterPage.SuspendLayout();
this.foldersPage.SuspendLayout();
this.operationsPage.SuspendLayout();
this.filterRadioFlow.SuspendLayout();
this.findChkFlow.SuspendLayout();
this.replacePageFlow.SuspendLayout();
this.filterPageFlow.SuspendLayout();
this.foldersPageFlow.SuspendLayout();
this.operationsPageFlow.SuspendLayout();
this.SuspendLayout();
this.hideLeftSide();
//
// findTxt
//
this.findTxt.Name = "findTxt";
this.findTxt.Dock = DockStyle.Top;
this.findTxt.SelectedValueChanged += new System.EventHandler(this.selectedItemFindTxt);
this.findTxt.TextChanged += new System.EventHandler(this.FindTxtTextChanged);
this.findTxt.KeyDown += new System.Windows.Forms.KeyEventHandler(this.keyDownHandler);
//
// resultsLbl
//
this.resultsLbl.Name = "resultsLbl";
this.resultsLbl.Text = "----";
this.resultsLbl.AutoSize = true;
//
// checkNoneRdo
//
this.checkNoneRdo.Name = "checkNoneRdo";
this.checkNoneRdo.Text = "None";
this.checkNoneRdo.AutoSize = true;
this.toolTip.SetToolTip(this.checkNoneRdo, "Uncheck all the entries to not replace");
this.checkNoneRdo.CheckedChanged += new System.EventHandler(this.CheckRdoCheckedChanged);
//
// checkcCustomeRdo
//
this.checkcCustomeRdo.Name = "checkcCustomeRdo";
this.checkcCustomeRdo.Text = "Custome";
this.checkcCustomeRdo.AutoSize = true;
this.toolTip.SetToolTip(this.checkcCustomeRdo, "Default for manually checked entries.");
this.checkcCustomeRdo.CheckedChanged += new System.EventHandler(this.CheckRdoCheckedChanged);
//
// checkFileRdo
//
this.checkFileRdo.Checked = true;
this.checkFileRdo.Name = "checkFileRdo";
this.checkFileRdo.Text = "File";
this.checkFileRdo.AutoSize = true;
this.toolTip.SetToolTip(this.checkFileRdo, "Check all the entries of the current file. (Same as All if \"search all opened fil" + "es\" is unchecked)");
this.checkFileRdo.CheckedChanged += new System.EventHandler(this.CheckRdoCheckedChanged);
//
// checkSelectonRdo
//
this.checkSelectonRdo.Name = "checkSelectonRdo";
this.checkSelectonRdo.Text = "Selection";
this.checkSelectonRdo.AutoSize = true;
this.toolTip.SetToolTip(this.checkSelectonRdo, "Check all the checkboxes that inside the selection.");
this.checkSelectonRdo.CheckedChanged += new System.EventHandler(this.CheckRdoCheckedChanged);
//
// checkFilterRdo
//
this.checkFilterRdo.Name = "checkFilterRdo";
this.checkFilterRdo.Text = "Filter";
this.checkFilterRdo.AutoSize = true;
this.toolTip.SetToolTip(this.checkFilterRdo, "Check the entries that match the filter string");
this.checkFilterRdo.CheckedChanged += new System.EventHandler(this.CheckRdoCheckedChanged);
//
// checkAllRdo
//
this.checkAllRdo.Name = "checkAllRdo";
this.checkAllRdo.Text = "All";
this.checkAllRdo.AutoSize = true;
this.toolTip.SetToolTip(this.checkAllRdo, "Check all the entries to replace");
this.checkAllRdo.CheckedChanged += new System.EventHandler(this.CheckRdoCheckedChanged);
//
// flowLayPan
//
this.filterRadioFlow.AutoSize = true;
this.filterRadioFlow.Controls.Add(this.resultsLbl);
this.filterRadioFlow.SetFlowBreak(this.resultsLbl, true);
this.filterRadioFlow.Controls.Add(checkNoneRdo);
this.filterRadioFlow.Controls.Add(checkcCustomeRdo);
this.filterRadioFlow.Controls.Add(checkFileRdo);
this.filterRadioFlow.Controls.Add(checkSelectonRdo);
this.filterRadioFlow.Controls.Add(checkFilterRdo);
this.filterRadioFlow.Controls.Add(checkAllRdo);
this.filterRadioFlow.FlowDirection = FlowDirection.LeftToRight;
this.filterRadioFlow.Dock = DockStyle.Bottom;
this.ResumeLayout();
//
// folderFilesChk
//
this.folderFilesChk.Name = "folderFilesChk";
this.folderFilesChk.Text = "All Files in Folder";
this.folderFilesChk.ThreeState = true;
this.folderFilesChk.AutoSize = true;
this.toolTip.SetToolTip(this.folderFilesChk, "Check this to set the next search to be in alll files in the above directory.");
this.folderFilesChk.CheckStateChanged += new System.EventHandler(this.FolderFilesChkCheckedStateChanged);
//
// browseBtn
//
this.browseBtn.Name = "browseBtn";
this.browseBtn.Text = "Browse...";
this.browseBtn.AutoSize = true;
this.toolTip.SetToolTip(this.browseBtn, "Browse for a folder to search in.");
this.browseBtn.Click += new System.EventHandler(this.BrowseBtnClick);
//
// searchSubfoldersChk
//
this.searchSubfoldersChk.CheckState = System.Windows.Forms.CheckState.Checked;
this.searchSubfoldersChk.Name = "searchSubfoldersChk";
this.searchSubfoldersChk.Text = "Subfolders";
this.searchSubfoldersChk.AutoSize = true;
this.toolTip.SetToolTip(this.searchSubfoldersChk, "Also search in subfolders.");
this.searchSubfoldersChk.CheckedChanged += new System.EventHandler(this.FolderFilesChkCheckedStateChanged);
//
// fileMaskTxt
//
this.fileMaskTxt.Name = "fileMaskTxt";
this.toolTip.SetToolTip(this.fileMaskTxt, "Specify the file mask to search in.");
//
// openFilesChk
//
this.openFilesChk.CheckState = System.Windows.Forms.CheckState.Checked;
this.openFilesChk.Name = "openFilesChk";
this.openFilesChk.Dock = DockStyle.Top;
this.openFilesChk.Text = "All Opened Files";
this.openFilesChk.AutoSize = true;
this.toolTip.SetToolTip(this.openFilesChk, "Show the reslts from all opened files.");
this.openFilesChk.CheckedChanged += new System.EventHandler(this.OptionsChkCheckedChanged);
//
// autoChk
//
this.autoChk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.autoChk.CheckState = System.Windows.Forms.CheckState.Checked;
this.autoChk.Name = "autoChk";
this.autoChk.Dock = DockStyle.Top;
this.autoChk.Text = "Automatic find";
this.autoChk.AutoSize = true;
this.toolTip.SetToolTip(this.autoChk, "List results immediately while typing in the find box.");
//
// autoFeedChk
//
this.autoFeedChk.CheckState = System.Windows.Forms.CheckState.Checked;
this.autoFeedChk.Name = "autoFeedChk";
this.autoFeedChk.Dock = DockStyle.Top;
this.autoFeedChk.Text = "Update as you type";
this.autoFeedChk.AutoSize = true;
this.toolTip.SetToolTip(this.autoFeedChk, "Update the find box when typing in the editor");
//
// regexHelpBtn
//
this.regexHelpBtn.Name = "regexHelpBtn";
this.regexHelpBtn.Text = "?";
this.regexHelpBtn.AutoSize = true;
this.toolTip.SetToolTip(this.regexHelpBtn, "Help about regular expressions");
this.regexHelpBtn.Click += new System.EventHandler(this.RegexHelpBtnClick);
//
// regexpChk
//
this.regexpChk.Name = "regexpChk";
this.regexpChk.Text = "RegEx";
this.regexpChk.AutoSize = true;
this.toolTip.SetToolTip(this.regexpChk, "Threat the find text as Regular Expression");
this.regexpChk.CheckedChanged += new System.EventHandler(this.regexpChk_CheckedChanged);
//
// wholeWordChk
//
this.wholeWordChk.Name = "wholeWordChk";
this.wholeWordChk.Text = "Whole Word";
this.wholeWordChk.AutoSize = true;
this.toolTip.SetToolTip(this.wholeWordChk, "Search for whole word only");
//
// matchCaseChk
//
this.matchCaseChk.Name = "matchCaseChk";
this.matchCaseChk.Text = "Match Case";
this.matchCaseChk.AutoSize = true;
this.toolTip.SetToolTip(this.matchCaseChk, "Ignore the case OF cHaraCtERs");
//
// ofrBtn
//
this.ofrBtn.Name = "ofrBtn";
this.ofrBtn.Text = "Open Files && Search ";
this.ofrBtn.AutoSize = true;
this.toolTip.SetToolTip(this.ofrBtn, "Open all the files in the results list and redo he search");
this.ofrBtn.Click += new System.EventHandler(this.OfrBtnClick);
//
// button1
//
this.clearReplaceTxt.Name = "button1";
this.clearReplaceTxt.Text = "Clear";
this.clearReplaceTxt.AutoSize = true;
this.toolTip.SetToolTip(this.clearReplaceTxt, "Clear the text from the find box");
this.clearReplaceTxt.Click += new System.EventHandler(this.clearReplaceTxtClick);
//
// copyFindReplaceBtn
//
this.copyFindReplaceBtn.Name = "copyFindReplaceBtn";
this.copyFindReplaceBtn.Text = "Copy";
this.copyFindReplaceBtn.AutoSize = true;
this.toolTip.SetToolTip(this.copyFindReplaceBtn, "Copies the text from the find box");
this.copyFindReplaceBtn.Click += new System.EventHandler(this.copyFindReplaceBtnClick);
//
// replaceBtn
//
this.replaceBtn.Name = "replaceBtn";
this.replaceBtn.Text = "Replace";
this.replaceBtn.AutoSize = true;
this.toolTip.SetToolTip(this.replaceBtn, "Replace the selected text in all the checked entries");
this.replaceBtn.Click += new System.EventHandler(this.ReplaceBtnClick);
//
// switchFindReplaceBtn
//
this.switchFindReplaceBtn.Name = "switchFindReplaceBtn";
this.switchFindReplaceBtn.Text = "Switch";
this.switchFindReplaceBtn.AutoSize = true;
this.toolTip.SetToolTip(this.switchFindReplaceBtn, "Switches the text between find and replace");
this.switchFindReplaceBtn.Click += new System.EventHandler(this.SwtchFindReplaceBtnClick);
//
// bookmarkBtn
//
this.bookmarkBtn.Name = "bookmarkBtn";
this.bookmarkBtn.Text = "Bookmark";
this.bookmarkBtn.AutoSize = true;
this.toolTip.SetToolTip(this.bookmarkBtn, "Bookmark all the selected items");
this.bookmarkBtn.Click += new System.EventHandler(this.bookmarkBtn_Click);
//
// deleteBtn
//
this.deleteBtn.Name = "deleteBtn";
this.deleteBtn.Text = "Delete";
this.deleteBtn.AutoSize = true;
this.toolTip.SetToolTip(this.deleteBtn, "Delete all selected line");
this.deleteBtn.Click += new System.EventHandler(this.deleteBtn_Click);
//
// regExReplaceChk
//
this.regExReplaceChk.Name = "regExReplaceChk";
this.regExReplaceChk.Text = "RegEx replace";
this.regExReplaceChk.AutoSize = true;
this.toolTip.SetToolTip(this.regExReplaceChk, "If checked, you can use searched groups from the match in your replace. \\n Write " +
"$1 to insert the text from the first group, and so on.");
//
// replacePageFlow
//
this.replacePageFlow.Controls.Add(this.replaceTxt);
this.replacePageFlow.Controls.Add(this.replaceBtn);
this.replacePageFlow.SetFlowBreak(this.replaceBtn, true);
this.replacePageFlow.Controls.Add(this.switchFindReplaceBtn);
this.replacePageFlow.Controls.Add(this.copyFindReplaceBtn);
this.replacePageFlow.Controls.Add(this.clearReplaceTxt);
this.replacePageFlow.Controls.Add(this.ofrBtn);
this.replacePageFlow.Controls.Add(this.regExReplaceChk);
this.replacePageFlow.Dock = DockStyle.Top;
this.replacePageFlow.AutoSize = true;
//
// tabControl
//
this.tabControl.Controls.Add(this.optionsPage);
this.tabControl.Controls.Add(this.replacePage);
this.tabControl.Controls.Add(this.filterPage);
this.tabControl.Controls.Add(this.foldersPage);
this.tabControl.Controls.Add(this.operationsPage);
this.tabControl.Name = "tabControl";
this.tabControl.SelectedIndex = 0;
this.tabControl.Dock = DockStyle.Fill;
this.tabControl.SelectedIndexChanged += new System.EventHandler(this.TabControlSelectedIndexChanged);
//
// optionsPage
//
this.optionsPage.Controls.Add(this.autoFeedChk);
this.optionsPage.Controls.Add(this.autoChk);
this.optionsPage.Controls.Add(this.openFilesChk);
this.optionsPage.Name = "optionsPage";
this.optionsPage.Text = "Options";
//
// replacePage
//
this.replacePage.Controls.Add(this.replacePageFlow);
this.replacePage.Name = "replacePage";
this.replacePage.Text = "Replace";
//
// replaceTxt
//
this.replaceTxt.Name = "replaceTxt";
this.replaceTxt.Text = "@FIND";
this.replaceTxt.AutoSize = true;
this.replaceTxt.KeyDown += new System.Windows.Forms.KeyEventHandler(this.keyDownHandler);
//
// filterPageFlow
//
this.filterPageFlow.Controls.Add(this.filterTxt);
this.filterPageFlow.SetFlowBreak(this.filterTxt, true);
this.filterPageFlow.Controls.Add(this.regexHelpBtn);
this.filterPageFlow.Controls.Add(this.clearFilterBtn);
this.filterPageFlow.Dock = DockStyle.Top;
//
// filterPage
//
this.filterPage.Controls.Add(this.filterPageFlow);
this.filterPage.Name = "filterPage";
this.filterPage.Text = "Filter";
//
// filterTxt
//
this.filterTxt.Items.AddRange(new object[] {
"",
"(import|new)\\s*[\\w\\.]*@FIND[\\.;]",
"(function|var)\\s*\\w*\\s*:\\s*@FIND\\s*[;\\(]"});
this.filterTxt.Name = "filterTxt";
this.filterTxt.TextChanged += new System.EventHandler(this.FilterTxtTextChanged);
//
// clearFilterBtn
//
this.clearFilterBtn.Name = "clearFilterBtn";
this.clearFilterBtn.Text = "X";
this.clearFilterBtn.AutoSize = true;
this.clearFilterBtn.Click += new System.EventHandler(this.clearFilterBtn_Click);
//
// foldersPageFlow
//
this.foldersPageFlow.Controls.Add(this.folderTxt);
this.foldersPageFlow.Controls.Add(this.browseBtn);
this.foldersPageFlow.SetFlowBreak(this.browseBtn, true);
this.foldersPageFlow.Controls.Add(this.folderFilesChk);
this.foldersPageFlow.Controls.Add(this.searchSubfoldersChk);
this.foldersPageFlow.Controls.Add(this.fileMaskTxt);
this.foldersPageFlow.Name = "foldersPageFlow";
this.foldersPageFlow.Dock = DockStyle.Top;
//
// foldersPage
//
this.foldersPage.Controls.Add(this.foldersPageFlow);
this.foldersPage.Name = "foldersPage";
this.foldersPage.Text = "Folders";
//
// folderTxt
//
this.folderTxt.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.folderTxt.Name = "folderTxt";
this.folderTxt.DrawMode = DrawMode.OwnerDrawFixed;
this.folderTxt.DrawItem += folderTxt_DrawItem;
this.folderTxt.DropDownClosed += folderTxt_DropDownClosed;
this.folderTxt.SelectedIndexChanged += new System.EventHandler(this.FolderTxtSelectedIndexChanged);
//
// operationsPageFlow
//
this.operationsPageFlow.Controls.Add(this.CopyResultsBtn);
this.operationsPageFlow.Controls.Add(this.deleteBtn);
this.operationsPageFlow.Controls.Add(this.bookmarkBtn);
this.operationsPageFlow.Dock = DockStyle.Top;
this.operationsPageFlow.Name = "operationsPageFlow";
//
// operationsPage
//
this.operationsPage.Controls.Add(this.operationsPageFlow);
this.operationsPage.Name = "operationsPage";
this.operationsPage.Text = "Operations";
//
// CopyResultsBtn
//
this.CopyResultsBtn.Name = "CopyResultsBtn";
this.CopyResultsBtn.Text = "Copy To Results";
this.CopyResultsBtn.AutoSize = true;
this.CopyResultsBtn.Click += new System.EventHandler(this.CopyResultsBtn_Click);
//
// at
//
this.at.Text = "@";
this.at.Width = -1;
//
// splitter
//
this.splitter.SplitterMoved += splitter_SplitterMoved;
//
// resultsLst
//
this.resultsLst.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.mark,
this.at,
this.result,
this.filename});
this.resultsLst.FullRowSelect = true;
this.resultsLst.GridLines = true;
this.resultsLst.LabelWrap = false;
this.resultsLst.AutoSize = true;
this.resultsLst.Dock = DockStyle.Fill;
this.resultsLst.Name = "resultsLst";
this.resultsLst.View = System.Windows.Forms.View.Details;
this.resultsLst.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.ResultsLstItemCheck);
this.resultsLst.SelectedIndexChanged += new System.EventHandler(this.resultsLst_SelectedIndexChanged);
this.resultsLst.Click += new System.EventHandler(this.ResultsLstClick);
this.resultsLst.DoubleClick += new System.EventHandler(this.ResultsLstDoubleClick);
this.resultsLst.MouseLeave += new System.EventHandler(this.resultsLst_MouseLeave);
this.resultsLst.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ResultsLstMouseMove);
this.resultsLst.SizeChanged += new EventHandler(this.ResultsLst_SizeChanged);
//
// mark
//
this.mark.Text = "";
this.mark.Width = -1;
//
// result
//
this.result.Text = "Result Line";
this.result.Width = -1;
//
// filename
//
this.filename.Text = "File Name";
this.filename.Width = -1;
//
// findChkCont
//
this.findChkFlow.Controls.Add(this.matchCaseChk);
this.findChkFlow.Controls.Add(this.wholeWordChk);
this.findChkFlow.Controls.Add(this.regexpChk);
this.findChkFlow.Name = "findChkCont";
this.findChkFlow.Dock = DockStyle.Top;
this.findChkFlow.Text = "Find";
this.findChkFlow.AutoSize = true;
//
// optionsPanel
//
this.optionsPanel.Controls.Add(tabControl);
this.optionsPanel.Controls.Add(findChkFlow);
this.optionsPanel.Controls.Add(findTxt);
this.optionsPanel.Controls.Add(filterRadioFlow);
this.optionsPanel.Size = new Size(375,200);
//
// PluginUI
//
this.BackColor = System.Drawing.SystemColors.Control;
this.Controls.AddRange(new Control[] { this.resultsLst, this.splitter,this.optionsPanel });
this.Name = "PluginUI";
splitter_SplitterMoved(null, null);
this.tabControl.ResumeLayout(false);
this.optionsPage.ResumeLayout(false);
this.replacePage.ResumeLayout(false);
this.replacePage.PerformLayout();
this.filterPage.ResumeLayout(false);
this.foldersPage.ResumeLayout(false);
this.foldersPage.PerformLayout();
this.operationsPage.ResumeLayout(false);
this.filterRadioFlow.ResumeLayout();
this.findChkFlow.ResumeLayout();
this.replacePageFlow.ResumeLayout();
this.filterPageFlow.ResumeLayout();
this.foldersPageFlow.ResumeLayout();
this.operationsPageFlow.ResumeLayout();
this.ResumeLayout(false);
}
private void splitter_SplitterMoved(object sender, SplitterEventArgs e)
{
this.folderTxt.Width = tabControl.Width - this.browseBtn.Width - 20;
this.filterTxt.Width = tabControl.Width - 20;
this.replaceTxt.Width = tabControl.Width - replaceBtn.Width - 20;
}
#endregion
#region settings and updates
/// <summary>
/// udate the selected settings
/// </summary>
/// <param name="settingsObject"></param>
public void UpdateSettings(Settings settingsObject)
{
autoFeedChk.Checked = settingsObject.FeedAsYouType;
autoChk.Checked = settingsObject.FindAsYouType;
//resizeToFit = resize;
ChangeFilterPresets(settingsObject.FilterPresets);
if (settingsObject.SearchHistoryLimit == 0)
{
settingsObject.SearchHistoryLimit = 10;
settingsObject.ResizeOptionsTab = true;
settingsObject.ResizeReplaceTab = false;
settingsObject.ResizeFilterTab = false;
settingsObject.ResizeFoldersTab = true;
settingsObject.ResizeOperationsTab = true;
}
findTxt.MaxDropDownItems = settingsObject.SearchHistoryLimit;
resultsLst.ShowGroups = settingsObject.GroupByFile;
}
/// <summary>
/// update the class paths list for the find in folder
/// </summary>
/// <param name="classPaths">new class paths</param>
public void UpdateFolderClassPaths(string[] classPaths)
{
string[] presets = classPaths;
folderTxt.BeginUpdate();
folderTxt.Items.Clear();
foreach (string itemTxt in presets)
{
folderTxt.Items.Add(itemTxt);
}
folderTxt.Text = presets[0];
lastPath = presets[0];
folderTxt.EndUpdate();
}
/// <summary>
/// show or hide the folder tab
/// </summary>
/// <param name="flag">show or hide</param>
private void ShowFolderMode(bool flag)
{
if (flag)
{
ShowReplaceMode(false);
plugin.UpdateProjectClassPaths();
if (folderFilesChk.CheckState == CheckState.Unchecked)
{
folderFilesChk.CheckState = CheckState.Checked;
}
}
else if (folderFilesChk.CheckState != CheckState.Indeterminate)
{
folderFilesChk.CheckState = CheckState.Unchecked;
}
}
/// <summary>
/// handle with focus
/// </summary>
public void PluginUI_FocusHandle(object sender, EventArgs e)
{
if (PluginBase.MainForm.DockPanel.ActiveContent == this.plugin.Panel)
{
revealLeftSide();
findTxt.Focus();
}
else
{
if (sender == null)
{
this.plugin.Panel.Show();
revealLeftSide();
this.ShowReplace = true;
this.replaceTxt.Focus();
}
else
{
Settings settingsObject = this.plugin.Settings as Settings;
if ((tabControl.SelectedTab == optionsPage && settingsObject.ResizeOptionsTab) || (tabControl.SelectedTab == replacePage && settingsObject.ResizeReplaceTab) || (tabControl.SelectedTab == filterPage && settingsObject.ResizeFilterTab) || (tabControl.SelectedTab == foldersPage && settingsObject.ResizeFoldersTab) || (tabControl.SelectedTab == operationsPage && settingsObject.ResizeOperationsTab))
{
tabControl.SelectedTab = optionsPage;
hideLeftSide();
}
}
}
}
/// <summary>
/// Stops the parse timer if not enabled.
/// </summary>
public void Terminate()
{
}
#endregion
#region Find Code
/// <summary>
/// set the text in the find box
/// </summary>
/// <param name="newText">new text</param>
public void SetFindText(string newText)
{
SetFindText(newText, false);
}
/// <summary>
/// Set the text in the find box, no matter what are the settings
/// </summary>
/// <param name="newText">new text</param>
/// <param name="force">true to force change it</param>
public void SetFindText(string newText, bool force)
{
if ((autoFeedChk.Checked) || force)
{
if (ShowReplace)
{
replaceTxt.Text = newText;
}
else
{
findTxt.Text = newText;
}
}
}
///<summary>
///lists all the results in the list box
///given a results object
///</summary>
public void ListAllResults(FindResults results)
{
resultsLst.BeginUpdate();
resultsLst.Items.Clear();
resultsLst.Groups.Clear();
FindMatch match = results.FirstResult();
String file = "";
ListViewGroup gr = null;
while (match != null)
{
if (file != match.FileName)
{
file = match.FileName;
gr = new ListViewGroup(file, HorizontalAlignment.Left);
gr.Name = file;
gr.Header = file;
this.resultsLst.Groups.Add(gr);
}
AddMatchToGroup(gr, match);
match = results.NextResult();
}
// if (resultsLst.Items.Count > 0)
// resultsLst.EnsureVisible(resultsLst.Items.Count-1);
CheckListItems();
this.mark.Width = -1;
this.at.Width = -1;
this.filename.Width = -1;
resultsLst.EndUpdate();
}
private void startSearch()
{
bool itemExists = false;
foreach (string cbi in findTxt.Items)
{
itemExists = cbi == findTxt.Text;
if (itemExists) break;
}
if (!itemExists)
findTxt.Items.Add(findTxt.Text);
ListAllFindText(findTxt.Text, 1);
}
///<summary>
/// Finds a text in open document, or all open documents and list it.
/// using text in find input box
/// </summary>
public void ListAllFindText()
{
ListAllFindText(findTxt.Text);
}
/// <summary>
/// Finds a text in open document, or all open documents and list it
/// </summary>
/// <param name="Text">text to find</param>
public void ListAllFindText(string Text)
{
ListAllFindText(Text, (plugin.Settings as Settings).IgnoreBelow);
}
/// <summary>
/// Finds a text in open document, or all open documents and list it
/// </summary>
/// <param name="Text">text to find</param>
/// <param name="minChars">characters threshold</param>
public void ListAllFindText(string Text, int minChars)
{
if (Text.Length >= minChars)
{
resultsLst.Tag = folderFilesChk.Checked ? "V": "X";
DefaultReplaceCheck();
FindResults results;
if ((folderFilesChk.CheckState == CheckState.Checked || folderFilesChk.CheckState == CheckState.Indeterminate) && tabControl.SelectedTab == foldersPage)
{
results = plugin.GetFindInFolderResultsList(Text, folderTxt.Text, fileMaskTxt.Text, searchSubfoldersChk.Checked);
if (folderFilesChk.CheckState == CheckState.Checked)
{
folderFilesChk.CheckState = CheckState.Unchecked;
}
}
else if (openFilesChk.Checked)
{
results = plugin.GetAllDocumentsResultsList(Text);
}
else
{
results = plugin.GetResultsList(Text);
}
resultsLst.Columns[2].Text = Text;
ListAllResults(results);
}
}
/// <summary>
/// adds a match item to a list group
/// </summary>
/// <param name="gr">a group</param>
/// <param name="match">the match to add to the group</param>
private void AddMatchToGroup(ListViewGroup gr, FindMatch match)
{
ListViewItem item = getListItemFromMatch(match);
item.Group = gr;
gr.Items.Add(item);
AddItemToList(item);
}
/// <summary>
/// Add a list view item to the list
/// </summary>
/// <param name="item">A list view item to add</param>
private void AddItemToList(ListViewItem item)
{
this.resultsLst.Items.Add(item);
}
/// <summary>
/// Add a match item to the list
/// </summary>
/// <param name="m">A match item</param>
public void AddMatchToList(FindMatch m)
{
AddItemToList(getListItemFromMatch(m));
}
/// <summary>
/// create a list item that represnts a match
/// </summary>
/// <param name="m"></param>
/// <returns></returns>
private ListViewItem getListItemFromMatch(FindMatch m)
{
string first = " ";
if (m.FileName == plugin.CurFile)
first = ">";
ListViewItem item = new ListViewItem(first, 0);
item.Tag = m;
item.SubItems.Add("" + (m.Line + 1));
item.SubItems.Add(m.LineText.Trim());
item.SubItems.Add(m.FileName.Substring(m.FileName.LastIndexOf("\\") + 1));
return item;
}
/// <summary>
/// Sets the flag of "find as you type"
/// </summary>
/// <param name="val">New value</param>
public void SetFindAsYouType(bool val)
{
autoChk.Checked = val;
}
#endregion
#region Replace code
/// <summary>
/// check the list items that need to be checked according to the settings
/// </summary>
private void CheckListItems()
{
if (!inReplace)
{
try
{
string curFile = plugin.CurFile;
string filterText = filterTxt.Tag as string;
foreach (ListViewItem item in resultsLst.Items)
{
FindMatch m = item.Tag as FindMatch;
if (checkAllRdo.Checked)
{
item.Checked = true;
}
else if (checkNoneRdo.Checked)
{
item.Checked = false;
}
else if (checkFileRdo.Checked)
{
item.Checked = (m.FileName == curFile);
}
else if (checkSelectonRdo.Checked)
{
int selStaert = m.Scintilla.SelectionStart;
int selEnd = m.Scintilla.SelectionEnd;
bool inRange = m.Position > selStaert & m.Position < selEnd;
item.Checked = (m.FileName == curFile) & inRange;
}
else if (checkFilterRdo.Checked)
{
item.Checked = IsMatchInItem(item, 2, filterText);
}
HilightItem(item, item.Checked);
}
UpdateStatusBar();
}
catch
{
checkNoneRdo.Checked = true;
}
}
}
/// <summary>
/// called when a selection was changed
/// </summary>
public void SelectionChanged()
{
SelectionChanged(true);
}
/// <summary>
/// Called when a selection is changed in the scientilla
/// </summary>
/// <param name="flag">Is there or isn't there a selection</param>
public void SelectionChanged(bool flag)
{