diff --git a/trunk/About.Designer.cs b/trunk/About.Designer.cs
index 1eb81b3..180ba9a 100644
--- a/trunk/About.Designer.cs
+++ b/trunk/About.Designer.cs
@@ -1,22 +1,60 @@
namespace LSLEditor
{
- partial class About
+ ///
+ /// About dialogue box form.
+ ///
+ public partial class About
{
///
/// Required designer variable.
///
private System.ComponentModel.IContainer components = null;
+ ///
+ /// Container for LSLife picture.
+ ///
+ private System.Windows.Forms.PictureBox pictureBox1;
+
+ ///
+ /// Container to hold all the elements.
+ ///
+ private System.Windows.Forms.GroupBox groupBox1;
+
+ ///
+ /// OK Button.
+ ///
+ private System.Windows.Forms.Button button1;
+
+ ///
+ /// Web Browser.
+ ///
+ private System.Windows.Forms.WebBrowser webBrowser1;
+
+ ///
+ /// Link label.
+ ///
+ private System.Windows.Forms.LinkLabel linkLabel1;
+
+ ///
+ /// Version label.
+ ///
+ private System.Windows.Forms.Label label1;
+
+ ///
+ /// LSL Editor label.
+ ///
+ private System.Windows.Forms.Label label2;
+
///
/// Clean up any resources being used.
///
- /// true if managed resources should be disposed; otherwise, false.
+ /// True if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
- if (disposing && (components != null))
- {
- components.Dispose();
+ if (disposing && (this.components != null)) {
+ this.components.Dispose();
}
+
base.Dispose(disposing);
}
@@ -133,13 +171,5 @@ namespace LSLEditor
}
#endregion
-
- private System.Windows.Forms.PictureBox pictureBox1;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.Button button1;
- private System.Windows.Forms.WebBrowser webBrowser1;
- private System.Windows.Forms.LinkLabel linkLabel1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.Label label1;
}
-}
\ No newline at end of file
+}
diff --git a/trunk/About.cs b/trunk/About.cs
index d84bb2b..92b529e 100644
--- a/trunk/About.cs
+++ b/trunk/About.cs
@@ -42,18 +42,23 @@
// ********
// */
using System;
+using System.ComponentModel;
using System.IO;
using System.Reflection;
-using System.ComponentModel;
using System.Windows.Forms;
namespace LSLEditor
{
+ /// About dialogue box form.
public partial class About : Form
{
+ ///
+ /// Initialises a new instance of the class.
+ ///
+ /// The parent form.
public About(LSLEditorForm parent)
{
- InitializeComponent();
+ this.InitializeComponent();
this.Icon = parent.Icon;
@@ -61,20 +66,35 @@ namespace LSLEditor
this.label2.Text = strVersion;
}
+ ///
+ /// OK/Close button.
+ ///
+ ///
+ ///
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
+ ///
+ /// Link to SourceForge page.
+ ///
+ ///
+ ///
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start(Properties.Settings.Default.ContactUrl);
}
+ ///
+ /// Loads the page.
+ ///
+ ///
+ ///
private void About_Load(object sender, EventArgs e)
{
string strExeFileName = Path.GetFileName(Assembly.GetExecutingAssembly().CodeBase);
- this.webBrowser1.Navigate("res://" + strExeFileName + "/"+ Properties.Settings.Default.About);
+ this.webBrowser1.Navigate("res://" + strExeFileName + "/" + Properties.Settings.Default.About);
}
}
}
\ No newline at end of file
diff --git a/trunk/Browser.cs b/trunk/Browser.cs
index 17d756b..f8b1573 100644
--- a/trunk/Browser.cs
+++ b/trunk/Browser.cs
@@ -69,46 +69,37 @@ namespace LSLEditor
{
WebBrowser axWebBrowser1 = sender as WebBrowser;
ToolStripStatusLabel status = axWebBrowser1.Tag as ToolStripStatusLabel;
- if (status == null)
- return;
- status.Text = axWebBrowser1.StatusText;
+ if (status != null) {
+ status.Text = axWebBrowser1.StatusText;
+ }
}
-
private void axWebBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
string strUrl = e.Url.ToString();
- if (strUrl.EndsWith(".lsl"))
- {
+ if (strUrl.EndsWith(".lsl")) {
e.Cancel = true;
- if (MessageBox.Show("Import LSL script?", "Import script", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
- return;
+ if (MessageBox.Show("Import LSL script?", "Import script", MessageBoxButtons.OKCancel) != DialogResult.Cancel) {
+ WebBrowser axWebBrowser1 = sender as WebBrowser;
+ axWebBrowser1.Stop();
- WebBrowser axWebBrowser1 = sender as WebBrowser;
- axWebBrowser1.Stop();
-
- this.lslEditorForm.OpenFile(strUrl,Guid.NewGuid());
+ this.lslEditorForm.OpenFile(strUrl, Guid.NewGuid());
+ }
}
}
public void ShowWebBrowser(string strTabName, string strUrl)
{
WebBrowser axWebBrowser1 = null;
- try
- {
- if (!Properties.Settings.Default.HelpNewTab)
- {
+ try {
+ if (!Properties.Settings.Default.HelpNewTab) {
TabPage tabPage = this.tabControl1.TabPages[0];
tabPage.Text = strTabName + " ";
axWebBrowser1 = tabPage.Controls[0] as WebBrowser;
}
- }
- catch
- {
- }
+ } catch { }
- if (axWebBrowser1 == null)
- {
+ if (axWebBrowser1 == null) {
TabPage tabPage = new TabPage(strTabName + " ");
tabPage.BackColor = Color.White;
@@ -117,7 +108,7 @@ namespace LSLEditor
ToolStripStatusLabel toolStripStatusLabel1 = new ToolStripStatusLabel();
StatusStrip statusStrip1 = new StatusStrip();
- statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripStatusLabel1});
+ statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripStatusLabel1 });
statusStrip1.Location = new System.Drawing.Point(0, 318);
statusStrip1.Name = "statusStrip1";
statusStrip1.Size = new System.Drawing.Size(584, 22);
@@ -148,29 +139,26 @@ namespace LSLEditor
private void closeToolStripMenuItem_Click(object sender, EventArgs e)
{
int intTabToClose = (int)this.contextMenuStrip1.Tag;
- if (intTabToClose >= this.tabControl1.TabCount)
- return;
- this.tabControl1.TabPages.RemoveAt(intTabToClose);
+ if (intTabToClose < this.tabControl1.TabCount) {
+ this.tabControl1.TabPages.RemoveAt(intTabToClose);
+ }
}
private void tabControl1_MouseDown(object sender, MouseEventArgs e)
{
TabControl tabControl = sender as TabControl;
- if (tabControl == null)
- return;
- if (e.Button == MouseButtons.Right)
- {
- for (int intI = 0; intI < tabControl.TabCount; intI++)
- {
- Rectangle rt = tabControl.GetTabRect(intI);
- if (e.X > rt.Left && e.X < rt.Right
- && e.Y > rt.Top && e.Y < rt.Bottom)
- {
- this.contextMenuStrip1.Tag = intI;
- this.contextMenuStrip1.Show(this.tabControl1, new Point(e.X, e.Y));
+ if (tabControl != null) {
+ if (e.Button == MouseButtons.Right) {
+ for (int intI = 0; intI < tabControl.TabCount; intI++) {
+ Rectangle rt = tabControl.GetTabRect(intI);
+ if (e.X > rt.Left && e.X < rt.Right
+ && e.Y > rt.Top && e.Y < rt.Bottom) {
+ this.contextMenuStrip1.Tag = intI;
+ this.contextMenuStrip1.Show(this.tabControl1, new Point(e.X, e.Y));
+ }
}
}
}
}
}
-}
\ No newline at end of file
+}
diff --git a/trunk/EditForm.cs b/trunk/EditForm.cs
index 888ccf3..e30436d 100644
--- a/trunk/EditForm.cs
+++ b/trunk/EditForm.cs
@@ -58,25 +58,21 @@ namespace LSLEditor
private string m_FullPathName;
private Guid m_Guid;
- // private bool sOutline = true;
+ // private bool sOutline = true;
public LSLEditorForm parent;
- public Encoding encodedAs = null;
+ public Encoding encodedAs = null;
private const int WM_NCACTIVATE = 0x0086;
protected override void WndProc(ref Message m)
{
- if (m.Msg == WM_NCACTIVATE)
- {
- if (m.LParam != IntPtr.Zero)
- {
+ if (m.Msg == WM_NCACTIVATE) {
+ if (m.LParam != IntPtr.Zero) {
m.WParam = new IntPtr(1);
- }
- else
- {
+ } else {
this.numberedTextBoxUC1.TextBox.MakeAllInvis();
}
}
- try { base.WndProc(ref m); } catch {}
+ try { base.WndProc(ref m); } catch { }
}
public SyntaxRichTextBox TextBox
@@ -123,10 +119,11 @@ namespace LSLEditor
}
set
{
- if(value)
+ if (value) {
this.tabPage1.Text = "Script";
- else
+ } else {
this.tabPage1.Text = "Text";
+ }
this.TextBox.ToolTipping = value;
}
}
@@ -141,7 +138,7 @@ namespace LSLEditor
this.Icon = lslEditorForm.Icon;
this.parent = lslEditorForm;
- this.numberedTextBoxUC1.TextBox.setEditform(this);
+ this.numberedTextBoxUC1.TextBox.setEditform(this);
this.numberedTextBoxUC1.TextBox.Init(this.parent, this.parent.ConfLSL);
this.numberedTextBoxUC1.TextBox.OnDirtyChanged += new IsDirtyHandler(TextBox_OnDirtyChanged);
@@ -149,25 +146,22 @@ namespace LSLEditor
this.Resize += new EventHandler(EditForm_Position);
this.Layout += new LayoutEventHandler(EditForm_Layout);
- ImageList imageList = new ImageList();
- imageList.Images.Add(new Bitmap(this.GetType(), "Images.Unknown.gif"));
- imageList.Images.Add(new Bitmap(this.GetType(), "Images.Functions.gif"));
- imageList.Images.Add(new Bitmap(this.GetType(), "Images.Events.gif"));
- imageList.Images.Add(new Bitmap(this.GetType(), "Images.Constants.gif"));
- imageList.Images.Add(new Bitmap(this.GetType(), "Images.Class.gif"));
- imageList.Images.Add(new Bitmap(this.GetType(), "Images.Vars.gif"));
- imageList.Images.Add(new Bitmap(this.GetType(), "Images.Properties.gif"));
- imageList.Images.Add(new Bitmap(this.GetType(), "Images.States.gif"));
+ ImageList imageList = new ImageList();
+ imageList.Images.Add(new Bitmap(this.GetType(), "Images.Unknown.gif"));
+ imageList.Images.Add(new Bitmap(this.GetType(), "Images.Functions.gif"));
+ imageList.Images.Add(new Bitmap(this.GetType(), "Images.Events.gif"));
+ imageList.Images.Add(new Bitmap(this.GetType(), "Images.Constants.gif"));
+ imageList.Images.Add(new Bitmap(this.GetType(), "Images.Class.gif"));
+ imageList.Images.Add(new Bitmap(this.GetType(), "Images.Vars.gif"));
+ imageList.Images.Add(new Bitmap(this.GetType(), "Images.Properties.gif"));
+ imageList.Images.Add(new Bitmap(this.GetType(), "Images.States.gif"));
- this.tvOutline.ImageList = imageList;
- if (lslEditorForm.outlineToolStripMenuItem.Checked)
- {
- splitContainer1.Panel2Collapsed = false;
- }
- else
- {
- splitContainer1.Panel2Collapsed = true;
- }
+ this.tvOutline.ImageList = imageList;
+ if (lslEditorForm.outlineToolStripMenuItem.Checked) {
+ splitContainer1.Panel2Collapsed = false;
+ } else {
+ splitContainer1.Panel2Collapsed = true;
+ }
SetFont();
}
@@ -178,8 +172,9 @@ namespace LSLEditor
void EditForm_Layout(object sender, LayoutEventArgs e)
{
- if (this.WindowState == FormWindowState.Minimized)
+ if (this.WindowState == FormWindowState.Minimized) {
this.numberedTextBoxUC1.TextBox.MakeAllInvis();
+ }
}
void EditForm_Position(object sender, EventArgs e)
@@ -190,16 +185,18 @@ namespace LSLEditor
void TextBox_OnDirtyChanged(object sender, EventArgs e)
{
this.Text = this.ScriptName;
- if (this.numberedTextBoxUC1.TextBox.Dirty)
- this.Text = this.Text.Trim()+"* ";
- else
- this.Text = this.Text.Trim()+" ";
+ if (this.numberedTextBoxUC1.TextBox.Dirty) {
+ this.Text = this.Text.Trim() + "* ";
+ } else {
+ this.Text = this.Text.Trim() + " ";
+ }
TabPage tabPage = this.Tag as TabPage;
- if (tabPage != null)
+ if (tabPage != null) {
tabPage.Text = this.Text;
+ }
this.parent.OnDirtyChanged(this.numberedTextBoxUC1.TextBox.Dirty);
- }
+ }
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
@@ -216,20 +213,19 @@ namespace LSLEditor
{
this.m_FullPathName = value;
string strDirectory = Path.GetDirectoryName(this.m_FullPathName);
- if (Directory.Exists(strDirectory))
- {
+ if (Directory.Exists(strDirectory)) {
Properties.Settings.Default.WorkingDirectory = strDirectory;
- }
- else
- {
- if(!Directory.Exists(Properties.Settings.Default.WorkingDirectory))
+ } else {
+ if (!Directory.Exists(Properties.Settings.Default.WorkingDirectory)) {
Properties.Settings.Default.WorkingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
+ }
this.m_FullPathName = Path.Combine(Properties.Settings.Default.WorkingDirectory, this.m_FullPathName);
}
this.Text = this.ScriptName;
TabPage tabPage = this.Tag as TabPage;
- if (tabPage != null)
+ if (tabPage != null) {
tabPage.Text = this.Text + " ";
+ }
}
}
@@ -263,53 +259,50 @@ namespace LSLEditor
private int PercentageIndentTab()
{
+ int intResult;
int intSpaces = 0;
int intTabs = 0;
StringReader sr = new StringReader(this.TextBox.Text);
- while (true)
- {
+ while (true) {
string strLine = sr.ReadLine();
- if (strLine == null)
- break;
- if (strLine.Length == 0)
- continue;
- if (strLine[0] == ' ')
+ if (strLine == null) break;
+ if (strLine.Length == 0) continue;
+ if (strLine[0] == ' ') {
intSpaces++;
- else if (strLine[0] == '\t')
+ } else if (strLine[0] == '\t') {
intTabs++;
+ }
}
- if (intTabs == 0 && intSpaces==0)
- return 50;
- return (int)Math.Round((100.0 * intTabs) / (intTabs + intSpaces));
+ if (intTabs == 0 && intSpaces == 0) {
+ intResult = 50;
+ } else {
+ intResult = (int)Math.Round((100.0 * intTabs) / (intTabs + intSpaces));
+ }
+ return intResult;
}
public void LoadFile(string strPath)
{
- if(strPath.StartsWith("http://"))
+ if (strPath.StartsWith("http://")) {
this.FullPathName = Path.GetFileName(strPath);
- else
+ } else {
this.FullPathName = strPath;
+ }
this.encodedAs = this.numberedTextBoxUC1.TextBox.LoadFile(strPath);
- if (!this.IsScript)
- return;
+ if (this.IsScript) {
- if (Properties.Settings.Default.IndentAutoCorrect)
- {
- this.TextBox.FormatDocument();
- this.TextBox.ClearUndoStack();
- }
- else
- {
- if (Properties.Settings.Default.IndentWarning)
- {
- if ((PercentageIndentTab() > 50 && Properties.Settings.Default.SL4SpacesIndent) ||
- (PercentageIndentTab() < 50 && !Properties.Settings.Default.SL4SpacesIndent))
- {
- if (MessageBox.Show("Indent scheme differs from settings\nDo you want to correct it?\nIt can also be corrected by pressing Ctrl-D or turn on Autocorrection (tools menu)", "Indent Warning!!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
- {
- this.TextBox.FormatDocument();
- //this.TextBox.ClearUndoStack();
+ if (Properties.Settings.Default.IndentAutoCorrect) {
+ this.TextBox.FormatDocument();
+ this.TextBox.ClearUndoStack();
+ } else {
+ if (Properties.Settings.Default.IndentWarning) {
+ if ((PercentageIndentTab() > 50 && Properties.Settings.Default.SL4SpacesIndent) ||
+ (PercentageIndentTab() < 50 && !Properties.Settings.Default.SL4SpacesIndent)) {
+ if (MessageBox.Show("Indent scheme differs from settings\nDo you want to correct it?\nIt can also be corrected by pressing Ctrl-D or turn on Autocorrection (tools menu)", "Indent Warning!!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) {
+ this.TextBox.FormatDocument();
+ //this.TextBox.ClearUndoStack();
+ }
}
}
}
@@ -319,32 +312,28 @@ namespace LSLEditor
public void SaveCurrentFile(string strPath)
{
this.FullPathName = strPath;
- Encoding encodeAs = this.encodedAs;
- if (this.IsScript && encodeAs == null)
- {
- switch (Properties.Settings.Default.OutputFormat)
- {
- case "UTF8":
- encodeAs = Encoding.UTF8;
- break;
- case "Unicode":
- encodeAs = Encoding.Unicode;
- break;
- case "BigEndianUnicode":
- encodeAs = Encoding.BigEndianUnicode;
- break;
- default:
- encodeAs = Encoding.Default;
- break;
- }
- }
- else if (encodeAs == null)
- {
- encodeAs = Encoding.UTF8;
- }
+ Encoding encodeAs = this.encodedAs;
+ if (this.IsScript && encodeAs == null) {
+ switch (Properties.Settings.Default.OutputFormat) {
+ case "UTF8":
+ encodeAs = Encoding.UTF8;
+ break;
+ case "Unicode":
+ encodeAs = Encoding.Unicode;
+ break;
+ case "BigEndianUnicode":
+ encodeAs = Encoding.BigEndianUnicode;
+ break;
+ default:
+ encodeAs = Encoding.Default;
+ break;
+ }
+ } else if (encodeAs == null) {
+ encodeAs = Encoding.UTF8;
+ }
- this.numberedTextBoxUC1.TextBox.SaveCurrentFile(strPath, encodeAs);
- this.encodedAs = encodeAs;
+ this.numberedTextBoxUC1.TextBox.SaveCurrentFile(strPath, encodeAs);
+ this.encodedAs = encodeAs;
}
public void SaveCurrentFile()
@@ -381,16 +370,15 @@ namespace LSLEditor
{
this.numberedTextBoxUC1.TextBox.MakeAllInvis();
- if (runtime != null)
- {
+ if (runtime != null) {
this.components.Remove(runtime);
- if (!runtime.IsDisposed)
+ if (!runtime.IsDisposed) {
runtime.Dispose();
+ }
runtime = null;
}
-
- for (int intI = this.tabControl1.TabPages.Count - 1; intI > 0; intI--)
- {
+
+ for (int intI = this.tabControl1.TabPages.Count - 1; intI > 0; intI--) {
this.tabControl1.TabPages.RemoveAt(intI);
}
}
@@ -400,65 +388,62 @@ namespace LSLEditor
public bool StartCompiler()
{
+ bool blnResult = false;
//if (this.disableCompilesyntaxCheckToolStripMenuItem.Checked)
// return false;
- if (!this.IsScript)
- return false;
+ if (this.IsScript) {
+ StopCompiler();
- StopCompiler();
+ if (this.parent != null) {
+ runtime = new RuntimeConsole(this.parent);
- if (this.parent == null)
- return false;
+ // for disposing
+ this.components.Add(runtime);
- runtime = new RuntimeConsole(this.parent);
+ if (!runtime.Compile(this)) {
+ this.tabControl1.SelectedIndex = 0;
+ return false;
+ }
- // for disposing
- this.components.Add(runtime);
-
- if (!runtime.Compile(this))
- {
- this.tabControl1.SelectedIndex = 0;
- return false;
+ TabPage tabPage = new TabPage("Debug");
+ tabPage.Controls.Add(runtime);
+ this.tabControl1.TabPages.Add(tabPage);
+ this.tabControl1.SelectedIndex = 1;
+ blnResult = true;
+ }
}
-
- TabPage tabPage = new TabPage("Debug");
- tabPage.Controls.Add(runtime);
- this.tabControl1.TabPages.Add(tabPage);
- this.tabControl1.SelectedIndex = 1;
- return true;
+ return blnResult;
}
public bool SyntaxCheck()
{
+ bool blnResult = false;
//if (this.disableCompilesyntaxCheckToolStripMenuItem.Checked)
// return false;
- if (!this.IsScript)
- return false;
+ if (this.IsScript) {
+ LSL2CSharp translator = new LSL2CSharp(ConfLSL);
+ string strCSharp = translator.Parse(SourceCode);
- LSL2CSharp translator = new LSL2CSharp(ConfLSL);
- string strCSharp = translator.Parse(SourceCode);
+ if (System.Diagnostics.Debugger.IsAttached) {
+ for (int intI = this.tabControl1.TabPages.Count - 1; intI > 0; intI--) {
+ this.tabControl1.TabPages.RemoveAt(intI);
+ }
- if (System.Diagnostics.Debugger.IsAttached)
- {
- for (int intI = this.tabControl1.TabPages.Count - 1; intI > 0; intI--)
- {
- this.tabControl1.TabPages.RemoveAt(intI);
+ // TODO
+ TabPage tabPage = new TabPage("C#");
+ NumberedTextBox.NumberedTextBoxUC numberedTextBoxUC1 = new NumberedTextBox.NumberedTextBoxUC();
+ numberedTextBoxUC1.TextBox.Init(null, this.ConfCSharp);
+ numberedTextBoxUC1.TextBox.Text = strCSharp;
+ numberedTextBoxUC1.TextBox.ReadOnly = true;
+ numberedTextBoxUC1.Dock = DockStyle.Fill;
+ tabPage.Controls.Add(numberedTextBoxUC1);
+ this.tabControl.TabPages.Add(tabPage);
}
-
- // TODO
- TabPage tabPage = new TabPage("C#");
- NumberedTextBox.NumberedTextBoxUC numberedTextBoxUC1 = new NumberedTextBox.NumberedTextBoxUC();
- numberedTextBoxUC1.TextBox.Init(null, this.ConfCSharp);
- numberedTextBoxUC1.TextBox.Text = strCSharp;
- numberedTextBoxUC1.TextBox.ReadOnly = true;
- numberedTextBoxUC1.Dock = DockStyle.Fill;
- tabPage.Controls.Add(numberedTextBoxUC1);
- this.tabControl.TabPages.Add(tabPage);
+ blnResult = (null != CompilerHelper.CompileCSharp(this, strCSharp));
}
-
- return (null != CompilerHelper.CompileCSharp(this, strCSharp));
+ return blnResult;
}
public int Find(string strSearch, int intStart, int intEnd, RichTextBoxFinds options)
@@ -476,13 +461,13 @@ namespace LSLEditor
private void EditForm_FormClosing(object sender, FormClosingEventArgs e)
{
this.parent.CancelClosing = false;
- if (this.Dirty)
- {
+ if (this.Dirty) {
DialogResult dialogResult = MessageBox.Show(this, @"Save """ + this.ScriptName + @"""?", "File has changed", MessageBoxButtons.YesNoCancel);
- if (dialogResult == DialogResult.Yes)
- e.Cancel = !this.parent.SaveFile(this,false);
- else
+ if (dialogResult == DialogResult.Yes) {
+ e.Cancel = !this.parent.SaveFile(this, false);
+ } else {
e.Cancel = (dialogResult == DialogResult.Cancel);
+ }
}
this.parent.CancelClosing = e.Cancel;
}
@@ -492,44 +477,42 @@ namespace LSLEditor
//this.disableCompilesyntaxCheckToolStripMenuItem.Checked = !this.disableCompilesyntaxCheckToolStripMenuItem.Checked;
}
- private void tvOutline_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
- {
- this.parent.BeginInvoke(new TreeNodeMouseClickEventHandler(
- delegate(object sender2, TreeNodeMouseClickEventArgs e2)
- {
- if (e.Node.Tag is Helpers.OutlineHelper)
- {
- Helpers.OutlineHelper ohOutline = (Helpers.OutlineHelper)e.Node.Tag;
- if (ohOutline.line < this.TextBox.Lines.Length)
- {
- //editForm.Focus();
- //editForm.TextBox.Select();
- //editForm.TextBox.Goto(ohOutline.line + 1);
+ private void tvOutline_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
+ {
+ this.parent.BeginInvoke(new TreeNodeMouseClickEventHandler(
+ delegate(object sender2, TreeNodeMouseClickEventArgs e2)
+ {
+ if (e.Node.Tag is Helpers.OutlineHelper) {
+ Helpers.OutlineHelper ohOutline = (Helpers.OutlineHelper)e.Node.Tag;
+ if (ohOutline.line < this.TextBox.Lines.Length) {
+ //editForm.Focus();
+ //editForm.TextBox.Select();
+ //editForm.TextBox.Goto(ohOutline.line + 1);
- //TextBox.Focus();
- this.TextBox.Select();
- this.TextBox.SelectionStart = this.TextBox.GetFirstCharIndexFromLine(ohOutline.line);
-
+ //TextBox.Focus();
+ this.TextBox.Select();
+ this.TextBox.SelectionStart = this.TextBox.GetFirstCharIndexFromLine(ohOutline.line);
- }
- }
- }), sender, e);
- }
- private void tvOutline_AfterSelect(object sender, TreeViewEventArgs e)
- {
-
- //this.TextBox.Select
- }
+ }
+ }
+ }), sender, e);
+ }
- private void splitContainer1_Click(object sender, EventArgs e)
- {
+ private void tvOutline_AfterSelect(object sender, TreeViewEventArgs e)
+ {
- }
+ //this.TextBox.Select
+ }
- private void tvOutline_VisibleChanged(object sender, EventArgs e)
- {
- this.tvOutline.ExpandAll();
- }
+ private void splitContainer1_Click(object sender, EventArgs e)
+ {
+
+ }
+
+ private void tvOutline_VisibleChanged(object sender, EventArgs e)
+ {
+ this.tvOutline.ExpandAll();
+ }
}
-}
\ No newline at end of file
+}
diff --git a/trunk/FindWindow.cs b/trunk/FindWindow.cs
index e50325f..b0260dc 100644
--- a/trunk/FindWindow.cs
+++ b/trunk/FindWindow.cs
@@ -89,14 +89,12 @@ namespace LSLEditor
set
{
this.label1.Text = ""; // clear out message
- if (value != "")
- {
+ if (value != "") {
this.comboBoxFind.Text = value;
- }
- else
- {
- if (this.comboBoxFind.Items.Count > 0)
+ } else {
+ if (this.comboBoxFind.Items.Count > 0) {
this.comboBoxFind.SelectedIndex = this.comboBoxFind.Items.Count - 1;
+ }
}
}
}
@@ -106,17 +104,16 @@ namespace LSLEditor
string strText = comboBox.Text;
bool Found = false;
- foreach (string strC in comboBox.Items)
- {
- if (strC == strText)
- {
+ foreach (string strC in comboBox.Items) {
+ if (strC == strText) {
Found = true;
break;
}
}
- if (!Found)
+ if (!Found) {
comboBox.Items.Add(strText);
+ }
return Found;
}
@@ -124,40 +121,35 @@ namespace LSLEditor
{
this.label1.Text = "";
EditForm editForm = this.lslEditForm.ActiveMdiForm as EditForm;
- if (editForm == null)
- return;
+ if (editForm != null) {
+ if (!UpdateComboBox(this.comboBoxFind)) {
+ editForm.TextBox.SelectionLength = 0;
+ editForm.TextBox.SelectionStart = 0;
+ }
- if (!UpdateComboBox(this.comboBoxFind))
- {
- editForm.TextBox.SelectionLength = 0;
- editForm.TextBox.SelectionStart = 0;
- }
+ RichTextBoxFinds options = RichTextBoxFinds.None;
- RichTextBoxFinds options = RichTextBoxFinds.None;
+ if (this.checkBoxMatchCase.Checked) options |= RichTextBoxFinds.MatchCase;
+ if (this.checkBoxReverse.Checked) options |= RichTextBoxFinds.Reverse;
+ if (this.checkBoxWholeWord.Checked) options |= RichTextBoxFinds.WholeWord;
- if (this.checkBoxMatchCase.Checked) options |= RichTextBoxFinds.MatchCase;
- if (this.checkBoxReverse.Checked) options |= RichTextBoxFinds.Reverse;
- if (this.checkBoxWholeWord.Checked) options |= RichTextBoxFinds.WholeWord;
+ if (this.checkBoxReverse.Checked) {
+ intStart = 0; // start cant change ;-)
+ intEnd = editForm.TextBox.SelectionStart;
+ } else {
+ intStart = editForm.TextBox.SelectionStart + editForm.TextBox.SelectionLength;
+ if (intStart == editForm.TextBox.Text.Length) {
+ intStart = 0;
+ }
+ intEnd = editForm.TextBox.Text.Length - 1; // length can change!!
+ }
- if (this.checkBoxReverse.Checked)
- {
- intStart = 0; // start cant change ;-)
- intEnd = editForm.TextBox.SelectionStart;
- }
- else
- {
- intStart = editForm.TextBox.SelectionStart + editForm.TextBox.SelectionLength;
- if (intStart == editForm.TextBox.Text.Length)
- intStart = 0;
- intEnd = editForm.TextBox.Text.Length - 1; // length can change!!
- }
-
- string strFind = this.comboBoxFind.Text;
- int intIndex = editForm.Find(strFind, intStart, intEnd, options);
- if (intIndex < 0)
- {
- this.label1.Text = "Not found...";
- return;
+ string strFind = this.comboBoxFind.Text;
+ int intIndex = editForm.Find(strFind, intStart, intEnd, options);
+ if (intIndex < 0) {
+ this.label1.Text = "Not found...";
+ return;
+ }
}
}
@@ -169,15 +161,11 @@ namespace LSLEditor
private void comboBoxFind_KeyDown(object sender, KeyEventArgs e)
{
- if (e.KeyCode == Keys.Return)
- {
- if (this.Replace.Enabled)
- {
+ if (e.KeyCode == Keys.Return) {
+ if (this.Replace.Enabled) {
this.comboBoxReplace.Focus();
e.SuppressKeyPress = true;
- }
- else
- {
+ } else {
Find();
e.SuppressKeyPress = true;
}
@@ -187,30 +175,26 @@ namespace LSLEditor
private void Replace_Click(object sender, EventArgs e)
{
EditForm editForm = this.lslEditForm.ActiveMdiForm as EditForm;
- if (editForm == null)
- return;
+ if (editForm != null) {
+ UpdateComboBox(this.comboBoxReplace);
- UpdateComboBox(this.comboBoxReplace);
+ if (editForm.TextBox.SelectionLength > 0) {
+ string strReplacement = this.comboBoxReplace.Text;
+ editForm.TextBox.ReplaceSelectedText(strReplacement);
+ }
- if (editForm.TextBox.SelectionLength > 0)
- {
- string strReplacement = this.comboBoxReplace.Text;
- editForm.TextBox.ReplaceSelectedText(strReplacement);
+ Find();
+ this.Focus();
}
-
- Find();
- this.Focus();
}
// WildCardToRegex not used!!
private string WildCardToRegex(string strWildCard)
{
StringBuilder sb = new StringBuilder(strWildCard.Length + 8);
- for (int intI = 0; intI < strWildCard.Length; intI++)
- {
+ for (int intI = 0; intI < strWildCard.Length; intI++) {
char chrC = strWildCard[intI];
- switch (chrC)
- {
+ switch (chrC) {
case '*':
sb.Append(".*");
break;
@@ -233,42 +217,41 @@ namespace LSLEditor
private void ReplaceAll_Click(object sender, EventArgs e)
{
EditForm editForm = this.lslEditForm.ActiveMdiForm as EditForm;
- if (editForm == null)
- return;
+ if (editForm == null) {
+ UpdateComboBox(this.comboBoxReplace);
- UpdateComboBox(this.comboBoxReplace);
+ string strPattern;
+ string strFind = Regex.Escape(this.comboBoxFind.Text);
+ string strReplacement = this.comboBoxReplace.Text;
+ string strSourceCode = editForm.SourceCode;
- string strPattern;
- string strFind = Regex.Escape(this.comboBoxFind.Text);
- string strReplacement = this.comboBoxReplace.Text;
- string strSourceCode = editForm.SourceCode;
+ RegexOptions regexOptions = RegexOptions.Compiled;
+ if (!this.checkBoxMatchCase.Checked) {
+ regexOptions |= RegexOptions.IgnoreCase;
+ }
+ if (this.checkBoxWholeWord.Checked) {
+ strPattern = @"\b" + strFind + @"\b";
+ } else {
+ strPattern = strFind;
+ }
- RegexOptions regexOptions = RegexOptions.Compiled;
- if (!this.checkBoxMatchCase.Checked)
- regexOptions |= RegexOptions.IgnoreCase;
- if (this.checkBoxWholeWord.Checked)
- strPattern = @"\b" + strFind + @"\b";
- else
- strPattern = strFind;
+ Regex regex = new Regex(strPattern, regexOptions);
- Regex regex = new Regex(strPattern, regexOptions);
-
- int intCount = 0;
- foreach(Match m in regex.Matches(strSourceCode))
- {
- if (m.Value.Length > 0)
- intCount++;
+ int intCount = 0;
+ foreach (Match m in regex.Matches(strSourceCode)) {
+ if (m.Value.Length > 0) {
+ intCount++;
+ }
+ }
+ if (intCount == 0) {
+ MessageBox.Show("No matches found");
+ } else {
+ if (MessageBox.Show("There are " + intCount + " occurences, replace them all?", "Find and Replace", MessageBoxButtons.YesNoCancel) == DialogResult.Yes) {
+ editForm.SourceCode = regex.Replace(strSourceCode, strReplacement);
+ }
+ }
+ this.Focus();
}
- if (intCount == 0)
- {
- MessageBox.Show("No matches found");
- }
- else
- {
- if (MessageBox.Show("There are " + intCount + " occurences, replace them all?", "Find and Replace", MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
- editForm.SourceCode = regex.Replace(strSourceCode, strReplacement);
- }
- this.Focus();
}
private void FindWindow_FormClosing(object sender, FormClosingEventArgs e)
@@ -281,22 +264,19 @@ namespace LSLEditor
private void FindWindow_KeyDown(object sender, KeyEventArgs e)
{
- if (e.KeyData == Keys.Escape)
- {
+ if (e.KeyData == Keys.Escape) {
this.Visible = false;
e.SuppressKeyPress = true;
e.Handled = true;
}
- if (e.KeyCode == Keys.Return)
- {
+ if (e.KeyCode == Keys.Return) {
Find();
e.SuppressKeyPress = true;
this.Focus();
}
- if (e.KeyCode == Keys.F3)
- {
+ if (e.KeyCode == Keys.F3) {
Find();
e.SuppressKeyPress = true;
this.Focus();
@@ -309,7 +289,5 @@ namespace LSLEditor
{
this.comboBoxFind.Focus();
}
-
-
}
-}
\ No newline at end of file
+}
diff --git a/trunk/GotoWindow.cs b/trunk/GotoWindow.cs
index f431384..d69b693 100644
--- a/trunk/GotoWindow.cs
+++ b/trunk/GotoWindow.cs
@@ -56,7 +56,7 @@ namespace LSLEditor
this.lslEditForm = lslEditForm;
EditForm editForm = this.lslEditForm.ActiveMdiForm as EditForm;
- this.label1.Text = "Line number (1-"+editForm.TextBox.Lines.Length+")";
+ this.label1.Text = "Line number (1-" + editForm.TextBox.Lines.Length + ")";
}
private void button1_Click(object sender, EventArgs e)
@@ -67,16 +67,12 @@ namespace LSLEditor
private void Goto()
{
EditForm editForm = this.lslEditForm.ActiveMdiForm as EditForm;
- if (editForm == null)
- return;
- try
- {
- int intLine = Convert.ToInt32(this.textBox1.Text);
- editForm.TextBox.Goto(intLine);
- this.Close();
- }
- catch
- {
+ if (editForm != null) {
+ try {
+ int intLine = Convert.ToInt32(this.textBox1.Text);
+ editForm.TextBox.Goto(intLine);
+ this.Close();
+ } catch { }
}
}
@@ -87,12 +83,11 @@ namespace LSLEditor
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
- if (e.KeyCode == Keys.Return)
- {
+ if (e.KeyCode == Keys.Return) {
Goto();
e.SuppressKeyPress = true;
}
}
}
-}
\ No newline at end of file
+}
diff --git a/trunk/LSLEditorForm.cs b/trunk/LSLEditorForm.cs
index 085be90..da23a30 100644
--- a/trunk/LSLEditorForm.cs
+++ b/trunk/LSLEditorForm.cs
@@ -69,7 +69,6 @@ using LSLEditor.Docking;
// At the bottom of the form there are
-
// 1) tabcontrol1 , holding tabbed documents
// 2) splitter1, for increasing simulator window
// 3) panel1 , holding simulator or listview for compiler errors
@@ -114,16 +113,12 @@ namespace LSLEditor
private const int WM_NCACTIVATE = 0x0086;
protected override void WndProc(ref Message m)
{
- if (m.Msg == WM_NCACTIVATE)
- {
- if (m.LParam != IntPtr.Zero)
- {
+ if (m.Msg == WM_NCACTIVATE) {
+ if (m.LParam != IntPtr.Zero) {
m.WParam = new IntPtr(1);
}
- }
- else
- {
- try { curProc.MaxWorkingSet = curProc.MaxWorkingSet; } catch {}
+ } else {
+ try { curProc.MaxWorkingSet = curProc.MaxWorkingSet; } catch { }
}
base.WndProc(ref m);
}
@@ -138,15 +133,18 @@ namespace LSLEditor
private void SetDefaultProperties()
{
- if (Properties.Settings.Default.FontEditor == null)
+ if (Properties.Settings.Default.FontEditor == null) {
Properties.Settings.Default.FontEditor = new Font("Courier New", 9.75F, FontStyle.Regular);
+ }
- if (Properties.Settings.Default.FontTooltips == null)
+ if (Properties.Settings.Default.FontTooltips == null) {
Properties.Settings.Default.FontTooltips = new Font(SystemFonts.MessageBoxFont.Name, 9.75F, FontStyle.Regular);
+ }
string strLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
- if (Properties.Settings.Default.ProjectLocation == "")
+ if (Properties.Settings.Default.ProjectLocation == "") {
Properties.Settings.Default.ProjectLocation = strLocation;
+ }
}
public LSLEditorForm(string[] args)
@@ -154,17 +152,14 @@ namespace LSLEditor
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", false);
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US", false);
- if (args.Length == 1)
- {
- if (args[0] == "/reset")
- {
+ if (args.Length == 1) {
+ if (args[0] == "/reset") {
Properties.Settings.Default.Reset();
Properties.Settings.Default.CallUpgrade = false;
}
}
- if (Properties.Settings.Default.CallUpgrade)
- {
+ if (Properties.Settings.Default.CallUpgrade) {
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.CallUpgrade = false;
}
@@ -185,12 +180,9 @@ namespace LSLEditor
SetupChildForms();
- try
- {
+ try {
Start(args);
- }
- catch (Exception exception)
- {
+ } catch (Exception exception) {
MessageBox.Show("Error: " + OopsFormatter.ApplyFormatting(exception.Message), "Oops");
}
}
@@ -199,11 +191,12 @@ namespace LSLEditor
{
get
{
- if (this.IsMdiContainer)
+ if (this.IsMdiContainer) {
return this.MdiChildren;
+ }
List