diff --git a/trunk/Helpers/LSLIConverter.cs b/trunk/Helpers/LSLIConverter.cs index a100580..9dea866 100644 --- a/trunk/Helpers/LSLIConverter.cs +++ b/trunk/Helpers/LSLIConverter.cs @@ -57,9 +57,9 @@ namespace LSLEditor.Helpers public const string LSL_EXT = ".lsl"; public const string LSLI_EXT = ".lsli"; - private const string INCLUDE_REGEX = "(\n|^)//@include\\(\".*?\"\\)"; - private const string BEGIN_REGEX = "(\n|^)" + BEGIN; //"(\n|^)//@BEGIN" - private const string END_REGEX = "(\n|^)" + END; + private const string INCLUDE_REGEX = "(\\s+|^)//@include\\(\".*?\"\\)";// Eerst was '\\s+' '\n' + private const string BEGIN_REGEX = "(\\s+|^)" + BEGIN; //"(\n|^)//@BEGIN" + private const string END_REGEX = "(\\s+|^)" + END; private List implementedIncludes = new List(); private int includeDepth = 0; @@ -132,18 +132,47 @@ namespace LSLEditor.Helpers return relativePath; } + public static List AllIndexesOf(string str, string value) + { + if (String.IsNullOrEmpty(value)) + throw new ArgumentException("the string to find may not be empty", "value"); + List indexes = new List(); + for (int index = 0; ; index += value.Length) + { + index = str.IndexOf(value, index); + if (index == -1) + return indexes; + indexes.Add(index); + } + } + /// /// This is a hack to get the correct line, since problems arose in WriteAfterLine when inserting index-based /// /// /// - private int GetCorrectIndexOfLine(string lineBefore, string context) // TODO + private int GetCorrectIndexOfLine(string lineBefore, string context) { - //int correctIndex = -1; - //if(lineBefore.Trim('\n') == BEGIN) - //{ - // correctIndex = context.Where(l => l).LastIndexOf(lineBefore); - //} + if (Regex.IsMatch(lineBefore.Trim('\n'), INCLUDE_REGEX) + && lineBefore.Trim('\n').EndsWith(Regex.Match(lineBefore.Trim('\n'), INCLUDE_REGEX).ToString())) // Line before this line is an include statement, that means this is a BEGIN statement + { + // Get all matches with this linebefore + List allIndexes = AllIndexesOf(context, lineBefore); + + foreach(int index in allIndexes) + { + // Check wether there is already a begin statement + string actualLineBefore = context.Substring(index + lineBefore.Length).Trim('\n'); + if (actualLineBefore.StartsWith(BEGIN)) + { + continue; + } else + { + return index; + } + } + + } return context.LastIndexOf(lineBefore); } @@ -157,7 +186,6 @@ namespace LSLEditor.Helpers private StringBuilder WriteAfterLine(StringBuilder context, string newLine, string lineBefore) // TODO: HIJ MOET KIJKEN NAAR DE INDEX VAN LINEBEFORE, NIET ZELF DE INDEX OPZOEKEN { string ctx = context.ToString(); - //int lastIndexOfLineBefore = ctx.LastIndexOf(lineBefore); int lastIndexOfLineBefore = GetCorrectIndexOfLine(lineBefore, ctx); int includeIndex = lastIndexOfLineBefore + lineBefore.Length; @@ -178,34 +206,29 @@ namespace LSLEditor.Helpers return context; } - /// - /// Creates a new line in the context after a specified index - /// - /// - /// - /// - /// Context with the new line - //private StringBuilder WriteAfterLine(StringBuilder context, string newLine, int indexOfNewLine) // DEZE IS BETER, MAAR IN PRAKTIJK WERKT NIET... - //{ - // string ctx = context.ToString(); - // int includeIndex = indexOfNewLine; + private void ShowError(string message) + { + if (!editForm.verboseQueue.Contains(message)) + { + MessageBox.Show(message, "Oops...", MessageBoxButtons.OK, MessageBoxIcon.Error); + editForm.verboseQueue.Add(message); + } + } - // string hasSeperator = context.ToString().Substring(indexOfNewLine - 1, 1); - // if (hasSeperator != "\n") - // { - // newLine = "\n" + newLine; - // } + private string GetTabsForIncludeDepth(int includeDepth, bool OneLess = false) // TODO: Dit wordt wss een setting. Tabs hangt namelijk af van de hoeveelheid ingedente include statement. + { + string tabs = ""; + if(OneLess && includeDepth != 0) + { + includeDepth--; + } - // hasSeperator = newLine.Substring(newLine.Length - 1, 1); - // if (hasSeperator != "\n") - // { - // newLine += "\n"; - // } - - // context.Insert(includeIndex, newLine); - // string test = context.ToString(); - // return context; - //} + for(int i = 0; i < includeDepth; i++) + { + tabs += "\t"; + } + return tabs; + } /// /// Imports scripts from //@include statements @@ -213,7 +236,7 @@ namespace LSLEditor.Helpers /// Sourcecode /// Path of the source code of the script /// Sourcecode with imported scripts - private string ImportScripts(string strC, string pathOfScript) // TODO: Lange functie, kan ik deze opsplitten? + private string ImportScripts(string strC, string pathOfScript, bool ShowBeginEnd = true) // TODO: Lange functie, kan ik deze opsplitten? { if(!LSLIPathHelper.IsLSLI(pathOfScript)) { @@ -255,30 +278,46 @@ namespace LSLEditor.Helpers if (pathOfInclude != "" && !this.implementedIncludes.Contains(Path.GetFullPath(pathOfInclude))) { - sb = this.WriteAfterLine(sb, BEGIN, line); + if(ShowBeginEnd) + { + sb = this.WriteAfterLine(sb, GetTabsForIncludeDepth(includeDepth, true) + BEGIN, line); + } // Insert included script - string script = "// Empty script\n"; + string script = GetTabsForIncludeDepth(includeDepth) + "// Empty script\n"; using (StreamReader sr = new StreamReader(pathOfInclude)) { this.implementedIncludes.Add(Path.GetFullPath(pathOfInclude)); string scriptRaw = sr.ReadToEnd(); - scriptRaw = scriptRaw.Replace("\n", "\n\t"); + scriptRaw = GetTabsForIncludeDepth(includeDepth) + scriptRaw.Replace("\n", "\n" + GetTabsForIncludeDepth(includeDepth)); // If there are includes in the included script if (Regex.IsMatch(scriptRaw, INCLUDE_REGEX)) { // Then import these scripts too - script = "\n" + ImportScripts(scriptRaw, pathOfInclude) + "\n"; - } else if(scriptRaw != "" && scriptRaw != " ") + if (ShowBeginEnd) + { + script = "\n" + ImportScripts(scriptRaw, pathOfInclude) + "\n"; + } else + { + script = "\n" + ImportScripts(scriptRaw, pathOfInclude, false) + "\n"; + } + } else if(!Regex.IsMatch(scriptRaw, "^\\s*$"))// Check if its not empty or whitespace // scriptRaw != "" && scriptRaw != " ") { script = scriptRaw + "\n"; } } - - this.WriteAfterLine(sb, script, BEGIN + "\n"); - this.WriteAfterLine(sb, END, script); + if (ShowBeginEnd) + { + this.WriteAfterLine(sb, script, BEGIN + "\n"); + this.WriteAfterLine(sb, GetTabsForIncludeDepth(includeDepth, true) + END, script); + } else + { + this.WriteAfterLine(sb, script, line); + string ctx = sb.ToString(); + sb = new StringBuilder(ctx.Remove(ctx.IndexOf(line.TrimStart('\n')), line.TrimStart('\n').Length)); + } } else if (pathOfInclude != "" && this.implementedIncludes.Contains(Path.GetFullPath(pathOfInclude))) { @@ -286,22 +325,14 @@ namespace LSLEditor.Helpers "\". In script \"" + Path.GetFileName(pathOfScript) + "\". Line " + lineNumber + "."; - if (!editForm.verboseQueue.Contains(message)) - { - MessageBox.Show(message, "Oops...", MessageBoxButtons.OK, MessageBoxIcon.Error); - editForm.verboseQueue.Add(message); - } + ShowError(message); } else { string correctPath = Path.GetFullPath(GetRelativePath(pathOfScript, Environment.CurrentDirectory) + pathOfIncludeOriginal); string message = "Error: Unable to find file \"" + correctPath + "\". In script \"" + Path.GetFileName(pathOfScript) + "\". Line " + lineNumber + "."; - - if (!editForm.verboseQueue.Contains(message)) - { - MessageBox.Show(message, "Oops...", MessageBoxButtons.OK, MessageBoxIcon.Error); - editForm.verboseQueue.Add(message); - } + + ShowError(message); } } includeDepth--; @@ -405,10 +436,10 @@ namespace LSLEditor.Helpers /// /// /// LSL - public string ExpandToLSL(EditForm editForm) + public string ExpandToLSL(EditForm editForm, bool ShowBeginEnd = true) { this.editForm = editForm; - string sourceCode = ImportScripts(editForm.SourceCode, editForm.FullPathName); + string sourceCode = ImportScripts(editForm.SourceCode, editForm.FullPathName, ShowBeginEnd); return sourceCode; } } diff --git a/trunk/Helpers/LSLIPathHelper.cs b/trunk/Helpers/LSLIPathHelper.cs index e9aebd7..4c8afb1 100644 --- a/trunk/Helpers/LSLIPathHelper.cs +++ b/trunk/Helpers/LSLIPathHelper.cs @@ -144,7 +144,7 @@ namespace LSLEditor.Helpers return filename; } - private static string RemoveDotInFrontOfFilename(string filename) + public static string RemoveDotInFrontOfFilename(string filename) { int afterLastIndexOfSeperator = (filename.LastIndexOf('\\') > filename.LastIndexOf('/') ? filename.LastIndexOf('\\') : filename.LastIndexOf('/')) + 1; diff --git a/trunk/LSLEditorForm.Designer.cs b/trunk/LSLEditorForm.Designer.cs index d6d9c08..1df0d70 100644 --- a/trunk/LSLEditorForm.Designer.cs +++ b/trunk/LSLEditorForm.Designer.cs @@ -69,6 +69,8 @@ namespace LSLEditor this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.SaveAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); this.pageSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.printPreviewtoolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -106,6 +108,7 @@ namespace LSLEditor this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator(); this.CollapseToLSLIToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.expandToLSLToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.viewLSLIToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.viewlStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.solutionExplorerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.outlineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -146,7 +149,6 @@ namespace LSLEditor this.pageSetupDialog1 = new System.Windows.Forms.PageSetupDialog(); this.openSolutionFilesDialog = new System.Windows.Forms.OpenFileDialog(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); - this.viewLSLIToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.dockPanel = new LSLEditor.Docking.DockPanel(); this.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); @@ -186,6 +188,8 @@ namespace LSLEditor this.saveToolStripMenuItem, this.saveAsToolStripMenuItem, this.SaveAllToolStripMenuItem, + this.toolStripSeparator11, + this.toolStripMenuItem2, this.toolStripSeparator3, this.pageSettingsToolStripMenuItem, this.printPreviewtoolStripMenuItem, @@ -209,7 +213,7 @@ namespace LSLEditor this.newFileToolStripMenuItem, this.notecardToolStripMenuItem}); this.newToolStripMenuItem.Name = "newToolStripMenuItem"; - this.newToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.newToolStripMenuItem.Size = new System.Drawing.Size(191, 22); this.newToolStripMenuItem.Text = "New"; // // newProjectToolStripMenuItem @@ -244,7 +248,7 @@ namespace LSLEditor this.openNotecardFilesToolStripMenuItem, this.openScriptFilesToolStripMenuItem}); this.openToolStripMenuItem.Name = "openToolStripMenuItem"; - this.openToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.openToolStripMenuItem.Size = new System.Drawing.Size(191, 22); this.openToolStripMenuItem.Text = "Open"; // // openProjectSolutionToolStripMenuItem @@ -278,7 +282,7 @@ namespace LSLEditor // toolStripSeparator5 // this.toolStripSeparator5.Name = "toolStripSeparator5"; - this.toolStripSeparator5.Size = new System.Drawing.Size(184, 6); + this.toolStripSeparator5.Size = new System.Drawing.Size(188, 6); // // addToolStripMenuItem // @@ -287,7 +291,7 @@ namespace LSLEditor this.toolStripSeparator19, this.existingProjectToolStripMenuItem}); this.addToolStripMenuItem.Name = "addToolStripMenuItem"; - this.addToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.addToolStripMenuItem.Size = new System.Drawing.Size(191, 22); this.addToolStripMenuItem.Text = "Add"; this.addToolStripMenuItem.Visible = false; // @@ -313,14 +317,14 @@ namespace LSLEditor // addToolStripSeparator // this.addToolStripSeparator.Name = "addToolStripSeparator"; - this.addToolStripSeparator.Size = new System.Drawing.Size(184, 6); + this.addToolStripSeparator.Size = new System.Drawing.Size(188, 6); this.addToolStripSeparator.Visible = false; // // closeFileToolStripMenuItem // this.closeFileToolStripMenuItem.Name = "closeFileToolStripMenuItem"; this.closeFileToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.W))); - this.closeFileToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.closeFileToolStripMenuItem.Size = new System.Drawing.Size(191, 22); this.closeFileToolStripMenuItem.Text = "Close"; this.closeFileToolStripMenuItem.Click += new System.EventHandler(this.closeFileToolStripMenuItem_Click); // @@ -328,40 +332,40 @@ namespace LSLEditor // this.closeSolutiontoolStripMenuItem.Enabled = false; this.closeSolutiontoolStripMenuItem.Name = "closeSolutiontoolStripMenuItem"; - this.closeSolutiontoolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.closeSolutiontoolStripMenuItem.Size = new System.Drawing.Size(191, 22); this.closeSolutiontoolStripMenuItem.Text = "Close Solution"; this.closeSolutiontoolStripMenuItem.Click += new System.EventHandler(this.closeSolutiontoolStripMenuItem_Click); // // toolStripSeparator20 // this.toolStripSeparator20.Name = "toolStripSeparator20"; - this.toolStripSeparator20.Size = new System.Drawing.Size(184, 6); + this.toolStripSeparator20.Size = new System.Drawing.Size(188, 6); // // importExampleToolStripMenuItem // this.importExampleToolStripMenuItem.Name = "importExampleToolStripMenuItem"; - this.importExampleToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.importExampleToolStripMenuItem.Size = new System.Drawing.Size(191, 22); this.importExampleToolStripMenuItem.Text = "Import Example..."; this.importExampleToolStripMenuItem.Click += new System.EventHandler(this.importExampleToolStripMenuItem_Click); // // toolStripSeparator4 // this.toolStripSeparator4.Name = "toolStripSeparator4"; - this.toolStripSeparator4.Size = new System.Drawing.Size(184, 6); + this.toolStripSeparator4.Size = new System.Drawing.Size(188, 6); // // saveToolStripMenuItem // this.saveToolStripMenuItem.Image = global::LSLEditor.Properties.Resources.SAVE; this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); - this.saveToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.saveToolStripMenuItem.Size = new System.Drawing.Size(191, 22); this.saveToolStripMenuItem.Text = "Save"; this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click); // // saveAsToolStripMenuItem // this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem"; - this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(191, 22); this.saveAsToolStripMenuItem.Text = "Save As..."; this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click); // @@ -371,26 +375,40 @@ namespace LSLEditor this.SaveAllToolStripMenuItem.Name = "SaveAllToolStripMenuItem"; this.SaveAllToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) | System.Windows.Forms.Keys.S))); - this.SaveAllToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.SaveAllToolStripMenuItem.Size = new System.Drawing.Size(191, 22); this.SaveAllToolStripMenuItem.Text = "Save All"; this.SaveAllToolStripMenuItem.Click += new System.EventHandler(this.SaveAllToolStripMenuItem_Click); // + // toolStripSeparator11 + // + this.toolStripSeparator11.Name = "toolStripSeparator11"; + this.toolStripSeparator11.Size = new System.Drawing.Size(188, 6); + // + // toolStripMenuItem2 + // + this.toolStripMenuItem2.Image = global::LSLEditor.Properties.Resources.export_file_32; + this.toolStripMenuItem2.Name = "toolStripMenuItem2"; + this.toolStripMenuItem2.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E))); + this.toolStripMenuItem2.Size = new System.Drawing.Size(191, 22); + this.toolStripMenuItem2.Text = "Export to LSL..."; + this.toolStripMenuItem2.Click += new System.EventHandler(this.toolStripMenuItem2_Click); + // // toolStripSeparator3 // this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(184, 6); + this.toolStripSeparator3.Size = new System.Drawing.Size(188, 6); // // pageSettingsToolStripMenuItem // this.pageSettingsToolStripMenuItem.Name = "pageSettingsToolStripMenuItem"; - this.pageSettingsToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.pageSettingsToolStripMenuItem.Size = new System.Drawing.Size(191, 22); this.pageSettingsToolStripMenuItem.Text = "Page settings..."; this.pageSettingsToolStripMenuItem.Click += new System.EventHandler(this.pageSettingsToolStripMenuItem_Click); // // printPreviewtoolStripMenuItem // this.printPreviewtoolStripMenuItem.Name = "printPreviewtoolStripMenuItem"; - this.printPreviewtoolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.printPreviewtoolStripMenuItem.Size = new System.Drawing.Size(191, 22); this.printPreviewtoolStripMenuItem.Text = "Print Preview..."; this.printPreviewtoolStripMenuItem.Click += new System.EventHandler(this.printPreviewtoolStripMenuItem_Click); // @@ -399,45 +417,45 @@ namespace LSLEditor this.printToolStripMenuItem.Image = global::LSLEditor.Properties.Resources.PRINT; this.printToolStripMenuItem.Name = "printToolStripMenuItem"; this.printToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.P))); - this.printToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.printToolStripMenuItem.Size = new System.Drawing.Size(191, 22); this.printToolStripMenuItem.Text = "Print..."; this.printToolStripMenuItem.Click += new System.EventHandler(this.printToolStripMenuItem_Click); // // toolStripSeparator2 // this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(184, 6); + this.toolStripSeparator2.Size = new System.Drawing.Size(188, 6); // // copyToClipboardToolStripMenuItem // this.copyToClipboardToolStripMenuItem.Name = "copyToClipboardToolStripMenuItem"; - this.copyToClipboardToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.copyToClipboardToolStripMenuItem.Size = new System.Drawing.Size(191, 22); this.copyToClipboardToolStripMenuItem.Text = "Copy to clipboard"; this.copyToClipboardToolStripMenuItem.Click += new System.EventHandler(this.copyToClipboardToolStripMenuItem_Click); // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(184, 6); + this.toolStripSeparator1.Size = new System.Drawing.Size(188, 6); // // recentFileToolStripMenuItem // this.recentFileToolStripMenuItem.Name = "recentFileToolStripMenuItem"; - this.recentFileToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.recentFileToolStripMenuItem.Size = new System.Drawing.Size(191, 22); this.recentFileToolStripMenuItem.Text = "Recent Files"; this.recentFileToolStripMenuItem.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.recentFileToolStripMenuItem_DropDownItemClicked); // // recentProjectToolStripMenuItem // this.recentProjectToolStripMenuItem.Name = "recentProjectToolStripMenuItem"; - this.recentProjectToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.recentProjectToolStripMenuItem.Size = new System.Drawing.Size(191, 22); this.recentProjectToolStripMenuItem.Text = "Recent Solutions"; this.recentProjectToolStripMenuItem.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.recentProjectToolStripMenuItem_DropDownItemClicked); // // toolStripSeparator21 // this.toolStripSeparator21.Name = "toolStripSeparator21"; - this.toolStripSeparator21.Size = new System.Drawing.Size(184, 6); + this.toolStripSeparator21.Size = new System.Drawing.Size(188, 6); // // exitToolStripMenuItem // @@ -445,7 +463,7 @@ namespace LSLEditor this.exitToolStripMenuItem.ShortcutKeyDisplayString = ""; this.exitToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4))); this.exitToolStripMenuItem.ShowShortcutKeys = false; - this.exitToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.exitToolStripMenuItem.Size = new System.Drawing.Size(191, 22); this.exitToolStripMenuItem.Text = "Exit"; this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); // @@ -675,6 +693,14 @@ namespace LSLEditor this.expandToLSLToolStripMenuItem.Text = "Expand to LSL"; this.expandToLSLToolStripMenuItem.Click += new System.EventHandler(this.expandToLSLToolStripMenuItem_Click); // + // viewLSLIToolStripMenuItem + // + this.viewLSLIToolStripMenuItem.Name = "viewLSLIToolStripMenuItem"; + this.viewLSLIToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F12; + this.viewLSLIToolStripMenuItem.Size = new System.Drawing.Size(225, 22); + this.viewLSLIToolStripMenuItem.Text = "View LSLI"; + this.viewLSLIToolStripMenuItem.Click += new System.EventHandler(this.viewLSLIToolStripMenuItem_Click); + // // viewlStripMenuItem // this.viewlStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -941,14 +967,6 @@ namespace LSLEditor // this.openSolutionFilesDialog.FileName = "openFileDialog2"; // - // viewLSLIToolStripMenuItem - // - this.viewLSLIToolStripMenuItem.Name = "viewLSLIToolStripMenuItem"; - this.viewLSLIToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F12; - this.viewLSLIToolStripMenuItem.Size = new System.Drawing.Size(225, 22); - this.viewLSLIToolStripMenuItem.Text = "View LSLI"; - this.viewLSLIToolStripMenuItem.Click += new System.EventHandler(this.viewLSLIToolStripMenuItem_Click); - // // dockPanel // this.dockPanel.ActiveAutoHideContent = null; @@ -1137,5 +1155,7 @@ namespace LSLEditor private System.Windows.Forms.ToolStripMenuItem CollapseToLSLIToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem expandToLSLToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem viewLSLIToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator11; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2; } } \ No newline at end of file diff --git a/trunk/LSLEditorForm.cs b/trunk/LSLEditorForm.cs index 36925a3..ab34ec1 100644 --- a/trunk/LSLEditorForm.cs +++ b/trunk/LSLEditorForm.cs @@ -279,7 +279,7 @@ namespace LSLEditor { string fileFilterNotes = "Notecard files (*.txt)|*.txt|All files (*.*)|*.*"; string fileFilterScripts = "Secondlife script files (*.lsl;*.lsli)|*.lsl;*.lsli|All files (*.*)|*.*"; - string fileFilterSolutions = "LSLEditor Solution File (*.sol)|*.sol|All Files (*.*)|*.*"; + string fileFilterSolutions = "LSLEditor Solution File (*.sol)|*.sol|All Files (*.*)|*.*"; this.ConfLSL = GetXmlFromResource(Properties.Settings.Default.ConfLSL); this.ConfCSharp = GetXmlFromResource(Properties.Settings.Default.ConfCSharp); @@ -1750,7 +1750,21 @@ namespace LSLEditor private void fileToolStripMenuItem_Click(object sender, EventArgs e) { - SetupFileMenu(); + EditForm editForm = this.ActiveMdiForm as EditForm; + + if (editForm != null) + { + if (Helpers.LSLIPathHelper.IsLSLI(editForm.ScriptName) || Helpers.LSLIPathHelper.IsExpandedLSL(editForm.ScriptName)) + { + toolStripMenuItem2.Enabled = true; + } + else + { + toolStripMenuItem2.Enabled = false; + } + } + + SetupFileMenu(); } private void forumStripMenuItem_Click(object sender, EventArgs e) @@ -1919,5 +1933,28 @@ namespace LSLEditor } } } + + private void toolStripMenuItem2_Click(object sender, EventArgs e) + { + StreamWriter streamWriter; + SaveFileDialog saveFileDialog1 = new SaveFileDialog(); + EditForm editForm = this.ActiveMdiForm as EditForm; + + saveFileDialog1.Filter = "Secondlife script files (*.lsl)|*.lsl"; + saveFileDialog1.FileName = Helpers.LSLIPathHelper.RemoveDotInFrontOfFilename(Helpers.LSLIPathHelper.RemoveExpandedSubExtension( + Path.GetFileNameWithoutExtension(editForm.ScriptName))) + Helpers.LSLIConverter.LSL_EXT; + saveFileDialog1.RestoreDirectory = true; + saveFileDialog1.Title = "Export to LSL"; + + if (saveFileDialog1.ShowDialog() == DialogResult.OK) + { + if ((streamWriter = new StreamWriter(saveFileDialog1.OpenFile())) != null) + { + Helpers.LSLIConverter lsliConverter = new Helpers.LSLIConverter(); + streamWriter.Write(lsliConverter.ExpandToLSL(editForm, false)); + streamWriter.Close(); + } + } + } } } diff --git a/trunk/Properties/AssemblyInfo.cs b/trunk/Properties/AssemblyInfo.cs index 0986f63..9e89003 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: // -[assembly: AssemblyVersion("2.55.0.549")] +[assembly: AssemblyVersion("2.55.0.590")] // // 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.55.0.549")] +[assembly: AssemblyFileVersionAttribute("2.55.0.590")] diff --git a/trunk/Properties/Resources.Designer.cs b/trunk/Properties/Resources.Designer.cs index 138da5b..654e376 100644 --- a/trunk/Properties/Resources.Designer.cs +++ b/trunk/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.296 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -19,7 +19,7 @@ namespace LSLEditor.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -60,6 +60,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap ADDITEM { get { object obj = ResourceManager.GetObject("ADDITEM", resourceCulture); @@ -67,6 +70,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap COPY { get { object obj = ResourceManager.GetObject("COPY", resourceCulture); @@ -74,6 +80,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap CUT { get { object obj = ResourceManager.GetObject("CUT", resourceCulture); @@ -81,6 +90,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap DEINDENT { get { object obj = ResourceManager.GetObject("DEINDENT", resourceCulture); @@ -88,6 +100,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap DELETE { get { object obj = ResourceManager.GetObject("DELETE", resourceCulture); @@ -95,6 +110,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap END { get { object obj = ResourceManager.GetObject("END", resourceCulture); @@ -102,6 +120,19 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap export_file_32 { + get { + object obj = ResourceManager.GetObject("export_file-32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap FIND { get { object obj = ResourceManager.GetObject("FIND", resourceCulture); @@ -109,6 +140,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap ININDENT { get { object obj = ResourceManager.GetObject("ININDENT", resourceCulture); @@ -116,6 +150,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap logo { get { object obj = ResourceManager.GetObject("logo", resourceCulture); @@ -123,6 +160,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap NEWDOC { get { object obj = ResourceManager.GetObject("NEWDOC", resourceCulture); @@ -130,6 +170,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap NEWPROJ { get { object obj = ResourceManager.GetObject("NEWPROJ", resourceCulture); @@ -137,6 +180,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap OPEN { get { object obj = ResourceManager.GetObject("OPEN", resourceCulture); @@ -144,6 +190,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap PASTE { get { object obj = ResourceManager.GetObject("PASTE", resourceCulture); @@ -151,6 +200,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap PRINT { get { object obj = ResourceManager.GetObject("PRINT", resourceCulture); @@ -158,6 +210,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap PROJECT { get { object obj = ResourceManager.GetObject("PROJECT", resourceCulture); @@ -165,6 +220,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap PROPS { get { object obj = ResourceManager.GetObject("PROPS", resourceCulture); @@ -172,6 +230,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap REDO { get { object obj = ResourceManager.GetObject("REDO", resourceCulture); @@ -179,6 +240,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap SAVE { get { object obj = ResourceManager.GetObject("SAVE", resourceCulture); @@ -186,6 +250,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap SAVEAS { get { object obj = ResourceManager.GetObject("SAVEAS", resourceCulture); @@ -193,6 +260,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap START { get { object obj = ResourceManager.GetObject("START", resourceCulture); @@ -200,6 +270,9 @@ namespace LSLEditor.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// internal static System.Drawing.Bitmap UNDO { get { object obj = ResourceManager.GetObject("UNDO", resourceCulture); diff --git a/trunk/Properties/Resources.resx b/trunk/Properties/Resources.resx index 7f5b767..9c4b912 100644 --- a/trunk/Properties/Resources.resx +++ b/trunk/Properties/Resources.resx @@ -118,47 +118,23 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - ..\icons\copy.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Images\logo.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\icons\inindent.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\icons\delete.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\icons\newproj.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\icons\print.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\icons\find.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\icons\save.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\icons\newdoc.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\icons\deindent.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\icons\paste.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\icons\props.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\icons\end.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\icons\open.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\icons\props.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icons\cut.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icons\find.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icons\undo.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\icons\project.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -166,19 +142,47 @@ ..\icons\redo.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\icons\saveas.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Images\logo.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\icons\undo.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\icons\paste.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\icons\start.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\icons\save.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\icons\cut.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\icons\delete.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icons\open.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\icons\additem.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\icons\newdoc.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icons\deindent.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icons\print.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icons\start.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icons\saveas.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icons\newproj.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\icons\copy.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + + ..\Resources\export_file-32.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/trunk/Resources/export_file-32.png b/trunk/Resources/export_file-32.png new file mode 100644 index 0000000..8b974b7 Binary files /dev/null and b/trunk/Resources/export_file-32.png differ diff --git a/trunk/lsleditor.csproj b/trunk/lsleditor.csproj index 37b9e6e..9745130 100644 --- a/trunk/lsleditor.csproj +++ b/trunk/lsleditor.csproj @@ -958,6 +958,7 @@ +