[mapguide-commits] r7162 - in trunk/Tools/Maestro: Maestro.AddIn.Scripting Maestro.AddIn.Scripting/Lang/Python Maestro.AddIn.Scripting/Properties Maestro.AddIn.Scripting/Resources Maestro.AddIn.Scripting/UI Maestro.Editors Maestro.Editors/Common Maestro.Editors/Common/Expression OSGeo.MapGuide.MaestroAPI Thirdparty/SharpDevelop/ICSharpCode.TextEditor Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Resources

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Oct 29 06:32:01 PDT 2012


Author: jng
Date: 2012-10-29 06:32:01 -0700 (Mon, 29 Oct 2012)
New Revision: 7162

Added:
   trunk/Tools/Maestro/Maestro.AddIn.Scripting/Resources/control.png
   trunk/Tools/Maestro/Maestro.Editors/Common/Expression/
   trunk/Tools/Maestro/Maestro.Editors/Common/Expression/FdoExpressionCompletionDataProvider.cs
   trunk/Tools/Maestro/Maestro.Editors/Common/ITextEditor.cs
   trunk/Tools/Maestro/Maestro.Editors/Common/TextEditor.cs
   trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Resources/FDO.xshd
   trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Resources/SQL.xshd
Removed:
   trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/ITextEditor.cs
   trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/TextEditor.cs
Modified:
   trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsole.cs
   trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsoleCompletionDataProvider.cs
   trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsoleHost.cs
   trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonOutputStream.cs
   trunk/Tools/Maestro/Maestro.AddIn.Scripting/Maestro.AddIn.Scripting.csproj
   trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.Designer.cs
   trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.resx
   trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.Designer.cs
   trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs
   trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.cs
   trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.designer.cs
   trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.resx
   trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj
   trunk/Tools/Maestro/Maestro.Editors/Strings.Designer.cs
   trunk/Tools/Maestro/Maestro.Editors/Strings.resx
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.Designer.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.resx
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Utility.cs
   trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/ICSharpCode.TextEditor.csproj
   trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Resources/SyntaxModes.xml
Log:
This submission includes the following changes:
 - #2161: Move some of the REPL classes up the Maestro.Editors
 - Update the FDO Expression Editor to use the ICSharpCode.TextEditor control, with auto-complete support
 - Add syntax highlighting definitions for SQL and FDO expressions

Deleted: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/ITextEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/ITextEditor.cs	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/ITextEditor.cs	2012-10-29 13:32:01 UTC (rev 7162)
@@ -1,133 +0,0 @@
-#region Disclaimer / License
-// Copyright (C) 2012, Jackie Ng
-// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
-// 
-// Original code from SharpDevelop 3.2.1 licensed under the same terms (LGPL 2.1)
-// Copyright 2002-2010 by
-//
-//  AlphaSierraPapa, Christoph Wille
-//  Vordernberger Strasse 27/8
-//  A-8700 Leoben
-//  Austria
-//
-//  email: office at alphasierrapapa.com
-//  court of jurisdiction: Landesgericht Leoben
-//
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-// 
-#endregion
-using ICSharpCode.TextEditor;
-using ICSharpCode.TextEditor.Document;
-using ICSharpCode.TextEditor.Gui.CompletionWindow;
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-
-namespace Maestro.AddIn.Scripting.Lang.Python
-{
-    /// <summary>
-    /// The interface that the text editor used by the PythonConsole needs to be implement. Note that
-    /// all the methods will be called on another thread not the main UI thread and will therefore need to
-    /// be invoked.
-    /// </summary>
-    internal interface ITextEditor
-    {
-        /// <summary>
-        /// Fired when a key is pressed but before any text has been added to the text editor.
-        /// </summary>
-        /// <remarks>
-        /// The KeyPress handler should return true if the text editor should not process the key and not
-        /// insert any text.
-        /// </remarks>
-        event KeyEventHandler KeyPress;
-
-        /// <summary>
-        /// Fired when dialog key is pressed but before any text has been added to the text editor.
-        /// </summary>
-        /// <remarks>
-        /// The DialogKeyPress handler should return true if the text editor should not process the
-        /// dialog key.
-        /// </remarks>
-        event DialogKeyProcessor DialogKeyPress;
-
-        /// <summary>
-        /// Gets or sets the indentation style.
-        /// </summary>
-        IndentStyle IndentStyle { get; set; }
-
-        /// <summary>
-        /// Inserts text at the current cursor location.
-        /// </summary>
-        void Write(string text);
-
-        /// <summary>
-        /// Inserts text at the current cursor location with the specified colour.
-        /// </summary>
-        void Write(string text, Color backgroundColor);
-
-        /// <summary>
-        /// Replaces the text at the specified index on the current line with the specified text.
-        /// </summary>
-        void Replace(int index, int length, string text);
-
-        /// <summary>
-        /// Gets or sets the current column position of the cursor on the current line.  This is zero based.
-        /// </summary>
-        int Column { get; set; }
-
-        /// <summary>
-        /// Gets the length of the currently selected text.
-        /// </summary>
-        int SelectionLength { get; }
-
-        /// <summary>
-        /// Gets the start position of the currently selected text.
-        /// </summary>
-        int SelectionStart { get; }
-
-        /// <summary>
-        /// Gets the current line the cursor is on. This is zero based.
-        /// </summary>
-        int Line { get; }
-
-        /// <summary>
-        /// Gets the total number of lines in the text editor.
-        /// </summary>
-        int TotalLines { get; }
-
-        /// <summary>
-        /// Gets the text for the specified line.
-        /// </summary>
-        string GetLine(int index);
-
-        /// <summary>
-        /// Shows the code completion window.
-        /// </summary>
-        void ShowCompletionWindow(ICompletionDataProvider completionDataProvider);
-
-        /// <summary>
-        /// Indicates whether the completion window is currently being displayed.
-        /// </summary>
-        bool IsCompletionWindowDisplayed { get; }
-
-        /// <summary>
-        /// Makes the current text content read only. Text can be entered at the end.
-        /// </summary>
-        void MakeCurrentContentReadOnly();
-    }
-}

Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsole.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsole.cs	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsole.cs	2012-10-29 13:32:01 UTC (rev 7162)
@@ -30,6 +30,7 @@
 // 
 #endregion
 using ICSharpCode.TextEditor.Document;
