diff --git a/src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/SQL.xshd b/src/AddIns/Misc/SharpServerTools/SharpDbTools/Resources/SQL.xshd similarity index 99% rename from src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/SQL.xshd rename to src/AddIns/Misc/SharpServerTools/SharpDbTools/Resources/SQL.xshd index d5d303b968..d6bc0542c6 100644 --- a/src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/SQL.xshd +++ b/src/AddIns/Misc/SharpServerTools/SharpDbTools/Resources/SQL.xshd @@ -152,13 +152,7 @@ - - - - - - - + diff --git a/src/AddIns/Misc/SharpServerTools/SharpDbTools/Resources/SyntaxModes.xml b/src/AddIns/Misc/SharpServerTools/SharpDbTools/Resources/SyntaxModes.xml new file mode 100644 index 0000000000..3d2364dd5d --- /dev/null +++ b/src/AddIns/Misc/SharpServerTools/SharpDbTools/Resources/SyntaxModes.xml @@ -0,0 +1,5 @@ + + + diff --git a/src/AddIns/Misc/SharpServerTools/SharpDbTools/SharpDbTools.csproj b/src/AddIns/Misc/SharpServerTools/SharpDbTools/SharpDbTools.csproj index fe9ce0daf6..e723aefb9e 100644 --- a/src/AddIns/Misc/SharpServerTools/SharpDbTools/SharpDbTools.csproj +++ b/src/AddIns/Misc/SharpServerTools/SharpDbTools/SharpDbTools.csproj @@ -37,6 +37,7 @@ SQLTool.cs + @@ -57,9 +58,11 @@ - + + + diff --git a/src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/SQLTool.cs b/src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/SQLTool.cs index d1c2382ecc..ba742fe038 100644 --- a/src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/SQLTool.cs +++ b/src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/SQLTool.cs @@ -45,13 +45,17 @@ namespace SharpDbTools.Forms sqlEditorControl = new TextEditorControl(); sqlEditorControl.Dock = DockStyle.Fill; - //sqlEditorControl.SetHighlighting("SQL"); + + // set up the highlighting manager for generic SQL string appPath = Path.GetDirectoryName(Application.ExecutablePath); - ICSharpCode.TextEditor.Document.FileSyntaxModeProvider provider = new ICSharpCode.TextEditor.Document.FileSyntaxModeProvider(appPath); + SQLToolResourceSyntaxModeProvider provider = new SQLToolResourceSyntaxModeProvider(); ICSharpCode.TextEditor.Document.HighlightingManager.Manager.AddSyntaxModeFileProvider(provider); sqlEditorControl.Document.HighlightingStrategy = ICSharpCode.TextEditor.Document.HighlightingManager.Manager.FindHighlighter("SQL"); + + // setup the SQLTool in the tab control + this.editorTab.Controls.Add(sqlEditorControl); // add context behaviour to the editor control diff --git a/src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/SQLToolResourceSyntaxModeProvider.cs b/src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/SQLToolResourceSyntaxModeProvider.cs new file mode 100644 index 0000000000..3cbab7b7e2 --- /dev/null +++ b/src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/SQLToolResourceSyntaxModeProvider.cs @@ -0,0 +1,54 @@ +/* + * User: dickon + * Date: 06/12/2006 + * Time: 12:53 + * + */ + +using System; +using System.Collections.Generic; +using System.Xml; +using System.Reflection; +using System.IO; + +using ICSharpCode.TextEditor.Document; + +namespace SharpDbTools.Forms +{ + /// + /// Implementation specifically for SQLTool, based on + /// a copy-and-paste reuse of ICSharpCode.TextEditor.ResourceSyntaxModeProvider + /// + public class SQLToolResourceSyntaxModeProvider: ISyntaxModeFileProvider + { + List syntaxModes = null; + + public ICollection SyntaxModes { + get { + return syntaxModes; + } + } + + public SQLToolResourceSyntaxModeProvider() + { + Assembly assembly = this.GetType().Assembly; + Stream syntaxModeStream = assembly.GetManifestResourceStream("SharpDbTools.Resources.SyntaxModes.xml"); + if (syntaxModeStream != null) { + syntaxModes = SyntaxMode.GetSyntaxModes(syntaxModeStream); + } else { + syntaxModes = new List(); + } + } + + public XmlTextReader GetSyntaxModeFile(SyntaxMode syntaxMode) + { + Assembly assembly = this.GetType().Assembly; + return new XmlTextReader(assembly.GetManifestResourceStream("SharpDbTools.Resources." + syntaxMode.FileName)); + } + + public void UpdateSyntaxModeList() + { + // resources don't change during runtime + } + } +}