UltimateZoneBuilder/Source/Core/Windows/ScriptFindReplaceForm.cs
MaxED 894279b4ba Added, Script Editor: added "Script Navigator" tab. It shows and allows to open text resources loaded by the editor.
WARNING: because of the large amount of added/modified code, bugs are possible, so backup your resources, save often and report bugs.
2016-11-24 11:55:11 +00:00

137 lines
No EOL
3 KiB
C#

#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.Windows.Forms;
#endregion
namespace CodeImp.DoomBuilder.Windows
{
public partial class ScriptFindReplaceForm : DelayedForm
{
#region ================== Variables
private bool appclose;
private bool canreplace;
#endregion
#region ================== Properties
internal bool CanReplace //mxd
{
get { return canreplace; }
set
{
canreplace = value;
labelreplace.Enabled = canreplace;
replacetext.Enabled = canreplace;
replacebutton.Enabled = canreplace;
replaceallbutton.Enabled = canreplace;
}
}
#endregion
#region ================== Constructor
// Constructor
public ScriptFindReplaceForm()
{
InitializeComponent();
}
#endregion
#region ================== Methods
// This makes the Find & Replace options
private FindReplaceOptions MakeOptions()
{
FindReplaceOptions options = new FindReplaceOptions();
options.FindText = findtext.Text;
options.CaseSensitive = casesensitive.Checked;
options.WholeWord = wordonly.Checked;
options.ReplaceWith = replacetext.Text;
return options;
}
// Close the window
new public void Close()
{
appclose = true;
base.Close();
}
// This sets the text to find
public void SetFindText(string text)
{
findtext.Text = text;
findtext.SelectAll();
}
#endregion
#region ================== Events
// Form is closing
private void ScriptFindReplaceForm_FormClosing(object sender, FormClosingEventArgs e)
{
if(!appclose)
{
General.Map.ScriptEditor.Editor.CloseFindReplace(true);
}
}
// Find Next
private void findnextbutton_Click(object sender, EventArgs e)
{
General.Map.ScriptEditor.Editor.FindNext(MakeOptions());
}
// Find Previous (mxd)
private void findpreviousbutton_Click(object sender, EventArgs e)
{
General.Map.ScriptEditor.Editor.FindPrevious(MakeOptions());
}
// 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());
}
// Close
private void closebutton_Click(object sender, EventArgs e)
{
General.Map.ScriptEditor.Editor.CloseFindReplace(false);
}
#endregion
}
}