+using Maestro.Editors.Common;
 using Microsoft.Scripting.Hosting.Shell;
 using System;
 using System.Collections.Generic;

Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsoleCompletionDataProvider.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsoleCompletionDataProvider.cs	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsoleCompletionDataProvider.cs	2012-10-29 13:32:01 UTC (rev 7162)
@@ -69,12 +69,13 @@
         public ICompletionData[] GenerateCompletionData(string line)
         {
             List<DefaultCompletionData> items = new List<DefaultCompletionData>();
-            //TODO: Breaks down on compound python expressions
             string name = GetName(line);
             if (!String.IsNullOrEmpty(name))
             {
                 try
                 {
+                    //TODO: It would be nice if we could get extra information besides the name. I'm not sure
+                    //if the DLR hosting API can give us anymore information
                     foreach (string member in memberProvider.GetMemberNames(name))
                     {
                         items.Add(new DefaultCompletionData(member, String.Empty, 0)); //ClassBrowserIconService.MethodIndex));
@@ -90,7 +91,10 @@
 
         string GetName(string text)
         {
-            int startIndex = text.LastIndexOfAny(new char[] { ' ', '+', '(' });
+            //Assume compacted expressions, meaning we need to take into account operators and non-whitespace tokens
+            //TODO: Still imperfect. A dot after a function expression brings up nothing. But a dot after a named variable will
+            //trigger auto-complete most of the time
+            int startIndex = text.LastIndexOfAny(new char[] { ' ', '+', '/', '*', '-', '%', '=', '>', '<', '&', '|', '^', '~', '(', ')' });
             string res = text.Substring(startIndex + 1);
             Debug.WriteLine("Evaluating python auto-complete options for: " + res);
             return res;

Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsoleHost.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsoleHost.cs	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsoleHost.cs	2012-10-29 13:32:01 UTC (rev 7162)
@@ -34,6 +34,7 @@
 using IronPython.Runtime;
 using Maestro.AddIn.Scripting.Services;
 using Maestro.AddIn.Scripting.UI;
+using Maestro.Editors.Common;
 using Microsoft.Scripting.Hosting;
 using Microsoft.Scripting.Hosting.Providers;
 using Microsoft.Scripting.Hosting.Shell;

Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonOutputStream.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonOutputStream.cs	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonOutputStream.cs	2012-10-29 13:32:01 UTC (rev 7162)
@@ -34,6 +34,7 @@
 using System.IO;
 using System.Linq;
 using System.Text;
+using Maestro.Editors.Common;
 
 namespace Maestro.AddIn.Scripting.Lang.Python
 {

Deleted: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/TextEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/TextEditor.cs	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/TextEditor.cs	2012-10-29 13:32:01 UTC (rev 7162)
@@ -1,245 +0,0 @@
-#region Disclaimer / License
-// Copyright (C) 2012, Jackie Ng
-// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
-// 
-// Original code from SharpDevelop 3.2.1 licensed under the same terms (LGPL 2.1)
-// Copyright 2002-2010 by
-//
-//  AlphaSierraPapa, Christoph Wille
-//  Vordernberger Strasse 27/8
-//  A-8700 Leoben
-//  Austria
-//
-//  email: office at alphasierrapapa.com
-//  court of jurisdiction: Landesgericht Leoben
-//
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-// 
-#endregion
-using ICSharpCode.TextEditor;
-using ICSharpCode.TextEditor.Document;
-using ICSharpCode.TextEditor.Gui.CompletionWindow;
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-
-namespace Maestro.AddIn.Scripting.Lang.Python
-{
-    internal class TextEditor : ITextEditor
-    {
-        delegate string GetLineInvoker(int index);
-        delegate void WriteInvoker(string text, Color color);
-
-        TextEditorControl textEditorControl;
-        TextArea textArea;
-        Color customLineColour = Color.LightGray;
-        TextMarker readOnlyMarker;
-
-        CodeCompletionWindow completionWindow;
-
-        public TextEditor(TextEditorControl textEditorControl)
-        {
-            this.textEditorControl = textEditorControl;
-            this.textArea = textEditorControl.ActiveTextAreaControl.TextArea;
-            textEditorControl.TextEditorProperties.SupportReadOnlySegments = true;
-        }
-
-        public IndentStyle IndentStyle
-        {
-            get { return textEditorControl.IndentStyle; }
-            set { SetIndentStyle(value); }
-        }
-
-        public event KeyEventHandler KeyPress
-        {
-            add { textArea.KeyEventHandler += value; }
-            remove { textArea.KeyEventHandler -= value; }
-        }
-
-        public event DialogKeyProcessor DialogKeyPress
-        {
-            add { textArea.DoProcessDialogKey += value; }
-            remove { textArea.DoProcessDialogKey -= value; }
-        }
-
-        public Color CustomLineColour
-        {
-            get { return customLineColour; }
-        }
-
-        public void Write(string text)
-        {
-            Write(text, Color.Empty);
-        }
-
-        public void Write(string text, Color backgroundColour)
-        {
-            if (textEditorControl.InvokeRequired)
-            {
-                WriteInvoker invoker = new WriteInvoker(Write);
-                textEditorControl.Invoke(invoker, new object[] { text, backgroundColour });
-            }
-            else
-            {
-                int offset = textEditorControl.Document.PositionToOffset(new TextLocation(Column, Line));
-                textEditorControl.ActiveTextAreaControl.TextArea.InsertString(text);
-
-                if (!backgroundColour.IsEmpty)
-                {
-                    TextMarker marker = new TextMarker(offset, text.Length, TextMarkerType.SolidBlock, backgroundColour);
-                    textEditorControl.Document.MarkerStrategy.AddMarker(marker);
-                    textEditorControl.Refresh();
-                }
-            }
-        }
-
-        public int Column
-        {
-            get { return textEditorControl.ActiveTextAreaControl.Caret.Column; }
-            set { textEditorControl.ActiveTextAreaControl.Caret.Column = value; }
-        }
-
-        public int SelectionStart
-        {
-            get
-            {
-                ColumnRange range = GetSelectionRange();
-                if (range != ColumnRange.NoColumn)
-                {
-                    return range.StartColumn;
-                }
-                return Column;
-            }
-        }
-
-        public int SelectionLength
-        {
-            get
-            {
-                ColumnRange range = GetSelectionRange();
-                return range.EndColumn - range.StartColumn;
-            }
-        }
-
-        /// <summary>
-        /// Gets the current cursor line.
-        /// </summary>
-        public int Line
-        {
-            get { return textArea.Caret.Line; }
-        }
-
-        /// <summary>
-        /// Gets the total number of lines in the text editor.
-        /// </summary>
-        public int TotalLines
-        {
-            get { return textEditorControl.Document.TotalNumberOfLines; }
-        }
-
-        /// <summary>
-        /// Gets the text for the specified line.
-        /// </summary>
-        public string GetLine(int index)
-        {
-            if (textEditorControl.InvokeRequired)
-            {
-                GetLineInvoker invoker = new GetLineInvoker(GetLine);
-                return (string)textEditorControl.Invoke(invoker, new object[] { index });
-            }
-            else
-            {
-                LineSegment lineSegment = textEditorControl.Document.GetLineSegment(index);
-                return textEditorControl.Document.GetText(lineSegment);
-            }
-        }
-
-        /// <summary>
-        /// Replaces the text at the specified index on the current line with the specified text.
-        /// </summary>
-        public void Replace(int index, int length, string text)
-        {
-            int currentLine = textEditorControl.ActiveTextAreaControl.Caret.Line;
-            LineSegment lineSegment = textEditorControl.Document.GetLineSegment(currentLine);
-            textEditorControl.Document.Replace(lineSegment.Offset + index, length, text);
-        }
-
-        /// <summary>
-        /// Makes the current text read only. Text can still be entered at the end.
-        /// </summary>
-        public void MakeCurrentContentReadOnly()
-        {
-            IDocument doc = textEditorControl.Document;
-            if (readOnlyMarker == null)
-            {
-                readOnlyMarker = new TextMarker(0, doc.TextLength, TextMarkerType.Invisible);
-                readOnlyMarker.IsReadOnly = true;
-                doc.MarkerStrategy.AddMarker(readOnlyMarker);
-            }
-            readOnlyMarker.Offset = 0;
-            readOnlyMarker.Length = doc.TextLength;
-            doc.UndoStack.ClearAll();
-        }
-
-        public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider)
-        {
-            completionWindow = CodeCompletionWindow.ShowCompletionWindow(textEditorControl.ParentForm, textEditorControl, String.Empty, completionDataProvider, ' ');
-            if (completionWindow != null)
-            {
-                completionWindow.Width = 250;
-                completionWindow.Closed += CompletionWindowClosed;
-            }
-        }
-
-        public bool IsCompletionWindowDisplayed
-        {
-            get { return completionWindow != null; }
-        }
-
-        /// <summary>
-        /// Gets the range of the currently selected text.
-        /// </summary>
-        ColumnRange GetSelectionRange()
-        {
-            return textArea.SelectionManager.GetSelectionAtLine(textArea.Caret.Line);
-        }
-
-        void SetIndentStyle(IndentStyle style)
-        {
-            if (textEditorControl.InvokeRequired)
-            {
-                Action<IndentStyle> action = SetIndentStyle;
-                textEditorControl.Invoke(action, new object[] { style });
-            }
-            else
-            {
-                textEditorControl.IndentStyle = style;
-            }
-        }
-
-        void CompletionWindowClosed(object source, EventArgs e)
-        {
-            if (completionWindow != null)
-            {
-                completionWindow.Closed -= CompletionWindowClosed;
-                completionWindow.Dispose();
-                completionWindow = null;
-            }
-        }
-    }
-}

Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Maestro.AddIn.Scripting.csproj
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Maestro.AddIn.Scripting.csproj	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Maestro.AddIn.Scripting.csproj	2012-10-29 13:32:01 UTC (rev 7162)
@@ -72,12 +72,10 @@
     <Compile Include="Commands\StartupCommand.cs" />
     <Compile Include="Lang\Python\CommandLineHistory.cs" />
     <Compile Include="Lang\Python\IMemberProvider.cs" />
-    <Compile Include="Lang\Python\ITextEditor.cs" />
     <Compile Include="Lang\Python\PythonConsole.cs" />
     <Compile Include="Lang\Python\PythonConsoleCompletionDataProvider.cs" />
     <Compile Include="Lang\Python\PythonConsoleHost.cs" />
     <Compile Include="Lang\Python\PythonOutputStream.cs" />
-    <Compile Include="Lang\Python\TextEditor.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Properties\Resources.Designer.cs">
       <AutoGen>True</AutoGen>
@@ -108,6 +106,7 @@
     <Content Include="Manifest.addin">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
+    <None Include="Resources\control.png" />
     <None Include="Resources\cross-script.png" />
     <None Include="Resources\block.png" />
   </ItemGroup>

Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.Designer.cs	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.Designer.cs	2012-10-29 13:32:01 UTC (rev 7162)
@@ -73,6 +73,16 @@
         /// <summary>
         ///   Looks up a localized resource of type System.Drawing.Bitmap.
         /// </summary>
+        internal static System.Drawing.Bitmap control {
+            get {
+                object obj = ResourceManager.GetObject("control", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized resource of type System.Drawing.Bitmap.
+        /// </summary>
         internal static System.Drawing.Bitmap cross_script {
             get {
                 object obj = ResourceManager.GetObject("cross-script", resourceCulture);

Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.resx	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.resx	2012-10-29 13:32:01 UTC (rev 7162)
@@ -124,4 +124,7 @@
   <data name="cross-script" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\Resources\cross-script.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
+  <data name="control" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\control.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
 </root>
\ No newline at end of file

Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Resources/control.png
===================================================================
(Binary files differ)


Property changes on: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Resources/control.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.Designer.cs	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.Designer.cs	2012-10-29 13:32:01 UTC (rev 7162)
@@ -30,6 +30,8 @@
         {
             this.textEditorControl = new ICSharpCode.TextEditor.TextEditorControl();
             this.toolStrip1 = new System.Windows.Forms.ToolStrip();
+            this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
+            this.btnLoadFile = new System.Windows.Forms.ToolStripButton();
             this.btnClear = new System.Windows.Forms.ToolStripButton();
             this.toolStrip1.SuspendLayout();
             this.SuspendLayout();
@@ -46,6 +48,8 @@
             // toolStrip1
             // 
             this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.btnLoadFile,
+            this.toolStripSeparator1,
             this.btnClear});
             this.toolStrip1.Location = new System.Drawing.Point(0, 0);
             this.toolStrip1.Name = "toolStrip1";
@@ -53,6 +57,20 @@
             this.toolStrip1.TabIndex = 1;
             this.toolStrip1.Text = "toolStrip1";
             // 
+            // toolStripSeparator1
+            // 
+            this.toolStripSeparator1.Name = "toolStripSeparator1";
+            this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
+            // 
+            // btnLoadFile
+            // 
+            this.btnLoadFile.Image = global::Maestro.AddIn.Scripting.Properties.Resources.control;
+            this.btnLoadFile.ImageTransparentColor = System.Drawing.Color.Magenta;
+            this.btnLoadFile.Name = "btnLoadFile";
+            this.btnLoadFile.Size = new System.Drawing.Size(69, 22);
+            this.btnLoadFile.Text = "Run File";
+            this.btnLoadFile.Click += new System.EventHandler(this.btnLoadFile_Click);
+            // 
             // btnClear
             // 
             this.btnClear.Image = global::Maestro.AddIn.Scripting.Properties.Resources.cross_script;
@@ -82,5 +100,7 @@
         private ICSharpCode.TextEditor.TextEditorControl textEditorControl;
         private System.Windows.Forms.ToolStrip toolStrip1;
         private System.Windows.Forms.ToolStripButton btnClear;
+        private System.Windows.Forms.ToolStripButton btnLoadFile;
+        private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
     }
 }

Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs	2012-10-29 13:32:01 UTC (rev 7162)
@@ -9,10 +9,12 @@
 using Maestro.Shared.UI;
 using ICSharpCode.TextEditor.Document;
 using System.IO;
+using Microsoft.Scripting.Hosting.Shell;
 
 namespace Maestro.AddIn.Scripting.UI
 {
     using Lang.Python;
+    using Maestro.Editors.Common;
 
     internal partial class IronPythonRepl : SingletonViewContent
     {
@@ -24,6 +26,7 @@
             InitializeComponent();
             textEditorControl.CreateControl();
 
+            textEditorControl.ShowLineNumbers = false;
             textEditorControl.ShowVRuler = false;
             textEditorControl.ShowHRuler = false;
 
@@ -52,14 +55,35 @@
             }
         }
 
+        private static void NewPrompt(IConsole con)
+        {
+            //HACK: Should be a way to get this from IronPython
+            con.Write(">>> ", Microsoft.Scripting.Hosting.Shell.Style.Prompt);
+        }
+
         private void btnClear_Click(object sender, EventArgs e)
         {
             textEditorControl.Text = string.Empty;
             var con = host.Console;
             var cmdline = con.CommandLine;
-            //HACK: Should be a way to get this from IronPython
-            con.Write(">>> ", Microsoft.Scripting.Hosting.Shell.Style.Prompt);
+            NewPrompt(con);
             textEditorControl.Refresh();
         }
+
+        private void btnLoadFile_Click(object sender, EventArgs e)
+        {
+            using (var picker = DialogFactory.OpenFile())
+            {
+                picker.Filter = "*.py|*.py"; //NOXLATE
+                if (picker.ShowDialog() == DialogResult.OK)
+                {
+                    var con = host.Console;
+                    var cmdline = con.CommandLine;
+                    con.WriteLine();
+                    cmdline.ScriptScope.Engine.ExecuteFile(picker.FileName);
+                    NewPrompt(con);
+                }
+            }
+        }
     }
 }


Property changes on: trunk/Tools/Maestro/Maestro.Editors/Common/Expression
___________________________________________________________________
Added: bugtraq:number
   + true

Added: trunk/Tools/Maestro/Maestro.Editors/Common/Expression/FdoExpressionCompletionDataProvider.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/Expression/FdoExpressionCompletionDataProvider.cs	                        (rev 0)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/Expression/FdoExpressionCompletionDataProvider.cs	2012-10-29 13:32:01 UTC (rev 7162)
@@ -0,0 +1,387 @@
+using ICSharpCode.TextEditor;
+using ICSharpCode.TextEditor.Document;
+using ICSharpCode.TextEditor.Gui.CompletionWindow;
+using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.MaestroAPI.Schema;
+using OSGeo.MapGuide.ObjectModels.Capabilities;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+
+namespace Maestro.Editors.Common.Expression
+{
+    //NOTE:
+    //
+    //It seems the auto-complete capabilities of the ICSharpCode.TextEditor assume object-oriented languages or languages
+    //that involve a member access operator (., -> or anything similar), so we have to use a custom ICompletionData that
+    //compensates for the lack of such contexts
+    //
+    //NOTE/TODO:
+    //Auto-completions are currently case-sensitive and will only trigger on the correct case.
+
+    internal class FdoExpressionCompletionDataProvider : ICompletionDataProvider
+    {
+        private ClassDefinition _klass;
+        private FdoProviderCapabilities _caps;
+
+        public FdoExpressionCompletionDataProvider(ClassDefinition cls, FdoProviderCapabilities caps)
+        {
+            _klass = cls;
+            _caps = caps;
+            this.DefaultIndex = 0;
+            this.PreSelection = null;
+            this.ImageList = new System.Windows.Forms.ImageList();
+            this.ImageList.Images.Add(Properties.Resources.block);
+            this.ImageList.Images.Add(Properties.Resources.property);
+            this.ImageList.Images.Add(Properties.Resources.funnel);
+        }
+
+        public System.Windows.Forms.ImageList ImageList
+        {
+            get;
+            private set;
+        }
+
+        public string PreSelection
+        {
+            get;
+            private set;
+        }
+
+        public int DefaultIndex
+        {
+            get;
+            private set;
+        }
+
+        public bool InsertSpace
+        {
+            get;
+            set;
+        }
+
+        public CompletionDataProviderKeyResult ProcessKey(char key)
+        {
+            CompletionDataProviderKeyResult res;
+            if (key == ' ' && this.InsertSpace)
+            {
+                this.InsertSpace = false; // insert space only once
+                res = CompletionDataProviderKeyResult.BeforeStartKey;
+            }
+            else if (char.IsLetterOrDigit(key) || key == '_')
+            {
+                this.InsertSpace = false; // don't insert space if user types normally
+                res = CompletionDataProviderKeyResult.NormalKey;
+            }
+            else
+            {
+                // do not reset insertSpace when doing an insertion!
+                res = CompletionDataProviderKeyResult.InsertionKey;
+            }
+            return res;
+        }
+
+        public bool InsertAction(ICompletionData data, TextArea textArea, int insertionOffset, char key)
+        {
+            if (this.InsertSpace)
+            {
+                textArea.Document.Insert(insertionOffset++, " ");
+            }
+            textArea.Caret.Position = textArea.Document.OffsetToPosition(insertionOffset);
+
+            var res = data.InsertAction(textArea, key);
+            var fdoComp = (FdoCompletionData)data;
+            if (fdoComp.ImageIndex == 0 && fdoComp.AppendText.Length > 2) //Function and not an empty function call
+            {
+                //Rewind caret so it is at the start of the function call (at first parameter)
+                var offset = textArea.Caret.Offset;
+                offset -= (fdoComp.AppendText.Length - 1);
+                textArea.Caret.Position = textArea.Document.OffsetToPosition(offset);
+                textArea.SelectionManager.ClearSelection();
+                textArea.SelectionManager.SetSelection(textArea.Caret.Position, textArea.Document.OffsetToPosition(offset + (fdoComp.HighlightLength - 1)));
+            }
+            return res;
+        }
+
+        /// <summary>
+        /// Gets the line of text up to the cursor position.
+        /// </summary>
+        string GetLineText(TextArea textArea)
+        {
+            LineSegment lineSegment = textArea.Document.GetLineSegmentForOffset(textArea.Caret.Offset);
+            return textArea.Document.GetText(lineSegment);
+        }
+
+        public ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped)
+        {
+            return GenerateCompletionData((GetLineText(textArea) + charTyped).Trim());
+        }
+
+        class FdoCompletionData : DefaultCompletionData
+        {
+            private string _insertText;
+            private string _appendText;
+            private int _highlightLength = 0;
+
+            public int HighlightLength { get { return _highlightLength; } }
+
+            public string InsertText { get { return _insertText; } }
+
+            public string AppendText { get { return _appendText; } }
+
+            public FdoCompletionData(string prefix, string text, string description, int imageIndex)
+                : base(text, description, imageIndex)
+            {
+                _insertText = text.Substring(prefix.Length);
+                _appendText = string.Empty;
+            }
+
+            public FdoCompletionData(string prefix, string text, string description, string appendText, int highlightLength, int imageIndex)
+                : this(prefix, text, description, imageIndex)
+            {
+                _appendText = appendText;
+                _highlightLength = highlightLength;
+            }
+
+            public override bool InsertAction(TextArea textArea, char ch)
+            {
+                textArea.InsertString(_insertText + _appendText);
+                return false;
+            }
+        }
+
+        private ICompletionData[] GenerateCompletionData(string line)
+        {
+            Debug.WriteLine("FDO auto-complete: " + line);
+            List<DefaultCompletionData> items = new List<DefaultCompletionData>();
+            string name = GetName(line);
+            if (!String.IsNullOrEmpty(name))
+            {
+                try
+                {
+                    foreach (var func in GetMatchingFdoFunctions(name))
+                    {
+                        var member = CreateFdoFunctionDescriptor(func);
+                        int highlightLength = 0;
+                        if (func.ArgumentDefinitionList.Count > 0)
+                        {
+                            highlightLength = func.ArgumentDefinitionList[0].Name.Length + 2; // [ and ]
+                        }
+                        items.Add(new FdoCompletionData(name, member.Name, member.Description, member.AppendText, highlightLength, 0));
+                    }
+                    foreach (var member in GetMatchingClassProperties(name))
+                    {
+                        items.Add(new FdoCompletionData(name, member.Name, member.Description, 1));
+                    }
+                    foreach (var member in GetMatchingFdoConditions(name))
+                    {
+                        items.Add(new FdoCompletionData(name, member.Name, member.Description, member.AppendText, member.AppendText.Length - 1, 2));
+                    }
+                    foreach (var member in GetMatchingFdoOperators(name))
+                    {
+                        items.Add(new FdoCompletionData(name, member.Name, member.Description, member.AppendText, 0, 2));
+                    }
+                    items.Sort((a, b) => { return a.Text.CompareTo(b.Text); });
+                }
+                catch
+                {
+                    // Do nothing.
+                }
+            }
+            return items.ToArray();
+        }
+
+        class Descriptor
+        {
+            public string Name;
+            public string Description;
+            public string AppendText;
+        }
+
+        private IEnumerable<FdoProviderCapabilitiesExpressionFunctionDefinition> GetMatchingFdoFunctions(string name)
+        {
+            foreach (var func in _caps.Expression.FunctionDefinitionList.Concat(Utility.GetStylizationFunctions()))
+            {
+                if (func.Name.StartsWith(name))
+                    yield return func;
+            }
+        }
+
+        private IEnumerable<Descriptor> GetMatchingFdoConditions(string name)
+        {
+            foreach (var cond in _caps.Filter.Condition)
+            {
+                if (cond.ToString().ToUpper().StartsWith(name))
+                {
+                    var desc = CreateFdoConditionDescriptor(cond);
+                    if (desc != null)
+                        yield return desc;
+                }
+            }
+        }
+
+        private Descriptor CreateFdoConditionDescriptor(FdoProviderCapabilitiesFilterType cond)
+        {
+            if (cond == FdoProviderCapabilitiesFilterType.Null)
+            {
+                return new Descriptor()
+                {
+                    Name = cond.ToString().ToUpper(),
+                    Description = "[property] NULL" //NOXLATE
+                };
+            }
+            else if (cond == FdoProviderCapabilitiesFilterType.In)
+            {
+                return new Descriptor()
+                {
+                    Name = cond.ToString().ToUpper(),
+                    Description = "[property] IN ([value1], [value2], ..., [valueN])", //NOXLATE
+                    AppendText = " ([value1], [value2])" //NOXLATE
+                };
+            }
+            else if (cond == FdoProviderCapabilitiesFilterType.Like)
+            {
+                return new Descriptor()
+                {
+                    Name = cond.ToString().ToUpper(),
+                    Description = "[property] LIKE [string value]", //NOXLATE
+                    AppendText = " [string value]" //NOXLATE
+                };
+            }
+            return null; //Handled by operators
+        }
+
+        private static Descriptor CreateBinaryDistanceOperator(string opName)
+        {
+            return new Descriptor()
+            {
+                Name = opName.ToUpper(),
+                Description = "[property] " + opName + " [number]", //NOXLATE
+                AppendText = " [number]" //NOXLATE
+            };
+        }
+
+        private static Descriptor CreateBinarySpatialOperator(string opName)
+        {
+            return new Descriptor()
+            {
+                Name = opName.ToUpper(),
+                Description = "[geometry] " + opName + " GeomFromText('geometry wkt')", //NOXLATE
+                AppendText = " GeomFromText('geometry wkt')" //NOXLATE
+            };
+        }
+
+        private IEnumerable<Descriptor> GetMatchingFdoOperators(string name)
+        {
+            foreach (var op in _caps.Filter.Distance)
+            {
+                var opName = op.ToString().ToUpper();
+                if (opName.StartsWith(name))
+                    yield return CreateBinaryDistanceOperator(opName);
+            }
+            foreach (var op in _caps.Filter.Spatial)
+            {
+                var opName = op.ToString().ToUpper();
+                if (opName.StartsWith(name))
+                    yield return CreateBinarySpatialOperator(opName);
+            }
+        }
+
+        private IEnumerable<Descriptor> GetMatchingClassProperties(string name)
+        {
+            foreach (var prop in _klass.Properties)
+            {
+                if (prop.Name.StartsWith(name))
+                    yield return CreatePropertyDescriptor(prop);
+            }
+        }
+
+        private Descriptor CreateFdoFunctionDescriptor(FdoProviderCapabilitiesExpressionFunctionDefinition func)
+        {
+            var desc = new Descriptor();
+            desc.Name = func.Name;
+            string fmt = "{0}({1})"; //NOXLATE
+            List<string> args = new List<string>();
+            foreach (FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition argDef in func.ArgumentDefinitionList)
+            {
+                args.Add(argDef.Name.Trim());
+            }
+            string argsStr = StringifyFunctionArgs(args);
+            string expr = string.Format(fmt, func.Name, argsStr); //NOXLATE
+            desc.Description = string.Format(Strings.ExprEditorFunctionDesc, expr, func.Description, func.ReturnType, Environment.NewLine);
+            desc.AppendText = "(" + argsStr + ")";
+            return desc;
+        }
+
+        internal static string StringifyFunctionArgs(List<string> args)
+        {
+            string argsStr = args.Count > 0 ? "[" + string.Join("], [", args.ToArray()) + "]" : string.Empty; //NOXLATE
+            return argsStr;
+        }
+
+        private static Descriptor CreatePropertyDescriptor(PropertyDefinition prop)
+        {
+            var desc = new Descriptor();
+            desc.Name = prop.Name;
+
+            if (prop.Type == PropertyDefinitionType.Geometry)
+            {
+                var g = (GeometricPropertyDefinition)prop;
+                desc.Description = string.Format(Strings.FsPreview_GeometryPropertyNodeTooltip,
+                    g.Name,
+                    g.Description,
+                    g.GeometryTypesToString(),
+                    g.IsReadOnly,
+                    g.HasElevation,
+                    g.HasMeasure,
+                    g.SpatialContextAssociation,
+                    Environment.NewLine);
+            }
+            else if (prop.Type == PropertyDefinitionType.Data)
+            {
+                var d = (DataPropertyDefinition)prop;
+                desc.Description = string.Format(Strings.FsPreview_DataPropertyNodeTooltip,
+                    d.Name,
+                    d.Description,
+                    d.DataType.ToString(),
+                    d.IsNullable,
+                    d.IsReadOnly,
+                    d.Length,
+                    d.Precision,
+                    d.Scale,
+                    Environment.NewLine);
+            }
+            else if (prop.Type == PropertyDefinitionType.Raster)
+            {
+                var r = (RasterPropertyDefinition)prop;
+                desc.Description = string.Format(Strings.FsPreview_RasterPropertyNodeTooltip,
+                    r.Name,
+                    r.Description,
+                    r.IsNullable,
+                    r.DefaultImageXSize,
+                    r.DefaultImageYSize,
+                    r.SpatialContextAssociation,
+                    Environment.NewLine);
+            }
+            else
+            {
+                desc.Description = string.Format(Strings.FsPreview_GenericPropertyTooltip,
+                    prop.Name,
+                    prop.Type.ToString(),
+                    Environment.NewLine);
+            }
+
+            return desc;
+        }
+
+        private string GetName(string text)
+        {
+            int startIndex = text.LastIndexOfAny(new char[] { ' ', '+', '/', '*', '-', '%', '=', '>', '<', '&', '|', '^', '~', '(', ',', ')' }); //NOXLATE
+            string res = text.Substring(startIndex + 1);
+            Debug.WriteLine("Evaluating FDO auto-complete options for: " + res);
+            return res;
+        }
+    }
+}

Modified: trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.cs	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.cs	2012-10-29 13:32:01 UTC (rev 7162)
@@ -30,6 +30,8 @@
 using OSGeo.MapGuide.MaestroAPI.Exceptions;
 using Maestro.Shared.UI;
 using OSGeo.MapGuide.MaestroAPI.Schema;
+using Maestro.Editors.Common.Expression;
+using ICSharpCode.TextEditor.Gui.CompletionWindow;
 
 namespace Maestro.Editors.Common
 {
@@ -77,9 +79,10 @@
     public partial class ExpressionEditor : Form
     {
         private ClassDefinition _cls;
-        
         private IFeatureService _featSvc;
         private string m_featureSource = null;
+        private FdoProviderCapabilities _caps;
+        private ITextEditor _editor;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="ExpressionEditor"/> class.
@@ -87,9 +90,20 @@
         public ExpressionEditor()
         {
             InitializeComponent();
-            InitAutoComplete();
+            ExpressionText.SetHighlighting("FDO");
+            _editor = new TextEditor(ExpressionText);
+            _editor.KeyPress += OnEditorKeyPress;
         }
 
+        bool OnEditorKeyPress(char ch)
+        {
+            if (Char.IsLetter(ch))
+            {
+                ShowAutoComplete(ch);
+            }
+            return false;
+        }
+
         /// <summary>
         /// Gets or sets the expression.
         /// </summary>
@@ -115,8 +129,8 @@
                 _cls = cls;
                 _featSvc = featSvc;
                 m_featureSource = featuresSourceId;
+                _caps = caps;
 
-                //TODO: Perhaps add column type and indication of primary key
                 SortedList<string, PropertyDefinition> sortedCols = new SortedList<string, PropertyDefinition>();
                 foreach (var col in _cls.Properties)
                 {
@@ -144,10 +158,6 @@
                 if (ColumnName.Items.Count > 0)
                     ColumnName.SelectedIndex = 0;
 
-                LoadCompletableProperties(_cls.Properties);
-
-                //TODO: Figure out how to translate the enums into something usefull
-
                 //Functions
                 SortedList<string, FdoProviderCapabilitiesExpressionFunctionDefinition> sortedFuncs = new SortedList<string, FdoProviderCapabilitiesExpressionFunctionDefinition>();
                 foreach (FdoProviderCapabilitiesExpressionFunctionDefinition func in caps.Expression.FunctionDefinitionList)
@@ -157,7 +167,7 @@
 
                 if (attachStylizationFunctions)
                 {
-                    foreach (var func in GetStylizationFunctions())
+                    foreach (var func in Utility.GetStylizationFunctions())
                     {
                         sortedFuncs.Add(func.Name, func);
                     }
@@ -170,22 +180,20 @@
                     btn.Name = name;
                     btn.Text = name;
                     btn.ToolTipText = func.Description;
+
                     string fmt = "{0}({1})"; //NOXLATE
                     List<string> args = new List<string>();
                     foreach (FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition argDef in func.ArgumentDefinitionList)
                     {
                         args.Add(argDef.Name.Trim());
                     }
-                    string expr = string.Format(fmt, name, string.Join(", ", args.ToArray()));
+                    string expr = string.Format(fmt, name, FdoExpressionCompletionDataProvider.StringifyFunctionArgs(args));
                     btn.Click += delegate
                     {
                         InsertText(expr);
                     };
                     btnFunctions.DropDown.Items.Add(btn);
                 }
-                LoadCompletableFunctions(caps.Expression.FunctionDefinitionList);
-                if (attachStylizationFunctions)
-                    LoadCompletableFunctions(GetStylizationFunctions());
 
                 //Spatial Operators
                 foreach (FdoProviderCapabilitiesFilterOperation op in caps.Filter.Spatial)
@@ -195,7 +203,7 @@
                     btn.Name = btn.Text = btn.ToolTipText = op.ToString();
                     btn.Click += delegate
                     {
-                        InsertFilter(name);
+                        InsertSpatialFilter(name);
                     };
                     btnSpatial.DropDown.Items.Add(btn);
                 }
@@ -208,7 +216,7 @@
                     btn.Name = btn.Text = btn.ToolTipText = op.ToString();
                     btn.Click += delegate
                     {
-                        InsertFilter(name);
+                        InsertSpatialFilter(name);
                     };
                     btnDistance.DropDown.Items.Add(btn);
                 }
@@ -221,745 +229,45 @@
                     btn.Name = btn.Text = btn.ToolTipText = op.ToString();
                     btn.Click += delegate
                     {
-                        InsertFilter(name);
+                        InsertSpatialFilter(name);
                     };
                     btnCondition.DropDown.Items.Add(btn);
                 }
-
-                /*try
-                {
-                    /*FdoProviderCapabilities cap = m_connection.GetProviderCapabilities(m_providername);
-                    foreach (FdoProviderCapabilitiesFilterType cmd in cap.Filter.Condition)
-                        FunctionCombo.Items.Add(cmd.ToString());
-
-                    FunctionLabel.Enabled = FunctionCombo.Enabled = true;
-                }
-                catch
-                {
-                    FunctionLabel.Enabled = FunctionCombo.Enabled = false;
-                }*/
             }
             catch
             {
             }
-
         }
 
-        private IEnumerable<FdoProviderCapabilitiesExpressionFunctionDefinition> GetStylizationFunctions()
-        {
-            //ARGB
-            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
-            {
-                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>()
-                {
-                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
-                    {
-                        Name = "aValue", //NOXLATE
-                        Description = Strings.Func_ARGB_AValueDescription,
-                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.Int32
-                    },
-                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
-                    {
-                        Name = "rValue", //NOXLATE
-                        Description = Strings.Func_ARGB_RValueDescription,
-                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.Int32
-                    },
-                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
-                    {
-                        Name = "gValue", //NOXLATE
-                        Description = Strings.Func_ARGB_GValueDescription,
-                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.Int32
-                    },
-                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
-                    {
-                        Name = "bValue", //NOXLATE
-                        Description = Strings.Func_ARGB_BValueDescription,
-                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.Int32
-                    },
-                },
-                Description = Strings.Func_ARGB_Description,
-                Name = "ARGB", //NOXLATE
-                ReturnType = "Int32" //NOXLATE
-            };
-            //DECAP
-            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
-            {
-                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>()
-                {
-                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
-                    {
-                        Name = "strValue", //NOXLATE
-                        Description = Strings.Func_DECAP_StringValueDescription,
-                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
-                    }
-                },
-                Description = Strings.Func_DECAP_Description,
-                Name = "DECAP", //NOXLATE
-                ReturnType = "String" //NOXLATE
-            };
-            //FEATURECLASS
-            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
-            {
-                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>(),
-                Description = Strings.Func_FEATURECLASS_Description,
-                Name = "FEATURECLASS", //NOXLATE
-                ReturnType = "String" //NOXLATE
-            };
-            //FEATUREID
-            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
-            {
-                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>(),
-                Description = Strings.Func_FEATUREID_Description,
-                Name = "FEATUREID", //NOXLATE
-                ReturnType = "String" //NOXLATE
-            };
-            //IF
-            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
-            {
-                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>()
-                {
-                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
-                    {
-                        Name = "condition", //NOXLATE
-                        Description = Strings.Func_IF_ConditionDescription,
-                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
-                    },
-                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
-                    {
-                        Name = "trueValue", //NOXLATE
-                        Description = Strings.Func_IF_TrueValueDescription,
-                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
-                    },
-                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
-                    {
-                        Name = "falseValue", //NOXLATE
-                        Description = Strings.Func_IF_FalseValueDescription,
-                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
-                    }
-                },
-                Description = Strings.Func_IF_Description,
-                Name = "IF", //NOXLATE
-                ReturnType = "String" //NOXLATE
-            };
-            //LAYERID
-            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
-            {
-                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>(),
-                Description = Strings.Func_LAYERID_Description,
-                Name = "LAYERID", //NOXLATE
-                ReturnType = "String" //NOXLATE
-            };
-            //LOOKUP
-            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
-            {
-                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>()
-                {
-                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
-                    {
-                        Name = "expression", //NOXLATE
-                        Description = Strings.Func_LOOKUP_ExpressionDescription,
-                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
-                    },
-                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
-                    {
-                        Name = "defaultValue", //NOXLATE
-                        Description = Strings.Func_LOOKUP_DefaultValueDescription,
-                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
-                    },
-                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
-                    {
-                        Name = "index", //NOXLATE
-                        Description = Strings.Func_LOOKUP_IndexDescription,
-                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
-                    },
-                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
-                    {
-                        Name = "value", //NOXLATE
-                        Description = Strings.Func_LOOKUP_ValueDescription,
-                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
-                    }
-                },
-                Description = Strings.Func_LOOKUP_Description,
-                Name = "LOOKUP", //NOXLATE
-                ReturnType = "String" //NOXLATE
-            };
-            //MAPNAME
-            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
-            {
-                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>(),
-                Description = Strings.Func_MAPNAME_Description,
-                Name = "MAPNAME", //NOXLATE
-                ReturnType = "String" //NOXLATE
-            };
-            //RANGE
-            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
-            {
-                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>()
-                {
-                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
-                    {
-                        Name = "expression", //NOXLATE
-                        Description = Strings.Func_RANGE_ExpressionDescription,
-                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
-                    },
-                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
-                    {
-                        Name = "rangeMin", //NOXLATE
-                        Description = Strings.Func_RANGE_MinDescription,
-                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
-                    },
-                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
-                    {
-                        Name = "rangeMax", //NOXLATE
-                        Description = Strings.Func_RANGE_MaxDescription,
-                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
-                    },
-                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
-                    {
-                        Name = "defaultValue", //NOXLATE
-                        Description = Strings.Func_RANGE_DefaultValueDescription,
-                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
-                    },
-                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
-                    {
-                        Name = "value", //NOXLATE
-                        Description = Strings.Func_RANGE_ValueDescription,
-                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
-                    }
-                },
-                Description = Strings.Func_RANGE_Description,
-                Name = "RANGE", //NOXLATE
-                ReturnType = "String" //NOXLATE
-            };
-            //SESSION
-            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
-            {
-                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>(),
-                Description = Strings.Func_SESSION_Description,
-                Name = "SESSION", //NOXLATE
-                ReturnType = "String" //NOXLATE
-            };
-            //URLENCODE
-            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
-            {
-                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>()
-                {
-                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
-                    {
-                        Name = "strValue", //NOXLATE
-                        Description = Strings.Func_URLENCODE_StringValueDescription,
-                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
-                    }
-                },
-                Description = Strings.Func_URLENCODE_Description,
-                Name = "URLENCODE", //NOXLATE
-                ReturnType = "String" //NOXLATE
-            };
-        }
-
-        private void InsertText(string exprText)
-        {
-            int index = ExpressionText.SelectionStart;
-            if (ExpressionText.SelectionLength > 0)
-            {
-                ExpressionText.SelectedText = exprText;
-                ExpressionText.SelectionStart = index;
-            }
-            else
-            {
-                if (index > 0)
-                {
-                    string text = ExpressionText.Text;
-                    ExpressionText.Text = text.Insert(index, exprText);
-                    ExpressionText.SelectionStart = index;
-                }
-                else
-                {
-                    ExpressionText.Text = exprText;
-                    ExpressionText.SelectionStart = index;
-                }
-            }
-        }
-
-        private void InsertFilter(string op)
-        {
-            if (!string.IsNullOrEmpty(op))
-            {
-                string filterTemplate = Strings.GeomFilterTemplate;
-                string exprText = string.Format(filterTemplate, op);
-                InsertText(exprText);
-            }
-        }
-
         private void OKBtn_Click(object sender, EventArgs e)
         {
             this.DialogResult = DialogResult.OK;
             this.Close();
         }
 
-        private SortedList<string, AutoCompleteItem> _autoCompleteItems = new SortedList<string, AutoCompleteItem>();
-        private ImageListBox _autoBox;
+        private CodeCompletionWindow completionWindow;
 
-        enum AutoCompleteItemType : int
+        private void ShowAutoComplete(char ch)
         {
-            Property = 0,
-            Function = 1,
-        }
-
-        /// <summary>
-        /// Base auto-complete item
-        /// </summary>
-        abstract class AutoCompleteItem
-        {
-            public abstract AutoCompleteItemType Type { get; }
-
-            public abstract string Name { get; }
-
-            public abstract string ToolTipText { get; }
-
-            public abstract string AutoCompleteText { get; }
-        }
-
-        /// <summary>
-        /// Property auto-complete item
-        /// </summary>
-        class PropertyItem : AutoCompleteItem
-        {
-            private PropertyDefinition _propDef;
-
-            public PropertyItem(PropertyDefinition pd)
+            var provider = new FdoExpressionCompletionDataProvider(_cls, _caps);
+            completionWindow = CodeCompletionWindow.ShowCompletionWindow(ExpressionText.ParentForm, ExpressionText, String.Empty, provider, ch);
+            if (completionWindow != null)
             {
-                _propDef = pd;
+                completionWindow.Width = 250;
+                completionWindow.Closed += CompletionWindowClosed;
             }
-
-            public override AutoCompleteItemType Type
-            {
-                get { return AutoCompleteItemType.Property; }
-            }
-
-            public override string Name
-            {
-                get { return _propDef.Name; }
-            }
-
-            private string _ttText;
-
-            public override string ToolTipText
-            {
-                get
-                {
-                    if (string.IsNullOrEmpty(_ttText))
-                    {
-                        _ttText = string.Format(Strings.PropertyTooltip, _propDef.Name, _propDef.Type.ToString());
-                    }
-                    return _ttText;
-                }
-            }
-
-            public override string AutoCompleteText
-            {
-                get { return this.Name; }
-            }
         }
 
-        /// <summary>
-        /// Function auto-complete item
-        /// </summary>
-        class FunctionItem : AutoCompleteItem
+        void CompletionWindowClosed(object source, EventArgs e)
         {
-            private FdoProviderCapabilitiesExpressionFunctionDefinition _func;
-
-            public FunctionItem(FdoProviderCapabilitiesExpressionFunctionDefinition fd)
+            if (completionWindow != null)
             {
-                _func = fd;
+                completionWindow.Closed -= CompletionWindowClosed;
+                completionWindow.Dispose();
+                completionWindow = null;
             }
-
-            public override AutoCompleteItemType Type
-            {
-                get { return AutoCompleteItemType.Function; }
-            }
-
-            public override string Name
-            {
-                get { return _func.Name; }
-            }
-
-            private string _ttText;
-
-            public override string ToolTipText
-            {
-                get
-                {
-                    if (string.IsNullOrEmpty(_ttText))
-                        _ttText = string.Format(Strings.FunctionTooltip, GetReturnTypeString(), _func.Name, GetArgumentString(), _func.Description);
-
-                    return _ttText;
-                }
-            }
-
-            private string _argStr;
-
-            private string GetArgumentString()
-            {
-                if (string.IsNullOrEmpty(_argStr))
-                {
-                    List<string> tokens = new List<string>();
-                    foreach (FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition argDef in _func.ArgumentDefinitionList)
-                    {
-                        tokens.Add("[" + argDef.Name.Trim() + "]"); //NOXLATE
-                    }
-                    _argStr = string.Join(", ", tokens.ToArray()); //NOXLATE
-                }
-                return _argStr;
-            }
-
-            private string GetReturnTypeString()
-            {
-                return _func.ReturnType;
-            }
-
-            public override string AutoCompleteText
-            {
-                get
-                {
-                    return this.Name + "(" + GetArgumentString() + ")"; //NOXLATE
-                }
-            }
         }
 
-        private void InitAutoComplete()
-        {
-            _autoBox = new ImageListBox();
-            _autoBox.Visible = false;
-            _autoBox.ImageList = new ImageList();
-            _autoBox.ImageList.Images.Add(Properties.Resources.property);  //Property
-            _autoBox.ImageList.Images.Add(Properties.Resources.block); //Function
-            _autoBox.DoubleClick += new EventHandler(OnAutoCompleteDoubleClick);
-            _autoBox.SelectedIndexChanged += new EventHandler(OnAutoCompleteSelectedIndexChanged);
-            _autoBox.KeyDown += new KeyEventHandler(OnAutoCompleteKeyDown);
-            _autoBox.KeyUp += new KeyEventHandler(OnAutoCompleteKeyUp);
-            _autoBox.ValueMember = "Name"; //NOXLATE
-            _autoBox.Font = new Font(FontFamily.GenericMonospace, 10.0f);
-            ExpressionText.Controls.Add(_autoBox);
-        }
-
-        void OnAutoCompleteKeyDown(object sender, KeyEventArgs e)
-        {
-            ExpressionText.Focus();
-        }
-
-        void OnAutoCompleteKeyUp(object sender, KeyEventArgs e)
-        {
-            if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Enter)
-            {
-                PutAutoCompleteSuggestion();
-                _autoBox.Hide();
-                _autoCompleteTooltip.Hide(this);
-            }
-        }
-
-        void OnAutoCompleteSelectedIndexChanged(object sender, EventArgs e)
-        {
-            ExpressionText.Focus();
-            if (_autoBox.Visible && _autoBox.SelectedIndex >= 0 && _autoBox.Items.Count > 0)
-            {
-                string tt = ((_autoBox.SelectedItem as ImageListBoxItem).Tag as AutoCompleteItem).ToolTipText;
-                Point pt = GetCaretPoint();
-                pt.X += _autoBox.Width + 10;
-                pt.Y += 65;
-
-                _autoCompleteTooltip.Show(tt, this, pt.X, pt.Y);
-            }
-        }
-
-        void OnAutoCompleteDoubleClick(object sender, EventArgs e)
-        {
-            PutAutoCompleteSuggestion();
-            _autoBox.Hide();
-            _autoCompleteTooltip.Hide(this);
-        }
-
-        private void MoveAutoCompleteSelectionDown()
-        {
-            if (_autoBox.SelectedIndex < 0)
-            {
-                _autoBox.SelectedIndex = 0;
-            }
-            else
-            {
-                int idx = _autoBox.SelectedIndex;
-                if ((idx + 1) <= _autoBox.Items.Count - 1)
-                {
-                    _autoBox.SelectedIndex = idx + 1;
-                }
-            }
-        }
-
-        private void MoveAutoCompleteSelectionUp()
-        {
-            if (_autoBox.SelectedIndex < 0)
-            {
-                _autoBox.SelectedIndex = 0;
-            }
-            else
-            {
-                int idx = _autoBox.SelectedIndex;
-                if ((idx - 1) >= 0)
-                {
-                    _autoBox.SelectedIndex = idx - 1;
-                }
-            }
-        }
-
-        private void LoadCompletableProperties(IEnumerable<PropertyDefinition> cols)
-        {
-            foreach (var col in cols)
-            {
-                _autoCompleteItems[col.Name] = new PropertyItem(col);
-            }
-        }
-
-        private void LoadCompletableFunctions(IEnumerable<FdoProviderCapabilitiesExpressionFunctionDefinition> funcs)
-        {
-            foreach (FdoProviderCapabilitiesExpressionFunctionDefinition func in funcs)
-            {
-                _autoCompleteItems[func.Name] = new FunctionItem(func);
-            }
-        }
-
-        private void PutAutoCompleteSuggestion()
-        {
-            if (_autoBox.SelectedItems.Count == 1)
-            {
-                int pos = ExpressionText.SelectionStart;
-                string context;
-                char? c = GetContextBuffer(out context);
-
-                AutoCompleteItem aci = (_autoBox.SelectedItem as ImageListBoxItem).Tag as AutoCompleteItem;
-
-                string fullText = aci.AutoCompleteText;
-
-                int start = pos - context.Length;
-                int newPos = start + fullText.Length;
-                int selLength = -1;
-
-                //if it's a function, highlight the parameter (or the first parameter if there is multiple arguments
-                if (aci.Type == AutoCompleteItemType.Function)
-                {
-                    newPos = start + aci.Name.Length + 1; //Position the caret just after the opening bracket
-
-                    //Has at least two arguments
-                    int idx = fullText.IndexOf(","); //NOXLATE
-                    if (idx > 0)
-                        selLength = idx - aci.Name.Length - 1;
-                    else
-                        selLength = fullText.IndexOf(")") - fullText.IndexOf("(") - 1; //NOXLATE
-                }
-
-                string prefix = ExpressionText.Text.Substring(0, start);
-                string suffix = ExpressionText.Text.Substring(pos, ExpressionText.Text.Length - pos);
-
-                ExpressionText.Text = prefix + fullText + suffix;
-                ExpressionText.SelectionStart = newPos;
-                if (selLength > 0)
-                {
-                    ExpressionText.SelectionLength = selLength;
-                }
-                ExpressionText.ScrollToCaret();
-            }
-        }
-
-        private Point GetCaretPoint()
-        {
-            Point pt = ExpressionText.GetPositionFromCharIndex(ExpressionText.SelectionStart);
-            pt.Y += (int)Math.Ceiling(ExpressionText.Font.GetHeight()) + 2;
-            pt.X += 2; // for Courier, may need a better method
-            return pt;
-        }
-
-        private char? GetContextBuffer(out string buffer)
-        {
-            buffer = string.Empty;
-            int caretPos = ExpressionText.SelectionStart;
-            int currentPos = caretPos;
-            char? res = null;
-            if (caretPos > 0)
-            {
-                //Walk backwards
-                caretPos--;
-                char c = ExpressionText.Text[caretPos];
-                while (Char.IsLetterOrDigit(c))
-                {
-                    caretPos--;
-
-                    if (caretPos < 0)
-                        break;
-
-                    c = ExpressionText.Text[caretPos];
-                }
-
-                if (caretPos > 0)
-                {
-                    res = ExpressionText.Text[caretPos];
-                }
-                buffer = ExpressionText.Text.Substring(caretPos + 1, currentPos - caretPos - 1);
-            }
-            return res;
-        }
-
-        private void HandleKeyDown(KeyEventArgs e)
-        {
-            Keys code = e.KeyCode;
-            if (code == Keys.Escape)
-            {
-                if (_autoBox.Visible)
-                {
-                    e.SuppressKeyPress = true;
-                    _autoBox.Hide();
-                    _autoCompleteTooltip.Hide(this);
-                }
-            }
-            else if (code == Keys.Enter || code == Keys.Return)
-            {
-                if (_autoBox.Visible && _autoBox.SelectedItems.Count == 1)
-                {
-                    e.SuppressKeyPress = true;
-                    PutAutoCompleteSuggestion();
-                    _autoBox.Hide();
-                    _autoCompleteTooltip.Hide(this);
-                }
-            }
-        }
-
-        private void HandleKeyUp(KeyEventArgs e)
-        {
-            Keys code = e.KeyCode;
-            if (code == Keys.Oemcomma || code == Keys.OemOpenBrackets)
-            {
-                Complete(string.Empty);
-            }
-            else if (code == Keys.OemQuotes)
-            {
-                if (e.Modifiers == Keys.Shift)  // "
-                    InsertText("\""); //NOXLATE
-                else                            // '
-                    InsertText("'"); //NOXLATE
-
-            }
-            else if (code == Keys.D9 && e.Modifiers == Keys.Shift) // (
-            {
-                InsertText(")"); //NOXLATE
-            }
-            else if (code == Keys.Up || code == Keys.Down)
-            {
-                if (_autoBox.Visible)
-                {
-                    if (code == Keys.Up)
-                    {
-                        MoveAutoCompleteSelectionUp();
-                    }
-                    else
-                    {
-                        MoveAutoCompleteSelectionDown();
-                    }
-                }
-            }
-            else if (code == Keys.Back)
-            {
-                string context;
-                char? c = GetContextBuffer(out context);
-                if (!string.IsNullOrEmpty(context))
-                {
-                    Complete(context);
-                }
-                else
-                {
-                    if (_autoBox.Visible)
-                    {
-                        _autoBox.Hide();
-                        _autoCompleteTooltip.Hide(this);
-                    }
-                }
-            }
-            else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.Right)
-            {
-                string context;
-                char? c = GetContextBuffer(out context);
-                Complete(context);
-            }
-            else
-            {
-                if (e.Modifiers == Keys.None)
-                {
-                    bool alpha = (code >= Keys.A && code <= Keys.Z);
-                    bool numeric = (code >= Keys.D0 && code <= Keys.D9) || (code >= Keys.NumPad0 && code <= Keys.NumPad9);
-                    if (alpha || numeric)
-                    {
-                        string context;
-                        char? c = GetContextBuffer(out context);
-                        Complete(context);
-                    }
-                }
-            }
-        }
-
-        private List<AutoCompleteItem> GetItemsStartingWith(string text)
-        {
-            List<AutoCompleteItem> ati = new List<AutoCompleteItem>();
-            foreach (string key in _autoCompleteItems.Keys)
-            {
-                if (key.ToLower().StartsWith(text.Trim().ToLower()))
-                {
-                    ati.Add(_autoCompleteItems[key]);
-                }
-            }
-            return ati;
-        }
-
-        private void Complete(string text)
-        {
-            List<AutoCompleteItem> items = GetItemsStartingWith(text);
-            _autoBox.Items.Clear();
-
-            int width = 0;
-            foreach (AutoCompleteItem it in items)
-            {
-                ImageListBoxItem litem = new ImageListBoxItem();
-                litem.Text = it.Name;
-                litem.ImageIndex = (int)it.Type;
-                litem.Tag = it;
-
-                _autoBox.Items.Add(litem);
-                int length = TextRenderer.MeasureText(it.Name, _autoBox.Font).Width + 30; //For icon size
-                if (length > width)
-                    width = length;
-            }
-            _autoBox.Width = width;
-
-            if (!_autoBox.Visible)
-            {
-                if (_autoBox.Items.Count > 0)
-                {
-                    _autoBox.BringToFront();
-                    _autoBox.Show();
-                }
-            }
-
-            Point pt = GetCaretPoint();
-
-            _autoBox.Location = pt;
-        }
-
-        private void ExpressionText_KeyDown(object sender, KeyEventArgs e)
-        {
-            HandleKeyDown(e);
-        }
-
-        private void ExpressionText_KeyUp(object sender, KeyEventArgs e)
-        {
-            HandleKeyUp(e);
-        }
-
         private void ColumnName_Click(object sender, EventArgs e)
         {
 
@@ -1107,102 +415,15 @@
                 }
             }
         }
