2009-03-01 21:42:41 +00:00
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
* This program is released under GNU General Public License
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.ComponentModel;
|
|
|
|
using System.Drawing;
|
|
|
|
using System.Text;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
using System.IO;
|
|
|
|
using CodeImp.DoomBuilder.Data;
|
|
|
|
using CodeImp.DoomBuilder.Controls;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Windows
|
|
|
|
{
|
|
|
|
public partial class ScriptFindReplaceForm : DelayedForm
|
|
|
|
{
|
|
|
|
#region ================== Variables
|
|
|
|
|
2009-03-04 21:40:58 +00:00
|
|
|
private bool appclose;
|
|
|
|
|
2009-03-01 21:42:41 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
public ScriptFindReplaceForm()
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
2009-03-03 22:20:18 +00:00
|
|
|
|
2009-03-04 21:40:58 +00:00
|
|
|
#region ================== Methods
|
2009-03-03 22:20:18 +00:00
|
|
|
|
2009-03-04 21:40:58 +00:00
|
|
|
// This makes the Find & Replace options
|
|
|
|
private FindReplaceOptions MakeOptions()
|
2009-03-03 22:20:18 +00:00
|
|
|
{
|
|
|
|
FindReplaceOptions options = new FindReplaceOptions();
|
|
|
|
options.FindText = findtext.Text;
|
|
|
|
options.CaseSensitive = casesensitive.Checked;
|
|
|
|
options.WholeWord = wordonly.Checked;
|
|
|
|
options.ReplaceWith = replacetext.Text;
|
2009-03-04 21:40:58 +00:00
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Close the window
|
|
|
|
new public void Close()
|
|
|
|
{
|
|
|
|
appclose = true;
|
|
|
|
base.Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Events
|
|
|
|
|
|
|
|
// Form is closing
|
|
|
|
private void ScriptFindReplaceForm_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
|
{
|
|
|
|
if(!appclose)
|
2009-03-03 22:20:18 +00:00
|
|
|
{
|
2009-03-04 21:40:58 +00:00
|
|
|
General.Map.ScriptEditor.Editor.CloseFindReplace(true);
|
2009-03-03 22:20:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-04 21:40:58 +00:00
|
|
|
// Find Next
|
|
|
|
private void findnextbutton_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
General.Map.ScriptEditor.Editor.FindNext(MakeOptions());
|
|
|
|
}
|
2009-03-05 11:54:07 +00:00
|
|
|
|
|
|
|
// Replace
|
|
|
|
private void replacebutton_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
FindReplaceOptions options = MakeOptions();
|
|
|
|
|
|
|
|
General.Map.ScriptEditor.Editor.Replace(options);
|
|
|
|
General.Map.ScriptEditor.Editor.FindNext(options);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Replace All
|
|
|
|
private void replaceallbutton_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
General.Map.ScriptEditor.Editor.ReplaceAll(MakeOptions());
|
|
|
|
}
|
|
|
|
|
2009-03-04 21:40:58 +00:00
|
|
|
// Close
|
|
|
|
private void closebutton_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
General.Map.ScriptEditor.Editor.CloseFindReplace(false);
|
|
|
|
}
|
|
|
|
|
2009-03-03 22:20:18 +00:00
|
|
|
#endregion
|
2009-03-01 21:42:41 +00:00
|
|
|
}
|
|
|
|
}
|