0:   //  ReplaceDialog.cs
1:   //  Copyright (C) 2000 Mike Krueger
2:   //
3:   //  This program is free software; you can redistribute it and/or modify
4:   //  it under the terms of the GNU General Public License as published by
5:   //  the Free Software Foundation; either version 2 of the License, or
6:   //  (at your option) any later version.
7:   //
8:   //  This program is distributed in the hope that it will be useful,
9:   //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10:   //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11:   //  GNU General Public License for more details.
12:   //
13:   //  You should have received a copy of the GNU General Public License
14:   //  along with this program; if not, write to the Free Software
15:   //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16:  
17:   using System;
18:   using System.Drawing;
19:   using System.ComponentModel;
20:   using System.Windows.Forms;
21:  
22:   using SharpDevelop.Gui;
23:   using SharpDevelop.Internal.Text;
24:   using SharpDevelop.Internal.Text.Search;
25:   using SharpDevelop.Tool.Data;
26:  
27:   namespace SharpDevelop.Gui.Dialogs {
28:       
29:       public class ReplaceDialog : System.Windows.Forms.Form {
30:           
31:           private System.ComponentModel.Container components;
32:           private System.Windows.Forms.Button button6;
33:           private System.Windows.Forms.Button button5;
34:           private System.Windows.Forms.Label label3;
35:           private System.Windows.Forms.ComboBox comboBox1;
36:           private System.Windows.Forms.RadioButton radioButton2;
37:           private System.Windows.Forms.RadioButton radioButton1;
38:           private System.Windows.Forms.GroupBox groupBox1;
39:           private System.Windows.Forms.Label label2;
40:           private System.Windows.Forms.ComboBox OptionCombo;
41:           private System.Windows.Forms.CheckBox checkBox3;
42:           private System.Windows.Forms.CheckBox checkBox2;
43:           private System.Windows.Forms.CheckBox checkBox1;
44:           private System.Windows.Forms.Button button4;
45:           private System.Windows.Forms.Button button3;
46:           private System.Windows.Forms.Button button1;
47:           private System.Windows.Forms.ComboBox FindComboBox;
48:           private System.Windows.Forms.Label label1;
49:           
50:           private MainWindow main;
51:           
52:           public ReplaceDialog(MainWindow main)
53:           {
54:               InitializeComponent();
55:               
56:               Find.Main main;
57:               this.main main;
58:               
59:               button1.Click += new System.EventHandler(ClickFind);
60:               button5.Click += new System.EventHandler(ClickReplace);
61:               button6.Click += new System.EventHandler(ClickReplaceAll);
62:               button3.Click += new System.EventHandler(Close);
63:               
64:               CancelButton button3;
65:               MaximizeBox  MinimizeBox false;
66:               FormBorderStyle FormBorderStyle.FixedDialog;
67:                   
68:               ShowInTaskbar false;
69:               Owner main;
70:               StartPosition FormStartPosition.CenterParent;
71:               Icon null;
72:               Show();
73:               FindComboBox.Focus();
74:           }
75:           
76:           /// <summary>
77:           /// Clean up any resources being used.
78:           /// </summary>
79:           protected override void Dispose(bool disposing)
80:           {
81:               if (disposing) {
82:                   if (components != null){
83:                       components.Dispose();
84:                   }
85:               }
86:               base.Dispose(disposing);
87:           }
88:           
89:           protected override void OnClosing(CancelEventArgs e)
90:           {
91:               main.Select();
92:               base.OnClosing(e);
93:           }
94:           
95:           private void InitializeComponent()
96:           {
97:               this.components new System.ComponentModel.Container();
98:               this.comboBox1 new System.Windows.Forms.ComboBox();
99:               this.button1 new System.Windows.Forms.Button();
100:               this.button5 new System.Windows.Forms.Button();
101:               this.button6 new System.Windows.Forms.Button();
102:               this.radioButton1 new System.Windows.Forms.RadioButton();
103:               this.radioButton2 new System.Windows.Forms.RadioButton();
104:               this.button3 new System.Windows.Forms.Button();
105:               this.FindComboBox new System.Windows.Forms.ComboBox();
106:               this.button4 new System.Windows.Forms.Button();
107:               this.checkBox3 new System.Windows.Forms.CheckBox();
108:               this.checkBox2 new System.Windows.Forms.CheckBox();
109:               this.checkBox1 new System.Windows.Forms.CheckBox();
110:               this.label1 new System.Windows.Forms.Label();
111:               this.OptionCombo new System.Windows.Forms.ComboBox();
112:               this.groupBox1 new System.Windows.Forms.GroupBox();
113:               this.label2 new System.Windows.Forms.Label();
114:               this.label3 new System.Windows.Forms.Label();
115:               
116:               comboBox1.Text "";
117:               comboBox1.Location new System.Drawing.Point(9537);
118:               comboBox1.Size new System.Drawing.Size(26421);
119:               comboBox1.TabIndex 2;
120:               
121:               int buttonX    364;
122:               int buttonSize 108;
123:               button1.Location new System.Drawing.Point(buttonX8);
124:               button1.Size new System.Drawing.Size(buttonSize24);
125:               button1.TabIndex 12;
126:               button1.Text Resource.GetString("Dialog.NewProject.SearchReplace.FindNextButton");
127:               
128:               button3.Location new System.Drawing.Point(buttonX104);
129:               button3.Size new System.Drawing.Size(buttonSize24);
130:               button3.TabIndex 15;
131:               button3.Text Resource.GetString("Global.CloseButtonText");
132:               
133:               button4.Location new System.Drawing.Point(buttonX152);
134:               button4.Size new System.Drawing.Size(buttonSize24);
135:               button4.TabIndex 16;
136:               button4.Text Resource.GetString("Global.HelpButtonText");
137:               
138:               button5.Location new System.Drawing.Point(buttonX40);
139:               button5.Size new System.Drawing.Size(buttonSize24);
140:               button5.TabIndex 13;
141:               button5.Text Resource.GetString("Dialog.NewProject.SearchReplace.ReplaceButton");
142:               
143:               button6.Location new System.Drawing.Point(buttonX72);
144:               button6.Size new System.Drawing.Size(buttonSize24);
145:               button6.TabIndex 14;
146:               button6.Text Resource.GetString("Dialog.NewProject.SearchReplace.ReplaceAllButton");
147:               
148:               radioButton1.Location new System.Drawing.Point(816);
149:               radioButton1.Size new System.Drawing.Size(6416);
150:               radioButton1.TabIndex 0;
151:               radioButton1.Text Resource.GetString("Dialog.NewProject.SearchReplace.Up");
152:               radioButton1.Checked true;
153:               
154:               radioButton2.Location new System.Drawing.Point(6416);
155:               radioButton2.Size new System.Drawing.Size(6416);
156:               radioButton2.TabIndex 1;
157:               radioButton2.Text Resource.GetString("Dialog.NewProject.SearchReplace.Down");
158:               
159:               FindComboBox.Text "";
160:               FindComboBox.Location new System.Drawing.Point(9512);
161:               FindComboBox.Size new System.Drawing.Size(26421);
162:               FindComboBox.TabIndex 1;
163:               
164:               checkBox3.Location new System.Drawing.Point(23142);
165:               checkBox3.Text Resource.GetString("Dialog.NewProject.SearchReplace.WrapEnd");
166:               checkBox3.Size new System.Drawing.Size(11225);
167:               checkBox3.Checked true;
168:   //            checkBox3.AccessibleRole = System.Windows.Forms.AccessibleRoles.CheckButton;
169:               checkBox3.TabIndex 8;
170:               checkBox3.TextAlign System.Drawing.ContentAlignment.MiddleLeft;
171:               
172:               checkBox2.Location new System.Drawing.Point(23118);
173:               checkBox2.Text Resource.GetString("Dialog.NewProject.SearchReplace.WholeWord");
174:               checkBox2.Size new System.Drawing.Size(11225);
175:   //            checkBox2.AccessibleRole = System.Windows.Forms.AccessibleRoles.CheckButton;
176:               checkBox2.TabIndex 7;
177:               checkBox2.TextAlign System.Drawing.ContentAlignment.MiddleLeft;
178:               
179:               this.AutoScaleBaseSize new System.Drawing.Size(513);
180:               this.Text Resource.GetString("Dialog.NewProject.SearchReplace.ReplaceDialogName");
181:               
182:               //@design this.TrayLargeIcon = true;
183:               //@design this.TrayHeight = 0;
184:   //            this.TopMost = true;
185:               this.ClientSize new System.Drawing.Size(434 42183);
186:               
187:               checkBox1.Location new System.Drawing.Point(2394);
188:               checkBox1.Text Resource.GetString("Dialog.NewProject.SearchReplace.CaseSensitive");
189:               checkBox1.Size new System.Drawing.Size(11225);
190:       //        checkBox1.AccessibleRole = System.Windows.Forms.AccessibleRoles.CheckButton;
191:               checkBox1.TabIndex 6;
192:               checkBox1.TextAlign System.Drawing.ContentAlignment.MiddleLeft;
193:               
194:               label1.Location new System.Drawing.Point(216);
195:               label1.Text Resource.GetString("Dialog.NewProject.SearchReplace.FindWhat");
196:               label1.Size new System.Drawing.Size(7412);
197:               label1.TabIndex 0;
198:               
199:               OptionCombo.Text "";
200:               OptionCombo.Location new System.Drawing.Point(20891);
201:               OptionCombo.Size new System.Drawing.Size(14421);
202:   //            OptionCombo.Style = System.Windows.Forms.ComboBoxStyle.DropDownList;
203:               OptionCombo.TabIndex 9;
204:               OptionCombo.Items.Add(Resource.GetString("Global.Location.currentfile"));
205:               OptionCombo.Items.Add(Resource.GetString("Global.Location.allopenfiles"));
206:               OptionCombo.Items.Add(Resource.GetString("Global.Location.wholeproject"));
207:  
208:               OptionCombo.SelectedIndex 0;
209:               groupBox1.Location new System.Drawing.Point(175118);
210:               groupBox1.TabIndex 11;
211:               groupBox1.TabStop false;
212:               groupBox1.Text Resource.GetString("Dialog.NewProject.SearchReplace.DirectionText");
213:               groupBox1.Size new System.Drawing.Size(13440);
214:               
215:               label2.Location new System.Drawing.Point(14894);
216:               label2.Text Resource.GetString("Dialog.NewProject.SearchReplace.SearchIn");
217:               label2.Size new System.Drawing.Size(6014);
218:               label2.TabIndex 10;
219:               
220:               label3.Location new System.Drawing.Point(240);
221:               label3.Text Resource.GetString("Dialog.NewProject.SearchReplace.ReplaceWith");
222:               
223:               label3.Size new System.Drawing.Size(7414);
224:               label3.TabIndex 13;
225:               
226:               this.Controls.Add(button6);
227:               this.Controls.Add(button5);
228:               this.Controls.Add(label3);
229:               this.Controls.Add(comboBox1);
230:   //            this.Controls.Add(groupBox1);
231:               this.Controls.Add(label2);
232:               this.Controls.Add(OptionCombo);
233:               this.Controls.Add(checkBox3);
234:               this.Controls.Add(checkBox2);
235:               this.Controls.Add(checkBox1);
236:               this.Controls.Add(button4);
237:               this.Controls.Add(button3);
238:               this.Controls.Add(button1);
239:               this.Controls.Add(FindComboBox);
240:               this.Controls.Add(label1);
241:               groupBox1.Controls.Add(radioButton2);
242:               groupBox1.Controls.Add(radioButton1);
243:               
244:           }
245:           
246:           private void Close(object senderSystem.EventArgs e)
247:           {
248:               Close();
249:           }
250:           
251:           private void SetFind()
252:           {
253:               Find.search.BigOnly    = !checkBox1.Checked;
254:               Find.search.What       FindComboBox.Text;
255:               Find.search.WholeWords checkBox2.Checked;
256:               Find.WrapAtTheEnd      checkBox3.Checked;
257:           }
258:           
259:           void SetUpReplace()
260:           {
261:               Find find null;
262:               
263:               switch (OptionCombo.SelectedIndex){
264:                   case 0:
265:                       find new FindInBuffer();
266:                   break;
267:                   case 1:
268:                       find new FindInAllOpenFiles();
269:                   break;
270:                   case 2
271:                       find new FindInWholeProject();
272:                   break;
273:               }
274:               
275:               Find.search.BigOnly    = !checkBox1.Checked;
276:               Find.search.What       FindComboBox.Text;
277:               Find.search.WholeWords checkBox2.Checked;
278:               Find.WrapAtTheEnd      checkBox3.Checked;
279:   //            lastIndex              = OptionCombo.SelectedIndex;
280:               
281:               Find replace new Replace(findcomboBox1.Text);
282:   //            replace.main = main;
283:               
284:               FindDialog.find replace;
285:           }
286:           
287:           private void ClickFind(object senderSystem.EventArgs e)
288:           {
289:               if (FindComboBox.Text.Length == 0) {
290:                   return;
291:               }
292:               SetUpReplace();
293:               Replace replace = ((Replace)FindDialog.find);
294:               if(!replace.FindNext())
295:                   MessageBox.Show(Resource.GetString("Dialog.NewProject.SearchReplace.SearchStringNotFound"));
296:           }
297:           
298:           private void ClickReplace(object senderSystem.EventArgs e)
299:           {
300:               if (FindComboBox.Text.Length == 0) {
301:                   return;
302:               }
303:               SetUpReplace();
304:               Replace replace = ((Replace)FindDialog.find);
305:               replace.ReplaceMatching();
306:               ClickFind(nullnull);
307:           }
308:           
309:           private void ClickReplaceAll(object senderSystem.EventArgs e)
310:           {
311:               Find find null;
312:               if (FindComboBox.Text.Length == 0) {
313:                   return;
314:               }
315:               switch (OptionCombo.SelectedIndex) {
316:                   case 0:
317:            &nbs