-    }
 
-    // ImageListBoxItem class 
-    internal class ImageListBoxItem
-    {
-        private string _myText;
-        private int _myImageIndex;
-        // properties 
-        public string Text
+        private void InsertSpatialFilter(string text)
         {
-            get { return _myText; }
-            set { _myText = value; }
+            InsertText("[geometry] " + text + " GeomFromText('geometry wkt')");
         }
-        public int ImageIndex
-        {
-            get { return _myImageIndex; }
-            set { _myImageIndex = value; }
-        }
-        //constructor
-        public ImageListBoxItem(string text, int index)
-        {
-            _myText = text;
-            _myImageIndex = index;
-        }
-        public ImageListBoxItem(string text) : this(text, -1) { }
-        public ImageListBoxItem() : this("") { } //NOXLATE
 
-        private object _tag;
-
-        public object Tag
+        private void InsertText(string text)
         {
-            get { return _tag; }
-            set { _tag = value; }
+            ExpressionText.ActiveTextAreaControl.TextArea.InsertString(text);
         }
-
-        public override string ToString()
-        {
-            return _myText;
-        }
-    }//End of ImageListBoxItem class
-
-    // ImageListBox class 
-    //
-    // Based on GListBox
-    //
-    // http://www.codeproject.com/KB/combobox/glistbox.aspx
-
-    internal class ImageListBox : ListBox
-    {
-        private ImageList _myImageList;
-        public ImageList ImageList
-        {
-            get { return _myImageList; }
-            set { _myImageList = value; }
-        }
-        public ImageListBox()
-        {
-            // Set owner draw mode
-            this.DrawMode = DrawMode.OwnerDrawFixed;
-        }
-        protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
-        {
-            e.DrawBackground();
-            e.DrawFocusRectangle();
-            ImageListBoxItem item;
-            Rectangle bounds = e.Bounds;
-            Size imageSize = _myImageList.ImageSize;
-            try
-            {
-                item = (ImageListBoxItem)Items[e.Index];
-                if (item.ImageIndex != -1)
-                {
-                    _myImageList.Draw(e.Graphics, bounds.Left, bounds.Top, item.ImageIndex);
-                    e.Graphics.DrawString(item.Text, e.Font, new SolidBrush(e.ForeColor),
-                        bounds.Left + imageSize.Width, bounds.Top);
-                }
-                else
-                {
-                    e.Graphics.DrawString(item.Text, e.Font, new SolidBrush(e.ForeColor),
-                        bounds.Left, bounds.Top);
-                }
-            }
-            catch
-            {
-                if (e.Index != -1)
-                {
-                    e.Graphics.DrawString(Items[e.Index].ToString(), e.Font,
-                        new SolidBrush(e.ForeColor), bounds.Left, bounds.Top);
-                }
-                else
-                {
-                    e.Graphics.DrawString(Text, e.Font, new SolidBrush(e.ForeColor),
-                        bounds.Left, bounds.Top);
-                }
-            }
-            base.OnDrawItem(e);
-        }
-    }//End of ImageListBox class
+    }
 }
