[mapguide-commits] r7157 - in trunk/Tools/Maestro: Maestro Maestro.AddIn.Scripting Maestro.AddIn.Scripting/Commands Maestro.AddIn.Scripting/Lang Maestro.AddIn.Scripting/Lang/Python Maestro.AddIn.Scripting/Properties Maestro.AddIn.Scripting/Resources Maestro.AddIn.Scripting/Services Maestro.AddIn.Scripting/UI MaestroAPITestRunner
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Fri Oct 26 01:49:03 PDT 2012
Author: jng
Date: 2012-10-26 01:49:03 -0700 (Fri, 26 Oct 2012)
New Revision: 7157
Added:
trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/
trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/
trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/CommandLineHistory.cs
trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/IMemberProvider.cs
trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/ITextEditor.cs
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/Lang/Python/TextEditor.cs
trunk/Tools/Maestro/Maestro.AddIn.Scripting/Resources/
trunk/Tools/Maestro/Maestro.AddIn.Scripting/Resources/Python.xshd
trunk/Tools/Maestro/Maestro.AddIn.Scripting/Resources/block.png
Removed:
trunk/Tools/Maestro/Maestro.AddIn.Scripting/Services/ScriptingService.cs
trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IPEWrapper.cs
trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronTextBox.cs
trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/Paths.cs
trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.Designer.cs
trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.cs
trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.resx
trunk/Tools/Maestro/MaestroAPITestRunner/MGOS22/
Modified:
trunk/Tools/Maestro/Maestro.AddIn.Scripting/Commands/StartupCommand.cs
trunk/Tools/Maestro/Maestro.AddIn.Scripting/Maestro.AddIn.Scripting.csproj
trunk/Tools/Maestro/Maestro.AddIn.Scripting/Manifest.addin
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/Services/ScriptingClasses.cs
trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.Designer.cs
trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs
trunk/Tools/Maestro/Maestro/Maestro_All.sln
trunk/Tools/Maestro/MaestroAPITestRunner/MaestroAPITestRunner.csproj
Log:
This submission includes the following changes:
- #2161: Replace the IronPython REPL. This one is derived from the SharpDevelop Python binding source.
- Remove the LocalNative provider test setup from the MaestroAPITestRunner. We'll be partitioning off these bits separately as part of the ProviderTemplate builder.
Modified: trunk/Tools/Maestro/Maestro/Maestro_All.sln
===================================================================
--- trunk/Tools/Maestro/Maestro/Maestro_All.sln 2012-10-25 15:08:19 UTC (rev 7156)
+++ trunk/Tools/Maestro/Maestro/Maestro_All.sln 2012-10-26 08:49:03 UTC (rev 7157)
@@ -4,6 +4,12 @@
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Maestro", "Maestro.csproj", "{E0C36475-2B70-4F6D-ACE0-8943167806DC}"
ProjectSection(ProjectDependencies) = postProject
{B3A2B816-9F41-4857-A111-09D2DF2550D6} = {B3A2B816-9F41-4857-A111-09D2DF2550D6}
+ {8787FF3F-552F-46BE-B9D7-548B6162B079} = {8787FF3F-552F-46BE-B9D7-548B6162B079}
+ {2419F940-BFB7-4F3F-B5DA-1052EB4706E5} = {2419F940-BFB7-4F3F-B5DA-1052EB4706E5}
+ {9CC51643-37D6-4B8F-A0EA-E7606AA561EB} = {9CC51643-37D6-4B8F-A0EA-E7606AA561EB}
+ {19A769B5-7CFA-4E9F-90D8-BF4A17F918C4} = {19A769B5-7CFA-4E9F-90D8-BF4A17F918C4}
+ {3591C5BB-2B87-4FB4-AD87-9C8176DF9835} = {3591C5BB-2B87-4FB4-AD87-9C8176DF9835}
+ {32BA7DF6-1AFA-441D-9231-5624C5920706} = {32BA7DF6-1AFA-441D-9231-5624C5920706}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "..\Thirdparty\SharpDevelop\ICSharpCode.Core\ICSharpCode.Core.csproj", "{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}"
Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Commands/StartupCommand.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Commands/StartupCommand.cs 2012-10-25 15:08:19 UTC (rev 7156)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Commands/StartupCommand.cs 2012-10-26 08:49:03 UTC (rev 7157)
@@ -9,6 +9,7 @@
using Maestro.Base.Services;
using Props = ICSharpCode.Core.PropertyService;
using Maestro.Base.UI.Preferences;
+using ICSharpCode.TextEditor.Document;
namespace Maestro.AddIn.Scripting.Commands
{
Property changes on: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang
___________________________________________________________________
Added: bugtraq:number
+ true
Property changes on: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python
___________________________________________________________________
Added: bugtraq:number
+ true
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/CommandLineHistory.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/CommandLineHistory.cs (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/CommandLineHistory.cs 2012-10-26 08:49:03 UTC (rev 7157)
@@ -0,0 +1,120 @@
+#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 System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Maestro.AddIn.Scripting.Lang.Python
+{
+ /// <summary>
+ /// Stores the command line history for the PythonConsole.
+ /// </summary>
+ public class CommandLineHistory
+ {
+ List<string> lines = new List<string>();
+ int position;
+
+ public CommandLineHistory()
+ {
+ }
+
+ /// <summary>
+ /// Adds the command line to the history.
+ /// </summary>
+ public void Add(string line)
+ {
+ if (!String.IsNullOrEmpty(line))
+ {
+ int index = lines.Count - 1;
+ if (index >= 0)
+ {
+ if (lines[index] != line)
+ {
+ lines.Add(line);
+ }
+ }
+ else
+ {
+ lines.Add(line);
+ }
+ }
+ position = lines.Count;
+ }
+
+ /// <summary>
+ /// Gets the current command line. By default this will be the last command line entered.
+ /// </summary>
+ public string Current
+ {
+ get
+ {
+ if ((position >= 0) && (position < lines.Count))
+ {
+ return lines[position];
+ }
+ return null;
+ }
+ }
+
+ /// <summary>
+ /// Moves to the next command line.
+ /// </summary>
+ /// <returns>False if the current position is at the end of the command line history.</returns>
+ public bool MoveNext()
+ {
+ int nextPosition = position + 1;
+ if (nextPosition < lines.Count)
+ {
+ ++position;
+ }
+ return nextPosition < lines.Count;
+ }
+
+ /// <summary>
+ /// Moves to the previous command line.
+ /// </summary>
+ /// <returns>False if the current position is at the start of the command line history.</returns>
+ public bool MovePrevious()
+ {
+ if (position >= 0)
+ {
+ if (position == 0)
+ {
+ return false;
+ }
+ --position;
+ }
+ return position >= 0;
+ }
+ }
+}
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/IMemberProvider.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/IMemberProvider.cs (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/IMemberProvider.cs 2012-10-26 08:49:03 UTC (rev 7157)
@@ -0,0 +1,48 @@
+#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 System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Maestro.AddIn.Scripting.Lang.Python
+{
+ /// <summary>
+ /// Returns member names or global names for the python console command line.
+ /// </summary>
+ public interface IMemberProvider
+ {
+ IList<string> GetMemberNames(string name);
+
+ IList<string> GetGlobals(string name);
+ }
+}
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/ITextEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/ITextEditor.cs (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/ITextEditor.cs 2012-10-26 08:49:03 UTC (rev 7157)
@@ -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.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>
+ 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.AddIn.Scripting/Lang/Python/PythonConsole.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsole.cs (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsole.cs 2012-10-26 08:49:03 UTC (rev 7157)
@@ -0,0 +1,395 @@
+#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.Document;
+using Microsoft.Scripting.Hosting.Shell;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Windows.Forms;
+
+namespace Maestro.AddIn.Scripting.Lang.Python
+{
+ public class PythonConsole : IConsole, IDisposable, IMemberProvider
+ {
+ ITextEditor textEditor;
+ int lineReceivedEventIndex = 0; // The index into the waitHandles array where the lineReceivedEvent is stored.
+ ManualResetEvent lineReceivedEvent = new ManualResetEvent(false);
+ ManualResetEvent disposedEvent = new ManualResetEvent(false);
+ WaitHandle[] waitHandles;
+ int promptLength;
+ List<string> previousLines = new List<string>();
+ CommandLine commandLine;
+ CommandLineHistory commandLineHistory = new CommandLineHistory();
+
+ public PythonConsole(ITextEditor textEditor, CommandLine commandLine)
+ {
+ waitHandles = new WaitHandle[] { lineReceivedEvent, disposedEvent };
+
+ this.commandLine = commandLine;
+
+ this.textEditor = textEditor;
+ textEditor.KeyPress += ProcessKeyPress;
+ textEditor.DialogKeyPress += ProcessDialogKeyPress;
+ textEditor.IndentStyle = IndentStyle.None;
+ }
+
+ public void Dispose()
+ {
+ disposedEvent.Set();
+ //TextArea textArea = textEditor.ActiveTextAreaControl.TextArea;
+ //textArea.KeyEventHandler -= ProcessKeyPress;
+ //textArea.DoProcessDialogKey -= ProcessDialogKey;
+ }
+
+ public TextWriter Output
+ {
+ get
+ {
+ Console.WriteLine("PythonConsole.Output get");
+ return null;
+ }
+ set
+ {
+ Console.WriteLine("PythonConsole.Output set");
+ }
+ }
+
+ public TextWriter ErrorOutput
+ {
+ get
+ {
+ Console.WriteLine("PythonConsole.ErrorOutput get");
+ return null;
+ }
+ set
+ {
+ Console.WriteLine("PythonConsole.ErrorOutput get");
+ }
+ }
+
+ /// <summary>
+ /// Gets the member names of the specified item.
+ /// </summary>
+ public IList<string> GetMemberNames(string name)
+ {
+ return commandLine.GetMemberNames(name);
+ }
+
+ public IList<string> GetGlobals(string name)
+ {
+ return commandLine.GetGlobals(name);
+ }
+
+ /// <summary>
+ /// Returns the next line typed in by the console user. If no line is available this method
+ /// will block.
+ /// </summary>
+ public string ReadLine(int autoIndentSize)
+ {
+ Console.WriteLine("PythonConsole.ReadLine(): autoIndentSize: " + autoIndentSize);
+
+ string indent = String.Empty;
+ if (autoIndentSize > 0)
+ {
+ indent = String.Empty.PadLeft(autoIndentSize);
+ Write(indent, Style.Prompt);
+ }
+
+ string line = ReadLineFromTextEditor();
+ if (line != null)
+ {
+ Console.WriteLine("ReadLine: " + indent + line);
+ return indent + line;
+ }
+ return null;
+ }
+
+ /// <summary>
+ /// Writes text to the console.
+ /// </summary>
+ public void Write(string text, Style style)
+ {
+ Console.WriteLine("PythonConsole.Write(text, style): " + text);
+
+ textEditor.Write(text);
+
+ if (style == Style.Prompt)
+ {
+ promptLength = text.Length;
+ textEditor.MakeCurrentContentReadOnly();
+ }
+ }
+
+ /// <summary>
+ /// Writes text followed by a newline to the console.
+ /// </summary>
+ public void WriteLine(string text, Style style)
+ {
+ Write(text + Environment.NewLine, style);
+ }
+
+ /// <summary>
+ /// Writes an empty line to the console.
+ /// </summary>
+ public void WriteLine()
+ {
+ Write(Environment.NewLine, Style.Out);
+ }
+
+ /// <summary>
+ /// Indicates whether there is a line already read by the console and waiting to be processed.
+ /// </summary>
+ public bool IsLineAvailable
+ {
+ get
+ {
+ lock (previousLines)
+ {
+ return previousLines.Count > 0;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets the text that is yet to be processed from the console. This is the text that is being
+ /// typed in by the user who has not yet pressed the enter key.
+ /// </summary>
+ public string GetCurrentLine()
+ {
+ string fullLine = GetLastTextEditorLine();
+ return fullLine.Substring(promptLength);
+ }
+
+ /// <summary>
+ /// Gets the lines that have not been returned by the ReadLine method. This does not
+ /// include the current line.
+ /// </summary>
+ public string[] GetUnreadLines()
+ {
+ return previousLines.ToArray();
+ }
+
+ string GetLastTextEditorLine()
+ {
+ return textEditor.GetLine(textEditor.TotalLines - 1);
+ }
+
+ string ReadLineFromTextEditor()
+ {
+ int result = WaitHandle.WaitAny(waitHandles);
+ if (result == lineReceivedEventIndex)
+ {
+ lock (previousLines)
+ {
+ string line = previousLines[0];
+ previousLines.RemoveAt(0);
+ if (previousLines.Count == 0)
+ {
+ lineReceivedEvent.Reset();
+ }
+ return line;
+ }
+ }
+ return null;
+ }
+
+ /// <summary>
+ /// Processes characters entered into the text editor by the user.
+ /// </summary>
+ bool ProcessKeyPress(char ch)
+ {
+ if (IsInReadOnlyRegion)
+ {
+ return true;
+ }
+
+ if (ch == '\n')
+ {
+ OnEnterKeyPressed();
+ }
+
+ if (ch == '.')
+ {
+ ShowCompletionWindow();
+ }
+ return false;
+ }
+
+ /// <summary>
+ /// Process dialog keys such as the enter key when typed into the editor by the user.
+ /// </summary>
+ bool ProcessDialogKeyPress(Keys keyData)
+ {
+ if (textEditor.IsCompletionWindowDisplayed)
+ {
+ return false;
+ }
+
+ if (IsInReadOnlyRegion)
+ {
+ switch (keyData)
+ {
+ case Keys.Left:
+ case Keys.Right:
+ case Keys.Up:
+ case Keys.Down:
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ switch (keyData)
+ {
+ case Keys.Back:
+ return !CanBackspace;
+ case Keys.Home:
+ MoveToHomePosition();
+ return true;
+ case Keys.Down:
+ MoveToNextCommandLine();
+ return true;
+ case Keys.Up:
+ MoveToPreviousCommandLine();
+ return true;
+ }
+ return false;
+ }
+
+ /// <summary>
+ /// Move cursor to the end of the line before retrieving the line.
+ /// </summary>
+ void OnEnterKeyPressed()
+ {
+ lock (previousLines)
+ {
+ // Move cursor to the end of the line.
+ textEditor.Column = GetLastTextEditorLine().Length;
+
+ // Append line.
+ string currentLine = GetCurrentLine();
+ previousLines.Add(currentLine);
+ commandLineHistory.Add(currentLine);
+
+ lineReceivedEvent.Set();
+ }
+ }
+
+ /// <summary>
+ /// Returns true if the cursor is in a readonly text editor region.
+ /// </summary>
+ bool IsInReadOnlyRegion
+ {
+ get { return IsCurrentLineReadOnly || IsInPrompt; }
+ }
+
+ /// <summary>
+ /// Only the last line in the text editor is not read only.
+ /// </summary>
+ bool IsCurrentLineReadOnly
+ {
+ get { return textEditor.Line < textEditor.TotalLines - 1; }
+ }
+
+ /// <summary>
+ /// Determines whether the current cursor position is in a prompt.
+ /// </summary>
+ bool IsInPrompt
+ {
+ get { return textEditor.Column - promptLength < 0; }
+ }
+
+ /// <summary>
+ /// Returns true if the user can backspace at the current cursor position.
+ /// </summary>
+ bool CanBackspace
+ {
+ get
+ {
+ int cursorIndex = textEditor.Column - promptLength;
+ int selectionStartIndex = textEditor.SelectionStart - promptLength;
+ return cursorIndex > 0 && selectionStartIndex > 0;
+ }
+ }
+
+ void ShowCompletionWindow()
+ {
+ PythonConsoleCompletionDataProvider completionProvider = new PythonConsoleCompletionDataProvider(this);
+ textEditor.ShowCompletionWindow(completionProvider);
+ }
+
+ /// <summary>
+ /// The home position is at the start of the line after the prompt.
+ /// </summary>
+ void MoveToHomePosition()
+ {
+ textEditor.Column = promptLength;
+ }
+
+ /// <summary>
+ /// Shows the previous command line in the command line history.
+ /// </summary>
+ void MoveToPreviousCommandLine()
+ {
+ if (commandLineHistory.MovePrevious())
+ {
+ ReplaceCurrentLineTextAfterPrompt(commandLineHistory.Current);
+ }
+ }
+
+ /// <summary>
+ /// Shows the next command line in the command line history.
+ /// </summary>
+ void MoveToNextCommandLine()
+ {
+ if (commandLineHistory.MoveNext())
+ {
+ ReplaceCurrentLineTextAfterPrompt(commandLineHistory.Current);
+ }
+ }
+
+ /// <summary>
+ /// Replaces the current line text after the prompt with the specified text.
+ /// </summary>
+ void ReplaceCurrentLineTextAfterPrompt(string text)
+ {
+ string currentLine = GetCurrentLine();
+ textEditor.Replace(promptLength, currentLine.Length, text);
+
+ // Put cursor at end.
+ textEditor.Column = promptLength + text.Length;
+ }
+ }
+}
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsoleCompletionDataProvider.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsoleCompletionDataProvider.cs (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsoleCompletionDataProvider.cs 2012-10-26 08:49:03 UTC (rev 7157)
@@ -0,0 +1,161 @@
+#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.Linq;
+using System.Text;
+
+namespace Maestro.AddIn.Scripting.Lang.Python
+{
+ /// <summary>
+ /// Provides code completion for the Python Console window.
+ /// </summary>
+ public class PythonConsoleCompletionDataProvider : ICompletionDataProvider
+ {
+ IMemberProvider memberProvider;
+
+ public PythonConsoleCompletionDataProvider(IMemberProvider memberProvider)
+ {
+ this.memberProvider = memberProvider;
+ this.DefaultIndex = 0;
+ this.PreSelection = null;
+ this.ImageList = new System.Windows.Forms.ImageList();
+ this.ImageList.Images.Add(Properties.Resources.block);
+ }
+
+ public ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped)
+ {
+ return GenerateCompletionData(GetLineText(textArea));
+ }
+
+ /// <summary>
+ /// Generates completion data for the specified text. The text should be everything before
+ /// the dot character that triggered the completion. The text can contain the command line prompt
+ /// '>>>' as this will be ignored.
+ /// </summary>
+ public ICompletionData[] GenerateCompletionData(string line)
+ {
+ List<DefaultCompletionData> items = new List<DefaultCompletionData>();
+
+ string name = GetName(line);
+ if (!String.IsNullOrEmpty(name))
+ {
+ try
+ {
+ foreach (string member in memberProvider.GetMemberNames(name))
+ {
+ items.Add(new DefaultCompletionData(member, String.Empty, 0)); //ClassBrowserIconService.MethodIndex));
+ }
+ }
+ catch
+ {
+ // Do nothing.
+ }
+ }
+ return items.ToArray();
+ }
+
+ string GetName(string text)
+ {
+ int startIndex = text.LastIndexOf(' ');
+ return text.Substring(startIndex + 1);
+ }
+
+ /// <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 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);
+
+ return data.InsertAction(textArea, key);
+ }
+ }
+}
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsoleHost.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsoleHost.cs (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsoleHost.cs 2012-10-26 08:49:03 UTC (rev 7157)
@@ -0,0 +1,125 @@
+#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 IronPython.Hosting;
+using IronPython.Runtime;
+using Maestro.AddIn.Scripting.Services;
+using Microsoft.Scripting.Hosting;
+using Microsoft.Scripting.Hosting.Shell;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+
+namespace Maestro.AddIn.Scripting.Lang.Python
+{
+ /// <summary>
+ /// Hosts the python console.
+ /// </summary>
+ public class PythonConsoleHost : ConsoleHost, IDisposable
+ {
+ Thread thread;
+ ITextEditor textEditor;
+ PythonConsole pythonConsole;
+
+ public PythonConsoleHost(ITextEditor textEditor)
+ {
+ this.textEditor = textEditor;
+ }
+
+ protected override Type Provider
+ {
+ get { return typeof(PythonContext); }
+ }
+
+ /// <summary>
+ /// Runs the console host in its own thread.
+ /// </summary>
+ public void Run()
+ {
+ thread = new Thread(RunConsole);
+ thread.Start();
+ }
+
+ public void Dispose()
+ {
+ if (pythonConsole != null)
+ {
+ pythonConsole.Dispose();
+ }
+
+ if (thread != null)
+ {
+ thread.Join();
+ }
+ }
+
+ protected override CommandLine CreateCommandLine()
+ {
+ return new PythonCommandLine();
+ }
+
+ protected override OptionsParser CreateOptionsParser()
+ {
+ return new PythonOptionsParser();
+ }
+
+ /// <remarks>
+ /// After the engine is created the standard output is replaced with our custom Stream class so we
+ /// can redirect the stdout to the text editor window.
+ /// This can be done in this method since the Runtime object will have been created before this method
+ /// is called.
+ /// </remarks>
+ protected override IConsole CreateConsole(ScriptEngine engine, CommandLine commandLine, ConsoleOptions options)
+ {
+ SetOutput(new PythonOutputStream(textEditor));
+ pythonConsole = new PythonConsole(textEditor, commandLine);
+
+ engine.Runtime.Globals.SetVariable("app", new HostApplication());
+
+ return pythonConsole;
+ }
+
+ protected virtual void SetOutput(PythonOutputStream stream)
+ {
+ Runtime.IO.SetOutput(stream, Encoding.UTF8);
+ }
+
+ /// <summary>
+ /// Runs the console.
+ /// </summary>
+ void RunConsole()
+ {
+ Run(new string[0]);
+ }
+ }
+}
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonOutputStream.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonOutputStream.cs (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonOutputStream.cs 2012-10-26 08:49:03 UTC (rev 7157)
@@ -0,0 +1,102 @@
+#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 System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+
+namespace Maestro.AddIn.Scripting.Lang.Python
+{
+ public class PythonOutputStream : Stream
+ {
+ ITextEditor textEditor;
+
+ public PythonOutputStream(ITextEditor textEditor)
+ {
+ this.textEditor = textEditor;
+ }
+
+ public override bool CanRead
+ {
+ get { return false; }
+ }
+
+ public override bool CanSeek
+ {
+ get { return false; }
+ }
+
+ public override bool CanWrite
+ {
+ get { return true; }
+ }
+
+ public override long Length
+ {
+ get { return 0; }
+ }
+
+ public override long Position
+ {
+ get { return 0; }
+ set { }
+ }
+
+ public override void Flush()
+ {
+ }
+
+ public override long Seek(long offset, SeekOrigin origin)
+ {
+ return 0;
+ }
+
+ public override void SetLength(long value)
+ {
+ }
+
+ public override int Read(byte[] buffer, int offset, int count)
+ {
+ return 0;
+ }
+
+ /// <summary>
+ /// Assumes the bytes are UTF8 and writes them to the text editor.
+ /// </summary>
+ public override void Write(byte[] buffer, int offset, int count)
+ {
+ string text = UTF8Encoding.UTF8.GetString(buffer, offset, count);
+ textEditor.Write(text);
+ }
+ }
+}
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/TextEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/TextEditor.cs (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/TextEditor.cs 2012-10-26 08:49:03 UTC (rev 7157)
@@ -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.AddIn.Scripting.Lang.Python
+{
+ 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.AddIn.Scripting/Maestro.AddIn.Scripting.csproj
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Maestro.AddIn.Scripting.csproj 2012-10-25 15:08:19 UTC (rev 7156)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Maestro.AddIn.Scripting.csproj 2012-10-26 08:49:03 UTC (rev 7157)
@@ -69,20 +69,26 @@
<Link>SignedAssemblyInfo2.cs</Link>
</Compile>
<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>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
- <Compile Include="Services\ScriptingService.cs" />
<Compile Include="Services\ScriptingClasses.cs" />
<Compile Include="Strings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Strings.resx</DependentUpon>
</Compile>
- <Compile Include="UI\IPEWrapper.cs" />
<Compile Include="UI\IronPythonPreferences.cs">
<SubType>UserControl</SubType>
</Compile>
@@ -95,21 +101,13 @@
<Compile Include="UI\IronPythonRepl.Designer.cs">
<DependentUpon>IronPythonRepl.cs</DependentUpon>
</Compile>
- <Compile Include="UI\IronTextBox.cs">
- <SubType>Component</SubType>
- </Compile>
- <Compile Include="UI\Paths.cs" />
- <Compile Include="UI\TextWindow.cs">
- <SubType>Form</SubType>
- </Compile>
- <Compile Include="UI\TextWindow.Designer.cs">
- <DependentUpon>TextWindow.cs</DependentUpon>
- </Compile>
</ItemGroup>
<ItemGroup>
<Content Include="Manifest.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
+ <None Include="Resources\block.png" />
+ <None Include="Resources\Python.xshd" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Maestro.Base\Maestro.Base.csproj">
@@ -136,6 +134,10 @@
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
<Name>ICSharpCode.Core</Name>
</ProjectReference>
+ <ProjectReference Include="..\Thirdparty\SharpDevelop\ICSharpCode.TextEditor\ICSharpCode.TextEditor.csproj">
+ <Project>{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}</Project>
+ <Name>ICSharpCode.TextEditor</Name>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
@@ -153,9 +155,6 @@
<EmbeddedResource Include="UI\IronPythonRepl.resx">
<DependentUpon>IronPythonRepl.cs</DependentUpon>
</EmbeddedResource>
- <EmbeddedResource Include="UI\TextWindow.resx">
- <DependentUpon>TextWindow.cs</DependentUpon>
- </EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Manifest.addin
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Manifest.addin 2012-10-25 15:08:19 UTC (rev 7156)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Manifest.addin 2012-10-26 08:49:03 UTC (rev 7157)
@@ -23,11 +23,6 @@
<Class id="IPyPrefs" class="Maestro.AddIn.Scripting.UI.IronPythonPreferences" />
</Path>
- <!-- Application-level services -->
- <Path name="/Maestro/ApplicationServices">
- <Class id="ScriptingService" class="Maestro.AddIn.Scripting.Services.ScriptingService" />
- </Path>
-
<!-- Singleton view content -->
<Path name="/Maestro/Shell/SingleViewContent">
<Class id="IronPythonRepl" class="Maestro.AddIn.Scripting.UI.IronPythonRepl" />
Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.Designer.cs 2012-10-25 15:08:19 UTC (rev 7156)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.Designer.cs 2012-10-26 08:49:03 UTC (rev 7157)
@@ -59,5 +59,25 @@
resourceCulture = value;
}
}
+
+ /// <summary>
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ /// </summary>
+ internal static System.Drawing.Bitmap block {
+ get {
+ object obj = ResourceManager.GetObject("block", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized resource of type System.Byte[].
+ /// </summary>
+ internal static byte[] Python {
+ get {
+ object obj = ResourceManager.GetObject("Python", resourceCulture);
+ return ((byte[])(obj));
+ }
+ }
}
}
Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.resx 2012-10-25 15:08:19 UTC (rev 7156)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.resx 2012-10-26 08:49:03 UTC (rev 7157)
@@ -117,4 +117,11 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
+ <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <data name="block" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>..\Resources\block.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+ </data>
+ <data name="Python" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>..\Resources\Python.xshd;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </data>
</root>
\ No newline at end of file
Property changes on: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Resources
___________________________________________________________________
Added: bugtraq:number
+ true
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Resources/Python.xshd
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Resources/Python.xshd (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Resources/Python.xshd 2012-10-26 08:49:03 UTC (rev 7157)
@@ -0,0 +1,100 @@
+<SyntaxDefinition name="Python" extensions=".py">
+
+ <Properties>
+ <Property name="LineComment" value="#"/>
+ </Properties>
+
+ <Digits name="Digits" color="DarkBlue"/>
+
+ <RuleSets>
+ <RuleSet ignorecase="false">
+
+ <Delimiters>()[]{}@,:.`=;+-*/% &|^><</Delimiters>
+
+ <Span name="Char" stopateol="true" color="Magenta" escapecharacter="\">
+ <Begin>'</Begin>
+ <End>'</End>
+ </Span>
+
+ <Span name="DocComment" color="Green">
+ <Begin>"""</Begin>
+ <End>"""</End>
+ </Span>
+
+ <Span name="LineComment" stopateol="true" color="Green">
+ <Begin>#</Begin>
+ </Span>
+
+ <Span name="String" stopateol="true" color="Blue" escapecharacter="\">
+ <Begin>"</Begin>
+ <End>"</End>
+ </Span>
+
+ <MarkPrevious bold="true" color="MidnightBlue">(</MarkPrevious>
+
+ <KeyWords name="BuiltInStatements" bold="true" color="MidnightBlue">
+ <Key word="assert"/>
+ <Key word="del"/>
+ <Key word="exec"/>
+ <Key word="global"/>
+ <Key word="lambda"/>
+ <Key word="print"/>
+ </KeyWords>
+
+ <KeyWords name="ClassStatement" color="Blue" bold="true">
+ <Key word="class"/>
+ </KeyWords>
+
+ <KeyWords name="ExceptionHandlingStatements" bold="true" color="Teal">
+ <Key word="except"/>
+ <Key word="finally"/>
+ <Key word="raise"/>
+ <Key word="try"/>
+ </KeyWords>
+
+ <KeyWords name="FunctionDefinition" bold="true" color="Blue">
+ <Key word="def"/>
+ </KeyWords>
+
+ <KeyWords name="Imports" bold="true" color="Green">
+ <Key word="import"/>
+ <Key word="from"/>
+ </KeyWords>
+
+ <KeyWords name="IterationStatements" bold="true" color="Blue">
+ <Key word="for"/>
+ <Key word="in"/>
+ <Key word="while"/>
+ </KeyWords>
+
+ <KeyWords name="JumpStatements" color="Navy">
+ <Key word="break"/>
+ <Key word="continue"/>
+ <Key word="yield"/>
+ <Key word="return"/>
+ </KeyWords>
+
+ <KeyWords name="OperatorStatements" bold="true" color="DarkCyan">
+ <Key word="and"/>
+ <Key word="as"/>
+ <Key word="is"/>
+ <Key word="not"/>
+ <Key word="or"/>
+ </KeyWords>
+
+ <KeyWords name="PassStatement" color="Gray">
+ <Key word="pass"/>
+ </KeyWords>
+
+ <KeyWords name="SelectionStatements" bold="true" color="Blue">
+ <Key word="elif"/>
+ <Key word="else"/>
+ <Key word="if"/>
+ </KeyWords>
+
+ <KeyWords name="WithStatement" color="DarkViolet">
+ <Key word="with"/>
+ </KeyWords>
+ </RuleSet>
+ </RuleSets>
+</SyntaxDefinition>
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Resources/block.png
===================================================================
(Binary files differ)
Property changes on: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Resources/block.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Services/ScriptingClasses.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Services/ScriptingClasses.cs 2012-10-25 15:08:19 UTC (rev 7156)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Services/ScriptingClasses.cs 2012-10-26 08:49:03 UTC (rev 7157)
@@ -28,6 +28,7 @@
using Maestro.Base.Services;
using System.IO;
using Maestro.Editors.Common;
+using Microsoft.Scripting.Hosting.Shell;
namespace Maestro.AddIn.Scripting.Services
{
Deleted: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Services/ScriptingService.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Services/ScriptingService.cs 2012-10-25 15:08:19 UTC (rev 7156)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Services/ScriptingService.cs 2012-10-26 08:49:03 UTC (rev 7157)
@@ -1,76 +0,0 @@
-#region Disclaimer / License
-// Copyright (C) 2011, Jackie Ng
-// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
-//
-// 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 System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Maestro.Shared.UI;
-using Microsoft.Scripting.Hosting;
-using IronPython.Hosting;
-using ICSharpCode.Core;
-
-namespace Maestro.AddIn.Scripting.Services
-{
- public class ScriptingService : ServiceBase
- {
- private ScriptEngine _pyEngine;
- private ScriptScope _pyGlobalScope;
-
- public override void Initialize()
- {
- base.Initialize();
- _pyEngine = CreateDefaultEngine();
- _pyGlobalScope = _pyEngine.CreateScope();
- InitializeScope(_pyGlobalScope);
- }
-
- private void InitializeScope(ScriptScope scope)
- {
- scope.SetVariable("app", new HostApplication()); //NOXLATE
- }
-
- private static ScriptEngine CreateDefaultEngine()
- {
- return Python.CreateEngine();
- }
-
- /// <summary>
- /// Evaluates the given expression
- /// </summary>
- /// <param name="expression"></param>
- /// <returns></returns>
- public dynamic Evaluate(string expression)
- {
- return _pyEngine.Execute(expression, _pyGlobalScope);
- }
-
- /// <summary>
- /// Compiles and executes the script from the given file
- /// </summary>
- /// <param name="file"></param>
- /// <returns></returns>
- public dynamic CompileAndExecute(string file)
- {
- var source = _pyEngine.CreateScriptSourceFromFile(file);
- var compiled = source.Compile();
- return compiled.Execute(_pyGlobalScope);
- }
- }
-}
Deleted: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IPEWrapper.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IPEWrapper.cs 2012-10-25 15:08:19 UTC (rev 7156)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IPEWrapper.cs 2012-10-26 08:49:03 UTC (rev 7157)
@@ -1,128 +0,0 @@
-//---------------------------------------------------------------------------------
-//IPEWrapper.cs - version 2.7.6.0r
-//BY DOWNLOADING AND USING, YOU AGREE TO THE FOLLOWING TERMS:
-//Copyright (c) 2006-2008 by Joseph P. Socoloski III
-//LICENSE
-//Permission is hereby granted, free of charge, to any person obtaining a copy
-//of this software and associated documentation files (the "Software"), to deal
-//in the Software without restriction, including without limitation the rights
-//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-//copies of the Software, and to permit persons to whom the Software is
-//furnished to do so, subject to the following conditions:
-//
-//The above copyright notice and this permission notice shall be included in
-//all copies or substantial portions of the Software.
-//the MIT License, given here: <http://www.opensource.org/licenses/mit-license.php>
-//---------------------------------------------------------------------------------
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.IO;
-
-namespace Maestro.AddIn.Scripting.UI
-{
- public delegate void Response(string text);
-
- public class IPEStreamWrapper : Stream
- {
- MemoryStream _stream = new MemoryStream();
- Response _response;
-
- public IPEStreamWrapper(Response response)
- {
- _response = response;
- }
-
- public override bool CanRead
- {
- get { return false; }
- }
-
- public override bool CanSeek
- {
- get { return false; }
- }
-
- public override bool CanWrite
- {
- get { return _stream.CanWrite; }
- }
-
- public override long Length
- {
- get { return _stream.Length; }
- }
-
- public override long Position
- {
- get
- {
- return _stream.Position;
- }
- set
- {
- _stream.Position = value;
- }
- }
-
- public override void Flush()
- {
- _stream.Flush();
-
- _stream.Seek(0, SeekOrigin.Begin);
- StreamReader sr = new StreamReader(_stream, Encoding.ASCII);
- _response(sr.ReadToEnd());
- sr.Close();
- _stream = new MemoryStream();
- }
-
- public override long Seek(long offset, SeekOrigin origin)
- {
- return _stream.Seek(offset, origin);
- }
-
- public override void SetLength(long value)
- {
- _stream.SetLength(value);
- }
-
- public override int Read(byte[] buffer, int offset, int count)
- {
- return _stream.Read(buffer, offset, count);
- }
-
- public override void Write(byte[] buffer, int offset, int count)
- {
- _stream.Write(buffer, offset, count);
- }
-
- public static StringBuilder sbOutput = new StringBuilder();
-
- /// <summary>
- /// Method that allows capture of IronPython output
- /// </summary>
- /// <param name="text"></param>
- public static void IPEngineResponse(string text)
- {
-
- if (!string.IsNullOrEmpty(text.Trim()))
- {
- //sbOutput.Remove(0, sbOutput.Length); //Clear
- //to support newline for textbox use
- text = text.Replace("\\n", "\r\n"); //NOXLATE
- sbOutput.Append(text + Environment.NewLine);
- }
- }
-
- public static object retobject = new object();
- /// <summary>
- /// Method that allows capture of IronPython output
- /// </summary>
- /// <param name="text"></param>
- public static void IPEngineResponseO(object o)
- {
- Type itstype = o.GetType();
- retobject = o;
- }
- }
-}
Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.Designer.cs 2012-10-25 15:08:19 UTC (rev 7156)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.Designer.cs 2012-10-26 08:49:03 UTC (rev 7157)
@@ -28,18 +28,31 @@
/// </summary>
private void InitializeComponent()
{
+ this.textEditorControl = new ICSharpCode.TextEditor.TextEditorControl();
this.SuspendLayout();
//
+ // textEditorControl
+ //
+ this.textEditorControl.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.textEditorControl.IsReadOnly = false;
+ this.textEditorControl.Location = new System.Drawing.Point(0, 0);
+ this.textEditorControl.Name = "textEditorControl";
+ this.textEditorControl.Size = new System.Drawing.Size(594, 299);
+ this.textEditorControl.TabIndex = 0;
+ //
// IronPythonRepl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.textEditorControl);
this.Name = "IronPythonRepl";
- this.Size = new System.Drawing.Size(638, 277);
+ this.Size = new System.Drawing.Size(594, 299);
this.ResumeLayout(false);
}
#endregion
+
+ private ICSharpCode.TextEditor.TextEditorControl textEditorControl;
}
}
Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs 2012-10-25 15:08:19 UTC (rev 7156)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs 2012-10-26 08:49:03 UTC (rev 7157)
@@ -1,23 +1,4 @@
-#region Disclaimer / License
-// Copyright (C) 2012, Jackie Ng
-// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
-//
-// 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 System;
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
@@ -29,25 +10,31 @@
namespace Maestro.AddIn.Scripting.UI
{
+ using Lang.Python;
+
public partial class IronPythonRepl : SingletonViewContent
{
- private IronTextBoxControl _console;
+ private TextEditor textEditor;
+ private PythonConsoleHost host;
public IronPythonRepl()
{
InitializeComponent();
- _console = new IronTextBoxControl();
- _console.Prompt = ">>>"; //NOXLATE
- _console.Dock = DockStyle.Fill;
- this.Controls.Add(_console);
+ textEditorControl.CreateControl();
+ //TODO: Setup python syntax highlighting
+
this.Title = this.Description = Strings.Title_IronPython_Console;
+ this.Disposed += OnDisposed;
+
+ textEditor = new TextEditor(textEditorControl);
+ host = new PythonConsoleHost(textEditor);
+ host.Run();
}
- protected override void OnLoad(EventArgs e)
+ void OnDisposed(object sender, EventArgs e)
{
- _console.WriteText("help" + Environment.NewLine); //NOXLATE
- _console.SimEnter();
+ host.Dispose();
}
public override ViewRegion DefaultRegion
Deleted: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronTextBox.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronTextBox.cs 2012-10-25 15:08:19 UTC (rev 7156)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronTextBox.cs 2012-10-26 08:49:03 UTC (rev 7157)
@@ -1,1788 +0,0 @@
-//---------------------------------------------------------------------------------
-//IronTextBox.cs - version 2.0.2.0b
-// TextBox control based class designed to be used with Microsoft's IronPython.
-// Maybe useful for testing Python scripts with IronPython.
-//WHAT'S NEW:
-// -Updated License from GNU to Expat/MIT
-// -Tested with IronPython 2.03B
-//TO DO:
-// -Fix raw_input support: "s = raw_input('--> ')"
-// -Multiple arg support for "paths" command. eg. "paths -misc -python24"
-// -Intellisense ToolTip
-//
-//BY DOWNLOADING AND USING, YOU AGREE TO THE FOLLOWING TERMS:
-//Copyright (c) 2006-2008 by Joseph P. Socoloski III
-//LICENSE
-//Permission is hereby granted, free of charge, to any person obtaining a copy
-//of this software and associated documentation files (the "Software"), to deal
-//in the Software without restriction, including without limitation the rights
-//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-//copies of the Software, and to permit persons to whom the Software is
-//furnished to do so, subject to the following conditions:
-//
-//The above copyright notice and this permission notice shall be included in
-//all copies or substantial portions of the Software.
-//the MIT License, given here: <http://www.opensource.org/licenses/mit-license.php>
-//---------------------------------------------------------------------------------
-
-using System;
-using System.IO;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Data;
-using System.Text;
-using System.Windows.Forms;
-using System.ComponentModel;//ToolboxItem
-using System.Drawing; //ToolboxBitmap
-using IronPython.Runtime; //PythonDictionary
-using IronPython.Hosting; //PythonEngine
-using Microsoft.Scripting; //ScriptDomainManager
-using Microsoft.Scripting.Hosting;
-using OSGeo.MapGuide.MaestroAPI;
-
-namespace Maestro.AddIn.Scripting.UI
-{
- #region IronTextBox Class
- [ToolboxItem(true)]
- [ToolboxBitmap(typeof(IronTextBox))]
- [DesignerAttribute(typeof(IronTextBoxControl))]
- internal class IronTextBox : TextBox
- {
- #region IronTextBox members
- /// <summary>
- /// Default prompt text.
- /// </summary>
- private string prompt = ">>>"; //NOXLATE
-
- /// <summary>
- /// Used for storing commands.
- /// </summary>
- private CommandHistory commandHistory = new CommandHistory();
-
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.Container components = null;
-
- /// <summary>
- /// Holds temporary defFunc lines.
- /// </summary>
- public System.Text.StringBuilder defStmtBuilder = new System.Text.StringBuilder();
-
- /// <summary>
- /// StringCollection of all MiscDirs
- /// </summary>
- public static StringCollection scMisc = new StringCollection();
-
- /// <summary>
- /// StringCollection of all Python24Dirs
- /// </summary>
- public static StringCollection scPython24 = new StringCollection();
-
- /// <summary>
- /// StringCollection of all IronPythonDirs
- /// </summary>
- public static StringCollection scIronPython = new StringCollection();
-
- /// <summary>
- /// Intellisense ToolTip.
- /// </summary>
- System.Windows.Forms.ToolTip intellisense = new System.Windows.Forms.ToolTip();
-
- /// <summary>
- /// True if currently processing raw_text()
- /// </summary>
- public static Boolean IsRawInput = false;
-
- /// <summary>
- /// Hold raw_input prompt by user
- /// </summary>
- public string rawprompt = "";
-
- #endregion IronTextBox members
-
- internal IronTextBox()
- {
- InitializeComponent();
- printPrompt();
-
- // Set up the delays for the ToolTip.
- intellisense.AutoPopDelay = 1000;
- intellisense.InitialDelay = 100;
- intellisense.ReshowDelay = 100;
- // Force the ToolTip text to be displayed whether or not the form is active.
- intellisense.ShowAlways = true;
-
- }
-
- #region Overrides
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose(disposing);
- }
-
- /// <summary>
- /// Overridden to protect against deletion of contents
- /// cutting the text and deleting it from the context menu
- /// </summary>
- /// <param name="m"></param>
- protected override void WndProc(ref Message m)
- {
- switch (m.Msg)
- {
- case 0x0302: //WM_PASTE
- case 0x0300: //WM_CUT
- case 0x000C: //WM_SETTEXT
- if (!IsCaretAtWritablePosition())
- MoveCaretToEndOfText();
- break;
- case 0x0303: //WM_CLEAR
- return;
- }
- base.WndProc(ref m);
- }
- #endregion Overrides
-
- #region Component Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.SuspendLayout();
- //
- // consoleTextBox
- //
- this.BackColor = Color.White;
- this.Dock = DockStyle.Fill;
- this.Location = new Point(0, 0);
- this.MaxLength = 0;
- this.Multiline = true;
- this.Name = "consoleTextBox";
- this.AcceptsTab = true;
- this.AcceptsReturn = true; //for TextBox use
- this.ScrollBars = System.Windows.Forms.ScrollBars.Both; //for TextBox use
- //this.ScrollBars = RichTextBoxScrollBars.Both; //for RichTextBox use
- this.Size = new Size(400, 176);
- this.TabIndex = 0;
- this.Text = "";
- this.KeyPress += new KeyPressEventHandler(this.consoleTextBox_KeyPress);
- this.KeyDown += new KeyEventHandler(ConsoleControl_KeyDown);
- //
- // IronTextBoxControl
- //
- this.Name = "IronTextBox";
- this.Size = new Size(400, 176);
- this.ResumeLayout(false);
-
- }
- #endregion
-
- #region IronTextBox Base Methods
- /// <summary>
- /// Sends the prompt to the IronTextBox
- /// </summary>
- public void printPrompt()
- {
- string currentText = this.Text;
-
- //add newline if it does not exist
- if ((currentText.Length != 0) && (currentText[currentText.Length - 1] != '\n'))
- printLine();
-
- //add the prompt
- this.AddText(prompt);
- }
-
- /// <summary>
- /// Sends a newline character to the IronTextBox
- /// </summary>
- public void printLine()
- {
- this.AddText(System.Environment.NewLine);
- }
-
- /// <summary>
- /// Returns currentline's text string
- /// </summary>
- /// <returns>Returns currentline's text string</returns>
- public string GetTextAtPrompt()
- {
- if (GetCurrentLine() != "")
- return GetCurrentLine().Substring(prompt.Length);
- else
- {
- string mystring = (string)this.Lines.GetValue(this.Lines.Length - 2);
- return mystring.Substring(prompt.Length);
- }
- }
-
- /// <summary>
- /// Add a command to IronTextBox command history.
- /// </summary>
- /// <param name="currentCommand">IronTextBox command line</param>
- public void AddcommandHistory(string currentCommand)
- {
- commandHistory.Add(currentCommand);
- }
-
- /// <summary>
- /// Returns true if Keys.Enter
- /// </summary>
- /// <param name="key">Keys</param>
- /// <returns>Returns true if Keys.Enter</returns>
- private bool IsTerminatorKey(System.Windows.Forms.Keys key)
- {
- return key == Keys.Enter;
- }
-
- /// <summary>
- /// Returns true if (char)13 '\r'
- /// </summary>
- /// <param name="keyChar">char of keypressed</param>
- /// <returns>Returns true if (char)13 '\r'</returns>
- private bool IsTerminatorKey(char keyChar)
- {
- return ((int)keyChar) == 13;
- }
-
- /// <summary>
- /// Returns the current line, including prompt.
- /// </summary>
- /// <returns>Returns the current line, including prompt.</returns>
- private string GetCurrentLine()
- {
- if (this.Lines.Length > 0)
- {
- return (string)this.Lines.GetValue(this.Lines.GetLength(0) - 1);
- }
- else
- return string.Empty;
- }
-
- /// <summary>
- /// Replaces the text at the current prompt.
- /// </summary>
- /// <param name="text">new text to replace old text.</param>
- private void ReplaceTextAtPrompt(string text)
- {
- string currentLine = GetCurrentLine();
- int charactersAfterPrompt = currentLine.Length - prompt.Length;
-
- if (charactersAfterPrompt == 0)
- this.AddText(text);
- else
- {
- this.Select(this.TextLength - charactersAfterPrompt, charactersAfterPrompt);
- this.SelectedText = text;
- }
- }
-
- /// <summary>
- /// Returns true if caret is positioned on the currentline.
- /// </summary>
- /// <returns>Returns true if caret is positioned on the currentline.</returns>
- private bool IsCaretAtCurrentLine()
- {
- return this.TextLength - this.SelectionStart <= GetCurrentLine().Length;
- }
-
- /// <summary>
- /// Adds text to the IronTextBox
- /// </summary>
- /// <param name="text">text to be added</param>
- private void AddText(string text)
- {
- //Optional////////////
- scollection.Add(text); //Optional
- //this.Text = StringCollecttostring(scollection); //Optional
- //////////////////////
-
- this.Enabled = false;
- this.Text += text;
- MoveCaretToEndOfText();
- this.Enabled = true;
- this.Focus();
- this.Update();
- }
-
- /// <summary>
- /// Returns a string retrieved from a StringCollection.
- /// </summary>
- /// <param name="inCol">StringCollection to be searched.</param>
- public string StringCollecttostring(System.Collections.Specialized.StringCollection inCol)
- {
- string value = "";
- System.Collections.Specialized.StringEnumerator myEnumerator = inCol.GetEnumerator();
- while (myEnumerator.MoveNext())
- {
- value += myEnumerator.Current;
- }
-
- return value;
- }
-
- /// <summary>
- /// Move caret to the end of the current text.
- /// </summary>
- private void MoveCaretToEndOfText()
- {
- this.SelectionStart = this.TextLength;
- this.ScrollToCaret();
- }
-
- /// <summary>
- /// Returns true is the caret is just before the current prompt.
- /// </summary>
- /// <returns></returns>
- private bool IsCaretJustBeforePrompt()
- {
- return IsCaretAtCurrentLine() && GetCurrentCaretColumnPosition() == prompt.Length;
- }
-
- /// <summary>
- /// Returns the column position. Useful for selections.
- /// </summary>
- /// <returns></returns>
- private int GetCurrentCaretColumnPosition()
- {
- string currentLine = GetCurrentLine();
- int currentCaretPosition = this.SelectionStart;
- return (currentCaretPosition - this.TextLength + currentLine.Length);
- }
-
- /// <summary>
- /// Is the caret at a writable position.
- /// </summary>
- /// <returns></returns>
- private bool IsCaretAtWritablePosition()
- {
- return IsCaretAtCurrentLine() && GetCurrentCaretColumnPosition() >= prompt.Length;
- }
-
- /// <summary>
- /// Sets the text of the prompt. Default is ">>>"
- /// </summary>
- /// <param name="val">string of new prompt</param>
- public void SetPromptText(string val)
- {
- string currentLine = GetCurrentLine();
- this.Select(0, prompt.Length);
- this.SelectedText = val;
- prompt = val;
- }
-
- /// <summary>
- /// Gets and sets the IronTextBox prompt.
- /// </summary>
- public string Prompt
- {
- get { return prompt; }
- set { SetPromptText(value); }
- }
-
- /// <summary>
- /// Returns the string array of the command history.
- /// </summary>
- /// <returns></returns>
- public string[] GetCommandHistory()
- {
- return commandHistory.GetCommandHistory();
- }
-
- /// <summary>
- /// Adds text to the IronTextBox.
- /// </summary>
- /// <param name="text"></param>
- public void WriteText(string text)
- {
- this.AddText(text);
- }
-
- #region IronTextBox Events
- /// <summary>
- /// Handle KeyPress events here.
- /// </summary>
- /// <param name="sender">object</param>
- /// <param name="e">KeyPressEventArgs</param>
- private void consoleTextBox_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
- {
- //If current key is a backspace and is just before prompt, then stay put!
- if (e.KeyChar == (char)8 && IsCaretJustBeforePrompt())
- {
- e.Handled = true;
- return;
- }
-
- //If current key is enter
- if (IsTerminatorKey(e.KeyChar))
- {
- //**ANY CHANGES HERE MUST ALSO BE COPIED TO SimEnter()**
- e.Handled = true;
- string currentCommand = GetTextAtPrompt();
-
- //Optional: add the command to the stringcollection
- scollection.Add(currentCommand);
- ///////////////////////////////////////////////////
-
- //If it is not an empty command, then "fire" the command
- if (currentCommand.Length != 0 && this.defStmtBuilder.Length == 0 && !IsRawInput)
- {
- if (!currentCommand.Trim().Contains("raw_input")) //NOXLATE
- printLine();
- ((IronTextBoxControl)this.Parent).FireCommandEntered(currentCommand);
- commandHistory.Add(currentCommand);
- }
-
- //if we are doing a def statement (currentCommand.EndsWith(":"))
- if (this.defStmtBuilder.Length != 0)
- {
- if (currentCommand.EndsWith(":")) //NOXLATE
- {
- //we are in the first line of a def, it has already printed to console
-
- //autoindent the current autoindent value
- //int asize = Parser.GetNextAutoIndentSize(this.defStmtBuilder.ToString()+"\r\n", 4);
-
- //don't printPrompt();
- ReplaceTextAtPrompt("..." + CreateIndentstring(4)); //NOXLATE
- e.Handled = true;
- return;
-
- }
- else//We are past the first line, and are indenting or ending a def
- {
- this.defStmtBuilder.Append(currentCommand + "\r\n"); //NOXLATE
-
- //if it is an empty command let's see if we just finished a def statement
- if (currentCommand.Trim().Equals(string.Empty)) //NOXLATE
- {
- ((IronTextBoxControl)this.Parent).FireCommandEntered(this.defStmtBuilder.ToString().Trim());
- commandHistory.Add(this.defStmtBuilder.ToString());
-
- //we just finished a def so clear the defbuilder
- this.defStmtBuilder = this.defStmtBuilder.Remove(0, this.defStmtBuilder.Length);
- }
- else
- {
- //don't printPrompt();
- AddText("\r\n..." + CreateIndentstring(4)); //NOXLATE
- e.Handled = true;
- return;
- }
- }
- }
-
- //raw_input support...
- if (currentCommand.Trim().Contains("raw_input(")) //NOXLATE
- {
- IsRawInput = true;
-
- //Note: if raw_input is in quotes this will not work
- //fyi: IronPython.Modules.Builtin.RawInput();
- //remove the "\r\n" from IPEWrapper
- this.Text = this.Text.Remove(this.Text.Length - "\r\n".Length, "\r\n".Length); //NOXLATE
- rawprompt = (string)this.Lines.GetValue(this.Lines.Length - 1);
- MoveCaretToEndOfText();
-
- //AddText(temp);
- e.Handled = true;
- return;
- }
-
- if(IsRawInput)
- {
- string rawcommand = (string)this.Lines.GetValue(this.Lines.Length - 2);
- rawcommand = rawcommand.Replace(Prompt, string.Empty);
- string tempprompt = (string)this.Lines.GetValue(this.Lines.Length - 1);
-
- var iptemp = Python.CreateEngine();
-
- //examine to see what type of raw_input
- if (rawcommand.Trim().Equals("raw_input()")) //NOXLATE
- {
- IsRawInput = false;
- }
- else// s = raw_input('--> ')
- {
- IsRawInput = false;
- rawprompt = string.Empty;
- e.Handled = true;
- printPrompt();
- MoveCaretToEndOfText();
- return;
- }
-
-
- }
-
- //if(GetTextAtPrompt().Trim().Equals(""))
- printPrompt();
- }
-
-
- /*
- // Handle backspace and stringcollection to help the commandhistory accuracy and debugging.
- if (e.KeyChar == (char)8 && (GetStringCollectValue(scollection, scollection.Count - 1).Length == 1) && commandHistory.LastCommand.Contains(GetStringCollectValue(scollection, scollection.Count - 1)))
- {
- scollection.RemoveAt(scollection.Count - 1);
- }*/
-
- }
-
- /// <summary>
- /// Build a string of returning spaces for indenting
- /// </summary>
- /// <param name="indentsize"></param>
- /// <returns></returns>
- public string CreateIndentstring(int indentsize)
- {
- string r = string.Empty;
- for (int i = 0; i < indentsize; i++)
- {
- r += " "; //NOXLATE
- }
- return r;
- }
-
- /// <summary>
- /// KeyEvent control for staying inside the currentline and autocomplete features
- /// </summary>
- /// <param name="sender">object</param>
- /// <param name="e">KeyEventArgs</param>
- private void ConsoleControl_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
- {
- // If the caret is anywhere else, set it back when a key is pressed.
- if (!IsCaretAtWritablePosition() && !(e.Control || IsTerminatorKey(e.KeyCode)))
- {
- MoveCaretToEndOfText();
- }
-
- // Prevent caret from moving before the prompt
- if (e.KeyCode == System.Windows.Forms.Keys.Left && IsCaretJustBeforePrompt() || e.KeyCode == System.Windows.Forms.Keys.Back && IsCaretJustBeforePrompt())
- {
- e.Handled = true;
- }
- else if (e.KeyCode == System.Windows.Forms.Keys.Down)
- {
- if (commandHistory.DoesNextCommandExist())
- {
- ReplaceTextAtPrompt(commandHistory.GetNextCommand());
- }
- e.Handled = true;
- }
- else if (e.KeyCode == System.Windows.Forms.Keys.Up)
- {
- if (commandHistory.DoesPreviousCommandExist())
- {
- ReplaceTextAtPrompt(commandHistory.GetPreviousCommand());
- }
- e.Handled = true;
- }
- else if (e.KeyCode == System.Windows.Forms.Keys.Right)
- {
- // Performs command completion
- string currentTextAtPrompt = GetTextAtPrompt();
- string lastCommand = commandHistory.LastCommand;
-
- //If the last command is not nul and no text at the current prompt or lastcommand starts with the currenttext at the current prompt,
- //then autofill because the right arrow key was pressed.
- if (lastCommand != null && (currentTextAtPrompt.Length == 0 || lastCommand.StartsWith(currentTextAtPrompt)))
- {
- if (lastCommand.Length > currentTextAtPrompt.Length)
- {
- int i = scollection.Count;
- //scollection.Insert(scollection.Count, lastCommand[currentTextAtPrompt.Length].ToString());
- this.AddText(lastCommand[currentTextAtPrompt.Length].ToString());
- }
- }
- }
- }
-
-
- #endregion IronTextBox Events
-
- #endregion IronTextBox Base Methods
-
- #region IronTextBox IronPython Support
- /// <summary>
- /// Stores input commands from IronTextBox
- /// </summary>
- StringCollection input = new StringCollection();
-
- /// <summary>
- /// Stores output generated from IronPython
- /// </summary>
- StringCollection output = new StringCollection();
-
- #endregion IronTextBox IronPython Support
-
- #region StringCollection support
- /// <summary>
- /// Commands and strings from IronTextBox.AddText() gets stored here
- /// Status: Currently not used 3/12/06 11:16am
- /// </summary>
- System.Collections.Specialized.StringCollection scollection = new System.Collections.Specialized.StringCollection();
-
- /// <summary>
- /// Returns a string retrieved from a StringCollection.
- /// </summary>
- /// <param name="inCol">StringCollection to be searched.</param>
- /// <param name="index">index of StringCollection to retrieve.</param>
- public string GetStringCollectValue(System.Collections.Specialized.StringCollection inCol, int index)
- {
- string value = string.Empty;
- int count = 0;
- System.Collections.Specialized.StringEnumerator myEnumerator = inCol.GetEnumerator();
- while (myEnumerator.MoveNext())
- {
- if (index == count)
- {
- value = myEnumerator.Current;
- }
-
- count = count + 1;
- }
-
- return value;
- }
- #endregion StringCollection support
- }
- #endregion IronTextBox Class
-
- #region IronTextBoxControl Class
- /// <summary>
- /// Summary description for IronTextBoxControl.
- /// </summary>
- public class IronTextBoxControl : UserControl
- {
- #region IronTextBoxControl members
- /// <summary>
- /// Main IronPython ScriptEngine
- /// </summary>
- public ScriptEngine engine;
-
- /// <summary>
- /// Main IronPython ScriptScope
- /// </summary>
- public ScriptScope scope;
-
- /// <summary>
- /// The IronTextBox member.
- /// </summary>
- private IronTextBox consoleTextBox;
-
- /// <summary>
- /// The CommandEntered event
- /// </summary>
- public event EventCommandEntered CommandEntered;
-
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private Container components = null;
-
- /// <summary>
- /// Adds def lines one by one.
- /// </summary>
- public StringBuilder defBuilder
- {
- get { return consoleTextBox.defStmtBuilder; }
- set
- {
- if (consoleTextBox != null)
- consoleTextBox.defStmtBuilder = value;
- }
- }
-
- /// <summary>
- /// Returns the string array of the command history.
- /// </summary>
- /// <returns></returns>
- public string[] GetCommandHistory()
- {
- return consoleTextBox.GetCommandHistory();
- }
-
- /// <summary>
- /// Gets and sets console text ForeColor.
- /// </summary>
- public Color ConsoleTextForeColor
- {
- get { return consoleTextBox != null ? consoleTextBox.ForeColor : Color.Black; }
- set
- {
- if (consoleTextBox != null)
- consoleTextBox.ForeColor = value;
- }
- }
-
- /// <summary>
- /// Gets and sets console text BackColor.
- /// </summary>
- public Color ConsoleTextBackColor
- {
- get { return consoleTextBox != null ? consoleTextBox.BackColor : Color.White; }
- set
- {
- if (consoleTextBox != null)
- consoleTextBox.BackColor = value;
- }
- }
-
- /// <summary>
- /// Gets and sets console Font.
- /// </summary>
- public Font ConsoleTextFont
- {
- get { return consoleTextBox != null ? consoleTextBox.Font : new Font("Lucida Console", 8); }
- set
- {
- if (consoleTextBox != null)
- consoleTextBox.Font = value;
- }
- }
-
- /// <summary>
- /// Gets and sets string to be used for the Prompt.
- /// </summary>
- public string Prompt
- {
- get { return consoleTextBox.Prompt; }
- set { consoleTextBox.Prompt = value; }
- }
- #endregion IronTextBoxControl members
-
- /// <summary>
- /// IronTextBoxControl
- /// </summary>
- public IronTextBoxControl()
- {
- InitializeComponent();
-
- //Create the ScriptRuntime
- engine = Python.CreateEngine(); //ScriptRuntime.Create().GetEngine("py");
- //Create the scope for the ScriptEngine
- scope = engine.CreateScope();
- //Expose our host application
- scope.SetVariable("app", new Services.HostApplication()); //NOXLATE
- //IronTextBox's CommandEntered event
- CommandEntered += new EventCommandEntered(irontextboxControl_CommandEntered);
- }
-
- /// <summary>
- /// Executes the Python file within the IronTextBox environment.
- /// A nice way to quickly get a Python module in CLI to test or use.
- /// </summary>
- /// <param name="pyfile">Python file (.py)</param>
- /// <returns>object</returns>
- object DoIPExecuteFile(string pyfile)
- {
- ScriptSource source = engine.CreateScriptSourceFromFile(pyfile);
- return source.Execute(scope);
- }
-
- /// <summary>
- /// Executes the code in SourceCodeKind.SingleStatement to fire the command event
- /// Use DoIPEvaluate if you do not wish to fire the command event
- /// </summary>
- /// <param name="pycode">python statement</param>
- /// <returns>object</returns>
- object DoIPExecute(string pycode)
- {
- ScriptSource source = engine.CreateScriptSourceFromString(pycode, SourceCodeKind.SingleStatement);
- return source.Execute(scope);
- }
-
- /// <summary>
- /// Executes the code in SourceCodeKind.Expression not to fire the command event
- /// Use DoIPExecute if you do wish to fire the command event
- /// </summary>
- /// <param name="pycode">Python expression</param>
- /// <returns>object</returns>
- object DoIPEvaluate(string pycode)
- {
- ScriptSource source = engine.CreateScriptSourceFromString(pycode, SourceCodeKind.Expression);
- return source.Execute(scope);
- }
-
- /// <summary>
- /// irontextboxControl_CommandEntered
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void irontextboxControl_CommandEntered(object sender, CommandEnteredEventArgs e)
- {
- string command = e.Command.TrimEnd();
-
- engine.Runtime.IO.SetOutput(new IPEStreamWrapper(IPEStreamWrapper.IPEngineResponse), engine.Runtime.IO.InputEncoding);
-
- //Create a temp object to use
- //object tempobject;
-
- //Begin IronTextBox evaluation if something there....
- if (command != string.Empty)
- {
- if (command == "cls") //NOXLATE
- this.Clear();
- else if (command.StartsWith("refl ")) //NOXLATE
- this.ReflectIdentifier(command.Substring(5), false);
- else if (command.StartsWith("reflw ")) //NOXLATE
- this.ReflectIdentifier(command.Substring(6), true);
- else if (command.StartsWith("printw ")) //NOXLATE
- this.PrintIdentifier(command.Substring(7), true);
- else if (command == "history") //NOXLATE
- {
- string[] commands = this.GetCommandHistory();
- StringBuilder stringBuilder = new StringBuilder(commands.Length);
- foreach (string s in commands)
- {
- stringBuilder.Append(s);
- stringBuilder.Append(System.Environment.NewLine);
- }
- this.WriteText(stringBuilder.ToString());
- }
- else if (command == "help") //NOXLATE
- {
- this.WriteText(GetHelpText());
- }
- else if (command == "newconsole") //NOXLATE
- {
- //consoleTextBox.global_eng = new PythonEngine();
- this.WriteText("Not currently supported\r\n"); //NOXLATE
- }
- else if (command.StartsWith("prompt") && command.Length == 6)
- {
- string[] parts = command.Split(new char[] { '=' }); //NOXLATE
- if (parts.Length == 2 && parts[0].Trim() == "prompt") //NOXLATE
- this.Prompt = parts[1].Trim();
- }
- else if (command == "btaf") //NOXLATE
- {
- //btaf = Browse To Append File....
- //Check to see if sys is loaded
- if (!DoIPEvaluate("dir()").ToString().Contains("sys")) //NOXLATE
- {
- consoleTextBox.printPrompt();
- consoleTextBox.WriteText("import sys"); //NOXLATE
- this.SimEnter();
- }
-
- System.Windows.Forms.FolderBrowserDialog ofd = new System.Windows.Forms.FolderBrowserDialog();
- ofd.SelectedPath = Paths.MiscDirs.vs_Projects;
- ofd.ShowDialog();
- consoleTextBox.printPrompt();
- consoleTextBox.WriteText("sys.path.append(\"" + ofd.SelectedPath + "\")"); //NOXLATE
- this.SimEnter();
- }
- else if (command == "runfile") //NOXLATE
- {
- //runfile - Run a .Py file. Calls OpenFileDialog to PythonEngine.RunFile....
- // goodfor debuging .y file within IDE
- this.Runfile();
- }
- else if (command == "btwfi") //NOXLATE
- {
- //btwfi - Browse To Walk FIle. Calls OpenFileDialog.
- this.WalkPythonFile();
- }
- else if (command == "rew") //NOXLATE
- {
- //btwfi - Browse To Walk FIle. Calls OpenFileDialog.
- StringBuilder SBCode = new StringBuilder();
- this.RewritePyFiletoSB(out SBCode);
- DoIPExecute(SBCode.ToString()); //transformed object code from a .py
- }
- else if (command.StartsWith("paths")) //NOXLATE
- {
- //Appends all hardcoded common paths stored in Paths
- //paths [-arg] - [args: -misc, -python24, -ironpython, -all] (-all=default)
- if (command.Contains(" -")) //NOXLATE
- {
- string[] splitcommand = command.Split('-'); //NOXLATE
- splitcommand[1] = splitcommand[1].Trim();
- this.ImportPaths(splitcommand[1]);
- }
- else
- this.ImportPaths(command.Trim());
-
- }
- else if (command.TrimEnd().EndsWith(":") == true) //NOXLATE
- {
- //Need to do a ReadStatement...
- try
- {
- //bool isMultiLine = false;
- int numberOfBlankLines = 0;
- object ExecWrapper = null;
- //bool result;
-
- string line = command;
- if (line == null)
- {
- if (ExecWrapper != null)
- {
- //Ops.Call(ExecWrapper, new object[] { null });//not needed for IP2?
- }
- //result = false;
- }
-
- defBuilder.Append(line);
- defBuilder.Append("\r\n"); //NOXLATE
-
- bool endOfInput = (line.Length == 0);
-
- //old//s = ParsetheText(consoleTextBox.global_eng.Sys, new CompilerContext(), defBuilder.ToString(), endOfInput, out parsingMultiLineString, out isMultiLine);
- string[] seperators = new string[] { "\r" }; //NOXLATE
- string[] allpieces = defBuilder.ToString().Split(seperators, StringSplitOptions.None);
-
- if (/*Options.AutoIndentSize != 0 &&*/ line.Trim().Length == 0)
- numberOfBlankLines++;
- else
- numberOfBlankLines = 0;
-
-
- if (allpieces.Length > 1)
- {
- // Note that splitting a string literal over multiple lines does not
- // constitute a multi-line statement.
- //isMultiLine = true;
- }
-
- //autoIndentSize = Parser.GetNextAutoIndentSize(defBuilder.ToString(), autoIndentSize);//Not needed in IP2?
- //result = true;
- }
- catch
- {
- }
- }
-
- else //misc commands...
- {
- try
- {
- DoIPExecute(command);
- this.WriteText(Environment.NewLine + IPEStreamWrapper.sbOutput.ToString());
- //added to fix "rearviewmirror" (IPEStreamWrapper.sbOutput not clearing) bug.
- IPEStreamWrapper.sbOutput.Remove(0, IPEStreamWrapper.sbOutput.Length); //Clear
- }
-
- catch (Exception err)//catch any errors
- {
- this.WriteText("\r\nERROR: " + err.Message); //NOXLATE
- }
- }
- }
- }
-
- private void PrintIdentifier(string identifier, bool newWindow)
- {
- try
- {
- dynamic obj = scope.GetVariable(identifier);
- if (newWindow)
- new TextWindow(obj.ToString()).ShowDialog();
- else
- WriteText(obj.ToString());
- }
- catch (Exception ex)
- {
- WriteText("ERROR: " + ex.Message); //NOXLATE
- }
- }
-
- private void ReflectIdentifier(string identifier, bool newWindow)
- {
- try
- {
- dynamic obj = scope.GetVariable(identifier);
- var sb = new StringBuilder();
- sb.Append("========= Reflecting " + identifier + " ==========" + Environment.NewLine); //NOXLATE
- Type t = obj.GetType();
- sb.Append("CLR Type: " + t.Name + Environment.NewLine); //NOXLATE
- sb.Append("Methods:" + Environment.NewLine); //NOXLATE
- foreach (var method in t.GetMethods())
- {
- sb.Append(" - " + method.ToString() + Environment.NewLine); //NOXLATE
- }
- sb.Append("Properties:" + Environment.NewLine); //NOXLATE
- foreach (var prop in t.GetProperties())
- {
- sb.Append(" - " + prop.Name + " (" + prop.PropertyType.Name + ")" + Environment.NewLine); //NOXLATE
- }
- sb.Append("========= Reflection complete ==========" + Environment.NewLine); //NOXLATE
- if (newWindow)
- new TextWindow(sb.ToString()).ShowDialog();
- else
- WriteText(sb.ToString());
- }
- catch (Exception ex)
- {
- WriteText("ERROR: " + ex.Message); //NOXLATE
- }
- }
-
- /// <summary>
- /// Displays information about IronTextBox and user's IronPython version.
- /// </summary>
- /// <returns>Returns string information about IronTextBox and user's IronPython version.</returns>
- public string GetHelpText()
- {
- string helpText;
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.Append("*******************************************"); //NOXLATE
- stringBuilder.Append(System.Environment.NewLine);
- stringBuilder.Append("** Maestro IronPython Console Help **"); //NOXLATE
- stringBuilder.Append(System.Environment.NewLine);
- stringBuilder.Append("*******************************************"); //NOXLATE
- stringBuilder.Append(System.Environment.NewLine);
- //stringBuilder.Append("You are using " + engine.LanguageDisplayName + " (" + engine.LanguageVersion + ")"); //NOXLATE
- stringBuilder.Append("You are using " + engine.Setup.DisplayName + " (" + engine.LanguageVersion + ")"); //NOXLATE
- stringBuilder.Append(System.Environment.NewLine);
- stringBuilder.Append(System.Environment.NewLine);
- stringBuilder.Append("Commands Available:"); //NOXLATE
- stringBuilder.Append(System.Environment.NewLine);
- stringBuilder.Append(" prompt - Changes prompt. Usage: prompt=<desired_prompt>"); //NOXLATE
- stringBuilder.Append(System.Environment.NewLine);
- stringBuilder.Append(" history - prints history of entered commands."); //NOXLATE
- stringBuilder.Append(System.Environment.NewLine);
- stringBuilder.Append(" cls - Clears the screen."); //NOXLATE
- stringBuilder.Append(System.Environment.NewLine);
- //stringBuilder.Append(" newconsole - Clears the current PythonEngine.");
- stringBuilder.Append(" refl <variable> - Displays all members/properties of a given variable"); //NOXLATE
- stringBuilder.Append(System.Environment.NewLine);
- stringBuilder.Append(" reflw <variable> - Displays all members/properties of a given variable to a new window"); //NOXLATE
- stringBuilder.Append(System.Environment.NewLine);
- stringBuilder.Append(" printw <variable> - Prints the value of the given variable to a new window"); //NOXLATE
- stringBuilder.Append(System.Environment.NewLine);
- stringBuilder.Append(" btaf - Browse To Append Folder. Calls FolderBrowserDialog."); //NOXLATE
- stringBuilder.Append(System.Environment.NewLine);
- stringBuilder.Append(" btwfi - Browse To Walk FIle. Calls OpenFileDialog."); //NOXLATE
- stringBuilder.Append(System.Environment.NewLine);
- stringBuilder.Append(" paths [-arg] - [args: -misc, -python24, -ironpython, -all] (-all=default)"); //NOXLATE
- stringBuilder.Append(System.Environment.NewLine);
- stringBuilder.Append(" rew - Re-Write a Python file into a StringBuilder.(for testing)"); //NOXLATE
- stringBuilder.Append(System.Environment.NewLine);
- stringBuilder.Append(" runfile - Run a .Py file. Calls OpenFileDialog to PythonEngine.RunFile."); //NOXLATE
- stringBuilder.Append(System.Environment.NewLine);
- helpText = stringBuilder.ToString();
- return helpText;
- }
-
- #region Component Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.consoleTextBox = new IronTextBox();
- this.SuspendLayout();
- //
- // consoleTextBox
- //
- // this.consoleTextBox.AcceptsReturn = true;
- this.consoleTextBox.AcceptsTab = true;
- this.consoleTextBox.BackColor = Color.White;
- this.consoleTextBox.Dock = DockStyle.Fill;
- this.consoleTextBox.Location = new Point(0, 0);
- this.consoleTextBox.Multiline = true;
- this.consoleTextBox.Name = "consoleTextBox";
- this.consoleTextBox.Prompt = ">>>";
- this.consoleTextBox.ScrollBars = ScrollBars.Both; //for TextBox use
- //this.consoleTextBox.ScrollBars = RichTextBoxScrollBars.Both; //for RichTextBox use
- this.consoleTextBox.Font = new Font("Lucida Console", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((Byte)(0)));
- this.consoleTextBox.Size = new Size(232, 216);
- this.consoleTextBox.TabIndex = 0;
- this.consoleTextBox.Text = "";
- //
- // IronTextBoxControl
- //
- this.Controls.Add(this.consoleTextBox);
- this.Name = "IronTextBoxControl";
- this.Size = new Size(232, 216);
- this.ResumeLayout(false);
-
- }
- #endregion
-
- #region Overides
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose(disposing);
- }
- #endregion Overides
-
- /// <summary>
- /// Run the command.
- /// </summary>
- /// <param name="command">Command line string.</param>
- internal void FireCommandEntered(string command)
- {
- OnCommandEntered(command);
- }
-
- /// <summary>
- /// Creates new EventCommandEntered event.
- /// </summary>
- /// <param name="command">Command line string.</param>
- protected virtual void OnCommandEntered(string command)
- {
- if (CommandEntered != null)
- CommandEntered(command, new CommandEnteredEventArgs(command));
- }
-
- /// <summary>
- /// Clear the current text in the IronTextBox.
- /// </summary>
- public void Clear()
- {
- consoleTextBox.Clear();
- }
-
- /// <summary>
- /// Send text to the IronTextBox.
- /// </summary>
- /// <param name="text"></param>
- public void WriteText(string text)
- {
- consoleTextBox.WriteText(text);
- }
-
- /// <summary>
- /// Simulate the Enter KeyPress event.
- /// </summary>
- public void SimEnter()
- {
- string currentCommand = consoleTextBox.GetTextAtPrompt();
- consoleTextBox.Focus();
-
- //Optional: add the command to the stringcollection
- //consoleTextBox.scollection.Add(currentCommand);
- ///////////////////////////////////////////////////
-
- //If it is not an empty command, then "fire" the command
- if (currentCommand.Length != 0)
- {
- //consoleTextBox.printLine();
- ((IronTextBoxControl)consoleTextBox.Parent).FireCommandEntered(currentCommand);
- consoleTextBox.AddcommandHistory(currentCommand);
- }
- else
- {
- //if it is an empty command let's see if we just finished a def statement
- if (consoleTextBox.defStmtBuilder.Length != 0)
- {
- ((IronTextBoxControl)consoleTextBox.Parent).FireCommandEntered(consoleTextBox.defStmtBuilder.ToString());
- consoleTextBox.AddcommandHistory(consoleTextBox.defStmtBuilder.ToString());
-
- //we just finished a def so clear the defbuilder
- consoleTextBox.defStmtBuilder = consoleTextBox.defStmtBuilder.Remove(0, consoleTextBox.defStmtBuilder.Length);
- }
- }
- consoleTextBox.printPrompt();
- }
-
- /// <summary>
- /// Opens a Python files and reads line by line into IronTextBox.
- /// </summary>
- /// <param name="fullpathfilename">fullpathfilename</param>
- public void WalkPythonFile(string fullpathfilename)
- {
- try
- {
- string filetext = File.ReadAllText(fullpathfilename);
- //tabs create a problem when trying to remove comments
- filetext = filetext.Replace("\t", " "); //NOXLATE
-
- // Create an instance of StreamReader to read from a file.
- // The using statement also closes the StreamReader.
- using (StringReader sr = new StringReader(filetext))
- {
- String line;
- StringBuilder sb = new StringBuilder();
- int pos = 0;
- // Read and display lines from the file until the end of
- // the file is reached.
- while ((line = sr.ReadLine()) != null)
- {
- //if the line is a # comment line, or a single line do not add...
- if (!line.StartsWith("#") && !line.StartsWith(" #") && !line.StartsWith(" #") && !line.StartsWith(" #") && !line.Equals("\r\n") && line != "") //NOXLATE
- {
- //catch """ comments
- if (line.StartsWith("\"\"\"") || line.StartsWith(" \"\"\"") || line.StartsWith(" \"\"\"") || line.StartsWith(" \"\"\"")) //NOXLATE
- {
- //the line may also end with """, so if it is not read until end
- if (!IsSingleCommentLine(line))
- {
- //get to the end of the comments
- while (!sr.ReadLine().TrimEnd().EndsWith("\"\"\"")) //NOXLATE
- {
- //do nothing
- }
- }
-
- //reassign line
- line = sr.ReadLine();
- }
-
- //the line may also end with """, so if it is not read until end
- if (!IsSingleCommentLine(line))
- {
- //if the line ends with """, then delete """ and read until end
- if (line.TrimEnd().EndsWith("\"\"\"") && line.IndexOf("\"\"\"") == line.Length - 3) //NOXLATE
- {
- //remove """ and reassign line
- line = line.Remove(line.Length - 3);
-
- //get to the end of the comments
- while (!sr.ReadLine().TrimEnd().EndsWith("\"\"\"")) //NOXLATE
- {
- //do nothing
- }
- }
- //then append line
- sb.AppendLine(line);
-
- consoleTextBox.WriteText(line);
- SimEnter();
- }
- }
-
-
- pos = sb.Length;
- //if a blank line, enter previous text as a FuncDef
- if (line == string.Empty && sb.Length != 0)
- {
- try //try to find last ""
- {
- //consoleTextBox.WriteText(sb.ToString());
- SimEnter();
- }
- catch
- {
-
- }
-
- }
- //consoleTextBox.WriteText(line);
-
- }
- }
- }
- catch (Exception e)
- {
- // Let the user know what went wrong.
- consoleTextBox.WriteText("The file could not be read:"); //NOXLATE
- consoleTextBox.WriteText(e.Message);
- }
-
- }
-
- /// <summary>
- /// Opens a FolderBrowserDialog to load a Python file to read it line by line into IronTextBox.
- /// </summary>
- public void WalkPythonFile()
- {
- try
- {
- //See if sys is imported...
- if (!DoIPEvaluate("dir()").ToString().Contains("sys")) //NOXLATE
- {
- consoleTextBox.printPrompt();
- consoleTextBox.WriteText("import sys"); //NOXLATE
- this.SimEnter();
- }
-
- //Browse to the file...
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.InitialDirectory = Paths.MiscDirs.vs_Projects;
- ofd.Filter = string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickPy, "py") + "|" + StringConstants.AllFilesFilter; //NOXLATE
- ofd.ShowDialog();
-
- //Ask the user if they would like to append the path
- string message = "Do you need to append the folder:\r\n" + Path.GetDirectoryName(Path.GetFullPath(ofd.FileName)) + "\r\n\r\nto the PythonEngine?"; //NOXLATE
- string caption = "Append Folder Path"; //NOXLATE
- MessageBoxButtons buttons = MessageBoxButtons.YesNo;
- DialogResult result;
-
- // Displays the MessageBox.
- result = MessageBox.Show(this, message, caption, buttons);
- if (result == DialogResult.Yes)
- {
- consoleTextBox.printPrompt();
- consoleTextBox.WriteText("sys.path.append(\"" + Path.GetDirectoryName(Path.GetFullPath(ofd.FileName)) + "\")"); //NOXLATE
- this.SimEnter();
-
- //Keep asking until No
- while (result.Equals(DialogResult.Yes))
- {
- //Ask the user if more folders are needed to be appended
- message = "Do you need to append another folder?"; //NOXLATE
- result = MessageBox.Show(this, message, caption, buttons);
- if (result == DialogResult.Yes)
- {
- System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
- fbd.SelectedPath = Path.GetDirectoryName(Path.GetFullPath(ofd.FileName));
- fbd.ShowDialog();
- consoleTextBox.printPrompt();
- consoleTextBox.WriteText("sys.path.append(\"" + fbd.SelectedPath + "\")"); //NOXLATE
- this.SimEnter();
- }
- }
- }
-
- WalkPythonFile(ofd.FileName);
- }
- catch (Exception e)
- {
- // Let the user know what went wrong.
- consoleTextBox.WriteText("The file could not be read:"); //NOXLATE
- consoleTextBox.WriteText(e.Message);
- }
- }
-
- /// <summary>
- /// Run a .Py file. Calls OpenFileDialog to PythonEngine.RunFile.
- /// </summary>
- public void Runfile()
- {
- try
- {
- //Browse to the file...
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.InitialDirectory = Paths.MiscDirs.vs_Projects;
- ofd.Filter = string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickPy, "py") + "|" + StringConstants.AllFilesFilter; //NOXLATE
- ofd.ShowDialog();
-
- DoIPExecuteFile(ofd.FileName);
-
- }
- catch (Exception ex)
- {
- consoleTextBox.WriteText("The file could not be read:"); //NOXLATE
- consoleTextBox.WriteText(ex.Message);
- }
-
- }
-
- /// <summary>
- /// Opens a Python file and reads line by line into a StringBuilder.
- /// </summary>
- /// <param name="sbCode">out StringBuilder</param>
- public void RewritePyFiletoSB(out StringBuilder sbCode)
- {
- StringBuilder sb = new StringBuilder();
-
- //See if sys is imported...
- if (!DoIPEvaluate("dir()").ToString().Contains("sys")) //NOXLATE
- {
- consoleTextBox.printPrompt();
- consoleTextBox.WriteText("import sys"); //NOXLATE
- this.SimEnter();
- }
-
- //Browse to the file...
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.InitialDirectory = Paths.MiscDirs.vs_Projects;
- ofd.Filter = string.Format(OSGeo.MapGuide.MaestroAPI.Strings.GenericFilter, OSGeo.MapGuide.MaestroAPI.Strings.PickPy, "py") + "|" + StringConstants.AllFilesFilter; //NOXLATE
- ofd.ShowDialog();
-
- try
- {
- string filetext = File.ReadAllText(ofd.FileName);
- //tabs create a problem when trying to remove comments
- filetext = filetext.Replace("\t", " "); //NOXLATE
-
- // Create an instance of StreamReader to read from a file.
- // The using statement also closes the StreamReader.
- using (StringReader sr = new StringReader(filetext))
- {
- String line;
- int pos = 0;
- // Read and display lines from the file until the end of
- // the file is reached.
- while ((line = sr.ReadLine()) != null)
- {
-
- /////temp testing
- /// " # unpp augmented predicate"
- /// " """ "
- ///if (line == " def chunk_lemmatised(self,lemmatised_text):")
- ///{
- /// int temp = pos;
- ///}
- /////temp testing
-
- //if the line is a # comment line, or a single line do not add...
- if (!line.StartsWith("#") && !line.StartsWith(" #") && !line.StartsWith(" #") && !line.StartsWith(" #") && !line.Equals("\r\n") && line != "") //NOXLATE
- {
- //catch """ comments
- if (line.StartsWith("\"\"\"") || line.StartsWith(" \"\"\"") || line.StartsWith(" \"\"\"") || line.StartsWith(" \"\"\"")) //NOXLATE
- {
- //the line may also end with """, so if it is not read until end
- if (!IsSingleCommentLine(line))
- {
- //get to the end of the comments
- while (!sr.ReadLine().TrimEnd().EndsWith("\"\"\"")) //NOXLATE
- {
- //do nothing
- }
- }
-
- //reassign line
- line = sr.ReadLine();
- }
-
- //the line may also end with """, so if it is not read until end
- if (!IsSingleCommentLine(line))
- {
- //if the line ends with """, then delete """ and read until end
- if (line.TrimEnd().EndsWith("\"\"\"") && line.IndexOf("\"\"\"") == line.Length - 3) //NOXLATE
- {
- //remove """ and reassign line
- line = line.Remove(line.Length - 3);
-
- //get to the end of the comments
- while (!sr.ReadLine().TrimEnd().EndsWith("\"\"\"")) //NOXLATE
- {
- //do nothing
- }
- }
- //then append line
- sb.AppendLine(line);
- }
- }
- pos = sb.Length;
- }
- }
- }
- catch (Exception e)
- {
- // Let the user know what went wrong.
- consoleTextBox.WriteText("The file could not be read:"); //NOXLATE
- consoleTextBox.WriteText(e.Message);
- }
-
- sbCode = sb;
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="line"></param>
- /// <returns>true if line begins with #, or begins with """ and endwith """</returns>
- public bool IsSingleCommentLine(string line)
- {
- //Trim the end of the line because sometimes whitespace after """
- line = line.TrimEnd();
-
- if (line.StartsWith("#") || line.StartsWith(" #") || line.StartsWith(" #") || line.StartsWith(" #") && line != "") //NOXLATE
- {
- return true;
- }
- else if (line.StartsWith("\"\"\"") || line.StartsWith(" \"\"\"") || line.StartsWith(" \"\"\"") || line.StartsWith(" \"\"\"")) //NOXLATE
- {
- if (line.TrimEnd().EndsWith("\"\"\"") && line.IndexOf("\"\"\"") != line.Length - 3) //NOXLATE
- {
- return true;
- }
- else
- return false;
- }
- else
- return false;
- }
-
- /// <summary>
- /// Returns aa ArrayList from a StringCollection
- /// </summary>
- /// <param name="StringColin">Incoming StringCollection.</param>
- public ArrayList Convert_StringCollectiontoArrayList(StringCollection StringColin)
- {
- ArrayList newArrayList = new ArrayList();
-
- StringEnumerator myEnumerator = StringColin.GetEnumerator();
- while (myEnumerator.MoveNext())
- newArrayList.Add(myEnumerator.Current.ToString());
-
- return newArrayList;
- }
-
- /// <summary>
- /// ImportPaths
- /// </summary>
- /// <param name="arg"></param>
- public void ImportPaths(string arg)
- {
- StringCollection scMiscDirs = new StringCollection();
- scMiscDirs.Add(Paths.MiscDirs.ConceptNet);
- scMiscDirs.Add(Paths.MiscDirs.montylingua);
- scMiscDirs.Add(Paths.MiscDirs.vs_Projects);
- StringEnumerator SCEMiscDirs = scMiscDirs.GetEnumerator();
-
- StringCollection scPython24Dirs = new StringCollection();
- scPython24Dirs.Add(Paths.Python24Dirs.Python24_DLLs);
- scPython24Dirs.Add(Paths.Python24Dirs.Python24_Lib);
- scPython24Dirs.Add(Paths.Python24Dirs.Python24_Lib_lib_tk);
- scPython24Dirs.Add(Paths.Python24Dirs.Python24_libs);
- scPython24Dirs.Add(Paths.Python24Dirs.Python24_Tools);
- scPython24Dirs.Add(Paths.Python24Dirs.Python24_Tools_Scripts);
- StringEnumerator SCEPython24Dirs = scPython24Dirs.GetEnumerator();
-
- StringCollection scIronPythonDirs = new StringCollection();
- scIronPythonDirs.Add(Paths.IronPythonDirs.IronPython_Tutorial);
- //scIronPythonDirs.Add(Paths.IronPythonDirs.Runtime);
- StringEnumerator SCEIronPythonDirs = scIronPythonDirs.GetEnumerator();
-
- //Create All SC
- StringCollection scAll = new StringCollection();
- while (SCEMiscDirs.MoveNext())
- {
- scAll.Add(SCEMiscDirs.Current);
- }
- while (SCEPython24Dirs.MoveNext())
- {
- scAll.Add(SCEPython24Dirs.Current);
- }
- while (SCEIronPythonDirs.MoveNext())
- {
- scAll.Add(SCEIronPythonDirs.Current);
- }
- StringEnumerator SCEAll = scAll.GetEnumerator();
-
- //Reset Enums
- SCEMiscDirs.Reset();
- SCEPython24Dirs.Reset();
- SCEIronPythonDirs.Reset();
-
- //Check to see if sys is loaded
- if (!DoIPEvaluate("dir()").ToString().Contains("sys")) //NOXLATE
- {
- consoleTextBox.printPrompt();
- consoleTextBox.WriteText("import sys"); //NOXLATE
- this.SimEnter();
- }
- else
- consoleTextBox.printPrompt();
-
-
- try
- {
- switch (arg)
- {
- case "misc": //NOXLATE
- {
- while (SCEMiscDirs.MoveNext())
- {
- //consoleTextBox.printPrompt();
- consoleTextBox.WriteText("sys.path.append(\"" + SCEMiscDirs.Current + "\")"); //NOXLATE
- this.SimEnter();
- }
- break;
- }
- case "python24": //NOXLATE
- {
- while (SCEPython24Dirs.MoveNext())
- {
- //consoleTextBox.printPrompt();
- consoleTextBox.WriteText("sys.path.append(\"" + SCEPython24Dirs.Current + "\")"); //NOXLATE
- this.SimEnter();
- }
- break;
- }
- case "ironpython": //NOXLATE
- {
- while (SCEIronPythonDirs.MoveNext())
- {
- //consoleTextBox.printPrompt();
- consoleTextBox.WriteText("sys.path.append(\"" + SCEIronPythonDirs.Current + "\")"); //NOXLATE
- this.SimEnter();
- }
- break;
- }
- case "all": //NOXLATE
- {
- while (SCEAll.MoveNext())
- {
- //consoleTextBox.printPrompt();
- consoleTextBox.WriteText("sys.path.append(\"" + SCEAll.Current + "\")"); //NOXLATE
- this.SimEnter();
- }
- break;
- }
- case "paths": //NOXLATE
- {
- while (SCEAll.MoveNext())
- {
- //consoleTextBox.printPrompt();
- consoleTextBox.WriteText("sys.path.append(\"" + SCEAll.Current + "\")"); //NOXLATE
- this.SimEnter();
- }
- break;
- }
- default:
- consoleTextBox.WriteText("Invalid arg. Only: -misc, -python24, -ironpython, -all"); //NOXLATE
- break;
- }
- }
- catch (Exception e)
- {
- // Let the user know what went wrong.
- consoleTextBox.WriteText("ImportPaths error: "); //NOXLATE
- consoleTextBox.WriteText(e.Message);
- }
- }
- }
- #endregion IronTextBoxControl Class
-
- #region CommandHistory Class
- internal class CommandHistory
- {
- private int currentPosn;
- private string lastCommand;
- private ArrayList commandHistory = new ArrayList();
-
- internal CommandHistory()
- {
- }
-
- internal void Add(string command)
- {
- if (command != lastCommand)
- {
- commandHistory.Add(command);
- lastCommand = command;
- currentPosn = commandHistory.Count;
- }
- }
-
- internal bool DoesPreviousCommandExist()
- {
- return currentPosn > 0;
- }
-
- internal bool DoesNextCommandExist()
- {
- return currentPosn < commandHistory.Count - 1;
- }
-
- internal string GetPreviousCommand()
- {
- lastCommand = (string)commandHistory[--currentPosn];
- return lastCommand;
- }
-
- internal string GetNextCommand()
- {
- lastCommand = (string)commandHistory[++currentPosn];
- return LastCommand;
- }
-
- internal string LastCommand
- {
- get { return lastCommand; }
- }
-
- internal string[] GetCommandHistory()
- {
- return (string[])commandHistory.ToArray(typeof(string));
- }
- }
- #endregion CommandHistory Class
-
- #region Utils
- namespace Utils
- {
- /// <summary>
- ///
- /// </summary>
- public class Converts
- {
- /// <summary>
- /// Custom MessageBox call. Excepts some random objects from IronPython and converts to string.
- /// </summary>
- /// <param name="inobject">Output object from IronPython.</param>
- public static void MessageBoxIronPy(Object inobject)
- {
- Type itstype = inobject.GetType();
-
- switch (itstype.FullName)
- {
- case "IronPython.Runtime.PythonDictionary": //NOXLATE
- PythonDictionary IPDict = new PythonDictionary();
- IPDict = (PythonDictionary)inobject;
- MessageBox.Show(IPDict.ToString());
- break;
- case "IronPython.Runtime.List": //NOXLATE
- List IPList = new List();
- IPList = (List)inobject;
- MessageBox.Show(IPList.ToString());
- break;
- case "System.String": //NOXLATE
- MessageBox.Show(inobject.ToString());
- break;
- case "System.Int32": //NOXLATE
- MessageBox.Show(Convert.ToString(inobject));
- break;
- case "System.Collections.Specialized.StringCollection": //NOXLATE
- StringCollection IPSC = new StringCollection();
- IPSC = (StringCollection)inobject;
- StringEnumerator SCE = IPSC.GetEnumerator();
- string output = string.Empty;
- while (SCE.MoveNext())
- output += SCE.Current.ToString();
- MessageBox.Show(output);
- break;
- default:
- MessageBox.Show(inobject.GetType().ToString() + " not yet implemented."); //NOXLATE
- break;
- }
- }
- }
- }
- #endregion Utils
-
- #region CommandEnteredEventArgs Class
- /// <summary>
- /// Command argument class.
- /// </summary>
- public class CommandEnteredEventArgs : EventArgs
- {
- string command;
- public CommandEnteredEventArgs(string command)
- {
- this.command = command;
- }
-
- public string Command
- {
- get { return command; }
- }
- }
- #endregion CommandEnteredEventArgs Class
-
- public delegate void EventCommandEntered(object sender, CommandEnteredEventArgs e);
-}
Deleted: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/Paths.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/Paths.cs 2012-10-25 15:08:19 UTC (rev 7156)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/Paths.cs 2012-10-26 08:49:03 UTC (rev 7157)
@@ -1,249 +0,0 @@
-//---------------------------------------------------------------------------------
-//Paths.cs - version 2.0.2.0b
-// TextBox control based class designed to be used with Microsoft's IronPython.
-// Maybe useful for testing Python scripts with IronPython.
-//
-// WHAT'S NEW:
-// - Updated IronPython_Tutorial to point to IronPython 2.0B2 path
-// - Added Python25Dirs
-// TO DO:
-//
-//BY DOWNLOADING AND USING, YOU AGREE TO THE FOLLOWING TERMS:
-//Copyright (c) 2006-2008 by Joseph P. Socoloski III
-//LICENSE
-//Permission is hereby granted, free of charge, to any person obtaining a copy
-//of this software and associated documentation files (the "Software"), to deal
-//in the Software without restriction, including without limitation the rights
-//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-//copies of the Software, and to permit persons to whom the Software is
-//furnished to do so, subject to the following conditions:
-//
-//The above copyright notice and this permission notice shall be included in
-//all copies or substantial portions of the Software.
-//the MIT License, given here: <http://www.opensource.org/licenses/mit-license.php>
-//---------------------------------------------------------------------------------
-using System;
-using System.IO;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Text;
-using IronPython.Hosting;
-
-
-namespace Maestro.AddIn.Scripting.UI
-{
- namespace Paths
- {
- /// <summary>
- /// Misc Paths. Customize here.
- /// </summary>
- public class MiscDirs
- {
- /// <summary>
- /// MIT's ConceptNet 2.1 directory.
- /// default: "...MyDocuments) + @"\Python Projects\conceptnet2.1"
- /// </summary>
- public static string ConceptNet = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Python Projects\conceptnet2.1"; //NOXLATE
-
- /// <summary>
- /// MIT's MontyLingua directory.
- /// default: "...MyDocuments) + @"\Python Projects\conceptnet2.1\montylingua"
- /// </summary>
- public static string montylingua = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Python Projects\conceptnet2.1\montylingua"; //NOXLATE
-
- /// <summary>
- /// Visual Studio\Projects Folder.
- /// default: "..MyDocuments) + @"\Visual Studio 2008\Projects"
- /// </summary>
- public static string vs_Projects = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Visual Studio 2008\Projects"; //NOXLATE
-
- /*
- /// <summary>
- /// StringCollection of all MiscDirs
- /// </summary>
- public static StringCollection scMiscDirs
- {
- get
- {
- IronTextBox.scMisc.Clear();
- IronTextBox.scMisc.Add(ConceptNet);
- IronTextBox.scMisc.Add(montylingua);
- IronTextBox.scMisc.Add(vs_Projects);
- return IronTextBox.scMisc; }
- //set { IronTextBox.scMisc = value; }
- }
- */
-
- /// <summary>
- /// Misc Paths.
- /// </summary>
- public MiscDirs()
- {
-
- }
- }
-
- /// <summary>
- /// Python 2.4 Paths. Customize here.
- /// </summary>
- public class Python24Dirs
- {
- /// <summary>
- /// Folder to Python library modules.
- /// default: "C:\Python24\Lib"
- /// </summary>
- public static string Python24_Lib = @"C:\Python24\Lib"; //NOXLATE
-
- /// <summary>
- /// Folder to Tkinter library modules.
- /// default: "C:\Python24\Lib\lib-tk"
- /// </summary>
- public static string Python24_Lib_lib_tk = @"C:\Python24\Lib\lib-tk"; //NOXLATE
-
- /// <summary>
- /// default: "C:\Python24\libs"
- /// </summary>
- public static string Python24_libs = @"C:\Python24\libs"; //NOXLATE
-
- /// <summary>
- /// default: "C:\Python24\DLLs"
- /// </summary>
- public static string Python24_DLLs = @"C:\Python24\DLLs"; //NOXLATE
-
- /// <summary>
- /// Some useful programs written in Python.
- /// default: "C:\Python24\Tools"
- /// </summary>
- public static string Python24_Tools = @"C:\Python24\Tools"; //NOXLATE
-
- /// <summary>
- /// Some useful programs written in Python.
- /// default: "C:\Python24\Tools\Scripts"
- /// </summary>
- public static string Python24_Tools_Scripts = @"C:\Python24\Tools\Scripts"; //NOXLATE
-
- /*
- /// <summary>
- /// StringCollection of all Python24Dirs
- /// </summary>
- public static StringCollection scPython24Dirs
- {
- get
- {
- IronTextBox.scPython24.Clear();
- IronTextBox.scPython24.Add(Python24_Lib);
- IronTextBox.scPython24.Add(Python24_Lib_lib_tk);
- IronTextBox.scPython24.Add(Python24_libs);
- IronTextBox.scPython24.Add(Python24_DLLs);
- IronTextBox.scPython24.Add(Python24_Tools);
- IronTextBox.scPython24.Add(Python24_Tools_Scripts);
- return IronTextBox.scPython24;
- }
- }
- */
-
- /// <summary>
- /// Python 2.4 Paths
- /// </summary>
- public Python24Dirs()
- {
-
- }
- }
-
- /// <summary>
- /// Python 2.5 Paths. Customize here.
- /// </summary>
- public class Python25Dirs
- {
- /// <summary>
- /// Folder to Python library modules.
- /// default: "C:\Python25\Lib"
- /// </summary>
- public static string Python25_Lib = @"C:\Python25\Lib"; //NOXLATE
-
- /// <summary>
- /// Folder to Tkinter library modules.
- /// default: "C:\Python25\Lib\lib-tk"
- /// </summary>
- public static string Python25_Lib_lib_tk = @"C:\Python25\Lib\lib-tk"; //NOXLATE
-
- /// <summary>
- /// default: "C:\Python25\libs"
- /// </summary>
- public static string Python25_libs = @"C:\Python25\libs"; //NOXLATE
-
- /// <summary>
- /// default: "C:\Python25\DLLs"
- /// </summary>
- public static string Python25_DLLs = @"C:\Python25\DLLs"; //NOXLATE
-
- /// <summary>
- /// Some useful programs written in Python.
- /// default: "C:\Python25\Tools"
- /// </summary>
- public static string Python25_Tools = @"C:\Python25\Tools"; //NOXLATE
-
- /// <summary>
- /// Some useful programs written in Python.
- /// default: "C:\Python25\Tools\Scripts"
- /// </summary>
- public static string Python25_Tools_Scripts = @"C:\Python25\Tools\Scripts"; //NOXLATE
-
- /*
- /// <summary>
- /// StringCollection of all Python25Dirs
- /// </summary>
- public static StringCollection scPython25Dirs
- {
- get
- {
- IronTextBox.scPython25.Clear();
- IronTextBox.scPython25.Add(Python25_Lib);
- IronTextBox.scPython25.Add(Python25_Lib_lib_tk);
- IronTextBox.scPython25.Add(Python25_libs);
- IronTextBox.scPython25.Add(Python25_DLLs);
- IronTextBox.scPython25.Add(Python25_Tools);
- IronTextBox.scPython25.Add(Python25_Tools_Scripts);
- return IronTextBox.scPython25;
- }
- }
- */
-
- /// <summary>
- /// Python 2.5 Paths
- /// </summary>
- public Python25Dirs()
- {
-
- }
- }
-
- /// <summary>
- /// IronPython Paths. Customize here.
- /// </summary>
- public class IronPythonDirs
- {
- /// <summary>
- /// Current Assembly.Location
- /// </summary>
- public static string Runtime = Path.GetDirectoryName(typeof(Python).Assembly.Location);
-
- /// <summary>
- /// IronPython Tutorial scripts.
- /// default: "...MyDocuments) + @"\Visual Studio 2008\Projects\IronPython-2.0B2\Tutorial"
- /// </summary>
- public static string IronPython_Tutorial = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Visual Studio 2008\Projects\IronPython-2.0B2\Tutorial"; //NOXLATE
-
- /// <summary>
- /// IronPython Paths
- /// </summary>
- static IronPythonDirs()
- {
-
- }
- }
-
- }
-
-}
Deleted: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.Designer.cs 2012-10-25 15:08:19 UTC (rev 7156)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.Designer.cs 2012-10-26 08:49:03 UTC (rev 7157)
@@ -1,63 +0,0 @@
-namespace Maestro.AddIn.Scripting.UI
-{
- partial class TextWindow
- {
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.IContainer components = null;
-
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.txtBox = new System.Windows.Forms.TextBox();
- this.SuspendLayout();
- //
- // txtBox
- //
- this.txtBox.Dock = System.Windows.Forms.DockStyle.Fill;
- this.txtBox.Font = new System.Drawing.Font("Lucida Console", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.txtBox.Location = new System.Drawing.Point(0, 0);
- this.txtBox.Multiline = true;
- this.txtBox.Name = "txtBox";
- this.txtBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
- this.txtBox.Size = new System.Drawing.Size(624, 442);
- this.txtBox.TabIndex = 0;
- //
- // TextWindow
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(624, 442);
- this.Controls.Add(this.txtBox);
- this.Name = "TextWindow";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
- this.Text = "TextWindow";
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.TextBox txtBox;
- }
-}
\ No newline at end of file
Deleted: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.cs 2012-10-25 15:08:19 UTC (rev 7156)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.cs 2012-10-26 08:49:03 UTC (rev 7157)
@@ -1,39 +0,0 @@
-#region Disclaimer / License
-// Copyright (C) 2012, Jackie Ng
-// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
-//
-// 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 System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Windows.Forms;
-
-namespace Maestro.AddIn.Scripting.UI
-{
- public partial class TextWindow : Form
- {
- public TextWindow(string text)
- {
- InitializeComponent();
- txtBox.Text = text;
- }
- }
-}
Deleted: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.resx 2012-10-25 15:08:19 UTC (rev 7156)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.resx 2012-10-26 08:49:03 UTC (rev 7157)
@@ -1,120 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<root>
- <!--
- Microsoft ResX Schema
-
- Version 2.0
-
- The primary goals of this format is to allow a simple XML format
- that is mostly human readable. The generation and parsing of the
- various data types are done through the TypeConverter classes
- associated with the data types.
-
- Example:
-
- ... ado.net/XML headers & schema ...
- <resheader name="resmimetype">text/microsoft-resx</resheader>
- <resheader name="version">2.0</resheader>
- <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
- <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
- <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
- <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
- <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
- <value>[base64 mime encoded serialized .NET Framework object]</value>
- </data>
- <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
- <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
- <comment>This is a comment</comment>
- </data>
-
- There are any number of "resheader" rows that contain simple
- name/value pairs.
-
- Each data row contains a name, and value. The row also contains a
- type or mimetype. Type corresponds to a .NET class that support
- text/value conversion through the TypeConverter architecture.
- Classes that don't support this are serialized and stored with the
- mimetype set.
-
- The mimetype is used for serialized objects, and tells the
- ResXResourceReader how to depersist the object. This is currently not
- extensible. For a given mimetype the value must be set accordingly:
-
- Note - application/x-microsoft.net.object.binary.base64 is the format
- that the ResXResourceWriter will generate, however the reader can
- read any of the formats listed below.
-
- mimetype: application/x-microsoft.net.object.binary.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.soap.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.bytearray.base64
- value : The object must be serialized into a byte array
- : using a System.ComponentModel.TypeConverter
- : and then encoded with base64 encoding.
- -->
- <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
- <xsd:element name="root" msdata:IsDataSet="true">
- <xsd:complexType>
- <xsd:choice maxOccurs="unbounded">
- <xsd:element name="metadata">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- <xsd:attribute name="name" use="required" type="xsd:string" />
- <xsd:attribute name="type" type="xsd:string" />
- <xsd:attribute name="mimetype" type="xsd:string" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="assembly">
- <xsd:complexType>
- <xsd:attribute name="alias" type="xsd:string" />
- <xsd:attribute name="name" type="xsd:string" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="data">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
- <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
- <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="resheader">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- </xsd:complexType>
- </xsd:element>
- </xsd:schema>
- <resheader name="resmimetype">
- <value>text/microsoft-resx</value>
- </resheader>
- <resheader name="version">
- <value>2.0</value>
- </resheader>
- <resheader name="reader">
- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <resheader name="writer">
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
-</root>
\ No newline at end of file
Modified: trunk/Tools/Maestro/MaestroAPITestRunner/MaestroAPITestRunner.csproj
===================================================================
--- trunk/Tools/Maestro/MaestroAPITestRunner/MaestroAPITestRunner.csproj 2012-10-25 15:08:19 UTC (rev 7156)
+++ trunk/Tools/Maestro/MaestroAPITestRunner/MaestroAPITestRunner.csproj 2012-10-26 08:49:03 UTC (rev 7157)
@@ -93,37 +93,11 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
- <None Include="MGOS22\webconfig.ini">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </None>
<None Include="Platform.ini">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
- <Content Include="..\SDK\bin\bin.x86.MGOS2.2.0\OSGeo.MapGuide.MaestroAPI.Native32-2.2.0.dll">
- <Link>MGOS22\OSGeo.MapGuide.MaestroAPI.Native32-2.2.0.dll</Link>
- </Content>
- <Content Include="..\Thirdparty\MGOS_2_2_0_x86\OSGeo.MapGuide.Foundation.dll">
- <Link>MGOS22\OSGeo.MapGuide.Foundation.dll</Link>
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="..\Thirdparty\MGOS_2_2_0_x86\OSGeo.MapGuide.Geometry.dll">
- <Link>MGOS22\OSGeo.MapGuide.Geometry.dll</Link>
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="..\Thirdparty\MGOS_2_2_0_x86\OSGeo.MapGuide.MapGuideCommon.dll">
- <Link>MGOS22\OSGeo.MapGuide.MapGuideCommon.dll</Link>
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="..\Thirdparty\MGOS_2_2_0_x86\OSGeo.MapGuide.PlatformBase.dll">
- <Link>MGOS22\OSGeo.MapGuide.PlatformBase.dll</Link>
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
- <Content Include="..\Thirdparty\MGOS_2_2_0_x86\OSGeo.MapGuide.Web.dll">
- <Link>MGOS22\OSGeo.MapGuide.Web.dll</Link>
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
- </Content>
<Content Include="ConnectionProviders.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
More information about the mapguide-commits
mailing list