diff --git a/trunk/About.cs b/trunk/About.cs index d84bb2b..36b3bdc 100644 --- a/trunk/About.cs +++ b/trunk/About.cs @@ -74,7 +74,7 @@ namespace LSLEditor 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 a69dabd..e30436d 100644 --- a/trunk/EditForm.cs +++ b/trunk/EditForm.cs @@ -65,18 +65,14 @@ 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 - { + } 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; } } @@ -160,12 +157,9 @@ namespace LSLEditor imageList.Images.Add(new Bitmap(this.GetType(), "Images.States.gif")); this.tvOutline.ImageList = imageList; - if (lslEditorForm.outlineToolStripMenuItem.Checked) - { + if (lslEditorForm.outlineToolStripMenuItem.Checked) { splitContainer1.Panel2Collapsed = false; - } - else - { + } 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,13 +185,15 @@ 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); } @@ -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(); + } } } } @@ -320,10 +313,8 @@ namespace LSLEditor { this.FullPathName = strPath; Encoding encodeAs = this.encodedAs; - if (this.IsScript && encodeAs == null) - { - switch (Properties.Settings.Default.OutputFormat) - { + if (this.IsScript && encodeAs == null) { + switch (Properties.Settings.Default.OutputFormat) { case "UTF8": encodeAs = Encoding.UTF8; break; @@ -337,9 +328,7 @@ namespace LSLEditor encodeAs = Encoding.Default; break; } - } - else if (encodeAs == null) - { + } else if (encodeAs == null) { encodeAs = Encoding.UTF8; } @@ -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; } @@ -497,11 +482,9 @@ namespace LSLEditor this.parent.BeginInvoke(new TreeNodeMouseClickEventHandler( delegate(object sender2, TreeNodeMouseClickEventArgs e2) { - if (e.Node.Tag is Helpers.OutlineHelper) - { + if (e.Node.Tag is Helpers.OutlineHelper) { Helpers.OutlineHelper ohOutline = (Helpers.OutlineHelper)e.Node.Tag; - if (ohOutline.line < this.TextBox.Lines.Length) - { + if (ohOutline.line < this.TextBox.Lines.Length) { //editForm.Focus(); //editForm.TextBox.Select(); //editForm.TextBox.Goto(ohOutline.line + 1); @@ -509,7 +492,7 @@ namespace LSLEditor //TextBox.Focus(); this.TextBox.Select(); this.TextBox.SelectionStart = this.TextBox.GetFirstCharIndexFromLine(ohOutline.line); - + } } @@ -518,7 +501,7 @@ namespace LSLEditor private void tvOutline_AfterSelect(object sender, TreeViewEventArgs e) { - + //this.TextBox.Select } @@ -532,4 +515,4 @@ namespace LSLEditor 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
children = new List(); - //TODO: Find Child forms + //TODO: Find Child forms //foreach (TabPage tabPage in this.tabControlExtended1.TabPages) // children.Add(tabPage.Tag as Form); return children.ToArray(); @@ -214,28 +207,26 @@ namespace LSLEditor { get { - if (this.IsMdiContainer) - return this.ActiveMdiChild; - else - { + Form form = null; + if (this.IsMdiContainer) { + form = this.ActiveMdiChild; + } else { //TODO: Get Active Mdi Form - return null; + //return null; //dockPanel.ActiveContent - // if (this.tabControlExtended1.SelectedTab == null) - // return null; - // return this.tabControlExtended1.SelectedTab.Tag as Form; + // if (this.tabControlExtended1.SelectedTab == null) + // return null; + // return this.tabControlExtended1.SelectedTab.Tag as Form; } + return form; } } public void ActivateMdiForm(Form form) { - if (this.IsMdiContainer) - { + if (this.IsMdiContainer) { this.ActivateMdiChild(form); - } - else - { + } else { //TODO: Activate the right Mdi Form /*for (int intI = 0; intI < this.tabControlExtended1.TabCount; intI++) { @@ -253,8 +244,7 @@ namespace LSLEditor public void AddForm(DockContent form) { - if (this.IsMdiContainer) - { + if (this.IsMdiContainer) { //form.MdiParent = this; //form.Tag = null; //form.Show(); @@ -262,12 +252,7 @@ namespace LSLEditor //TODO: add form in the right way form.Show(dockPanel); - } - else - { - - - + } else { //form.Visible = false; //form.MdiParent = null; //TabPage tabPage = new TabPage(form.Text+" "); @@ -330,14 +315,12 @@ namespace LSLEditor Version version = Assembly.GetExecutingAssembly().GetName().Version; this.Text += " " + version.Major + "." + version.Minor; - if (System.Diagnostics.Debugger.IsAttached) - { + if (System.Diagnostics.Debugger.IsAttached) { this.Text += " (ALPHA)"; - } - else - { - if (Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location).Contains("beta")) + } else { + if (Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location).Contains("beta")) { this.Text += " (BETA)"; + } } //TODO: Fix close buttons on tabs @@ -345,29 +328,18 @@ namespace LSLEditor //this.tabControlExtended1.SetDrawMode(); //this.tabControlExtended1.OnTabClose += new EventHandler(tabControl1_OnTabClose); - if (args.Length == 0) - { + if (args.Length == 0) { NewFile(); - } - else - { - if (args[0] == "/reset") - { + } else { + if (args[0] == "/reset") { NewFile(); - } - else - { - if (Path.GetExtension(args[0]) == ".sol") - { + } else { + if (Path.GetExtension(args[0]) == ".sol") { this.SolutionExplorer.OpenSolution(args[0]); - } - else - { + } else { bool blnRun = false; - foreach (string strFileName in args) - { - if (strFileName == "/run") - { + foreach (string strFileName in args) { + if (strFileName == "/run") { blnRun = true; continue; } @@ -376,8 +348,7 @@ namespace LSLEditor editForm.TextBox.OnCursorPositionChanged += new SyntaxRichTextBox.CursorPositionChangedHandler(TextBox_OnCursorPositionChanged); AddForm(editForm); } - if (blnRun) - { + if (blnRun) { this.stopToolStripMenuItem.Enabled = true; StartSimulator(); } @@ -394,10 +365,11 @@ namespace LSLEditor private XmlDocument GetXmlFromResource(string strName) { XmlDocument xml = new XmlDocument(); - Stream resource = Assembly.GetExecutingAssembly().GetManifestResourceStream(this.GetType().Namespace + "."+strName); + Stream resource = Assembly.GetExecutingAssembly().GetManifestResourceStream(this.GetType().Namespace + "." + strName); - if (resource != null) + if (resource != null) { xml.Load(resource); + } return xml; } @@ -425,18 +397,16 @@ namespace LSLEditor public EditForm OpenFile(string strPath, Guid guid, bool blnIsScript) { EditForm editForm = null; - if (this.Children.Length > 0) - { + if (this.Children.Length > 0) { editForm = this.Children[0] as EditForm; - if (editForm != null && !editForm.IsDisposed) - { - if (editForm.ScriptName != Properties.Settings.Default.ExampleName || editForm.Dirty) + if (editForm != null && !editForm.IsDisposed) { + if (editForm.ScriptName != Properties.Settings.Default.ExampleName || editForm.Dirty) { editForm = null; + } } } - if (editForm == null) - { + if (editForm == null) { editForm = new EditForm(this); editForm.TextBox.OnCursorPositionChanged += new SyntaxRichTextBox.CursorPositionChangedHandler(TextBox_OnCursorPositionChanged); AddForm(editForm); @@ -461,33 +431,34 @@ namespace LSLEditor private void OpenFile(string strFileName) { - OpenFile(strFileName, Guid.Empty , true); + OpenFile(strFileName, Guid.Empty, true); } private string ClippedPath(string strPath) { - if (strPath.Length < Properties.Settings.Default.PathClipLength) - return strPath; - - string strRoot = Path.GetPathRoot(strPath); - string strTmp = ""; - while (strTmp.Length < Properties.Settings.Default.PathClipLength) - { - strTmp = Path.Combine(Path.GetFileName(strPath) , strTmp); - strPath = Path.GetDirectoryName(strPath); - if (strPath == strRoot || strPath == null) - break; + string strResult = strPath; + if (Properties.Settings.Default.PathClipLength < strPath.Length) { + string strRoot = Path.GetPathRoot(strPath); + string strTmp = ""; + while (strTmp.Length < Properties.Settings.Default.PathClipLength) { + strTmp = Path.Combine(Path.GetFileName(strPath), strTmp); + strPath = Path.GetDirectoryName(strPath); + if (strPath == strRoot || strPath == null) { + break; + } + } + strResult = Path.Combine(Path.Combine(strRoot, "..."), strTmp); } - return Path.Combine(Path.Combine(strRoot, "..."), strTmp); + return strPath; } private void InitRecentFileList() { - if (Properties.Settings.Default.RecentFileList == null) + if (Properties.Settings.Default.RecentFileList == null) { Properties.Settings.Default.RecentFileList = new System.Collections.Specialized.StringCollection(); + } int intLen = Properties.Settings.Default.RecentFileList.Count; - for (int intI = 0; intI < intLen; intI++) - { + for (int intI = 0; intI < intLen; intI++) { ToolStripMenuItem tsmi = new ToolStripMenuItem(ClippedPath(Properties.Settings.Default.RecentFileList[intI])); tsmi.Tag = Properties.Settings.Default.RecentFileList[intI]; this.recentFileToolStripMenuItem.DropDownItems.Add(tsmi); @@ -496,11 +467,11 @@ namespace LSLEditor private void InitRecentProjectList() { - if (Properties.Settings.Default.RecentProjectList == null) + if (Properties.Settings.Default.RecentProjectList == null) { Properties.Settings.Default.RecentProjectList = new System.Collections.Specialized.StringCollection(); + } int intLen = Properties.Settings.Default.RecentProjectList.Count; - for (int intI = 0; intI < intLen; intI++) - { + for (int intI = 0; intI < intLen; intI++) { ToolStripMenuItem tsmi = new ToolStripMenuItem(ClippedPath(Properties.Settings.Default.RecentProjectList[intI])); tsmi.Tag = Properties.Settings.Default.RecentProjectList[intI]; this.recentProjectToolStripMenuItem.DropDownItems.Add(tsmi); @@ -510,21 +481,21 @@ namespace LSLEditor private void InitPluginsList() { // erase old plugins - for (int intI = this.toolsStripMenuItem.DropDownItems.Count - 1; intI > 0; intI--) + for (int intI = this.toolsStripMenuItem.DropDownItems.Count - 1; intI > 0; intI--) { this.toolsStripMenuItem.DropDownItems.RemoveAt(intI); + } - if (Properties.Settings.Default.Plugins == null) - return; - - ToolStripMenuItem tsmi; - EventHandler handler = new EventHandler(this.PluginsHandler); - foreach (string strPlugin in Properties.Settings.Default.Plugins) - { - if(strPlugin.ToLower().Contains("lslint")) - tsmi = new ToolStripMenuItem(strPlugin, null, handler, Keys.F7); - else - tsmi = new ToolStripMenuItem(strPlugin, null, handler); - this.toolsStripMenuItem.DropDownItems.Add(tsmi); + if (Properties.Settings.Default.Plugins != null) { + ToolStripMenuItem tsmi; + EventHandler handler = new EventHandler(this.PluginsHandler); + foreach (string strPlugin in Properties.Settings.Default.Plugins) { + if (strPlugin.ToLower().Contains("lslint")) { + tsmi = new ToolStripMenuItem(strPlugin, null, handler, Keys.F7); + } else { + tsmi = new ToolStripMenuItem(strPlugin, null, handler); + } + this.toolsStripMenuItem.DropDownItems.Add(tsmi); + } } } @@ -535,17 +506,14 @@ namespace LSLEditor this.recentFileToolStripMenuItem.DropDownItems.Insert(0, tsmi); Properties.Settings.Default.RecentFileList.Insert(0, strPath); int intListLen = Properties.Settings.Default.RecentFileList.Count; - for (int intI = intListLen - 1; intI > 0; intI--) - { - if (strPath.ToLower() == Properties.Settings.Default.RecentFileList[intI].ToLower()) - { + for (int intI = intListLen - 1; intI > 0; intI--) { + if (strPath.ToLower() == Properties.Settings.Default.RecentFileList[intI].ToLower()) { this.recentFileToolStripMenuItem.DropDownItems.RemoveAt(intI); Properties.Settings.Default.RecentFileList.RemoveAt(intI); } } int intLen = Properties.Settings.Default.RecentFileMax; - if (this.recentFileToolStripMenuItem.DropDownItems.Count > intLen) - { + if (this.recentFileToolStripMenuItem.DropDownItems.Count > intLen) { this.recentFileToolStripMenuItem.DropDownItems.RemoveAt(intLen); Properties.Settings.Default.RecentFileList.RemoveAt(intLen); } @@ -556,25 +524,21 @@ namespace LSLEditor ToolStripMenuItem tsmi = new ToolStripMenuItem(ClippedPath(strPath)); tsmi.Tag = strPath; - if (AddToList) - { + if (AddToList) { this.recentProjectToolStripMenuItem.DropDownItems.Insert(0, tsmi); Properties.Settings.Default.RecentProjectList.Insert(0, strPath); } int intListLen = Properties.Settings.Default.RecentProjectList.Count; - for (int intI = intListLen - 1; intI > 0; intI--) - { - if (strPath.ToLower() == Properties.Settings.Default.RecentProjectList[intI].ToLower()) - { + for (int intI = intListLen - 1; intI > 0; intI--) { + if (strPath.ToLower() == Properties.Settings.Default.RecentProjectList[intI].ToLower()) { this.recentProjectToolStripMenuItem.DropDownItems.RemoveAt(intI); Properties.Settings.Default.RecentProjectList.RemoveAt(intI); } } int intLen = Properties.Settings.Default.RecentProjectMax; - if (this.recentProjectToolStripMenuItem.DropDownItems.Count > intLen) - { + if (this.recentProjectToolStripMenuItem.DropDownItems.Count > intLen) { this.recentProjectToolStripMenuItem.DropDownItems.RemoveAt(intLen); Properties.Settings.Default.RecentProjectList.RemoveAt(intLen); } @@ -584,12 +548,9 @@ namespace LSLEditor private void ReadNoteFiles() { this.openNoteFilesDialog.Multiselect = true; - if (this.openNoteFilesDialog.ShowDialog() == DialogResult.OK) - { - foreach (string strFileName in this.openNoteFilesDialog.FileNames) - { - if (File.Exists(strFileName)) - { + if (this.openNoteFilesDialog.ShowDialog() == DialogResult.OK) { + foreach (string strFileName in this.openNoteFilesDialog.FileNames) { + if (File.Exists(strFileName)) { OpenFile(strFileName, Guid.NewGuid(), false); UpdateRecentFileList(strFileName); } @@ -600,12 +561,9 @@ namespace LSLEditor private void ReadScriptFiles() { this.openScriptFilesDialog.Multiselect = true; - if (this.openScriptFilesDialog.ShowDialog() == DialogResult.OK) - { - foreach (string strFileName in this.openScriptFilesDialog.FileNames) - { - if (File.Exists(strFileName)) - { + if (this.openScriptFilesDialog.ShowDialog() == DialogResult.OK) { + foreach (string strFileName in this.openScriptFilesDialog.FileNames) { + if (File.Exists(strFileName)) { OpenFile(strFileName, Guid.NewGuid()); UpdateRecentFileList(strFileName); } @@ -625,17 +583,16 @@ namespace LSLEditor public bool SaveFile(EditForm editForm, bool blnSaveAs) { DialogResult dialogresult = DialogResult.OK; - if (editForm.FullPathName == Properties.Settings.Default.ExampleName || blnSaveAs) - { + if (editForm.FullPathName == Properties.Settings.Default.ExampleName || blnSaveAs) { SaveFileDialog saveDialog = editForm.IsScript ? this.saveScriptFilesDialog : this.saveNoteFilesDialog; saveDialog.FileName = editForm.FullPathName; string strExtension = Path.GetExtension(editForm.FullPathName); dialogresult = saveDialog.ShowDialog(); - if (dialogresult == DialogResult.OK) + if (dialogresult == DialogResult.OK) { editForm.FullPathName = saveDialog.FileName; + } } - if (dialogresult == DialogResult.OK) - { + if (dialogresult == DialogResult.OK) { editForm.SaveCurrentFile(); UpdateRecentFileList(editForm.FullPathName); return true; @@ -646,23 +603,24 @@ namespace LSLEditor // save file of active MDI child, if any private bool SaveActiveFile() { + bool blnResult = false; EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm == null) - return false; - // save as!! - // TODO: Refactor saveDialog to be a property of the form - SaveFileDialog saveDialog = editForm.IsScript ? this.saveScriptFilesDialog : this.saveNoteFilesDialog; - return SaveFile(editForm, true); + if (editForm != null) { + // save as!! + // TODO: Refactor saveDialog to be a property of the form + SaveFileDialog saveDialog = editForm.IsScript ? this.saveScriptFilesDialog : this.saveNoteFilesDialog; + blnResult = SaveFile(editForm, true); + } + return blnResult; } - private void saveToolStripMenuItem_Click(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm == null) - return; - editForm.SaveCurrentFile(); - this.Focus(); + if (editForm != null) { + editForm.SaveCurrentFile(); + this.Focus(); + } } private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) @@ -672,37 +630,30 @@ namespace LSLEditor private Browser GetBrowser() { - if (this.browser == null || this.browser.IsDisposed) - { + if (this.browser == null || this.browser.IsDisposed) { this.browser = new Browser(this); - if (Properties.Settings.Default.BrowserLocation != Point.Empty) - { + if (Properties.Settings.Default.BrowserLocation != Point.Empty) { this.browser.StartPosition = FormStartPosition.Manual; this.browser.Location = Properties.Settings.Default.BrowserLocation; } - if (Properties.Settings.Default.BrowserSize != Size.Empty) + if (Properties.Settings.Default.BrowserSize != Size.Empty) { this.browser.Size = Properties.Settings.Default.BrowserSize; + } this.browser.SizeChanged += new EventHandler(browser_SizeChanged); this.browser.LocationChanged += new EventHandler(browser_LocationChanged); - if (this.browserInWindowToolStripMenuItem.Checked) - { + if (this.browserInWindowToolStripMenuItem.Checked) { this.browser.MdiParent = null; this.browser.Show(); - } - else - { + } else { AddForm(this.browser); //this.browser.MdiParent = this; } } this.browser.Activate(); - if (this.IsMdiContainer) - { + if (this.IsMdiContainer) { this.ActivateMdiChild(this.browser); - } - else - { + } else { //TODO: find browser in childs /*for (int intI = 0; intI < this.tabControlExtended1.TabCount; intI++) { @@ -735,20 +686,17 @@ namespace LSLEditor { // Initialize the dialog's PrinterSettings property to hold user // defined printer settings. - pageSetupDialog1.PageSettings = - new System.Drawing.Printing.PageSettings(); + pageSetupDialog1.PageSettings = new System.Drawing.Printing.PageSettings(); // Initialize dialog's PrinterSettings property to hold user // set printer settings. - pageSetupDialog1.PrinterSettings = - new System.Drawing.Printing.PrinterSettings(); + pageSetupDialog1.PrinterSettings = new System.Drawing.Printing.PrinterSettings(); //Do not show the network in the printer dialog. pageSetupDialog1.ShowNetwork = false; //Show the dialog storing the result. - if (pageSetupDialog1.ShowDialog() != DialogResult.OK) - { + if (pageSetupDialog1.ShowDialog() != DialogResult.OK) { pageSetupDialog1.PageSettings = null; pageSetupDialog1.PrinterSettings = null; } @@ -757,8 +705,7 @@ namespace LSLEditor private void printPreviewtoolStripMenuItem_Click(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm != null) - { + if (editForm != null) { printerHelp(editForm); printer.PrintPreviewEditForm(editForm); } @@ -767,8 +714,7 @@ namespace LSLEditor private void printToolStripMenuItem_Click(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm != null) - { + if (editForm != null) { printerHelp(editForm); printer.PrintEditForm(editForm); } @@ -786,9 +732,9 @@ namespace LSLEditor private void copyToClipboardToolStripMenuItem_Click(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm == null) - return; - editForm.TextBox.ToClipBoard(); + if (editForm != null) { + editForm.TextBox.ToClipBoard(); + } } private void exitToolStripMenuItem_Click(object sender, EventArgs e) @@ -799,84 +745,82 @@ namespace LSLEditor private void undoToolStripMenuItem_Click(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm == null) - return; - editForm.TextBox.Undo(); + if (editForm != null) { + editForm.TextBox.Undo(); + } } private void redoToolStripMenuItem_Click(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm == null) - return; - editForm.TextBox.Redo(); + if (editForm != null) { + editForm.TextBox.Redo(); + } } private void cutToolStripMenuItem_Click(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm == null) - return; - editForm.TextBox.Cut(); + if (editForm != null) { + editForm.TextBox.Cut(); + } } private void copyToolStripMenuItem_Click(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm == null) - return; - editForm.TextBox.Copy(); + if (editForm != null) { + editForm.TextBox.Copy(); + } } private void pasteToolStripMenuItem_Click(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm == null) - return; - editForm.TextBox.Paste(); + if (editForm != null) { + editForm.TextBox.Paste(); + } } private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm == null) - return; - editForm.TextBox.Delete(); + if (editForm != null) { + editForm.TextBox.Delete(); + } } private void selectAllToolStripMenuItem_Click(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm == null) - return; - editForm.TextBox.SelectAll(); + if (editForm != null) { + editForm.TextBox.SelectAll(); + } } private void formatDocumentToolStripMenuItem_Click(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm == null) - return; - editForm.TextBox.FormatDocument(); + if (editForm != null) { + editForm.TextBox.FormatDocument(); + } } private void formatSelectedTextToolStripMenuItem_Click(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm == null) - return; - editForm.TextBox.AutoFormatSelectedText(); + if (editForm != null) { + editForm.TextBox.AutoFormatSelectedText(); + } } private void wordWrapToolStripMenuItem_Click(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm != null) - { + if (editForm != null) { ToolStripMenuItem tsmi = sender as ToolStripMenuItem; - if (tsmi != null) - { + if (tsmi != null) { tsmi.Checked = !tsmi.Checked; editForm.TextBox.WordWrap = tsmi.Checked; } @@ -912,11 +856,13 @@ namespace LSLEditor Font listBoxFont; Font toolTipFont; - 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); + } toolTipFont = Properties.Settings.Default.FontTooltips; listBoxFont = Properties.Settings.Default.FontEditor; @@ -926,11 +872,11 @@ namespace LSLEditor this.TooltipListBox.Font = toolTipFont; this.GListBoxWindow.Font = listBoxFont; - foreach (Form form in this.Children) - { + foreach (Form form in this.Children) { EditForm editForm = form as EditForm; - if (editForm == null || editForm.IsDisposed) + if (editForm == null || editForm.IsDisposed) { continue; + } editForm.SetFont(); } } @@ -975,7 +921,7 @@ namespace LSLEditor imageList.Images.Add(new Bitmap(this.GetType(), "Images.States.gif")); this.GListBoxWindow.GListBox.ImageList = imageList; - // this.tvOutline.ImageList = imageList; + // this.tvOutline.ImageList = imageList; this.Move += new EventHandler(LSLEditorForm_SetPosition); this.Resize += new EventHandler(LSLEditorForm_SetPosition); @@ -987,44 +933,43 @@ namespace LSLEditor void GListBox_SelectedIndexChanged(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm != null) + if (editForm != null) { editForm.TextBox.ShowTooltipOnListBox(); + } } void GListBox_DoubleClick(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm != null) + if (editForm != null) { editForm.TextBox.InsertSelectedWord(); + } } private void LSLEditorForm_SetPosition(object sender, EventArgs e) { - foreach (PermissionsForm pf in this.PermissionForms) - { + foreach (PermissionsForm pf in this.PermissionForms) { pf.Top = this.Top + 30; pf.Left = this.Right - pf.Width - 5; } - foreach(llDialogForm df in this.llDialogForms) - { + foreach (llDialogForm df in this.llDialogForms) { df.Top = this.Top + 30; df.Left = this.Right - df.Width - 5; } - foreach(llTextBoxForm tbf in this.llTextBoxForms) - { + foreach (llTextBoxForm tbf in this.llTextBoxForms) { tbf.Left = this.Left + this.Width / 2 - tbf.Width / 2; tbf.Top = this.Top + this.Height / 2 - tbf.Height / 2; } EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm != null) + if (editForm != null) { editForm.TextBox.SetPosition(Screen.PrimaryScreen.WorkingArea); + } } private void LoadProperties() { - try - { + try { //TODO: hmmm? //this.tabControlExtended1.Visible = false; @@ -1036,53 +981,45 @@ namespace LSLEditor Size size = Properties.Settings.Default.LSLEditorSize; Point location = Properties.Settings.Default.LSLEditorLocation; Rectangle rect = new Rectangle(location, size); - if(Screen.PrimaryScreen.WorkingArea.Contains(rect)) - { - if (size.Width > 100 && size.Height > 100) - { + if (Screen.PrimaryScreen.WorkingArea.Contains(rect)) { + if (size.Width > 100 && size.Height > 100) { this.Location = location; this.Size = size; } } - this.browserInWindowToolStripMenuItem.Checked = - Properties.Settings.Default.BrowserInWindow; + this.browserInWindowToolStripMenuItem.Checked = Properties.Settings.Default.BrowserInWindow; - this.WikiSepBrowserstoolStripMenuItem.Checked = - Properties.Settings.Default.WikiSeperateBrowser; + this.WikiSepBrowserstoolStripMenuItem.Checked = Properties.Settings.Default.WikiSeperateBrowser; - } - catch(Exception exception) - { + } catch (Exception exception) { MessageBox.Show("Error Properties: " + OopsFormatter.ApplyFormatting(exception.Message), "Oops, but continue"); } } + // TODO cleanup multiple return points public bool CloseAllOpenWindows() { - foreach (Form form in this.Children) - { + foreach (Form form in this.Children) { EditForm editForm = form as EditForm; - if (editForm == null || editForm.IsDisposed) + if (editForm == null || editForm.IsDisposed) { continue; + } ActivateMdiForm(editForm); - if (editForm.Dirty) - { + if (editForm.Dirty) { DialogResult dialogResult = MessageBox.Show(this, @"Save """ + editForm.ScriptName + @"""?", "File has changed", MessageBoxButtons.YesNoCancel); - if (dialogResult == DialogResult.Cancel) - { + if (dialogResult == DialogResult.Cancel) { return false; } - if (dialogResult == DialogResult.Yes) - { + if (dialogResult == DialogResult.Yes) { // TODO: Refactor saveDialog to be a property of the form SaveFileDialog saveDialog = editForm.IsScript ? this.saveScriptFilesDialog : this.saveNoteFilesDialog; - if(!SaveFile(editForm, false)) + if (!SaveFile(editForm, false)) { return false; + } } - if (dialogResult == DialogResult.No) - { + if (dialogResult == DialogResult.No) { editForm.Dirty = false; } } @@ -1091,59 +1028,50 @@ namespace LSLEditor return true; } + // TODO cleanup multiple return points private void LSLEditorForm_FormClosing(object sender, FormClosingEventArgs e) { - try - { + try { Properties.Settings.Default.LSLEditorSize = this.Size; Properties.Settings.Default.LSLEditorLocation = this.Location; Properties.Settings.Default.Save(); - if (this.IsMdiContainer) - { + if (this.IsMdiContainer) { // this is set by any EditForm close e.Cancel = this.CancelClosing; return; } - if (this.SolutionExplorer != null & !this.SolutionExplorer.IsDisposed) - { + if (this.SolutionExplorer != null & !this.SolutionExplorer.IsDisposed) { this.SolutionExplorer.CloseSolution(); } e.Cancel = !CloseAllOpenWindows(); - } - catch - { - } + } catch { } } private void helpKeywordToolStripMenuItem_Click(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm == null) - return; - - Point dummy; - string strKeyWord = editForm.TextBox.GetCurrentKeyWord(false, out dummy); - ShowHelpOnKeyWord(strKeyWord); + if (editForm != null) { + Point dummy; + string strKeyWord = editForm.TextBox.GetCurrentKeyWord(false, out dummy); + ShowHelpOnKeyWord(strKeyWord); + } } + // TODO cleanup multiple return points private void ShowHelpOnKeyWord(string strKeyWord) { - if (Properties.Settings.Default.HelpOffline) - { + if (Properties.Settings.Default.HelpOffline) { string strHelpFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Properties.Settings.Default.HelpOfflineFile); - if (!File.Exists(strHelpFile)) - { - if (MessageBox.Show("No Offline help, use Online Wiki?", "Offline Help fails", MessageBoxButtons.OKCancel,MessageBoxIcon.Question) != DialogResult.OK) + if (!File.Exists(strHelpFile)) { + if (MessageBox.Show("No Offline help, use Online Wiki?", "Offline Help fails", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) return; - } - else - { + } else { if (strKeyWord == "") Help.ShowHelp(this, strHelpFile); else @@ -1154,15 +1082,13 @@ namespace LSLEditor string strUrl = Properties.Settings.Default.Help + strKeyWord; - if (strKeyWord == "") + if (strKeyWord == "") { strKeyWord = "Help"; - - if (Properties.Settings.Default.WikiSeperateBrowser) - { - System.Diagnostics.Process.Start(strUrl); } - else - { + + if (Properties.Settings.Default.WikiSeperateBrowser) { + System.Diagnostics.Process.Start(strUrl); + } else { Browser browser = GetBrowser(); browser.ShowWebBrowser(strKeyWord, strUrl); } @@ -1190,8 +1116,7 @@ namespace LSLEditor private void InitSyntaxError() { // information out of every script - if (this.SyntaxErrors == null) - { + if (this.SyntaxErrors == null) { this.SyntaxErrors = new SyntaxError(); this.SyntaxErrors.OnSyntaxError += new SyntaxError.SyntaxErrorHandler(SyntaxErrors_OnSyntaxError); this.SyntaxErrors.Dock = DockStyle.Fill; @@ -1202,87 +1127,82 @@ namespace LSLEditor private void SyntaxErrors_OnSyntaxError(object sender, SyntaxError.SyntaxErrorEventArgs e) { EditForm editForm = null; - foreach (Form form in this.Children) - { + foreach (Form form in this.Children) { editForm = form as EditForm; - if (editForm == null || editForm.IsDisposed) + if (editForm == null || editForm.IsDisposed) { continue; - if (editForm.FullPathName == e.FullPathName) - { + } + if (editForm.FullPathName == e.FullPathName) { ActivateMdiForm(editForm); editForm.TextBox.Goto(e.Line, e.Char); editForm.Focus(); return; } } - editForm = OpenFile(e.FullPathName,e.EditFormGuid,e.IsScript); + editForm = OpenFile(e.FullPathName, e.EditFormGuid, e.IsScript); editForm.TextBox.Goto(e.Line, e.Char); editForm.Focus(); } private void StartSimulator() { - if (!SyntaxCheck(true)) - return; + if (SyntaxCheck(true)) { + this.SimulatorConsole = new SimulatorConsole(this.SolutionExplorer, this.Children); - this.SimulatorConsole = new SimulatorConsole(this.SolutionExplorer, this.Children); - - this.SimulatorConsole.Show(dockPanel); - //TODO: Show Simulator Console somewhere - //this.panel1.Controls.Clear(); - //this.panel1.Controls.Add(this.SimulatorConsole); - //this.panel1.Visible = true; - //this.splitter1.SplitPosition = Properties.Settings.Default.SimulatorSize.Height; + this.SimulatorConsole.Show(dockPanel); + //TODO: Show Simulator Console somewhere + //this.panel1.Controls.Clear(); + //this.panel1.Controls.Add(this.SimulatorConsole); + //this.panel1.Visible = true; + //this.splitter1.SplitPosition = Properties.Settings.Default.SimulatorSize.Height; + } } public void StopSimulator() { //TODO: Hide simulator? Or we could keep it like the debug output in VS //this.panel1.Visible = false; - if (this.SimulatorConsole != null) - { + if (this.SimulatorConsole != null) { this.SimulatorConsole.Stop(); this.SimulatorConsole.Dispose(); } this.SimulatorConsole = null; } - private bool SyntaxCheck(bool Silent) { //TODO: What do we hide on SyntaxCheck? //this.panel1.Visible = false; InitSyntaxError(); - foreach (Form form in this.Children) - { + foreach (Form form in this.Children) { EditForm editForm = form as EditForm; - if (editForm == null || editForm.IsDisposed) + if (editForm == null || editForm.IsDisposed) { continue; - if (Properties.Settings.Default.AutoSaveOnDebug) - { - if (editForm.Dirty) + } + if (Properties.Settings.Default.AutoSaveOnDebug) { + if (editForm.Dirty) { editForm.SaveCurrentFile(); + } } editForm.SyntaxCheck(); } - if (this.SyntaxErrors.HasErrors) - { + bool blnResult = false; + if (this.SyntaxErrors.HasErrors) { this.SyntaxErrors.Show(dockPanel); //TODO: Show errors somewhere in an output //this.panel1.Controls.Clear(); //this.panel1.Controls.Add(this.SyntaxErrors); //this.panel1.Visible = true; //this.splitter1.SplitPosition = Properties.Settings.Default.SimulatorSize.Height; - return false; - } - else - { - if (!Silent) + } else { + if (!Silent) { MessageBox.Show("LSL Syntax seems OK", "LSL Syntax Checker", MessageBoxButtons.OK, MessageBoxIcon.Information); - return true; + } + blnResult = true; } + return blnResult; } private void releaseNotesToolStripMenuItem_Click(object sender, EventArgs e) @@ -1321,18 +1241,15 @@ namespace LSLEditor private void tabControlExtended1_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(tabControl, 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(tabControl, new Point(e.X, e.Y)); + } } } } @@ -1340,11 +1257,11 @@ namespace LSLEditor private bool IsInSolutionExplorer(Guid guid) { - if (this.SolutionExplorer == null || this.SolutionExplorer.IsDisposed) - return false; - if (this.SolutionExplorer.GetKey(guid) == null) - return false; - return true; + bool blnResult = true; + if (this.SolutionExplorer == null || this.SolutionExplorer.IsDisposed || this.SolutionExplorer.GetKey(guid) == null) { + blnResult = false; + } + return blnResult; } @@ -1415,31 +1332,27 @@ namespace LSLEditor private void toolStripMenuItem1_Click(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm == null) - return; - if (GotoWindow == null || GotoWindow.IsDisposed) - { - GotoWindow = new GotoWindow(this); - if (Properties.Settings.Default.GotoLocation != Point.Empty) - { - GotoWindow.StartPosition = FormStartPosition.Manual; - GotoWindow.Location = Properties.Settings.Default.GotoLocation; + if (editForm != null) { + if (GotoWindow == null || GotoWindow.IsDisposed) { + GotoWindow = new GotoWindow(this); + if (Properties.Settings.Default.GotoLocation != Point.Empty) { + GotoWindow.StartPosition = FormStartPosition.Manual; + GotoWindow.Location = Properties.Settings.Default.GotoLocation; + } + GotoWindow.LocationChanged += new EventHandler(gotoForm_LocationChanged); } - GotoWindow.LocationChanged += new EventHandler(gotoForm_LocationChanged); + GotoWindow.Show(this); } - GotoWindow.Show(this); } public void CloseActiveWindow() { - if (this.IsMdiContainer) - { - if(this.ActiveMdiForm!=null && !this.ActiveMdiForm.IsDisposed) + if (this.IsMdiContainer) { + if (this.ActiveMdiForm != null && !this.ActiveMdiForm.IsDisposed) { this.ActiveMdiForm.Close(); - } - else - { + } + } else { //TODO: Find a new way /* int intTabToClose = this.tabControlExtended1.SelectedIndex; @@ -1464,8 +1377,7 @@ namespace LSLEditor private void LSLEditorForm_Load(object sender, EventArgs e) { LoadProperties(); - if (Properties.Settings.Default.CheckForUpdates) - { + if (Properties.Settings.Default.CheckForUpdates) { updateApplicationForm = new UpdateApplicationForm(); updateApplicationForm.Icon = this.Icon; updateApplicationForm.OnUpdateAvailable += new EventHandler(updateApplicationForm_OnUpdateAvailable); @@ -1481,42 +1393,43 @@ namespace LSLEditor private void commentInToolStripMenuItem_Click(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm == null) - return; - editForm.TextBox.MultiLineComment(true); + if (editForm != null) { + editForm.TextBox.MultiLineComment(true); + } } private void uncommentingSelectedTextToolStripMenuItem_Click(object sender, EventArgs e) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm == null) - return; - editForm.TextBox.MultiLineComment(false); + if (editForm != null) { + editForm.TextBox.MultiLineComment(false); + } } private void FindandReplace(bool blnReplaceAlso) { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm == null) - return; - if (findWindow == null || findWindow.IsDisposed) - { - findWindow = new FindWindow(this); - findWindow.LocationChanged += new EventHandler(findForm_LocationChanged); + if (editForm != null) { + if (findWindow == null || findWindow.IsDisposed) { + findWindow = new FindWindow(this); + findWindow.LocationChanged += new EventHandler(findForm_LocationChanged); + } + Rectangle rect = new Rectangle(this.Location, this.Size); + if (rect.Contains(Properties.Settings.Default.FindLocation)) { + findWindow.Location = Properties.Settings.Default.FindLocation; + } else { + findWindow.Location = this.Location; + } + Point dummy; + findWindow.ReplaceAlso = blnReplaceAlso; + findWindow.KeyWord = editForm.TextBox.GetCurrentKeyWord(false, out dummy); + if (findWindow.Visible == false) { + findWindow.Show(this); + } + findWindow.FindFocus(); } - Rectangle rect = new Rectangle(this.Location, this.Size); - if (rect.Contains(Properties.Settings.Default.FindLocation)) - findWindow.Location = Properties.Settings.Default.FindLocation; - else - findWindow.Location = this.Location; - Point dummy; - findWindow.ReplaceAlso = blnReplaceAlso; - findWindow.KeyWord = editForm.TextBox.GetCurrentKeyWord(false, out dummy); - if (findWindow.Visible == false) - findWindow.Show(this); - findWindow.FindFocus(); } private void replaceToolStripMenuItem_Click(object sender, EventArgs e) @@ -1531,8 +1444,9 @@ namespace LSLEditor private void findNextToolStripMenuItem_Click(object sender, EventArgs e) { - if (findWindow != null && !findWindow.IsDisposed) + if (findWindow != null && !findWindow.IsDisposed) { findWindow.Find(); + } } @@ -1540,12 +1454,9 @@ namespace LSLEditor { //TODO: We need another way to activate the Solution Explorer //this.panel2.Visible = blnVisible; - if (blnVisible) - { + if (blnVisible) { m_SolutionExplorer.Show(dockPanel); - } - else - { + } else { m_SolutionExplorer.Hide(); } this.solutionExplorerToolStripMenuItem.Checked = blnVisible; @@ -1592,14 +1503,13 @@ namespace LSLEditor private void recentFileToolStripMenuItem_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) { ToolStripMenuItem tsmi = e.ClickedItem as ToolStripMenuItem; - if (tsmi == null) - return; + if (tsmi != null) { + this.fileStripMenuItem.HideDropDown(); - this.fileStripMenuItem.HideDropDown(); - - string strPath = tsmi.Tag.ToString(); - OpenFile(strPath, Guid.NewGuid()); - UpdateRecentFileList(strPath); + string strPath = tsmi.Tag.ToString(); + OpenFile(strPath, Guid.NewGuid()); + UpdateRecentFileList(strPath); + } } private void makeBugReporttoolStripMenuItem_Click(object sender, EventArgs e) @@ -1624,12 +1534,11 @@ namespace LSLEditor #region SolutionExplorer private void openProjectSolutionToolStripMenuItem_Click(object sender, EventArgs e) { - if (this.openSolutionFilesDialog.ShowDialog(this) == DialogResult.OK) - { - if (File.Exists(this.openSolutionFilesDialog.FileName)) - { - if(CloseAllOpenWindows()) + if (this.openSolutionFilesDialog.ShowDialog(this) == DialogResult.OK) { + if (File.Exists(this.openSolutionFilesDialog.FileName)) { + if (CloseAllOpenWindows()) { this.SolutionExplorer.OpenSolution(this.openSolutionFilesDialog.FileName); + } } } } @@ -1637,8 +1546,9 @@ namespace LSLEditor private void newProjectToolStripMenuItem_Click(object sender, EventArgs e) { NewProject np = new NewProject(this); - if (np.ShowDialog(this) == DialogResult.OK) + if (np.ShowDialog(this) == DialogResult.OK) { CloseAllOpenWindows(); + } } @@ -1661,52 +1571,45 @@ namespace LSLEditor { this.SolutionExplorer.AddNewObject(); } - #endregion SolutionExplorer private void recentProjectToolStripMenuItem_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) { ToolStripMenuItem tsmi = e.ClickedItem as ToolStripMenuItem; - if (tsmi == null) - return; + if (tsmi != null) { + this.fileStripMenuItem.HideDropDown(); - this.fileStripMenuItem.HideDropDown(); - - if (CloseAllOpenWindows()) - { - string strPath = tsmi.Tag.ToString(); - this.SolutionExplorer.OpenSolution(strPath); + if (CloseAllOpenWindows()) { + string strPath = tsmi.Tag.ToString(); + this.SolutionExplorer.OpenSolution(strPath); + } } } private void LSLEditorForm_DragEnter(object sender, DragEventArgs e) { - if (e.Data.GetDataPresent(DataFormats.FileDrop)) + if (e.Data.GetDataPresent(DataFormats.FileDrop)) { e.Effect = DragDropEffects.Copy; - else + } else { e.Effect = DragDropEffects.None; + } } private delegate void DelegateOpenFile(string s); private void LSLEditorForm_DragDrop(object sender, DragEventArgs e) { - try - { + try { DelegateOpenFile delegateOpenFile = new DelegateOpenFile(OpenFile); Array allFiles = (Array)e.Data.GetData(DataFormats.FileDrop); - if (allFiles == null) - return; + if (allFiles != null) { + for (int intI = 0; intI < allFiles.Length; intI++) { + string strFileName = allFiles.GetValue(intI).ToString(); + this.BeginInvoke(delegateOpenFile, new object[] { strFileName }); + } - for (int intI = 0; intI < allFiles.Length; intI++) - { - string strFileName = allFiles.GetValue(intI).ToString(); - this.BeginInvoke(delegateOpenFile, new object[] { strFileName }); + this.Activate(); // in the case Explorer overlaps this form } - - this.Activate(); // in the case Explorer overlaps this form - } - catch - { + } catch { // Error in DragDrop function (dont show messagebox, explorer is waiting } } @@ -1740,19 +1643,13 @@ namespace LSLEditor Plugins.LSLint lslint = new Plugins.LSLint(); - if (lslint.SyntaxCheck(this)) - { - if (lslint.HasErrors) - { + if (lslint.SyntaxCheck(this)) { + if (lslint.HasErrors) { this.SyntaxErrors.Show(dockPanel); - } - else - { + } else { MessageBox.Show("LSL Syntax seems OK", "LSLint Syntax Checker", MessageBoxButtons.OK, MessageBoxIcon.Information); } - } - else - { + } else { MessageBox.Show("LSLint:" + lslint.ExceptionMessage, "LSLint plugin", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -1764,15 +1661,12 @@ namespace LSLEditor private void SvnPlugin() { - if (File.Exists(Svn.Executable)) - { + if (File.Exists(Svn.Executable)) { Properties.Settings.Default.VersionControl = true; Properties.Settings.Default.VersionControlSVN = true; Properties.Settings.Default.SvnExe = Svn.Executable; MessageBox.Show("SVN is installed and can be used in the solution explorer", "SVN information", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - else - { + } else { Properties.Settings.Default.VersionControl = false; Properties.Settings.Default.VersionControlSVN = false; MessageBox.Show("SVN is NOT installed (can not find svn binary)", "SVN information", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -1791,36 +1685,35 @@ namespace LSLEditor //this.panel1.Visible = false; ToolStripMenuItem tsmi = sender as ToolStripMenuItem; - if (tsmi == null) - return; - - switch (tsmi.Text.ToLower()) - { - case "lslint": - LSLint(); - break; - case "particles": - Particles(); - break; - case "svn (version control)": - SvnPlugin(); - break; - default: - GenericPlugin(tsmi.Text); - //MessageBox.Show("Unknown plugin", "LSLEditor plugins warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); - break; + if (tsmi != null) { + switch (tsmi.Text.ToLower()) { + case "lslint": + LSLint(); + break; + case "particles": + Particles(); + break; + case "svn (version control)": + SvnPlugin(); + break; + default: + GenericPlugin(tsmi.Text); + //MessageBox.Show("Unknown plugin", "LSLEditor plugins warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); + break; + } } } private void SaveAllToolStripMenuItem_Click(object sender, EventArgs e) { - foreach (Form form in this.Children) - { + foreach (Form form in this.Children) { EditForm editForm = form as EditForm; - if (editForm == null || editForm.IsDisposed) + if (editForm == null || editForm.IsDisposed) { continue; - if (editForm.Dirty) + } + if (editForm.Dirty) { editForm.SaveCurrentFile(); + } } // save it all, also solution explorer file if (this.SolutionExplorer != null & !this.SolutionExplorer.IsDisposed) @@ -1830,15 +1723,12 @@ namespace LSLEditor private void SetupFileMenu() { EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm != null) - { + if (editForm != null) { this.saveToolStripMenuItem.Text = "Save " + editForm.ScriptName; this.saveScriptFilesDialog.FileName = editForm.ScriptName; this.saveToolStripMenuItem.Enabled = editForm.Dirty; this.closeFileToolStripMenuItem.Enabled = true; - } - else - { + } else { this.closeFileToolStripMenuItem.Enabled = false; } } @@ -1847,8 +1737,9 @@ namespace LSLEditor { SetupFileMenu(); EditForm ef = this.ActiveMdiForm as EditForm; - if (ef != null) + if (ef != null) { ef.SetFocus(); + } } private void LSLEditorForm_MdiChildActivate(object sender, EventArgs e) @@ -1882,10 +1773,10 @@ namespace LSLEditor { //NativeHelper.SendMyKeys.PasteTextToApp("hello", "SecondLife", null); EditForm editForm = this.ActiveMdiForm as EditForm; - if (editForm == null) - return; - editForm.TextBox.ToClipBoard(); - NativeHelper.SendMyKeys.ClipBoardToApp("SecondLife", null); + if (editForm != null) { + editForm.TextBox.ToClipBoard(); + NativeHelper.SendMyKeys.ClipBoardToApp("SecondLife", null); + } } private void outlineToolStripMenuItem_Click(object sender, EventArgs e) @@ -1895,30 +1786,22 @@ namespace LSLEditor private void outlineToolStripMenuItem_CheckedChanged(object sender, EventArgs e) { - foreach (Form k in this.Children) - { + foreach (Form k in this.Children) { EditForm editForm = k as EditForm; - if (editForm == null) - return; - if (outlineToolStripMenuItem.Checked) - { - editForm.splitContainer1.Panel2Collapsed = false; - } - else - { - editForm.splitContainer1.Panel2Collapsed = true; + if (editForm == null) { + if (outlineToolStripMenuItem.Checked) { + editForm.splitContainer1.Panel2Collapsed = false; + } else { + editForm.splitContainer1.Panel2Collapsed = true; + } } } } - - private void toolStripMenuItem9_Click_1(object sender, EventArgs e) { Browser browser = GetBrowser(); browser.ShowWebBrowser("LSLEditor QA", Properties.Settings.Default.qasite); } - - } -} \ No newline at end of file +} diff --git a/trunk/PermissionsForm.cs b/trunk/PermissionsForm.cs index ab834a6..4d64c37 100644 --- a/trunk/PermissionsForm.cs +++ b/trunk/PermissionsForm.cs @@ -72,28 +72,35 @@ namespace LSLEditor StringBuilder sb = new StringBuilder(); - if ((intPermissions & SecondLife.PERMISSION_DEBIT) == SecondLife.PERMISSION_DEBIT) + if ((intPermissions & SecondLife.PERMISSION_DEBIT) == SecondLife.PERMISSION_DEBIT) { sb.AppendLine("Take Linden dollars (L$) from you"); + } - if ((intPermissions & SecondLife.PERMISSION_TAKE_CONTROLS) == SecondLife.PERMISSION_TAKE_CONTROLS) + if ((intPermissions & SecondLife.PERMISSION_TAKE_CONTROLS) == SecondLife.PERMISSION_TAKE_CONTROLS) { sb.AppendLine("Act on your control inputs"); + } - if ((intPermissions & SecondLife.PERMISSION_TRIGGER_ANIMATION) == SecondLife.PERMISSION_TRIGGER_ANIMATION) + if ((intPermissions & SecondLife.PERMISSION_TRIGGER_ANIMATION) == SecondLife.PERMISSION_TRIGGER_ANIMATION) { sb.AppendLine("Animate your avatar"); + } - if ((intPermissions & SecondLife.PERMISSION_ATTACH) == SecondLife.PERMISSION_ATTACH) + if ((intPermissions & SecondLife.PERMISSION_ATTACH) == SecondLife.PERMISSION_ATTACH) { sb.AppendLine("Attach to your avatar"); + } - if ((intPermissions & SecondLife.PERMISSION_CHANGE_LINKS) == SecondLife.PERMISSION_CHANGE_LINKS) + if ((intPermissions & SecondLife.PERMISSION_CHANGE_LINKS) == SecondLife.PERMISSION_CHANGE_LINKS) { sb.AppendLine("Link and delink from other objects"); + } - if ((intPermissions & SecondLife.PERMISSION_TRACK_CAMERA) == SecondLife.PERMISSION_TRACK_CAMERA) + if ((intPermissions & SecondLife.PERMISSION_TRACK_CAMERA) == SecondLife.PERMISSION_TRACK_CAMERA) { sb.AppendLine("Track your camera"); + } - if ((intPermissions & SecondLife.PERMISSION_CONTROL_CAMERA) == SecondLife.PERMISSION_CONTROL_CAMERA) + if ((intPermissions & SecondLife.PERMISSION_CONTROL_CAMERA) == SecondLife.PERMISSION_CONTROL_CAMERA) { sb.AppendLine("Control your camera"); + } - this.label1.Text = "'"+strObjectName+"', an object owned by '"+strOwner + "',\nwould like to:"; + this.label1.Text = "'" + strObjectName + "', an object owned by '" + strOwner + "',\nwould like to:"; this.label2.Text = sb.ToString(); } @@ -109,4 +116,4 @@ namespace LSLEditor this.Close(); } } -} \ No newline at end of file +} diff --git a/trunk/Properties/AssemblyInfo.cs b/trunk/Properties/AssemblyInfo.cs index aeaf400..5f3912f 100644 --- a/trunk/Properties/AssemblyInfo.cs +++ b/trunk/Properties/AssemblyInfo.cs @@ -70,7 +70,7 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: // We use a Major.Minor.Bugfix.Build pattern. -[assembly: AssemblyVersion("2.999.999.7")] +[assembly: AssemblyVersion("2.999.999.13")] // // In order to sign your assembly you must specify a key to use. Refer to the @@ -100,4 +100,4 @@ using System.Runtime.InteropServices; [assembly: AssemblyDelaySign(false)] //[assembly: AssemblyKeyName("")] [assembly: ComVisibleAttribute(false)] -[assembly: AssemblyFileVersionAttribute("2.999.999.7")] +[assembly: AssemblyFileVersionAttribute("2.999.999.13")] diff --git a/trunk/RuntimeConsole.cs b/trunk/RuntimeConsole.cs index 0bf28d6..47ad84e 100644 --- a/trunk/RuntimeConsole.cs +++ b/trunk/RuntimeConsole.cs @@ -74,27 +74,29 @@ namespace LSLEditor private bool GetNewHost() { + bool blnResult = false; Assembly assembly = CompilerHelper.CompileCSharp(editForm, CSharpCode); - if (assembly == null) - return false; + if (assembly != null) { + if (SecondLifeHost != null) { + SecondLifeHost.Dispose(); + } + SecondLifeHost = null; - if(SecondLifeHost!=null) - SecondLifeHost.Dispose(); - SecondLifeHost = null; + SecondLifeHost = new SecondLifeHost(this.mainForm, assembly, editForm.FullPathName, editForm.guid); + SecondLifeHost.OnChat += editForm.ChatHandler; + SecondLifeHost.OnMessageLinked += editForm.MessageLinkedHandler; + SecondLifeHost.OnDie += new EventHandler(host_OnDie); + SecondLifeHost.OnReset += new EventHandler(SecondLifeHost_OnReset); + SecondLifeHost.OnListenChannelsChanged += new EventHandler(SecondLifeHost_OnListenChannelsChanged); - SecondLifeHost = new SecondLifeHost(this.mainForm, assembly, editForm.FullPathName, editForm.guid); - SecondLifeHost.OnChat += editForm.ChatHandler; - SecondLifeHost.OnMessageLinked += editForm.MessageLinkedHandler; - SecondLifeHost.OnDie += new EventHandler(host_OnDie); - SecondLifeHost.OnReset += new EventHandler(SecondLifeHost_OnReset); - SecondLifeHost.OnListenChannelsChanged += new EventHandler(SecondLifeHost_OnListenChannelsChanged); + SecondLifeHost.OnVerboseMessage += new SecondLifeHost.SecondLifeHostMessageHandler(host_OnVerboseMessage); + SecondLifeHost.OnStateChange += new SecondLifeHost.SecondLifeHostMessageHandler(host_OnStateChange); - SecondLifeHost.OnVerboseMessage += new SecondLifeHost.SecondLifeHostMessageHandler(host_OnVerboseMessage); - SecondLifeHost.OnStateChange += new SecondLifeHost.SecondLifeHostMessageHandler(host_OnStateChange); + SecondLifeHost.State("default", true); - SecondLifeHost.State("default", true); - - return true; + blnResult = true; + } + return blnResult; } public bool Compile(EditForm editForm) @@ -119,8 +121,7 @@ namespace LSLEditor private void ResetScriptWatch() { - while (true) - { + while (true) { this.ResetScriptEvent.WaitOne(); SecondLifeHost.Dispose(); @@ -131,13 +132,10 @@ namespace LSLEditor private delegate void AddListenChannelsDelegate(ComboBox comboBox, string[] channels); private void AddListenChannelsToComboxBox(ComboBox comboBox, string[] channels) { - if (comboBox.InvokeRequired) - { + if (comboBox.InvokeRequired) { comboBox.Invoke(new AddListenChannelsDelegate(AddListenChannelsToComboxBox), - new object[] { comboBox , channels }); - } - else - { + new object[] { comboBox, channels }); + } else { comboBox.Items.Clear(); comboBox.Items.AddRange(channels); comboBox.SelectedIndex = 0; @@ -145,18 +143,19 @@ namespace LSLEditor } private void SecondLifeHost_OnListenChannelsChanged(object sender, EventArgs e) { - foreach (Control control in this.panel4.Controls) - { + foreach (Control control in this.panel4.Controls) { GroupboxEvent gbe = control as GroupboxEvent; - if (gbe == null) + if (gbe == null) { continue; - foreach (Control control1 in gbe.Controls) - { + } + foreach (Control control1 in gbe.Controls) { GroupBox gb = control1 as GroupBox; - if (gb == null) + if (gb == null) { continue; - if (gb.Name!="listen_0") + } + if (gb.Name != "listen_0") { continue; + } ComboBox comboBox = gb.Controls[0] as ComboBox; AddListenChannelsToComboxBox(comboBox, SecondLifeHost.GetListenChannels()); } @@ -165,13 +164,10 @@ namespace LSLEditor void host_OnDie(object sender, EventArgs e) { - if(this.panel1.InvokeRequired) - { + if (this.panel1.InvokeRequired) { // using Evenhandler definition as a delegate this.panel1.Invoke(new EventHandler(host_OnDie)); - } - else - { + } else { this.panel1.Enabled = false; } } @@ -185,16 +181,11 @@ namespace LSLEditor private delegate void SetStateComboboxDelegate(string strName); public void SetStateCombobox(string strName) { - if (this.comboBox1.InvokeRequired) - { + if (this.comboBox1.InvokeRequired) { this.comboBox1.Invoke(new SetStateComboboxDelegate(SetStateCombobox), new object[] { strName }); - } - else - { - for (int intI = 0; intI < this.comboBox1.Items.Count; intI++) - { - if (this.comboBox1.Items[intI].ToString() == strName) - { + } else { + for (int intI = 0; intI < this.comboBox1.Items.Count; intI++) { + if (this.comboBox1.Items[intI].ToString() == strName) { this.comboBox1.SelectedIndex = intI; break; } @@ -204,13 +195,13 @@ namespace LSLEditor private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e) { - if (SecondLifeHost == null) - return; - string strStateName = (string)this.comboBox1.Items[this.comboBox1.SelectedIndex]; - if (strStateName != "") - { - if (SecondLifeHost.CurrentStateName != strStateName) - SecondLifeHost.State(strStateName,true); + if (SecondLifeHost != null) { + string strStateName = (string)this.comboBox1.Items[this.comboBox1.SelectedIndex]; + if (strStateName != "") { + if (SecondLifeHost.CurrentStateName != strStateName) { + SecondLifeHost.State(strStateName, true); + } + } } } @@ -230,8 +221,7 @@ namespace LSLEditor strC = translator.Parse(strC); - foreach (string strState in translator.States) - { + foreach (string strState in translator.States) { this.comboBox1.Items.Add(strState); } return strC; @@ -240,18 +230,14 @@ namespace LSLEditor private delegate void ShowLifeEventsDelegate(); private void ShowLifeEvents() { - if (this.panel4.InvokeRequired) - { + if (this.panel4.InvokeRequired) { this.panel4.Invoke(new ShowLifeEventsDelegate(ShowLifeEvents), null); - } - else - { + } else { int intX = 8; int intY = 0; this.panel4.Controls.Clear(); - foreach (string strEventName in SecondLifeHost.GetEvents()) - { + foreach (string strEventName in SecondLifeHost.GetEvents()) { string strArgs = SecondLifeHost.GetArgumentsFromMethod(strEventName); GroupboxEvent ge = new GroupboxEvent(new Point(intX, intY), strEventName, strArgs, new System.EventHandler(this.buttonEvent_Click)); this.panel4.Controls.Add(ge); @@ -265,28 +251,23 @@ namespace LSLEditor // Verbose public void VerboseConsole(string strLine) { - if (this.textBox2.IsDisposed) - return; - if (this.textBox2.InvokeRequired) - { - this.textBox2.Invoke(new AppendTextDelegate(VerboseConsole), new object[] { strLine }); - } - else - { - this.textBox2.AppendText(strLine.Replace("\n", "\r\n") + "\r\n"); + if (!this.textBox2.IsDisposed) { + if (this.textBox2.InvokeRequired) { + this.textBox2.Invoke(new AppendTextDelegate(VerboseConsole), new object[] { strLine }); + } else { + this.textBox2.AppendText(strLine.Replace("\n", "\r\n") + "\r\n"); + } } } private string GetArgumentValue(string strName) { - foreach (Control parent in this.panel4.Controls) - { - if (parent.Name == "GroupboxTextbox") - { - foreach (Control c in parent.Controls) - { - if (c.Name == strName) + foreach (Control parent in this.panel4.Controls) { + if (parent.Name == "GroupboxTextbox") { + foreach (Control c in parent.Controls) { + if (c.Name == strName) { return c.Controls[0].Text; + } } } } @@ -295,71 +276,62 @@ namespace LSLEditor private object[] GetArguments(string strName, string strArgs) { - if (strArgs == "") - return new object[0]; - - try - { - string[] args = strArgs.Trim().Split(new char[] { ',' }); - object[] argobjects = new object[args.Length]; - for (int intI = 0; intI < argobjects.Length; intI++) - { - string[] argument = args[intI].Trim().Split(new char[] { ' ' }); - if (argument.Length == 2) - { - string[] arArgs; - string strArgumentValue = GetArgumentValue(strName + "_" + intI); - string strArgumentName = argument[1]; - string strArgumentType = argument[0]; - switch (strArgumentType) - { - case "System.String": - argobjects[intI] = strArgumentValue; - break; - case "System.Int32": - argobjects[intI] = int.Parse(strArgumentValue); - break; - case "LSLEditor.SecondLife+Float": - argobjects[intI] = new SecondLife.Float(strArgumentValue); - break; - case "LSLEditor.SecondLife+integer": - argobjects[intI] = new SecondLife.integer(int.Parse(strArgumentValue)); - break; - case "LSLEditor.SecondLife+String": - argobjects[intI] = new SecondLife.String(strArgumentValue); - break; - case "LSLEditor.SecondLife+key": - argobjects[intI] = new SecondLife.key(strArgumentValue); - break; - case "LSLEditor.SecondLife+list": - argobjects[intI] = new SecondLife.list(new string[] { strArgumentValue } ); - break; - case "LSLEditor.SecondLife+rotation": - arArgs = strArgumentValue.Replace("<", "").Replace(">", "").Replace(" ", "").Split(new char[] { ',' }); - argobjects[intI] = new SecondLife.rotation(double.Parse(arArgs[0]), double.Parse(arArgs[1]), double.Parse(arArgs[2]), double.Parse(arArgs[3])); - break; - case "LSLEditor.SecondLife+vector": - arArgs = strArgumentValue.Replace("<", "").Replace(">", "").Replace(" ", "").Split(new char[] { ',' }); - argobjects[intI] = new SecondLife.vector(double.Parse(arArgs[0]), double.Parse(arArgs[1]), double.Parse(arArgs[2])); - break; - default: - MessageBox.Show("Compiler->GetArguments->[" + strArgumentType + "][" + strArgumentName + "]"); - argobjects[intI] = null; - break; + object[] objResult = new object[0]; + if (strArgs != "") { + try { + string[] args = strArgs.Trim().Split(new char[] { ',' }); + object[] argobjects = new object[args.Length]; + for (int intI = 0; intI < argobjects.Length; intI++) { + string[] argument = args[intI].Trim().Split(new char[] { ' ' }); + if (argument.Length == 2) { + string[] arArgs; + string strArgumentValue = GetArgumentValue(strName + "_" + intI); + string strArgumentName = argument[1]; + string strArgumentType = argument[0]; + switch (strArgumentType) { + case "System.String": + argobjects[intI] = strArgumentValue; + break; + case "System.Int32": + argobjects[intI] = int.Parse(strArgumentValue); + break; + case "LSLEditor.SecondLife+Float": + argobjects[intI] = new SecondLife.Float(strArgumentValue); + break; + case "LSLEditor.SecondLife+integer": + argobjects[intI] = new SecondLife.integer(int.Parse(strArgumentValue)); + break; + case "LSLEditor.SecondLife+String": + argobjects[intI] = new SecondLife.String(strArgumentValue); + break; + case "LSLEditor.SecondLife+key": + argobjects[intI] = new SecondLife.key(strArgumentValue); + break; + case "LSLEditor.SecondLife+list": + argobjects[intI] = new SecondLife.list(new string[] { strArgumentValue }); + break; + case "LSLEditor.SecondLife+rotation": + arArgs = strArgumentValue.Replace("<", "").Replace(">", "").Replace(" ", "").Split(new char[] { ',' }); + argobjects[intI] = new SecondLife.rotation(double.Parse(arArgs[0]), double.Parse(arArgs[1]), double.Parse(arArgs[2]), double.Parse(arArgs[3])); + break; + case "LSLEditor.SecondLife+vector": + arArgs = strArgumentValue.Replace("<", "").Replace(">", "").Replace(" ", "").Split(new char[] { ',' }); + argobjects[intI] = new SecondLife.vector(double.Parse(arArgs[0]), double.Parse(arArgs[1]), double.Parse(arArgs[2])); + break; + default: + MessageBox.Show("Compiler->GetArguments->[" + strArgumentType + "][" + strArgumentName + "]"); + argobjects[intI] = null; + break; + } + } else { + MessageBox.Show("Argument must be 'type name' [" + args[intI] + "]"); + break; } } - else - { - MessageBox.Show("Argument must be 'type name' [" + args[intI] + "]"); - break; - } - } - return argobjects; - } - catch - { - return new object[0]; + objResult = argobjects; + } catch { } } + return objResult; } private void buttonEvent_Click(object sender, System.EventArgs e) @@ -374,8 +346,9 @@ namespace LSLEditor private void Die() { - if (this.SecondLifeHost != null) + if (this.SecondLifeHost != null) { this.SecondLifeHost.Die(); + } } // Die @@ -386,8 +359,9 @@ namespace LSLEditor private void textBox2_KeyDown(object sender, KeyEventArgs e) { - if (e.Control && e.KeyCode == Keys.A) + if (e.Control && e.KeyCode == Keys.A) { this.textBox2.SelectAll(); + } } private void selectAllToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/trunk/SimulatorConsole.cs b/trunk/SimulatorConsole.cs index 08e0b66..b1c9df0 100644 --- a/trunk/SimulatorConsole.cs +++ b/trunk/SimulatorConsole.cs @@ -71,10 +71,12 @@ namespace LSLEditor this.History = new List(); this.intHistory = 0; - if (Properties.Settings.Default.SimulatorLocation != Point.Empty) + if (Properties.Settings.Default.SimulatorLocation != Point.Empty) { this.Location = Properties.Settings.Default.SimulatorLocation; - if (Properties.Settings.Default.SimulatorSize != Size.Empty) + } + if (Properties.Settings.Default.SimulatorSize != Size.Empty) { this.Size = Properties.Settings.Default.SimulatorSize; + } this.Clear(); @@ -86,11 +88,11 @@ namespace LSLEditor this.LocationChanged += new EventHandler(SimulatorConsole_LocationChanged); - foreach (Form form in this.Children) - { + foreach (Form form in this.Children) { EditForm editForm = form as EditForm; - if (editForm == null || editForm.IsDisposed) + if (editForm == null || editForm.IsDisposed) { continue; + } editForm.ChatHandler = chathandler; editForm.MessageLinkedHandler = messagelinkedhandler; editForm.StartCompiler(); @@ -99,11 +101,11 @@ namespace LSLEditor public void Stop() { - foreach (Form form in this.Children) - { + foreach (Form form in this.Children) { EditForm editForm = form as EditForm; - if (editForm == null || editForm.IsDisposed) + if (editForm == null || editForm.IsDisposed) { continue; + } editForm.StopCompiler(); } } @@ -118,24 +120,26 @@ namespace LSLEditor this.Listen(e); // talk only to the owner - if (e.how == CommunicationType.OwnerSay) - return; + if (e.how != CommunicationType.OwnerSay) { + foreach (Form form in this.Children) { + EditForm editForm = form as EditForm; + if (editForm == null || editForm.IsDisposed) { + continue; + } - foreach (Form form in this.Children) - { - EditForm editForm = form as EditForm; - if (editForm == null || editForm.IsDisposed) - continue; + if (editForm.runtime == null) { + continue; + } - if (editForm.runtime == null) - continue; + if (editForm.runtime.SecondLifeHost == null) { + continue; + } - if (editForm.runtime.SecondLifeHost == null) - continue; - - // prevent loops loops loops loops, dont talk to myself - if (sender != editForm.runtime.SecondLifeHost) - editForm.runtime.SecondLifeHost.Listen(e); + // prevent loops loops loops loops, dont talk to myself + if (sender != editForm.runtime.SecondLifeHost) { + editForm.runtime.SecondLifeHost.Listen(e); + } + } } } @@ -149,8 +153,7 @@ namespace LSLEditor List list; int intLinkNum = e.iLinkIndex; - switch (intLinkNum) - { + switch (intLinkNum) { case 1: // LINK_ROOT , root prim in linked set (but not in a single prim, which is 0) list = this.solutionExplorer.GetScripts(RootObjectGuid, false); break; @@ -160,8 +163,7 @@ namespace LSLEditor case -2: // LINK_ALL_OTHERS , all other prims in object besides prim function is in list = this.solutionExplorer.GetScripts(RootObjectGuid, true); // remove scripts in prim itself, and below - foreach (Guid guid in this.solutionExplorer.GetScripts(ObjectGuid, true)) - { + foreach (Guid guid in this.solutionExplorer.GetScripts(ObjectGuid, true)) { if (list.Contains(guid)) list.Remove(guid); } @@ -169,19 +171,18 @@ namespace LSLEditor case -3: // LINK_ALL_CHILDREN , all child prims in object list = this.solutionExplorer.GetScripts(RootObjectGuid, true); // remove root itself - foreach (Guid guid in this.solutionExplorer.GetScripts(RootObjectGuid, false)) - { + foreach (Guid guid in this.solutionExplorer.GetScripts(RootObjectGuid, false)) { if (list.Contains(guid)) list.Remove(guid); } break; - case -4: // LINK_THIS - /* - * From SL Wiki: "Causes the script to act only upon the prim the prim the script is in." - * This means LINK_THIS, links to every script in the prim, not just the caller. - * @author = MrSoundless - * @date = 28 April 2011 - */ + case -4: // LINK_THIS + /* + * From SL Wiki: "Causes the script to act only upon the prim the prim the script is in." + * This means LINK_THIS, links to every script in the prim, not just the caller. + * @author = MrSoundless + * @date = 28 April 2011 + */ list = new List(); //list.Add(secondLifeHostSender.guid); // 4 feb 2008 list = this.solutionExplorer.GetScripts(ObjectGuid, true); // 28 april 2011 @@ -193,36 +194,41 @@ namespace LSLEditor } // only send message to running scripts in list - foreach (Form form in this.Children) - { + foreach (Form form in this.Children) { EditForm editForm = form as EditForm; - if (editForm == null || editForm.IsDisposed) + if (editForm == null || editForm.IsDisposed) { continue; + } - if (editForm.runtime == null) + if (editForm.runtime == null) { continue; + } - if (editForm.runtime.SecondLifeHost == null) + if (editForm.runtime.SecondLifeHost == null) { continue; + } - if(list.Contains(editForm.guid)) + if (list.Contains(editForm.guid)) { editForm.runtime.SecondLifeHost.LinkMessage(e); + } } } private void SimulatorConsole_OnControl(object sender, EventArgs e) { - foreach (Form form in this.Children) - { + foreach (Form form in this.Children) { EditForm editForm = form as EditForm; - if (editForm == null || editForm.IsDisposed) + if (editForm == null || editForm.IsDisposed) { continue; + } - if (editForm.runtime == null) + if (editForm.runtime == null) { continue; + } - if (editForm.runtime.SecondLifeHost == null) + if (editForm.runtime.SecondLifeHost == null) { continue; + } editForm.runtime.SecondLifeHost.SendControl((Keys)sender); } @@ -231,47 +237,48 @@ namespace LSLEditor private delegate void AppendTextDelegate(string strLine); public void TalkToSimulatorConsole(string strLine) { - if (this.textBox2.InvokeRequired) - { + if (this.textBox2.InvokeRequired) { this.textBox2.Invoke(new AppendTextDelegate(TalkToSimulatorConsole), new object[] { strLine }); - } - else - { + } else { this.textBox2.AppendText(strLine.Replace("\n", "\r\n") + "\r\n"); } } private void Chat(int channel, string name, SecondLife.key id, string message, CommunicationType how) { - if (OnChat != null) + if (OnChat != null) { OnChat(this, new SecondLifeHostChatEventArgs(channel, name, id, message, how)); + } } public void Listen(SecondLifeHostChatEventArgs e) { // Translate the incomming messages a bit so it looks like SL. string strHow = ": "; - if (e.how == CommunicationType.Shout) + if (e.how == CommunicationType.Shout) { strHow = " shout: "; + } - if (e.how == CommunicationType.Whisper) + if (e.how == CommunicationType.Whisper) { strHow = " whispers: "; + } string strWho = e.name; string strMessage = e.message; - if (e.name == Properties.Settings.Default.AvatarName) + if (e.name == Properties.Settings.Default.AvatarName) { strWho = "You"; + } - if (e.message.ToString().StartsWith("/me")) - { + if (e.message.ToString().StartsWith("/me")) { strWho = e.name; strHow = " "; strMessage = e.message.ToString().Substring(3).Trim(); } - if (e.channel == 0) + if (e.channel == 0) { TalkToSimulatorConsole(strWho + strHow + strMessage); + } } private void Speak(CommunicationType how) @@ -283,35 +290,26 @@ namespace LSLEditor intHistory = History.Count; - if (strMessage == "") - return; - - if (strMessage[0] == '/') - { - if (strMessage.StartsWith("/me")) - { - // do nothing - } - else - { - string strChannel = ""; - for (int intI = 1; intI < strMessage.Length; intI++) - { - if (strMessage[intI] >= '0' && strMessage[intI] <= '9') - { - strChannel += strMessage[intI]; - if (intI < 10) - continue; + if (strMessage != ""){ + if (strMessage[0] == '/') { + if (strMessage.StartsWith("/me")) { + // do nothing + } else { + string strChannel = ""; + for (int intI = 1; intI < strMessage.Length; intI++) { + if (strMessage[intI] >= '0' && strMessage[intI] <= '9') { + strChannel += strMessage[intI]; + if (intI < 10) { + continue; + } + } + try { + intChannel = Convert.ToInt32(strChannel); + strMessage = strMessage.Substring(intI).Trim(); + } catch { + } + break; } - try - { - intChannel = Convert.ToInt32(strChannel); - strMessage = strMessage.Substring(intI).Trim(); - } - catch - { - } - break; } } } @@ -336,13 +334,16 @@ namespace LSLEditor private void ScrollChat(KeyEventArgs e) { e.SuppressKeyPress = true; - if (e.KeyCode == Keys.Up) + if (e.KeyCode == Keys.Up) { intHistory = Math.Max(0, intHistory - 1); - if (e.KeyCode == Keys.Down) + } + if (e.KeyCode == Keys.Down) { intHistory = Math.Min(History.Count, intHistory + 1); + } this.textBox1.Clear(); - if (intHistory != History.Count) + if (intHistory != History.Count) { this.textBox1.AppendText(History[intHistory]); + } } private void textBox1_KeyDown(object sender, KeyEventArgs e) @@ -350,23 +351,16 @@ namespace LSLEditor this.buttonSay.Enabled = true; this.buttonShout.Enabled = true; - if (e.KeyCode == Keys.Return) - { + if (e.KeyCode == Keys.Return) { Speak(CommunicationType.Say); e.SuppressKeyPress = true; } - if (e.Control && (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down)) - { + if (e.Control && (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down)) { ScrollChat(e); - } - else if (e.KeyCode == Keys.Down || - e.KeyCode == Keys.Left || - e.KeyCode == Keys.Right || - e.KeyCode == Keys.Up - ) - { - if (OnControl != null) + } else if (e.KeyCode == Keys.Down || e.KeyCode == Keys.Left || e.KeyCode == Keys.Right || e.KeyCode == Keys.Up ) { + if (OnControl != null) { OnControl(e.KeyCode, new EventArgs()); + } e.SuppressKeyPress = true; } } @@ -391,8 +385,9 @@ namespace LSLEditor private void textBox2_KeyDown(object sender, KeyEventArgs e) { - if (e.Control && e.KeyCode == Keys.A) + if (e.Control && e.KeyCode == Keys.A) { this.textBox2.SelectAll(); + } } private void copyToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/trunk/UpdateApplicationForm.cs b/trunk/UpdateApplicationForm.cs index cdaf6ff..16c53a5 100644 --- a/trunk/UpdateApplicationForm.cs +++ b/trunk/UpdateApplicationForm.cs @@ -112,10 +112,11 @@ namespace LSLEditor { Uri url; string strVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); - if (Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location).Contains("beta")) + if (Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location).Contains("beta")) { url = new Uri(Properties.Settings.Default.UpdateManifest + "?beta-" + strVersion); - else + } else { url = new Uri(Properties.Settings.Default.UpdateManifest + "?" + strVersion); + } manifest = new WebClient(); manifest.DownloadStringCompleted += new DownloadStringCompletedEventHandler(manifest_DownloadCompleted); @@ -130,28 +131,26 @@ namespace LSLEditor public void CheckForUpdate(bool blnForce) { - if (!blnForce) - { - if (Properties.Settings.Default.DeleteOldFiles) + if (!blnForce) { + if (Properties.Settings.Default.DeleteOldFiles) { DeleteOldFile(); + } DateTime dateTime = Properties.Settings.Default.CheckDate; - if (Properties.Settings.Default.CheckEveryDay) - { + if (Properties.Settings.Default.CheckEveryDay) { TimeSpan lastUpdate = DateTime.Now - dateTime; - if (lastUpdate.TotalDays >= 1.0) + if (lastUpdate.TotalDays >= 1.0) { blnForce = true; - } - else if (Properties.Settings.Default.CheckEveryWeek) - { + } + } else if (Properties.Settings.Default.CheckEveryWeek) { TimeSpan lastUpdate = DateTime.Now - dateTime; - if(lastUpdate.TotalDays >= 7.0) + if (lastUpdate.TotalDays >= 7.0) { blnForce = true; + } } } - if (blnForce) - { + if (blnForce) { Properties.Settings.Default.CheckDate = DateTime.Now; Properties.Settings.Default.Save(); // save also all settings @@ -164,7 +163,7 @@ namespace LSLEditor if (e.Error != null) return; - versionInfo bzip = new versionInfo(); + versionInfo bzip = new versionInfo(); versionInfo gzip = new versionInfo(); versionInfo wzip = new versionInfo(); @@ -176,19 +175,13 @@ namespace LSLEditor string strHelpHashMe = ""; string strHelpFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Properties.Settings.Default.HelpOfflineFile); - if (File.Exists(strHelpFile)) - { + if (File.Exists(strHelpFile)) { strHelpHashMe = Decompressor.MD5Verify.ComputeHash(strHelpFile); - } - else - { + } else { // help file does not exist - if (Properties.Settings.Default.HelpOffline || blnOnlyHelpFile) - { + if (Properties.Settings.Default.HelpOffline || blnOnlyHelpFile) { strHelpHashMe = "*"; // force new update - } - else - { + } else { strHelpHashMe = ""; // no update this.labelHelpFile.Visible = false; this.labelHelpversionString.Visible = false; @@ -196,22 +189,22 @@ namespace LSLEditor } StringReader sr = new StringReader(e.Result); - for (int intI = 0; intI < 255; intI++) - { + for (int intI = 0; intI < 255; intI++) { string strLine = sr.ReadLine(); - if (strLine == null) + if (strLine == null) { break; - + } + int intSplit = strLine.IndexOf("="); - if (intSplit < 0) + if (intSplit < 0) { continue; - + } + string strName = strLine.Substring(0, intSplit); string strValue = strLine.Substring(intSplit + 1); //All hashes are of the uncompressed file. However, different archives may contain different versions. - switch (strName) - { + switch (strName) { case "Version": case "BZipVersion": bzip = new versionInfo(strValue); @@ -274,46 +267,39 @@ namespace LSLEditor this.labelOurVersionString.Text = current.version.ToString(); this.labelLatestVersionString.Text = web.version.ToString(); - if (String.IsNullOrEmpty(web.uri) || (web.version.CompareTo(current.version) != 1)) - { + if (String.IsNullOrEmpty(web.uri) || (web.version.CompareTo(current.version) != 1)) { return; } - if (strHelpHashMe == "") + if (strHelpHashMe == "") { strHelpHashMe = strHelpHashWeb; + } - if (strHelpHashMe == strHelpHashWeb) - { + if (strHelpHashMe == strHelpHashWeb) { this.labelHelpversionString.Text = "Up to date"; this.strHelpUrl = null; - } - else - { + } else { this.labelHelpversionString.Text = "Out of date"; } - if (current.hash == web.hash) - { + if (current.hash == web.hash) { this.strDownloadUrl = null; - } - else - { + } else { this.strDownloadUrl = web.uri; } - if (this.blnOnlyHelpFile) - { + if (this.blnOnlyHelpFile) { this.strDownloadUrl = null; this.labelLatestVersion.Visible = false; this.labelLatestVersionString.Visible = false; } - if (this.strHelpUrl != null || this.strDownloadUrl != null) - { + if (this.strHelpUrl != null || this.strDownloadUrl != null) { this.buttonUpdate.Enabled = true; - if (OnUpdateAvailable != null) + if (OnUpdateAvailable != null) { OnUpdateAvailable(this, null); + } } } @@ -330,85 +316,85 @@ namespace LSLEditor private void Download() { - if (strHelpUrl != null) + if (strHelpUrl != null) { DownloadHelpFile(); // starts also DownloadProgram when finished - else + } else { DownloadProgram(); + } } private void DownloadHelpFile() { - if (strHelpUrl == null) - return; + if (strHelpUrl != null) { + Uri url = new Uri(strHelpUrl); - Uri url = new Uri(strHelpUrl); + client = new WebClient(); - client = new WebClient(); + if (this.strHelpReferer != null) { + client.Headers.Add("Referer", strHelpReferer); + } - if(this.strHelpReferer != null) - client.Headers.Add("Referer", strHelpReferer); + client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadHelpFileCompleted); + client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); - client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadHelpFileCompleted); - client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); + string strCurrentFile = Assembly.GetExecutingAssembly().Location; + string strDirectory = Path.GetDirectoryName(strCurrentFile); + string strNewFile = Path.Combine(strDirectory, Properties.Settings.Default.HelpOfflineFile); - string strCurrentFile = Assembly.GetExecutingAssembly().Location; - string strDirectory = Path.GetDirectoryName(strCurrentFile); - string strNewFile = Path.Combine(strDirectory, Properties.Settings.Default.HelpOfflineFile); + if (File.Exists(strNewFile)) { + File.Delete(strNewFile); + } - if (File.Exists(strNewFile)) - File.Delete(strNewFile); - - client.DownloadFileAsync(url, strNewFile); + client.DownloadFileAsync(url, strNewFile); + } } void client_DownloadHelpFileCompleted(object sender, AsyncCompletedEventArgs e) { - try - { - if (e.Error != null) + try { + if (e.Error != null) { throw e.Error; + } string strCurrentFile = Assembly.GetExecutingAssembly().Location; string strDirectory = Path.GetDirectoryName(strCurrentFile); string strNewFile = Path.Combine(strDirectory, Properties.Settings.Default.HelpOfflineFile); string strComputedHash = Decompressor.MD5Verify.ComputeHash(strNewFile); - if (strComputedHash != strHelpHashWeb) - { + if (strComputedHash != strHelpHashWeb) { this.buttonUpdate.Enabled = true; throw new Exception("MD5 Hash of HelpFile not correct, try downloading again!"); } - if (this.strDownloadUrl != null) + if (this.strDownloadUrl != null) { DownloadProgram(); - else + } else { this.Close(); - } - catch (Exception exception) - { + } + } catch (Exception exception) { MessageBox.Show(exception.Message, "Oops...", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void DownloadProgram() { - if (strDownloadUrl == null) - return; + if (strDownloadUrl != null) { + Uri url = new Uri(strDownloadUrl); - Uri url = new Uri(strDownloadUrl); + client = new WebClient(); + client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted); + client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); - client = new WebClient(); - client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted); - client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); + string strCurrentFile = Assembly.GetExecutingAssembly().Location; + string strDirectory = Path.GetDirectoryName(strCurrentFile); + string strNewFileName = Path.GetFileName(strDownloadUrl); + string strNewFile = Path.Combine(strDirectory, strNewFileName); - string strCurrentFile = Assembly.GetExecutingAssembly().Location; - string strDirectory = Path.GetDirectoryName(strCurrentFile); - string strNewFileName = Path.GetFileName(strDownloadUrl); - string strNewFile = Path.Combine(strDirectory, strNewFileName); + if (File.Exists(strNewFile)) { + File.Delete(strNewFile); + } - if (File.Exists(strNewFile)) - File.Delete(strNewFile); - - client.DownloadFileAsync(url, strNewFile, strNewFileName); + client.DownloadFileAsync(url, strNewFile, strNewFileName); + } } void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) @@ -418,10 +404,10 @@ namespace LSLEditor void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { - try - { - if (e.Error != null) + try { + if (e.Error != null) { throw e.Error; + } string strNewFileName = e.UserState.ToString(); @@ -433,8 +419,7 @@ namespace LSLEditor string strOldFile = Path.Combine(strDirectory, "_LSLEditor.exe"); string strExtension = Path.GetExtension(strNewFileName); - switch (strExtension) - { + switch (strExtension) { case ".bz2": Decompressor.BZip2.Decompress(File.OpenRead(strZipFile), File.Create(strNewFile)); break; @@ -449,16 +434,16 @@ namespace LSLEditor break; } string strComputedHash = Decompressor.MD5Verify.ComputeHash(strNewFile); - if (strComputedHash == strHashWeb) - { + if (strComputedHash == strHashWeb) { if (File.Exists(strOldFile)) File.Delete(strOldFile); File.Move(strCurrentFile, strOldFile); File.Move(strNewFile, strCurrentFile); - if (File.Exists(strZipFile)) + if (File.Exists(strZipFile)) { File.Delete(strZipFile); + } // save all there is pending (if any) Properties.Settings.Default.Save(); @@ -466,32 +451,28 @@ namespace LSLEditor System.Diagnostics.Process.Start(strCurrentFile); Environment.Exit(0); - } - else - { + } else { this.buttonUpdate.Enabled = true; throw new Exception("MD5 Hash not correct, try downloading again!"); } - } - catch (Exception exception) - { + } catch (Exception exception) { MessageBox.Show(exception.Message, "Oops...", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void UpdateApplicationForm_FormClosing(object sender, FormClosingEventArgs e) { - if (client != null) - { - if (client.IsBusy) + if (client != null) { + if (client.IsBusy) { client.CancelAsync(); + } client.Dispose(); } client = null; - if (manifest != null) - { - if (manifest.IsBusy) + if (manifest != null) { + if (manifest.IsBusy) { manifest.CancelAsync(); + } manifest.Dispose(); } manifest = null; @@ -502,9 +483,10 @@ namespace LSLEditor string strCurrentFile = Assembly.GetExecutingAssembly().Location; string strDirectory = Path.GetDirectoryName(strCurrentFile); string strOldFile = Path.Combine(strDirectory, "_LSLEditor.exe"); - if (File.Exists(strOldFile)) + if (File.Exists(strOldFile)) { File.Delete(strOldFile); + } } } -} \ No newline at end of file +} diff --git a/trunk/llDialogForm.cs b/trunk/llDialogForm.cs index 7adf465..aaaf176 100644 --- a/trunk/llDialogForm.cs +++ b/trunk/llDialogForm.cs @@ -58,7 +58,7 @@ namespace LSLEditor private string OwnerName; private SecondLife.key id; - public llDialogForm(SecondLifeHost host, SecondLife.String strObjectName, SecondLife.key id, SecondLife.String strOwner, SecondLife.String strMessage, SecondLife.list buttons, SecondLife.integer intChannel) + public llDialogForm(SecondLifeHost host, SecondLife.String strObjectName, SecondLife.key id, SecondLife.String strOwner, SecondLife.String strMessage, SecondLife.list buttons, SecondLife.integer intChannel) { InitializeComponent(); @@ -68,21 +68,19 @@ namespace LSLEditor this.ObjectName = strObjectName; this.id = id; - for (int intI = 1; intI <= 12; intI++) - { + for (int intI = 1; intI <= 12; intI++) { Button button = this.Controls["Button" + intI] as Button; button.Visible = false; } - this.label1.Text = strOwner + "'s '" + strObjectName +"'"; - this.label2.Text = strMessage.ToString().Replace("&","&&"); + this.label1.Text = strOwner + "'s '" + strObjectName + "'"; + this.label2.Text = strMessage.ToString().Replace("&", "&&"); - for (int intI = 1; intI <= buttons.Count; intI++) - { + for (int intI = 1; intI <= buttons.Count; intI++) { Button button = this.Controls["Button" + intI] as Button; if (button == null) continue; - button.Text = buttons[intI - 1].ToString().Replace("&","&&"); + button.Text = buttons[intI - 1].ToString().Replace("&", "&&"); button.Visible = true; button.Click += new EventHandler(button_Click); } @@ -91,10 +89,10 @@ namespace LSLEditor void button_Click(object sender, EventArgs e) { Button button = sender as Button; - if (button == null) - return; - host.Chat(this,this.Channel, this.OwnerName, this.id, button.Text.Replace("&&","&"), CommunicationType.Say); - this.Close(); + if (button != null) { + host.Chat(this, this.Channel, this.OwnerName, this.id, button.Text.Replace("&&", "&"), CommunicationType.Say); + this.Close(); + } } private void button13_Click(object sender, EventArgs e) @@ -102,4 +100,4 @@ namespace LSLEditor this.Close(); } } -} \ No newline at end of file +} diff --git a/trunk/llTextBoxForm.cs b/trunk/llTextBoxForm.cs index 4ee700f..470dfdb 100644 --- a/trunk/llTextBoxForm.cs +++ b/trunk/llTextBoxForm.cs @@ -12,40 +12,39 @@ using System.Windows.Forms; namespace LSLEditor { - public partial class llTextBoxForm : Form - { - private SecondLifeHost host; - private int Channel; - private string ObjectName; - private string OwnerName; - private SecondLife.key id; + public partial class llTextBoxForm : Form + { + private SecondLifeHost host; + private int Channel; + private string ObjectName; + private string OwnerName; + private SecondLife.key id; - public llTextBoxForm(SecondLifeHost host, SecondLife.String strObjectName, SecondLife.key id, SecondLife.String strOwner, SecondLife.String strMessage, SecondLife.integer intChannel) - { - InitializeComponent(); + public llTextBoxForm(SecondLifeHost host, SecondLife.String strObjectName, SecondLife.key id, SecondLife.String strOwner, SecondLife.String strMessage, SecondLife.integer intChannel) + { + InitializeComponent(); - this.host = host; - this.Channel = intChannel; - this.OwnerName = strOwner; - this.ObjectName = strObjectName; - this.id = id; + this.host = host; + this.Channel = intChannel; + this.OwnerName = strOwner; + this.ObjectName = strObjectName; + this.id = id; - this.label1.Text = strMessage.ToString().Replace("&", "&&"); - } + this.label1.Text = strMessage.ToString().Replace("&", "&&"); + } - private void buttonIgnore_Click(object sender, EventArgs e) - { - this.Close(); - } - - private void buttonOK_Click(object sender, EventArgs e) - { - Button button = sender as Button; - if (button == null) - return; - - host.Chat(this,this.Channel, this.OwnerName, this.id, textBox.Text.Replace("&&","&"), CommunicationType.Say); + private void buttonIgnore_Click(object sender, EventArgs e) + { this.Close(); - } - } -} \ No newline at end of file + } + + private void buttonOK_Click(object sender, EventArgs e) + { + Button button = sender as Button; + if (button != null) { + host.Chat(this, this.Channel, this.OwnerName, this.id, textBox.Text.Replace("&&", "&"), CommunicationType.Say); + this.Close(); + } + } + } +}