\ No newline at end of file

Modified: trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.designer.cs	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.designer.cs	2012-10-29 13:32:01 UTC (rev 7162)
@@ -33,7 +33,6 @@
             this.OKBtn = new System.Windows.Forms.Button();
             this.CancelBtn = new System.Windows.Forms.Button();
             this.panel1 = new System.Windows.Forms.Panel();
-            this.lblHint = new System.Windows.Forms.Label();
             this.toolStrip1 = new System.Windows.Forms.ToolStrip();
             this.btnProperties = new System.Windows.Forms.ToolStripDropDownButton();
             this.btnFunctions = new System.Windows.Forms.ToolStripDropDownButton();
@@ -45,8 +44,8 @@
             this.ColumnValue = new System.Windows.Forms.ToolStripComboBox();
             this.LookupValues = new System.Windows.Forms.ToolStripButton();
             this.ColumnName = new System.Windows.Forms.ToolStripComboBox();
-            this.ExpressionText = new System.Windows.Forms.TextBox();
             this._autoCompleteTooltip = new System.Windows.Forms.ToolTip(this.components);
+            this.ExpressionText = new ICSharpCode.TextEditor.TextEditorControl();
             this.panel1.SuspendLayout();
             this.toolStrip1.SuspendLayout();
             this.SuspendLayout();
@@ -67,17 +66,11 @@
             // 
             // panel1
             // 
-            this.panel1.Controls.Add(this.lblHint);
             this.panel1.Controls.Add(this.CancelBtn);
             this.panel1.Controls.Add(this.OKBtn);
             resources.ApplyResources(this.panel1, "panel1");
             this.panel1.Name = "panel1";
             // 
-            // lblHint
-            // 
-            resources.ApplyResources(this.lblHint, "lblHint");
-            this.lblHint.Name = "lblHint";
-            // 
             // toolStrip1
             // 
             this.toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
@@ -167,10 +160,10 @@
             // ExpressionText
             // 
             resources.ApplyResources(this.ExpressionText, "ExpressionText");
-            this.ExpressionText.HideSelection = false;
+            this.ExpressionText.IsReadOnly = false;
             this.ExpressionText.Name = "ExpressionText";
-            this.ExpressionText.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ExpressionText_KeyDown);
-            this.ExpressionText.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ExpressionText_KeyUp);
+            this.ExpressionText.ShowLineNumbers = false;
+            this.ExpressionText.ShowVRuler = false;
             // 
             // ExpressionEditor
             // 
@@ -182,7 +175,6 @@
             this.Controls.Add(this.panel1);
             this.Name = "ExpressionEditor";
             this.panel1.ResumeLayout(false);
-            this.panel1.PerformLayout();
             this.toolStrip1.ResumeLayout(false);
             this.toolStrip1.PerformLayout();
             this.ResumeLayout(false);
@@ -196,18 +188,17 @@
         private System.Windows.Forms.Button CancelBtn;
         private System.Windows.Forms.Panel panel1;
         private System.Windows.Forms.ToolStrip toolStrip1;
-        private System.Windows.Forms.TextBox ExpressionText;
         private System.Windows.Forms.ToolStripDropDownButton btnFilter;
         private System.Windows.Forms.ToolStripMenuItem btnCondition;
         private System.Windows.Forms.ToolStripMenuItem btnSpatial;
         private System.Windows.Forms.ToolStripMenuItem btnDistance;
         private System.Windows.Forms.ToolTip _autoCompleteTooltip;
-        private System.Windows.Forms.Label lblHint;
         private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
         private System.Windows.Forms.ToolStripComboBox ColumnName;
         private System.Windows.Forms.ToolStripButton LookupValues;
         private System.Windows.Forms.ToolStripComboBox ColumnValue;
         private System.Windows.Forms.ToolStripDropDownButton btnProperties;
         private System.Windows.Forms.ToolStripDropDownButton btnFunctions;
+        private ICSharpCode.TextEditor.TextEditorControl ExpressionText;
     }
 }
\ No newline at end of file

Modified: trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.resx	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.resx	2012-10-29 13:32:01 UTC (rev 7162)
@@ -123,7 +123,7 @@
   </data>
   <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
   <data name="OKBtn.Location" type="System.Drawing.Point, System.Drawing">
-    <value>342, 6</value>
+    <value>368, 6</value>
   </data>
   <data name="OKBtn.Size" type="System.Drawing.Size, System.Drawing">
     <value>75, 23</value>
@@ -145,13 +145,13 @@
     <value>panel1</value>
   </data>
   <data name=">>OKBtn.ZOrder" xml:space="preserve">
-    <value>2</value>
+    <value>1</value>
   </data>
   <data name="CancelBtn.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
     <value>Bottom, Right</value>
   </data>
   <data name="CancelBtn.Location" type="System.Drawing.Point, System.Drawing">
-    <value>423, 6</value>
+    <value>449, 6</value>
   </data>
   <data name="CancelBtn.Size" type="System.Drawing.Size, System.Drawing">
     <value>75, 23</value>
@@ -172,43 +172,16 @@
     <value>panel1</value>
   </data>
   <data name=">>CancelBtn.ZOrder" xml:space="preserve">
-    <value>1</value>
-  </data>
-  <data name="lblHint.AutoSize" type="System.Boolean, mscorlib">
-    <value>True</value>
-  </data>
-  <data name="lblHint.Location" type="System.Drawing.Point, System.Drawing">
-    <value>12, 11</value>
-  </data>
-  <data name="lblHint.Size" type="System.Drawing.Size, System.Drawing">
-    <value>202, 13</value>
-  </data>
-  <data name="lblHint.TabIndex" type="System.Int32, mscorlib">
-    <value>4</value>
-  </data>
-  <data name="lblHint.Text" xml:space="preserve">
-    <value>Press Alt + Right to invoke auto-complete</value>
-  </data>
-  <data name=">>lblHint.Name" xml:space="preserve">
-    <value>lblHint</value>
-  </data>
-  <data name=">>lblHint.Type" xml:space="preserve">
-    <value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-  </data>
-  <data name=">>lblHint.Parent" xml:space="preserve">
-    <value>panel1</value>
-  </data>
-  <data name=">>lblHint.ZOrder" xml:space="preserve">
     <value>0</value>
   </data>
   <data name="panel1.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
     <value>Bottom</value>
   </data>
   <data name="panel1.Location" type="System.Drawing.Point, System.Drawing">
-    <value>0, 249</value>
+    <value>0, 244</value>
   </data>
   <data name="panel1.Size" type="System.Drawing.Size, System.Drawing">
-    <value>510, 40</value>
+    <value>536, 40</value>
   </data>
   <data name="panel1.TabIndex" type="System.Int32, mscorlib">
     <value>4</value>
@@ -304,7 +277,7 @@
     <value>0, 0</value>
   </data>
   <data name="toolStrip1.Size" type="System.Drawing.Size, System.Drawing">
-    <value>510, 25</value>
+    <value>536, 25</value>
   </data>
   <data name="toolStrip1.TabIndex" type="System.Int32, mscorlib">
     <value>5</value>
@@ -324,20 +297,17 @@
   <data name=">>toolStrip1.ZOrder" xml:space="preserve">
     <value>1</value>
   </data>
+  <metadata name="_autoCompleteTooltip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>116, 17</value>
+  </metadata>
   <data name="ExpressionText.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
     <value>Fill</value>
   </data>
-  <data name="ExpressionText.Font" type="System.Drawing.Font, System.Drawing">
-    <value>Courier New, 12pt</value>
-  </data>
   <data name="ExpressionText.Location" type="System.Drawing.Point, System.Drawing">
     <value>0, 25</value>
   </data>
-  <data name="ExpressionText.Multiline" type="System.Boolean, mscorlib">
-    <value>True</value>
-  </data>
   <data name="ExpressionText.Size" type="System.Drawing.Size, System.Drawing">
-    <value>510, 224</value>
+    <value>536, 219</value>
   </data>
   <data name="ExpressionText.TabIndex" type="System.Int32, mscorlib">
     <value>6</value>
@@ -346,7 +316,7 @@
     <value>ExpressionText</value>
   </data>
   <data name=">>ExpressionText.Type" xml:space="preserve">
-    <value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+    <value>ICSharpCode.TextEditor.TextEditorControl, ICSharpCode.TextEditor, Version=4.2.0.8783, Culture=neutral, PublicKeyToken=4d61825e8dd49f1a</value>
   </data>
   <data name=">>ExpressionText.Parent" xml:space="preserve">
     <value>$this</value>
@@ -354,14 +324,11 @@
   <data name=">>ExpressionText.ZOrder" xml:space="preserve">
     <value>0</value>
   </data>
-  <metadata name="_autoCompleteTooltip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>116, 17</value>
-  </metadata>
   <metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
   <data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
-    <value>510, 289</value>
+    <value>536, 284</value>
   </data>
   <data name="$this.MinimumSize" type="System.Drawing.Size, System.Drawing">
     <value>500, 300</value>

Added: trunk/Tools/Maestro/Maestro.Editors/Common/ITextEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/ITextEditor.cs	                        (rev 0)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/ITextEditor.cs	2012-10-29 13:32:01 UTC (rev 7162)
@@ -0,0 +1,133 @@
+#region Disclaimer / License
+// Copyright (C) 2012, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+// 
+// Original code from SharpDevelop 3.2.1 licensed under the same terms (LGPL 2.1)
+// Copyright 2002-2010 by
+//
+//  AlphaSierraPapa, Christoph Wille
+//  Vordernberger Strasse 27/8
+//  A-8700 Leoben
+//  Austria
+//
+//  email: office at alphasierrapapa.com
+//  court of jurisdiction: Landesgericht Leoben
+//
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+#endregion
+using ICSharpCode.TextEditor;
+using ICSharpCode.TextEditor.Document;
+using ICSharpCode.TextEditor.Gui.CompletionWindow;
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+
+namespace Maestro.Editors.Common
+{
+    /// <summary>
+    /// A text editor controller interface that supports auto-completion. Note that
+    /// all the methods will be called on another thread not the main UI thread and will therefore need to
+    /// be invoked.
+    /// </summary>
+    public interface ITextEditor
+    {
+        /// <summary>
+        /// Fired when a key is pressed but before any text has been added to the text editor.
+        /// </summary>
+        /// <remarks>
+        /// The KeyPress handler should return true if the text editor should not process the key and not
+        /// insert any text.
+        /// </remarks>
+        event KeyEventHandler KeyPress;
+
+        /// <summary>
+        /// Fired when dialog key is pressed but before any text has been added to the text editor.
+        /// </summary>
+        /// <remarks>
+        /// The DialogKeyPress handler should return true if the text editor should not process the
+        /// dialog key.
+        /// </remarks>
+        event DialogKeyProcessor DialogKeyPress;
+
+        /// <summary>
+        /// Gets or sets the indentation style.
+        /// </summary>
+        IndentStyle IndentStyle { get; set; }
+
+        /// <summary>
+        /// Inserts text at the current cursor location.
+        /// </summary>
+        void Write(string text);
+
+        /// <summary>
+        /// Inserts text at the current cursor location with the specified colour.
+        /// </summary>
+        void Write(string text, Color backgroundColor);
+
+        /// <summary>
+        /// Replaces the text at the specified index on the current line with the specified text.
+        /// </summary>
+        void Replace(int index, int length, string text);
+
+        /// <summary>
+        /// Gets or sets the current column position of the cursor on the current line.  This is zero based.
+        /// </summary>
+        int Column { get; set; }
+
+        /// <summary>
+        /// Gets the length of the currently selected text.
+        /// </summary>
+        int SelectionLength { get; }
+
+        /// <summary>
+        /// Gets the start position of the currently selected text.
+        /// </summary>
+        int SelectionStart { get; }
+
+        /// <summary>
+        /// Gets the current line the cursor is on. This is zero based.
+        /// </summary>
+        int Line { get; }
+
+        /// <summary>
+        /// Gets the total number of lines in the text editor.
+        /// </summary>
+        int TotalLines { get; }
+
+        /// <summary>
+        /// Gets the text for the specified line.
+        /// </summary>
+        string GetLine(int index);
+
+        /// <summary>
+        /// Shows the code completion window.
+        /// </summary>
+        void ShowCompletionWindow(ICompletionDataProvider completionDataProvider);
+
+        /// <summary>
+        /// Indicates whether the completion window is currently being displayed.
+        /// </summary>
+        bool IsCompletionWindowDisplayed { get; }
+
+        /// <summary>
+        /// Makes the current text content read only. Text can be entered at the end.
+        /// </summary>
+        void MakeCurrentContentReadOnly();
+    }
+}

Added: trunk/Tools/Maestro/Maestro.Editors/Common/TextEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/TextEditor.cs	                        (rev 0)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/TextEditor.cs	2012-10-29 13:32:01 UTC (rev 7162)
@@ -0,0 +1,245 @@
+#region Disclaimer / License
+// Copyright (C) 2012, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+// 
+// Original code from SharpDevelop 3.2.1 licensed under the same terms (LGPL 2.1)
+// Copyright 2002-2010 by
+//
+//  AlphaSierraPapa, Christoph Wille
+//  Vordernberger Strasse 27/8
+//  A-8700 Leoben
+//  Austria
+//
+//  email: office at alphasierrapapa.com
+//  court of jurisdiction: Landesgericht Leoben
+//
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+#endregion
+using ICSharpCode.TextEditor;
+using ICSharpCode.TextEditor.Document;
+using ICSharpCode.TextEditor.Gui.CompletionWindow;
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+
+namespace Maestro.Editors.Common
+{
+    public class TextEditor : ITextEditor
+    {
+        delegate string GetLineInvoker(int index);
+        delegate void WriteInvoker(string text, Color color);
+
+        TextEditorControl textEditorControl;
+        TextArea textArea;
+        Color customLineColour = Color.LightGray;
+        TextMarker readOnlyMarker;
+
+        CodeCompletionWindow completionWindow;
+
+        public TextEditor(TextEditorControl textEditorControl)
+        {
+            this.textEditorControl = textEditorControl;
+            this.textArea = textEditorControl.ActiveTextAreaControl.TextArea;
+            textEditorControl.TextEditorProperties.SupportReadOnlySegments = true;
+        }
+
+        public IndentStyle IndentStyle
+        {
+            get { return textEditorControl.IndentStyle; }
+            set { SetIndentStyle(value); }
+        }
+
+        public event KeyEventHandler KeyPress
+        {
+            add { textArea.KeyEventHandler += value; }
+            remove { textArea.KeyEventHandler -= value; }
+        }
+
+        public event DialogKeyProcessor DialogKeyPress
+        {
+            add { textArea.DoProcessDialogKey += value; }
+            remove { textArea.DoProcessDialogKey -= value; }
+        }
+
+        public Color CustomLineColour
+        {
+            get { return customLineColour; }
+        }
+
+        public void Write(string text)
+        {
+            Write(text, Color.Empty);
+        }
+
+        public void Write(string text, Color backgroundColour)
+        {
+            if (textEditorControl.InvokeRequired)
+            {
+                WriteInvoker invoker = new WriteInvoker(Write);
+                textEditorControl.Invoke(invoker, new object[] { text, backgroundColour });
+            }
+            else
+            {
+                int offset = textEditorControl.Document.PositionToOffset(new TextLocation(Column, Line));
+                textEditorControl.ActiveTextAreaControl.TextArea.InsertString(text);
+
+                if (!backgroundColour.IsEmpty)
+                {
+                    TextMarker marker = new TextMarker(offset, text.Length, TextMarkerType.SolidBlock, backgroundColour);
+                    textEditorControl.Document.MarkerStrategy.AddMarker(marker);
+                    textEditorControl.Refresh();
+                }
+            }
+        }
+
+        public int Column
+        {
+            get { return textEditorControl.ActiveTextAreaControl.Caret.Column; }
+            set { textEditorControl.ActiveTextAreaControl.Caret.Column = value; }
+        }
+
+        public int SelectionStart
+        {
+            get
+            {
+                ColumnRange range = GetSelectionRange();
+                if (range != ColumnRange.NoColumn)
+                {
+                    return range.StartColumn;
+                }
+                return Column;
+            }
+        }
+
+        public int SelectionLength
+        {
+            get
+            {
+                ColumnRange range = GetSelectionRange();
+                return range.EndColumn - range.StartColumn;
+            }
+        }
+
+        /// <summary>
+        /// Gets the current cursor line.
+        /// </summary>
+        public int Line
+        {
+            get { return textArea.Caret.Line; }
+        }
+
+        /// <summary>
+        /// Gets the total number of lines in the text editor.
+        /// </summary>
+        public int TotalLines
+        {
+            get { return textEditorControl.Document.TotalNumberOfLines; }
+        }
+
+        /// <summary>
+        /// Gets the text for the specified line.
+        /// </summary>
+        public string GetLine(int index)
+        {
+            if (textEditorControl.InvokeRequired)
+            {
+                GetLineInvoker invoker = new GetLineInvoker(GetLine);
+                return (string)textEditorControl.Invoke(invoker, new object[] { index });
+            }
+            else
+            {
+                LineSegment lineSegment = textEditorControl.Document.GetLineSegment(index);
+                return textEditorControl.Document.GetText(lineSegment);
+            }
+        }
+
+        /// <summary>
+        /// Replaces the text at the specified index on the current line with the specified text.
+        /// </summary>
+        public void Replace(int index, int length, string text)
+        {
+            int currentLine = textEditorControl.ActiveTextAreaControl.Caret.Line;
+            LineSegment lineSegment = textEditorControl.Document.GetLineSegment(currentLine);
+            textEditorControl.Document.Replace(lineSegment.Offset + index, length, text);
+        }
+
+        /// <summary>
+        /// Makes the current text read only. Text can still be entered at the end.
+        /// </summary>
+        public void MakeCurrentContentReadOnly()
+        {
+            IDocument doc = textEditorControl.Document;
+            if (readOnlyMarker == null)
+            {
+                readOnlyMarker = new TextMarker(0, doc.TextLength, TextMarkerType.Invisible);
+                readOnlyMarker.IsReadOnly = true;
+                doc.MarkerStrategy.AddMarker(readOnlyMarker);
+            }
+            readOnlyMarker.Offset = 0;
+            readOnlyMarker.Length = doc.TextLength;
+            doc.UndoStack.ClearAll();
+        }
+
+        public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider)
+        {
+            completionWindow = CodeCompletionWindow.ShowCompletionWindow(textEditorControl.ParentForm, textEditorControl, String.Empty, completionDataProvider, ' ');
+            if (completionWindow != null)
+            {
+                completionWindow.Width = 250;
+                completionWindow.Closed += CompletionWindowClosed;
+            }
+        }
+
+        public bool IsCompletionWindowDisplayed
+        {
+            get { return completionWindow != null; }
+        }
+
+        /// <summary>
+        /// Gets the range of the currently selected text.
+        /// </summary>
+        ColumnRange GetSelectionRange()
+        {
+            return textArea.SelectionManager.GetSelectionAtLine(textArea.Caret.Line);
+        }
+
+        void SetIndentStyle(IndentStyle style)
+        {
+            if (textEditorControl.InvokeRequired)
+            {
+                Action<IndentStyle> action = SetIndentStyle;
+                textEditorControl.Invoke(action, new object[] { style });
+            }
+            else
+            {
+                textEditorControl.IndentStyle = style;
+            }
+        }
+
+        void CompletionWindowClosed(object source, EventArgs e)
+        {
+            if (completionWindow != null)
+            {
+                completionWindow.Closed -= CompletionWindowClosed;
+                completionWindow.Dispose();
+                completionWindow = null;
+            }
+        }
+    }
+}

Modified: trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj	2012-10-29 13:32:01 UTC (rev 7162)
@@ -105,6 +105,7 @@
     <Compile Include="Common\ExpressionEditor.designer.cs">
       <DependentUpon>ExpressionEditor.cs</DependentUpon>
     </Compile>
+    <Compile Include="Common\Expression\FdoExpressionCompletionDataProvider.cs" />
     <Compile Include="Common\FindReplaceDialog.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -126,6 +127,7 @@
     <Compile Include="Common\GenericItemSelectionDialog.Designer.cs">
       <DependentUpon>GenericItemSelectionDialog.cs</DependentUpon>
     </Compile>
+    <Compile Include="Common\ITextEditor.cs" />
     <Compile Include="Common\NsDoc.cs" />
     <Compile Include="Common\RepositoryTreeModel.cs" />
     <Compile Include="Common\RepositoryView.cs">
@@ -152,6 +154,7 @@
     <Compile Include="Common\SymbolPicker.Designer.cs">
       <DependentUpon>SymbolPicker.cs</DependentUpon>
     </Compile>
+    <Compile Include="Common\TextEditor.cs" />
     <Compile Include="Common\UnmanagedFileBrowser.cs">
       <SubType>Form</SubType>
     </Compile>

Modified: trunk/Tools/Maestro/Maestro.Editors/Strings.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Strings.Designer.cs	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/Maestro.Editors/Strings.Designer.cs	2012-10-29 13:32:01 UTC (rev 7162)
@@ -538,6 +538,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to {0}{3}{1}{3}Returns: {2}.
+        /// </summary>
+        internal static string ExprEditorFunctionDesc {
+            get {
+                return ResourceManager.GetString("ExprEditorFunctionDesc", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Expression....
         /// </summary>
         internal static string ExpressionItem {
@@ -763,6 +772,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Property: {0}{2}Type: {1}.
+        /// </summary>
+        internal static string FsPreview_GenericPropertyTooltip {
+            get {
+                return ResourceManager.GetString("FsPreview_GenericPropertyTooltip", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Name: {0}{7}Description: {1}{7}Geometry Types: {2}{7}Read Only: {3}{7}Has Elevation: {4}{7}Has Measure: {5}{7}Spatial Context: {6}.
         /// </summary>
         internal static string FsPreview_GeometryPropertyNodeTooltip {
@@ -790,267 +808,6 @@
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to Alpha value.
-        /// </summary>
-        internal static string Func_ARGB_AValueDescription {
-            get {
-                return ResourceManager.GetString("Func_ARGB_AValueDescription", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Blue value.
-        /// </summary>
-        internal static string Func_ARGB_BValueDescription {
-            get {
-                return ResourceManager.GetString("Func_ARGB_BValueDescription", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Color generation function.
-        /// </summary>
-        internal static string Func_ARGB_Description {
-            get {
-                return ResourceManager.GetString("Func_ARGB_Description", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Green value.
-        /// </summary>
-        internal static string Func_ARGB_GValueDescription {
-            get {
-                return ResourceManager.GetString("Func_ARGB_GValueDescription", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Red value.
-        /// </summary>
-        internal static string Func_ARGB_RValueDescription {
-            get {
-                return ResourceManager.GetString("Func_ARGB_RValueDescription", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to String formatting function.
-        /// </summary>
-        internal static string Func_DECAP_Description {
-            get {
-                return ResourceManager.GetString("Func_DECAP_Description", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to String to format.
-        /// </summary>
-        internal static string Func_DECAP_StringValueDescription {
-            get {
-                return ResourceManager.GetString("Func_DECAP_StringValueDescription", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Returns the active feature class name.
-        /// </summary>
-        internal static string Func_FEATURECLASS_Description {
-            get {
-                return ResourceManager.GetString("Func_FEATURECLASS_Description", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Returns the active feature Id.
-        /// </summary>
-        internal static string Func_FEATUREID_Description {
-            get {
-                return ResourceManager.GetString("Func_FEATUREID_Description", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Boolean expression (filter) encapsulated in a string.
-        /// </summary>
-        internal static string Func_IF_ConditionDescription {
-            get {
-                return ResourceManager.GetString("Func_IF_ConditionDescription", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to If evaluator for style theming.
-        /// </summary>
-        internal static string Func_IF_Description {
-            get {
-                return ResourceManager.GetString("Func_IF_Description", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Returned if condition is false.
-        /// </summary>
-        internal static string Func_IF_FalseValueDescription {
-            get {
-                return ResourceManager.GetString("Func_IF_FalseValueDescription", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Returned if condition is true.
-        /// </summary>
-        internal static string Func_IF_TrueValueDescription {
-            get {
-                return ResourceManager.GetString("Func_IF_TrueValueDescription", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Returns the active layer Id.
-        /// </summary>
-        internal static string Func_LAYERID_Description {
-            get {
-                return ResourceManager.GetString("Func_LAYERID_Description", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Default value returned if expression does not evaluate to any of the keys.
-        /// </summary>
-        internal static string Func_LOOKUP_DefaultValueDescription {
-            get {
-                return ResourceManager.GetString("Func_LOOKUP_DefaultValueDescription", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Lookup table for style theming.
-        /// </summary>
-        internal static string Func_LOOKUP_Description {
-            get {
-                return ResourceManager.GetString("Func_LOOKUP_Description", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Key expression.
-        /// </summary>
-        internal static string Func_LOOKUP_ExpressionDescription {
-            get {
-                return ResourceManager.GetString("Func_LOOKUP_ExpressionDescription", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Lookup index that can be matched by the key expression.
-        /// </summary>
-        internal static string Func_LOOKUP_IndexDescription {
-            get {
-                return ResourceManager.GetString("Func_LOOKUP_IndexDescription", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Value that is returned when the key expression matches the associated index.
-        /// </summary>
-        internal static string Func_LOOKUP_ValueDescription {
-            get {
-                return ResourceManager.GetString("Func_LOOKUP_ValueDescription", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Returns the active map name.
-        /// </summary>
-        internal static string Func_MAPNAME_Description {
-            get {
-                return ResourceManager.GetString("Func_MAPNAME_Description", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Default value returned if expression does not fall into any of the ranges.
-        /// </summary>
-        internal static string Func_RANGE_DefaultValueDescription {
-            get {
-                return ResourceManager.GetString("Func_RANGE_DefaultValueDescription", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Range table for style theming.
-        /// </summary>
-        internal static string Func_RANGE_Description {
-            get {
-                return ResourceManager.GetString("Func_RANGE_Description", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Key expression.
-        /// </summary>
-        internal static string Func_RANGE_ExpressionDescription {
-            get {
-                return ResourceManager.GetString("Func_RANGE_ExpressionDescription", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Exclusive maximum of range that can be matched by the key expression.
-        /// </summary>
-        internal static string Func_RANGE_MaxDescription {
-            get {
-                return ResourceManager.GetString("Func_RANGE_MaxDescription", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Inclusive minimum of range that can be matched by the key expression.
-        /// </summary>
-        internal static string Func_RANGE_MinDescription {
-            get {
-                return ResourceManager.GetString("Func_RANGE_MinDescription", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Value that is returned when the key expression matches the associated range.
-        /// </summary>
-        internal static string Func_RANGE_ValueDescription {
-            get {
-                return ResourceManager.GetString("Func_RANGE_ValueDescription", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Returns the active session.
-        /// </summary>
-        internal static string Func_SESSION_Description {
-            get {
-                return ResourceManager.GetString("Func_SESSION_Description", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to String encoding function.
-        /// </summary>
-        internal static string Func_URLENCODE_Description {
-            get {
-                return ResourceManager.GetString("Func_URLENCODE_Description", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to String to URL encode.
-        /// </summary>
-        internal static string Func_URLENCODE_StringValueDescription {
-            get {
-                return ResourceManager.GetString("Func_URLENCODE_StringValueDescription", resourceCulture);
-            }
-        }
-        
-        /// <summary>
         ///   Looks up a localized string similar to Function: {1}({2})
         ///Description: {3}
         ///Returns: {0}.

Modified: trunk/Tools/Maestro/Maestro.Editors/Strings.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Strings.resx	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/Maestro.Editors/Strings.resx	2012-10-29 13:32:01 UTC (rev 7162)
@@ -732,93 +732,6 @@
 Description: {3}
 Returns: {0}</value>
   </data>
-  <data name="Func_ARGB_AValueDescription" xml:space="preserve">
-    <value>Alpha value</value>
-  </data>
-  <data name="Func_ARGB_BValueDescription" xml:space="preserve">
-    <value>Blue value</value>
-  </data>
-  <data name="Func_ARGB_Description" xml:space="preserve">
-    <value>Color generation function</value>
-  </data>
-  <data name="Func_ARGB_GValueDescription" xml:space="preserve">
-    <value>Green value</value>
-  </data>
-  <data name="Func_ARGB_RValueDescription" xml:space="preserve">
-    <value>Red value</value>
-  </data>
-  <data name="Func_DECAP_Description" xml:space="preserve">
-    <value>String formatting function</value>
-  </data>
-  <data name="Func_DECAP_StringValueDescription" xml:space="preserve">
-    <value>String to format</value>
-  </data>
-  <data name="Func_FEATURECLASS_Description" xml:space="preserve">
-    <value>Returns the active feature class name</value>
-  </data>
-  <data name="Func_FEATUREID_Description" xml:space="preserve">
-    <value>Returns the active feature Id</value>
-  </data>
-  <data name="Func_IF_ConditionDescription" xml:space="preserve">
-    <value>Boolean expression (filter) encapsulated in a string</value>
-  </data>
-  <data name="Func_IF_Description" xml:space="preserve">
-    <value>If evaluator for style theming</value>
-  </data>
-  <data name="Func_IF_FalseValueDescription" xml:space="preserve">
-    <value>Returned if condition is false</value>
-  </data>
-  <data name="Func_IF_TrueValueDescription" xml:space="preserve">
-    <value>Returned if condition is true</value>
-  </data>
-  <data name="Func_LAYERID_Description" xml:space="preserve">
-    <value>Returns the active layer Id</value>
-  </data>
-  <data name="Func_LOOKUP_DefaultValueDescription" xml:space="preserve">
-    <value>Default value returned if expression does not evaluate to any of the keys</value>
-  </data>
-  <data name="Func_LOOKUP_Description" xml:space="preserve">
-    <value>Lookup table for style theming</value>
-  </data>
-  <data name="Func_LOOKUP_ExpressionDescription" xml:space="preserve">
-    <value>Key expression</value>
-  </data>
-  <data name="Func_LOOKUP_IndexDescription" xml:space="preserve">
-    <value>Lookup index that can be matched by the key expression</value>
-  </data>
-  <data name="Func_LOOKUP_ValueDescription" xml:space="preserve">
-    <value>Value that is returned when the key expression matches the associated index</value>
-  </data>
-  <data name="Func_MAPNAME_Description" xml:space="preserve">
-    <value>Returns the active map name</value>
-  </data>
-  <data name="Func_RANGE_DefaultValueDescription" xml:space="preserve">
-    <value>Default value returned if expression does not fall into any of the ranges</value>
-  </data>
-  <data name="Func_RANGE_Description" xml:space="preserve">
-    <value>Range table for style theming</value>
-  </data>
-  <data name="Func_RANGE_ExpressionDescription" xml:space="preserve">
-    <value>Key expression</value>
-  </data>
-  <data name="Func_RANGE_MaxDescription" xml:space="preserve">
-    <value>Exclusive maximum of range that can be matched by the key expression</value>
-  </data>
-  <data name="Func_RANGE_MinDescription" xml:space="preserve">
-    <value>Inclusive minimum of range that can be matched by the key expression</value>
-  </data>
-  <data name="Func_RANGE_ValueDescription" xml:space="preserve">
-    <value>Value that is returned when the key expression matches the associated range</value>
-  </data>
-  <data name="Func_SESSION_Description" xml:space="preserve">
-    <value>Returns the active session</value>
-  </data>
-  <data name="Func_URLENCODE_Description" xml:space="preserve">
-    <value>String encoding function</value>
-  </data>
-  <data name="Func_URLENCODE_StringValueDescription" xml:space="preserve">
-    <value>String to URL encode</value>
-  </data>
   <data name="GenericError" xml:space="preserve">
     <value>An error occured: {0}</value>
   </data>
@@ -1455,4 +1368,10 @@
   <data name="ConfirmWmsLogicalClassSwap" xml:space="preserve">
     <value>In some cases, the actual WMS layer name would be generated in the FDO class description. Swap FDO logical class names with their descriptions?</value>
   </data>
+  <data name="FsPreview_GenericPropertyTooltip" xml:space="preserve">
+    <value>Property: {0}{2}Type: {1}</value>
+  </data>
+  <data name="ExprEditorFunctionDesc" xml:space="preserve">
+    <value>{0}{3}{1}{3}Returns: {2}</value>
+  </data>
 </root>
\ No newline at end of file

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.Designer.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.Designer.cs	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.Designer.cs	2012-10-29 13:32:01 UTC (rev 7162)
@@ -1494,6 +1494,267 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Alpha value.
+        /// </summary>
+        public static string Func_ARGB_AValueDescription {
+            get {
+                return ResourceManager.GetString("Func_ARGB_AValueDescription", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Blue value.
+        /// </summary>
+        public static string Func_ARGB_BValueDescription {
+            get {
+                return ResourceManager.GetString("Func_ARGB_BValueDescription", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Color generation function.
+        /// </summary>
+        public static string Func_ARGB_Description {
+            get {
+                return ResourceManager.GetString("Func_ARGB_Description", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Green value.
+        /// </summary>
+        public static string Func_ARGB_GValueDescription {
+            get {
+                return ResourceManager.GetString("Func_ARGB_GValueDescription", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Red value.
+        /// </summary>
+        public static string Func_ARGB_RValueDescription {
+            get {
+                return ResourceManager.GetString("Func_ARGB_RValueDescription", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to String formatting function.
+        /// </summary>
+        public static string Func_DECAP_Description {
+            get {
+                return ResourceManager.GetString("Func_DECAP_Description", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to String to format.
+        /// </summary>
+        public static string Func_DECAP_StringValueDescription {
+            get {
+                return ResourceManager.GetString("Func_DECAP_StringValueDescription", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Returns the active feature class name.
+        /// </summary>
+        public static string Func_FEATURECLASS_Description {
+            get {
+                return ResourceManager.GetString("Func_FEATURECLASS_Description", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Returns the active feature Id.
+        /// </summary>
+        public static string Func_FEATUREID_Description {
+            get {
+                return ResourceManager.GetString("Func_FEATUREID_Description", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Boolean expression (filter) encapsulated in a string.
+        /// </summary>
+        public static string Func_IF_ConditionDescription {
+            get {
+                return ResourceManager.GetString("Func_IF_ConditionDescription", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to If evaluator for style theming.
+        /// </summary>
+        public static string Func_IF_Description {
+            get {
+                return ResourceManager.GetString("Func_IF_Description", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Returned if condition is false.
+        /// </summary>
+        public static string Func_IF_FalseValueDescription {
+            get {
+                return ResourceManager.GetString("Func_IF_FalseValueDescription", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Returned if condition is true.
+        /// </summary>
+        public static string Func_IF_TrueValueDescription {
+            get {
+                return ResourceManager.GetString("Func_IF_TrueValueDescription", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Returns the active layer Id.
+        /// </summary>
+        public static string Func_LAYERID_Description {
+            get {
+                return ResourceManager.GetString("Func_LAYERID_Description", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Default value returned if expression does not evaluate to any of the keys.
+        /// </summary>
+        public static string Func_LOOKUP_DefaultValueDescription {
+            get {
+                return ResourceManager.GetString("Func_LOOKUP_DefaultValueDescription", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Lookup table for style theming.
+        /// </summary>
+        public static string Func_LOOKUP_Description {
+            get {
+                return ResourceManager.GetString("Func_LOOKUP_Description", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Key expression.
+        /// </summary>
+        public static string Func_LOOKUP_ExpressionDescription {
+            get {
+                return ResourceManager.GetString("Func_LOOKUP_ExpressionDescription", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Lookup index that can be matched by the key expression.
+        /// </summary>
+        public static string Func_LOOKUP_IndexDescription {
+            get {
+                return ResourceManager.GetString("Func_LOOKUP_IndexDescription", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Value that is returned when the key expression matches the associated index.
+        /// </summary>
+        public static string Func_LOOKUP_ValueDescription {
+            get {
+                return ResourceManager.GetString("Func_LOOKUP_ValueDescription", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Returns the active map name.
+        /// </summary>
+        public static string Func_MAPNAME_Description {
+            get {
+                return ResourceManager.GetString("Func_MAPNAME_Description", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Default value returned if expression does not fall into any of the ranges.
+        /// </summary>
+        public static string Func_RANGE_DefaultValueDescription {
+            get {
+                return ResourceManager.GetString("Func_RANGE_DefaultValueDescription", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Range table for style theming.
+        /// </summary>
+        public static string Func_RANGE_Description {
+            get {
+                return ResourceManager.GetString("Func_RANGE_Description", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Key expression.
+        /// </summary>
+        public static string Func_RANGE_ExpressionDescription {
+            get {
+                return ResourceManager.GetString("Func_RANGE_ExpressionDescription", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Exclusive maximum of range that can be matched by the key expression.
+        /// </summary>
+        public static string Func_RANGE_MaxDescription {
+            get {
+                return ResourceManager.GetString("Func_RANGE_MaxDescription", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Inclusive minimum of range that can be matched by the key expression.
+        /// </summary>
+        public static string Func_RANGE_MinDescription {
+            get {
+                return ResourceManager.GetString("Func_RANGE_MinDescription", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Value that is returned when the key expression matches the associated range.
+        /// </summary>
+        public static string Func_RANGE_ValueDescription {
+            get {
+                return ResourceManager.GetString("Func_RANGE_ValueDescription", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Returns the active session.
+        /// </summary>
+        public static string Func_SESSION_Description {
+            get {
+                return ResourceManager.GetString("Func_SESSION_Description", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to String encoding function.
+        /// </summary>
+        public static string Func_URLENCODE_Description {
+            get {
+                return ResourceManager.GetString("Func_URLENCODE_Description", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to String to URL encode.
+        /// </summary>
+        public static string Func_URLENCODE_StringValueDescription {
+            get {
+                return ResourceManager.GetString("Func_URLENCODE_StringValueDescription", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to {0} (*.{1})|*.{1}.
         /// </summary>
         public static string GenericFilter {

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.resx
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.resx	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Strings.resx	2012-10-29 13:32:01 UTC (rev 7162)
@@ -3345,4 +3345,91 @@
   <data name="ErrorConnectionCannotAutoRestartSession" xml:space="preserve">
     <value>This connection cannot auto-restart sessions. Most likely because this connection was just initialized with a session id and not with the credentials required to rebuild a new session</value>
   </data>
+  <data name="Func_ARGB_AValueDescription" xml:space="preserve">
+    <value>Alpha value</value>
+  </data>
+  <data name="Func_ARGB_BValueDescription" xml:space="preserve">
+    <value>Blue value</value>
+  </data>
+  <data name="Func_ARGB_Description" xml:space="preserve">
+    <value>Color generation function</value>
+  </data>
+  <data name="Func_ARGB_GValueDescription" xml:space="preserve">
+    <value>Green value</value>
+  </data>
+  <data name="Func_ARGB_RValueDescription" xml:space="preserve">
+    <value>Red value</value>
+  </data>
+  <data name="Func_DECAP_Description" xml:space="preserve">
+    <value>String formatting function</value>
+  </data>
+  <data name="Func_DECAP_StringValueDescription" xml:space="preserve">
+    <value>String to format</value>
+  </data>
+  <data name="Func_FEATURECLASS_Description" xml:space="preserve">
+    <value>Returns the active feature class name</value>
+  </data>
+  <data name="Func_FEATUREID_Description" xml:space="preserve">
+    <value>Returns the active feature Id</value>
+  </data>
+  <data name="Func_IF_ConditionDescription" xml:space="preserve">
+    <value>Boolean expression (filter) encapsulated in a string</value>
+  </data>
+  <data name="Func_IF_Description" xml:space="preserve">
+    <value>If evaluator for style theming</value>
+  </data>
+  <data name="Func_IF_FalseValueDescription" xml:space="preserve">
+    <value>Returned if condition is false</value>
+  </data>
+  <data name="Func_IF_TrueValueDescription" xml:space="preserve">
+    <value>Returned if condition is true</value>
+  </data>
+  <data name="Func_LAYERID_Description" xml:space="preserve">
+    <value>Returns the active layer Id</value>
+  </data>
+  <data name="Func_LOOKUP_DefaultValueDescription" xml:space="preserve">
+    <value>Default value returned if expression does not evaluate to any of the keys</value>
+  </data>
+  <data name="Func_LOOKUP_Description" xml:space="preserve">
+    <value>Lookup table for style theming</value>
+  </data>
+  <data name="Func_LOOKUP_ExpressionDescription" xml:space="preserve">
+    <value>Key expression</value>
+  </data>
+  <data name="Func_LOOKUP_IndexDescription" xml:space="preserve">
+    <value>Lookup index that can be matched by the key expression</value>
+  </data>
+  <data name="Func_LOOKUP_ValueDescription" xml:space="preserve">
+    <value>Value that is returned when the key expression matches the associated index</value>
+  </data>
+  <data name="Func_MAPNAME_Description" xml:space="preserve">
+    <value>Returns the active map name</value>
+  </data>
+  <data name="Func_RANGE_DefaultValueDescription" xml:space="preserve">
+    <value>Default value returned if expression does not fall into any of the ranges</value>
+  </data>
+  <data name="Func_RANGE_Description" xml:space="preserve">
+    <value>Range table for style theming</value>
+  </data>
+  <data name="Func_RANGE_ExpressionDescription" xml:space="preserve">
+    <value>Key expression</value>
+  </data>
+  <data name="Func_RANGE_MaxDescription" xml:space="preserve">
+    <value>Exclusive maximum of range that can be matched by the key expression</value>
+  </data>
+  <data name="Func_RANGE_MinDescription" xml:space="preserve">
+    <value>Inclusive minimum of range that can be matched by the key expression</value>
+  </data>
+  <data name="Func_RANGE_ValueDescription" xml:space="preserve">
+    <value>Value that is returned when the key expression matches the associated range</value>
+  </data>
+  <data name="Func_SESSION_Description" xml:space="preserve">
+    <value>Returns the active session</value>
+  </data>
+  <data name="Func_URLENCODE_Description" xml:space="preserve">
+    <value>String encoding function</value>
+  </data>
+  <data name="Func_URLENCODE_StringValueDescription" xml:space="preserve">
+    <value>String to URL encode</value>
+  </data>
 </root>
\ No newline at end of file

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Utility.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Utility.cs	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Utility.cs	2012-10-29 13:32:01 UTC (rev 7162)
@@ -32,6 +32,8 @@
 using OSGeo.MapGuide.MaestroAPI.Resource;
 using System.Text;
 using System.Text.RegularExpressions;
+using OSGeo.MapGuide.ObjectModels.Capabilities;
+using System.ComponentModel;
 
 namespace OSGeo.MapGuide.MaestroAPI
 {
@@ -1113,6 +1115,222 @@
         {
             return "'" + str + "'"; //NOXLATE
         }
+
+        /// <summary>
+        /// Returns the list of known FDO stylization expression functions
+        /// </summary>
+        /// <returns></returns>
+        public static IEnumerable<FdoProviderCapabilitiesExpressionFunctionDefinition> GetStylizationFunctions()
+        {
+            //ARGB
+            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
+            {
+                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>()
+                {
+                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
+                    {
+                        Name = "aValue", //NOXLATE
+                        Description = Strings.Func_ARGB_AValueDescription,
+                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.Int32
+                    },
+                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
+                    {
+                        Name = "rValue", //NOXLATE
+                        Description = Strings.Func_ARGB_RValueDescription,
+                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.Int32
+                    },
+                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
+                    {
+                        Name = "gValue", //NOXLATE
+                        Description = Strings.Func_ARGB_GValueDescription,
+                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.Int32
+                    },
+                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
+                    {
+                        Name = "bValue", //NOXLATE
+                        Description = Strings.Func_ARGB_BValueDescription,
+                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.Int32
+                    },
+                },
+                Description = Strings.Func_ARGB_Description,
+                Name = "ARGB", //NOXLATE
+                ReturnType = "Int32" //NOXLATE
+            };
+            //DECAP
+            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
+            {
+                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>()
+                {
+                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
+                    {
+                        Name = "strValue", //NOXLATE
+                        Description = Strings.Func_DECAP_StringValueDescription,
+                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
+                    }
+                },
+                Description = Strings.Func_DECAP_Description,
+                Name = "DECAP", //NOXLATE
+                ReturnType = "String" //NOXLATE
+            };
+            //FEATURECLASS
+            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
+            {
+                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>(),
+                Description = Strings.Func_FEATURECLASS_Description,
+                Name = "FEATURECLASS", //NOXLATE
+                ReturnType = "String" //NOXLATE
+            };
+            //FEATUREID
+            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
+            {
+                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>(),
+                Description = Strings.Func_FEATUREID_Description,
+                Name = "FEATUREID", //NOXLATE
+                ReturnType = "String" //NOXLATE
+            };
+            //IF
+            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
+            {
+                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>()
+                {
+                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
+                    {
+                        Name = "condition", //NOXLATE
+                        Description = Strings.Func_IF_ConditionDescription,
+                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
+                    },
+                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
+                    {
+                        Name = "trueValue", //NOXLATE
+                        Description = Strings.Func_IF_TrueValueDescription,
+                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
+                    },
+                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
+                    {
+                        Name = "falseValue", //NOXLATE
+                        Description = Strings.Func_IF_FalseValueDescription,
+                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
+                    }
+                },
+                Description = Strings.Func_IF_Description,
+                Name = "IF", //NOXLATE
+                ReturnType = "String" //NOXLATE
+            };
+            //LAYERID
+            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
+            {
+                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>(),
+                Description = Strings.Func_LAYERID_Description,
+                Name = "LAYERID", //NOXLATE
+                ReturnType = "String" //NOXLATE
+            };
+            //LOOKUP
+            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
+            {
+                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>()
+                {
+                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
+                    {
+                        Name = "expression", //NOXLATE
+                        Description = Strings.Func_LOOKUP_ExpressionDescription,
+                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
+                    },
+                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
+                    {
+                        Name = "defaultValue", //NOXLATE
+                        Description = Strings.Func_LOOKUP_DefaultValueDescription,
+                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
+                    },
+                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
+                    {
+                        Name = "index", //NOXLATE
+                        Description = Strings.Func_LOOKUP_IndexDescription,
+                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
+                    },
+                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
+                    {
+                        Name = "value", //NOXLATE
+                        Description = Strings.Func_LOOKUP_ValueDescription,
+                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
+                    }
+                },
+                Description = Strings.Func_LOOKUP_Description,
+                Name = "LOOKUP", //NOXLATE
+                ReturnType = "String" //NOXLATE
+            };
+            //MAPNAME
+            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
+            {
+                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>(),
+                Description = Strings.Func_MAPNAME_Description,
+                Name = "MAPNAME", //NOXLATE
+                ReturnType = "String" //NOXLATE
+            };
+            //RANGE
+            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
+            {
+                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>()
+                {
+                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
+                    {
+                        Name = "expression", //NOXLATE
+                        Description = Strings.Func_RANGE_ExpressionDescription,
+                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
+                    },
+                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
+                    {
+                        Name = "rangeMin", //NOXLATE
+                        Description = Strings.Func_RANGE_MinDescription,
+                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
+                    },
+                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
+                    {
+                        Name = "rangeMax", //NOXLATE
+                        Description = Strings.Func_RANGE_MaxDescription,
+                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
+                    },
+                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
+                    {
+                        Name = "defaultValue", //NOXLATE
+                        Description = Strings.Func_RANGE_DefaultValueDescription,
+                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
+                    },
+                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
+                    {
+                        Name = "value", //NOXLATE
+                        Description = Strings.Func_RANGE_ValueDescription,
+                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
+                    }
+                },
+                Description = Strings.Func_RANGE_Description,
+                Name = "RANGE", //NOXLATE
+                ReturnType = "String" //NOXLATE
+            };
+            //SESSION
+            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
+            {
+                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>(),
+                Description = Strings.Func_SESSION_Description,
+                Name = "SESSION", //NOXLATE
+                ReturnType = "String" //NOXLATE
+            };
+            //URLENCODE
+            yield return new FdoProviderCapabilitiesExpressionFunctionDefinition()
+            {
+                ArgumentDefinitionList = new BindingList<FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition>()
+                {
+                    new FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinition() 
+                    {
+                        Name = "strValue", //NOXLATE
+                        Description = Strings.Func_URLENCODE_StringValueDescription,
+                        DataType = FdoProviderCapabilitiesExpressionFunctionDefinitionArgumentDefinitionDataType.String
+                    }
+                },
+                Description = Strings.Func_URLENCODE_Description,
+                Name = "URLENCODE", //NOXLATE
+                ReturnType = "String" //NOXLATE
+            };
+        }
     }
 
     /// <summary>

Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/ICSharpCode.TextEditor.csproj
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/ICSharpCode.TextEditor.csproj	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/ICSharpCode.TextEditor.csproj	2012-10-29 13:32:01 UTC (rev 7162)
@@ -201,6 +201,7 @@
     <EmbeddedResource Include="Resources\Coco-Mode.xshd" />
     <EmbeddedResource Include="Resources\CSharp-Mode.xshd" />
     <EmbeddedResource Include="Resources\HTML-Mode.xshd" />
+    <EmbeddedResource Include="Resources\FDO.xshd" />
     <None Include="Resources\ICSharpCode.TextEditor.snk" />
     <EmbeddedResource Include="Resources\TextEditorControl.bmp" />
     <EmbeddedResource Include="Resources\Java-Mode.xshd" />
@@ -223,6 +224,7 @@
     <Compile Include="Src\Util\WeakCollection.cs" />
     <EmbeddedResource Include="Resources\Patch-Mode.xshd" />
     <EmbeddedResource Include="Resources\Python.xshd" />
+    <EmbeddedResource Include="Resources\SQL.xshd" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
 </Project>
\ No newline at end of file

Added: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Resources/FDO.xshd
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Resources/FDO.xshd	                        (rev 0)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Resources/FDO.xshd	2012-10-29 13:32:01 UTC (rev 7162)
@@ -0,0 +1,145 @@
+<?xml version = "1.0"?>
+
+<SyntaxDefinition name = "FDO" extensions = ".fdq">
+
+  <Environment>
+    <Default      color = "SystemColors.WindowText" bgcolor="SystemColors.Window"/>
+    <VRuler       color = "Blue"/>
+    <Selection    bgcolor = "LightBlue"/>
+    <LineNumbers  color = "Teal" bgcolor = "SystemColors.Window"/>
+    <InvalidLines color = "Red"/>
+    <EOLMarkers   color = "White"/>
+    <SpaceMarkers color = "#E0E0E5"/>
+    <TabMarkers   color = "#E0E0E5"/>
+    <CaretMarker  color = "Yellow"/>
+    <FoldLine     color = "#808080" bgcolor="Black"/>
+    <FoldMarker   color = "#808080" bgcolor="White"/>
+  </Environment>
+
+  <Properties>
+    <Property name="LineComment" value="--"/>
+  </Properties>
+
+  <Digits name = "Digits" bold = "false" italic = "false" color = "DarkBlue"/>
+
+  <RuleSets>
+    <RuleSet ignorecase = "true">
+
+      <Delimiters>=!><+-/*%&|^~.}{,;][?:()</Delimiters>
+
+      <Span name ="String" bold ="false" italic ="false" color ="Sienna" stopateol ="false">
+        <Begin>"</Begin>
+        <End>"</End>
+      </Span>
+
+      <Span name = "Character" bold = "false" italic = "false" color = "Sienna" stopateol = "true">
+        <Begin>'</Begin>
+        <End>'</End>
+      </Span>
+
+      <KeyWords name ="Punctuation" bold="false" italic = "false" color = "DarkSlateGray">
+        <Key word = "(" />
+        <Key word = ")" />
+      </KeyWords>
+
+      <KeyWords name ="Operators" bold="false" italic = "false" color = "DarkSlateGray">
+        <Key word = "+" />
+        <Key word = "-" />
+        <Key word = "*" />
+        <Key word = "/" />
+        <Key word = "<" />
+        <Key word = ">" />
+        <Key word = "=" />
+        <Key word = "<=" />
+        <Key word = ">=" />
+        <Key word = "like" />
+        <Key word = "and" />
+        <Key word = "or" />
+      </KeyWords>
+
+      <KeyWords name ="Functions" bold="false" italic = "false" color = "DarkRed">
+        <!-- Aggregate -->
+        <Key word = "avg" />
+        <Key word = "count" />
+        <Key word = "max" />
+        <Key word = "median" />
+        <Key word = "min" />
+        <Key word = "spatialextents" />
+        <Key word = "stddev" />
+        <Key word = "sum" />
+        <!-- Conversion -->
+        <Key word = "nullvalue" />
+        <Key word = "todate" />
+        <Key word = "todouble" />
+        <Key word = "tofloat" />
+        <Key word = "toint32" />
+        <Key word = "toint64" />
+        <Key word = "tostring" />
+        <!-- Date -->
+        <Key word = "addmonths" />
+        <Key word = "currentdate" />
+        <Key word = "extract" />
+        <Key word = "extracttodouble" />
+        <Key word = "extracttoint" />
+        <Key word = "monthsbetween" />
+        <!-- Geometry -->
+        <Key word = "area2d" />
+        <Key word = "length2d" />
+        <Key word = "m" />
+        <Key word = "x" />
+        <Key word = "y" />
+        <Key word = "z" />
+        <!-- Math -->
+        <Key word = "abs" />
+        <Key word = "acos" />
+        <Key word = "asin" />
+        <Key word = "atan" />
+        <Key word = "atan2" />
+        <Key word = "cos" />
+        <Key word = "exp" />
+        <Key word = "ln" />
+        <Key word = "log" />
+        <Key word = "mod" />
+        <Key word = "power" />
+        <Key word = "remainder" />
+        <Key word = "sin" />
+        <Key word = "sqrt" />
+        <Key word = "tan" />
+        <!-- Numeric -->
+        <Key word = "ceil" />
+        <Key word = "floor" />
+        <Key word = "round" />
+        <Key word = "sign" />
+        <Key word = "trunc" />
+        <!-- String -->
+        <Key word = "concat" />
+        <Key word = "instr" />
+        <Key word = "length" />
+        <Key word = "lower" />
+        <Key word = "lpad" />
+        <Key word = "ltrim" />
+        <Key word = "rpad" />
+        <Key word = "rtrim" />
+        <Key word = "soundex" />
+        <Key word = "substr" />
+        <Key word = "translate" />
+        <Key word = "trim" />
+        <Key word = "upper" />
+        <!-- Stylization -->
+        <Key word = "argb" />
+        <Key word = "decap" />
+        <Key word = "featureclass" />
+        <Key word = "featureid" />
+        <Key word = "if" />
+        <Key word = "layerid" />
+        <Key word = "lookup" />
+        <Key word = "mapname" />
+        <Key word = "range" />
+        <Key word = "session" />
+        <Key word = "urlencode" />
+        <!-- Other -->
+        <Key word = "geomfromtext" />
+      </KeyWords>
+    </RuleSet>
+  </RuleSets>
+</SyntaxDefinition>

Added: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Resources/SQL.xshd
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Resources/SQL.xshd	                        (rev 0)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Resources/SQL.xshd	2012-10-29 13:32:01 UTC (rev 7162)
@@ -0,0 +1,157 @@
+<?xml version = "1.0"?>
+
+<SyntaxDefinition name = "SQL" extensions = ".sql">
+
+  <Environment>
+    <Default      color = "SystemColors.WindowText" bgcolor="SystemColors.Window"/>
+    <VRuler       color = "Blue"/>
+    <Selection    bgcolor = "LightBlue"/>
+    <LineNumbers  color = "Teal" bgcolor = "SystemColors.Window"/>
+    <InvalidLines color = "Red"/>
+    <EOLMarkers   color = "White"/>
+    <SpaceMarkers color = "#E0E0E5"/>
+    <TabMarkers   color = "#E0E0E5"/>
+    <CaretMarker  color = "Yellow"/>
+    <FoldLine     color = "#808080" bgcolor="Black"/>
+    <FoldMarker   color = "#808080" bgcolor="White"/>
+  </Environment>
+
+  <Properties>
+    <Property name="LineComment" value="--"/>
+  </Properties>
+
+  <Digits name = "Digits" bold = "false" italic = "false" color = "DarkBlue"/>
+
+  <RuleSets>
+    <RuleSet ignorecase = "true">
+
+      <Delimiters>=!><+-/*%&|^~.}{,;][?:()</Delimiters>
+
+      <Span name ="LineComment" bold ="false" italic ="true" color ="DarkGreen" stopateol ="true">
+        <Begin>--</Begin>
+      </Span>
+
+      <Span name ="BlockComment" bold ="false" italic ="false" color ="DarkGreen" stopateol ="false">
+        <Begin>/*</Begin>
+        <End>*/</End>
+      </Span>
+
+      <Span name ="String" bold ="false" italic ="false" color ="Sienna" stopateol ="false">
+        <Begin>"</Begin>
+        <End>"</End>
+      </Span>
+
+      <Span name = "Character" bold = "false" italic = "false" color = "Sienna" stopateol = "true">
+        <Begin>'</Begin>
+        <End>'</End>
+      </Span>
+
+      <KeyWords name ="SqlKeywords" bold="false" italic = "false" color = "Blue">
+        <Key word = "from" />
+        <Key word = "where" />
+        <Key word = "in" />
+        <Key word = "on" />
+        <Key word = "exists" />
+        <Key word = "or" />
+        <Key word = "and" />
+        <Key word = "not" />
+        <Key word = "null" />
+        <Key word = "having" />
+        <Key word = "group" />
+        <Key word = "by" />
+        <Key word = "order" />
+
+
+        <Key word = "into" />
+        <Key word = "values" />
+        <Key word = "set" />
+        <Key word = "inner" />
+        <Key word = "outer" />
+        <Key word = "join" />
+        <Key word = "union" />
+        <Key word = "desc" />
+        <Key word = "asc" />
+      </KeyWords>
+
+      <KeyWords name ="SqlActionWords" bold="false" italic = "false" color = "Blue">
+        <Key word = "select" />
+        <Key word = "update" />
+        <Key word = "use" />
+        <Key word = "insert" />
+        <Key word = "create" />
+        <Key word = "drop" />
+        <Key word = "delete" />
+        <Key word = "truncate" />
+        <Key word = "alter" />
+        <Key word = "add" />
+      </KeyWords>
+
+      <KeyWords name ="SqlTypes" bold="false" italic = "false" color = "DarkRed">
+        <Key word = "varchar" />
+        <Key word = "nvarchar" />
+        <Key word = "char" />
+        <Key word = "nchar" />
+        <Key word = "int" />
+        <Key word = "text" />
+        <Key word = "ntext" />
+        <Key word = "double" />
+        <Key word = "money" />
+        <Key word = "bit" />
+      </KeyWords>
+
+      <KeyWords name ="SqlObjects" bold="false" italic = "false" color = "DarkRed">
+        <Key word = "table" />
+        <Key word = "proc" />
+        <Key word = "procedure" />
+        <Key word = "function" />
+        <Key word = "view" />
+        <Key word = "trigger" />
+        <Key word = "index" />
+        <Key word = "database" />
+      </KeyWords>
+
+      <KeyWords name ="TSql" bold="false" italic = "false" color = "DarkBlue">
+        <Key word = "IF" />
+        <Key word = "ELSE" />
+        <Key word = "CASE" />
+        <Key word = "RETURN" />
+        <Key word = "END" />
+        <Key word = "DECLARE" />
+
+        <Key word = "SWITCH" />
+        <Key word = "END" />
+
+        <Key word = "BEGIN" />
+        <Key word = "CASE" />
+        <Key word = "WHEN" />
+        <Key word = "END" />
+      </KeyWords>
+
+      <KeyWords name ="Punctuation" bold="false" italic = "false" color = "DarkSlateGray">
+        <Key word = "(" />
+        <Key word = ")" />
+      </KeyWords>
+
+      <KeyWords name ="Operators" bold="false" italic = "false" color = "DarkSlateGray">
+        <Key word = "<" />
+        <Key word = ">" />
+        <Key word = "=" />
+      </KeyWords>
+
+      <KeyWords name ="Functions" bold="false" italic = "false" color = "DarkRed">
+        <Key word = "substring" />
+        <Key word = "upper" />
+        <Key word = "lower" />
+        <Key word = "reverse" />
+        <Key word = "avg" />
+        <Key word = "min" />
+        <Key word = "max" />
+        <Key word = "replace" />
+        <Key word = "ltrim" />
+        <Key word = "rtrim" />
+        <Key word = "cast" />
+
+      </KeyWords>
+    </RuleSet>
+  </RuleSets>
+</SyntaxDefinition>

Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Resources/SyntaxModes.xml
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Resources/SyntaxModes.xml	2012-10-29 08:20:20 UTC (rev 7161)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.TextEditor/Resources/SyntaxModes.xml	2012-10-29 13:32:01 UTC (rev 7162)
@@ -26,8 +26,12 @@
 	<Mode file       = "HTML-Mode.xshd"
 	      name       = "HTML"
 	      extensions = ".htm;.html"/>
-	
-	<Mode file       = "Java-Mode.xshd"
+
+  <Mode file       = "FDO.xshd"
+	      name       = "FDO"
+	      extensions = ".fdq"/>
+
+  <Mode file       = "Java-Mode.xshd"
 	      name       = "Java"
 	      extensions = ".java"/>
 	
@@ -46,6 +50,10 @@
   <Mode file       = "Python.xshd"
 	      name       = "Python"
 	      extensions = ".py"/>
+
+  <Mode file       = "SQL.xshd"
+	      name       = "SQL"
+	      extensions = ".sql"/>
 	
 	<Mode file       = "Tex-Mode.xshd"
 	      name       = "TeX"



More information about the mapguide-commits mailing list