[mapguide-commits] r6516 - in trunk/Tools/Maestro: Maestro
Maestro.AddIn.Scripting Maestro.AddIn.Scripting/Commands
Maestro.AddIn.Scripting/Properties Maestro.AddIn.Scripting/Services
Maestro.AddIn.Scripting/UI Maestro.Base/UI Thirdparty/SharpDevelop
Thirdparty/SharpDevelop/ICSharpCode.Core
Thirdparty/SharpDevelop/ICSharpCode.Core/Configuration
Thirdparty/SharpDevelop/ICSharpCode.Core/Src
Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree
Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn
Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators
Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers
Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/Icon
Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem
Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem
Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services Thirdparty/SharpDeve
lop/ICSharpCode.Core/Src/Services/AnalyticsMonitor
Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility
Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService
Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService
Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService
Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/RegistryService
Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ResourceService
Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser
Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util
Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms
Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu
Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService
Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Properties
Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar
Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Feb 15 12:39:11 EST 2012
Author: jng
Date: 2012-02-15 09:39:10 -0800 (Wed, 15 Feb 2012)
New Revision: 6516
Added:
trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.Designer.cs
trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.resx
trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/
trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IPEWrapper.cs
trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.Designer.cs
trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs
trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.resx
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/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/IDialogMessageService.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AssemblyLocator.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/BuildItemArgs.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/TopologicalSort.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/AnalyticsMonitor/
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/AnalyticsMonitor/AnalyticsMonitorService.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/AnalyticsMonitor/IAnalyticsMonitor.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileName.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/RegistryService/
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/RegistryService/RegistryService.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ServiceNotFoundException.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/PropertyObjectTagProvider.cs
Removed:
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/AppDomainLaunchHelper.cs
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/Services/ScriptingClasses.cs
trunk/Tools/Maestro/Maestro.Base/UI/ResourceHeaderXmlDialog.cs
trunk/Tools/Maestro/Maestro/Program.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/GlobalAssemblyInfo.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ICSharpCode.Core.WinForms.csproj
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/IStatusUpdate.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/ISubmenuBuilder.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/Menu.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuCheckBox.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuCommand.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuSeparator.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuService.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/CustomDialog.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/InputBox.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/SaveErrorChooseDialog.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/SaveErrorInformDialog.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/WinFormsMessageService.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Properties/AssemblyInfo.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarCheckBox.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarComboBox.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarCommand.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarDropDownButton.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarLabel.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarSeparator.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarService.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarSplitButton.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarTextBox.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/ClipboardWrapper.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/NativeMethods.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/RightToLeftConverter.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/WinFormsResourceService.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Configuration/AssemblyInfo.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/ICSharpCode.Core.csproj
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddIn.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddInLoadException.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddInReference.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Codon.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ComplexCondition.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Condition.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/CompareConditionEvaluator.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/LazyConditionEvaluator.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/OwnerStateConditionEvaluator.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ClassDoozer.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/FileFilterDoozer.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/Icon/IconDescriptor.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/Icon/IconDoozer.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/IncludeDoozer.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/LazyDoozer.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/AbstractCheckableMenuCommand.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/AbstractMenuCommand.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/ICheckableMenuCommand.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/IMenuCommand.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/MenuItemDoozer.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/StringDoozer.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/AbstractComboBoxCommand.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/AbstractTextBoxCommand.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/IComboBoxCommand.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/ITextBoxCommand.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/ToolBarItemDoozer.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ExtensionPath.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IBuildItemsModifier.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ICondition.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IConditionEvaluator.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IDoozer.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Manifest.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Runtime.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInManager.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInTree.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInTreeNode.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/CoreStartup.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/TreePathNotFoundException.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/CoreException.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ApplicationStateInfoService.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileNameEventHandler.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileUtility.Minimal.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileUtility.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/ILoggingService.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/LoggingService.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/TextWriterLoggingService.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/IMessageService.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/MessageService.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/TextWriterMessageService.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/Properties.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/PropertyChangedEvent.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/PropertyService.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ResourceService/ResourceNotFoundException.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ResourceService/ResourceService.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ServiceManager.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/IStringTagProvider.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/StringParser.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/AbstractCommand.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/CallbackOnDispose.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/DebugTextWriter.cs
trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/ICommand.cs
Log:
This submission includes the following changes:
- Update SharpDevelop Core to 4.1. Port over the existing mono compatibility fix to ICSharpCode.Core.WinForms
- #1956: Add an IronPython REPL UI to the scripting addin. This uses source code from the MIT-licensed IronTextBox2 (http://www.codeproject.com/Articles/26391/IronTextBox2)
Modified: trunk/Tools/Maestro/Maestro/Program.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/Program.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Maestro/Program.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -51,17 +51,15 @@
string lang = PreferredSiteList.InitCulture();
- var btw = BroadcastTextWriter.Instance;
+ //var btw = BroadcastTextWriter.Instance;
// Logging service by default uses System.Diagnostics.Debug. Re-route this
// to our writer
- var wfmsg = WinFormsMessageService.Instance;
- ServiceManager.LoggingService = new TextWriterLoggingService(btw);
- ServiceManager.MessageService = wfmsg;
+ //var wfmsg = WinFormsMessageService.Instance;
+ //ServiceManager.LoggingService = new TextWriterLoggingService(btw);
+ //ServiceManager.MessageService = wfmsg;
- // The LoggingService is a small wrapper around log4net.
- // Our application contains a .config file telling log4net to write
- // to System.Diagnostics.Trace.
+ ServiceManager.Instance = new MaestroServiceManager();
LoggingService.Info("Application start");
// Setup Platform.ini if required
@@ -183,4 +181,30 @@
ErrorDialog.Show(e.Exception);
}
}
+
+ sealed class MaestroServiceManager : ServiceManager
+ {
+ static ILoggingService loggingService = new TextWriterLoggingService(BroadcastTextWriter.Instance);
+ static IMessageService messageService = new TextWriterMessageService(Console.Out);
+
+ public override ILoggingService LoggingService
+ {
+ get { return loggingService; }
+ }
+
+ public override IMessageService MessageService
+ {
+ get { return messageService; }
+ }
+
+ public override object GetService(Type serviceType)
+ {
+ if (serviceType == typeof(ILoggingService))
+ return loggingService;
+ else if (serviceType == typeof(IMessageService))
+ return messageService;
+ else
+ return null;
+ }
+ }
}
Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Commands/StartupCommand.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Commands/StartupCommand.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Commands/StartupCommand.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -3,6 +3,10 @@
using System.Linq;
using System.Text;
using ICSharpCode.Core;
+using Maestro.Base;
+using Maestro.AddIn.Scripting.UI;
+using Maestro.Shared.UI;
+using Maestro.Base.Services;
namespace Maestro.AddIn.Scripting.Commands
{
@@ -10,7 +14,14 @@
{
public override void Run()
{
-
+ ResourceService.RegisterNeutralImages(Properties.Resources.ResourceManager);
+ ResourceService.RegisterNeutralStrings(Properties.Resources.ResourceManager);
+
+ Workbench.WorkbenchInitialized += (sender, e) =>
+ {
+ var mgr = ServiceRegistry.GetService<ViewContentManager>();
+ mgr.OpenContent<IronPythonRepl>(ViewRegion.Bottom);
+ };
}
}
}
Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Maestro.AddIn.Scripting.csproj
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Maestro.AddIn.Scripting.csproj 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Maestro.AddIn.Scripting.csproj 2012-02-15 17:39:10 UTC (rev 6516)
@@ -53,6 +53,7 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
+ <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@@ -69,8 +70,30 @@
</Compile>
<Compile Include="Commands\StartupCommand.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="UI\IPEWrapper.cs" />
+ <Compile Include="UI\IronPythonRepl.cs">
+ <SubType>UserControl</SubType>
+ </Compile>
+ <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">
@@ -98,6 +121,18 @@
<Name>ICSharpCode.Core</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ </EmbeddedResource>
+ <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.
Other similar extension points exist, see Microsoft.Common.targets.
Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Manifest.addin
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Manifest.addin 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Manifest.addin 2012-02-15 17:39:10 UTC (rev 6516)
@@ -22,4 +22,9 @@
<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" />
+ </Path>
</AddIn>
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.Designer.cs (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.Designer.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,72 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.239
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Maestro.AddIn.Scripting.Properties {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Maestro.AddIn.Scripting.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to IronPython Console.
+ /// </summary>
+ internal static string Title_IronPython_Console {
+ get {
+ return ResourceManager.GetString("Title_IronPython_Console", resourceCulture);
+ }
+ }
+ }
+}
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.resx (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Properties/Resources.resx 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,123 @@
+<?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>
+ <data name="Title_IronPython_Console" xml:space="preserve">
+ <value>IronPython Console</value>
+ </data>
+</root>
\ No newline at end of file
Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Services/ScriptingClasses.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Services/ScriptingClasses.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Services/ScriptingClasses.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -26,11 +26,14 @@
using OSGeo.MapGuide.MaestroAPI;
using Maestro.Base;
using Maestro.Base.Services;
+using System.IO;
namespace Maestro.AddIn.Scripting.Services
{
/// <summary>
- /// A simplified helper class that is exposed to python scripts
+ /// A simplified helper class that is exposed to python scripts to provide
+ /// convenience functionality or to workaround concepts that don't cleanly
+ /// translate to IronPython (eg. Generics)
/// </summary>
public class HostApplication
{
@@ -51,6 +54,32 @@
}
/// <summary>
+ /// Gets the XML content of the given resource id
+ /// </summary>
+ /// <param name="conn"></param>
+ /// <param name="resourceId"></param>
+ /// <returns></returns>
+ public string GetResourceXml(IServerConnection conn, string resourceId)
+ {
+ var res = conn.ResourceService.GetResource(resourceId);
+ return ResourceTypeRegistry.SerializeAsString(res);
+ }
+
+ /// <summary>
+ /// Sets the XML content of the given resource id
+ /// </summary>
+ /// <param name="conn"></param>
+ /// <param name="resourceId"></param>
+ /// <param name="xml"></param>
+ public void SetResourceXml(IServerConnection conn, string resourceId, string xml)
+ {
+ using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(xml)))
+ {
+ conn.ResourceService.SetResourceXmlData(resourceId, ms);
+ }
+ }
+
+ /// <summary>
/// Launches the specified url
/// </summary>
/// <param name="url"></param>
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IPEWrapper.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IPEWrapper.cs (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IPEWrapper.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,127 @@
+//---------------------------------------------------------------------------------
+//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
+ text = text.Replace("\\n", "\r\n"); //to support newline for textbox use
+ 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;
+ }
+ }
+}
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.Designer.cs (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.Designer.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,45 @@
+namespace Maestro.AddIn.Scripting.UI
+{
+ partial class IronPythonRepl
+ {
+ /// <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 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();
+ //
+ // IronPythonRepl
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Name = "IronPythonRepl";
+ this.Size = new System.Drawing.Size(638, 277);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+ }
+}
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,61 @@
+#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.Drawing;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using Maestro.Shared.UI;
+
+namespace Maestro.AddIn.Scripting.UI
+{
+ public partial class IronPythonRepl : SingletonViewContent
+ {
+ private IronTextBoxControl _console;
+
+ public IronPythonRepl()
+ {
+ InitializeComponent();
+ _console = new IronTextBoxControl();
+ _console.Prompt = ">>>";
+ _console.Dock = DockStyle.Fill;
+ this.Controls.Add(_console);
+
+ this.Title = this.Description = Properties.Resources.Title_IronPython_Console;
+ }
+
+ protected override void OnLoad(EventArgs e)
+ {
+ _console.WriteText("help" + Environment.NewLine);
+ _console.SimEnter();
+ }
+
+ public override ViewRegion DefaultRegion
+ {
+ get
+ {
+ return ViewRegion.Bottom;
+ }
+ }
+ }
+}
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.resx (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.resx 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,120 @@
+<?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
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronTextBox.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronTextBox.cs (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronTextBox.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,1790 @@
+//---------------------------------------------------------------------------------
+//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;
+
+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 = ">>>";
+
+ /// <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 "";
+ }
+
+ /// <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"))
+ 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(":"))
+ {
+ //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));
+ e.Handled = true;
+ return;
+
+ }
+ else//We are past the first line, and are indenting or ending a def
+ {
+ this.defStmtBuilder.Append(currentCommand + "\r\n");
+
+ //if it is an empty command let's see if we just finished a def statement
+ if (currentCommand.Trim().Equals(""))
+ {
+ ((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));
+ e.Handled = true;
+ return;
+ }
+ }
+ }
+
+ //raw_input support...
+ if (currentCommand.Trim().Contains("raw_input("))
+ {
+ 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);
+ 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 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()"))
+ {
+ IsRawInput = false;
+ }
+ else// s = raw_input('--> ')
+ {
+ IsRawInput = false;
+ rawprompt = "";
+ 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 = "";
+ for (int i = 0; i < indentsize; i++)
+ {
+ r += " ";
+ }
+ 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 = "";
+ 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());
+ //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 != "")
+ {
+ if (command == "cls")
+ this.Clear();
+ else if (command.StartsWith("refl "))
+ this.ReflectIdentifier(command.Substring(5), false);
+ else if (command.StartsWith("reflw "))
+ this.ReflectIdentifier(command.Substring(6), true);
+ else if (command.StartsWith("printw "))
+ this.PrintIdentifier(command.Substring(7), true);
+ else if (command == "history")
+ {
+ 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")
+ {
+ this.WriteText(GetHelpText());
+ }
+ else if (command == "newconsole")
+ {
+ //consoleTextBox.global_eng = new PythonEngine();
+ this.WriteText("Not currently supported\r\n");
+ }
+ else if (command.StartsWith("prompt") && command.Length == 6)
+ {
+ string[] parts = command.Split(new char[] { '=' });
+ if (parts.Length == 2 && parts[0].Trim() == "prompt")
+ this.Prompt = parts[1].Trim();
+ }
+ else if (command == "btaf")
+ {
+ //btaf = Browse To Append File....
+ //Check to see if sys is loaded
+ if (!DoIPEvaluate("dir()").ToString().Contains("sys"))
+ {
+ consoleTextBox.printPrompt();
+ consoleTextBox.WriteText("import sys");
+ 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 + "\")");
+ this.SimEnter();
+ }
+ else if (command == "runfile")
+ {
+ //runfile - Run a .Py file. Calls OpenFileDialog to PythonEngine.RunFile....
+ // goodfor debuging .y file within IDE
+ this.Runfile();
+ }
+ else if (command == "btwfi")
+ {
+ //btwfi - Browse To Walk FIle. Calls OpenFileDialog.
+ this.WalkPythonFile();
+ }
+ else if (command == "rew")
+ {
+ //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"))
+ {
+ //Appends all hardcoded common paths stored in Paths
+ //paths [-arg] - [args: -misc, -python24, -ironpython, -all] (-all=default)
+ if (command.Contains(" -"))
+ {
+ string[] splitcommand = command.Split('-');
+ splitcommand[1] = splitcommand[1].Trim();
+ this.ImportPaths(splitcommand[1]);
+ }
+ else
+ this.ImportPaths(command.Trim());
+
+ }
+ else if (command.TrimEnd().EndsWith(":") == true)
+ {
+ //Need to do a ReadStatement...
+ try
+ {
+ bool isMultiLine = false;
+ int autoIndentSize = 0;
+ 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");
+
+ bool endOfInput = (line.Length == 0);
+ bool parsingMultiLineString;
+ bool parsingMultiLineCmpdStmt;
+
+ //old//s = ParsetheText(consoleTextBox.global_eng.Sys, new CompilerContext(), defBuilder.ToString(), endOfInput, out parsingMultiLineString, out isMultiLine);
+ string[] seperators = new string[] { "\r" };
+ 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);
+ }
+ }
+ }
+ }
+
+ 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);
+ }
+ }
+
+ private void ReflectIdentifier(string identifier, bool newWindow)
+ {
+ try
+ {
+ dynamic obj = scope.GetVariable(identifier);
+ var sb = new StringBuilder();
+ sb.Append("========= Reflecting " + identifier + " ==========" + Environment.NewLine);
+ Type t = obj.GetType();
+ sb.Append("CLR Type: " + t.Name + Environment.NewLine);
+ sb.Append("Methods:" + Environment.NewLine);
+ foreach (var method in t.GetMethods())
+ {
+ sb.Append(" - " + method.ToString() + Environment.NewLine);
+ }
+ sb.Append("Properties:" + Environment.NewLine);
+ foreach (var prop in t.GetProperties())
+ {
+ sb.Append(" - " + prop.Name + " (" + prop.PropertyType.Name + ")" + Environment.NewLine);
+ }
+ sb.Append("========= Reflection complete ==========" + Environment.NewLine);
+ if (newWindow)
+ new TextWindow(sb.ToString()).ShowDialog();
+ else
+ WriteText(sb.ToString());
+ }
+ catch (Exception ex)
+ {
+ WriteText("ERROR: " + ex.Message);
+ }
+ }
+
+ /// <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("*******************************************");
+ stringBuilder.Append(System.Environment.NewLine);
+ stringBuilder.Append("** Maestro IronPython Console Help **");
+ stringBuilder.Append(System.Environment.NewLine);
+ stringBuilder.Append("*******************************************");
+ stringBuilder.Append(System.Environment.NewLine);
+ //stringBuilder.Append("You are using " + engine.LanguageDisplayName + " (" + engine.LanguageVersion + ")");
+ stringBuilder.Append("You are using " + engine.Setup.DisplayName + " (" + engine.LanguageVersion + ")");
+ stringBuilder.Append(System.Environment.NewLine);
+ stringBuilder.Append(System.Environment.NewLine);
+ stringBuilder.Append("Commands Available:");
+ stringBuilder.Append(System.Environment.NewLine);
+ stringBuilder.Append(" prompt - Changes prompt. Usage: prompt=<desired_prompt>");
+ stringBuilder.Append(System.Environment.NewLine);
+ stringBuilder.Append(" history - prints history of entered commands.");
+ stringBuilder.Append(System.Environment.NewLine);
+ stringBuilder.Append(" cls - Clears the screen.");
+ stringBuilder.Append(System.Environment.NewLine);
+ //stringBuilder.Append(" newconsole - Clears the current PythonEngine.");
+ stringBuilder.Append(" refl <variable> - Displays all members/properties of a given variable");
+ stringBuilder.Append(System.Environment.NewLine);
+ stringBuilder.Append(" reflw <variable> - Displays all members/properties of a given variable to a new window");
+ stringBuilder.Append(System.Environment.NewLine);
+ stringBuilder.Append(" printw <variable> - Prints the value of the given variable to a new window");
+ stringBuilder.Append(System.Environment.NewLine);
+ stringBuilder.Append(" btaf - Browse To Append Folder. Calls FolderBrowserDialog.");
+ stringBuilder.Append(System.Environment.NewLine);
+ stringBuilder.Append(" btwfi - Browse To Walk FIle. Calls OpenFileDialog.");
+ stringBuilder.Append(System.Environment.NewLine);
+ stringBuilder.Append(" paths [-arg] - [args: -misc, -python24, -ironpython, -all] (-all=default)");
+ stringBuilder.Append(System.Environment.NewLine);
+ stringBuilder.Append(" rew - Re-Write a Python file into a StringBuilder.(for testing)");
+ stringBuilder.Append(System.Environment.NewLine);
+ stringBuilder.Append(" runfile - Run a .Py file. Calls OpenFileDialog to PythonEngine.RunFile.");
+ 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", " ");
+
+ // 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 != "")
+ {
+ //catch """ comments
+ if (line.StartsWith("\"\"\"") || line.StartsWith(" \"\"\"") || line.StartsWith(" \"\"\"") || line.StartsWith(" \"\"\""))
+ {
+ //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("\"\"\""))
+ {
+ //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)
+ {
+ //remove """ and reassign line
+ line = line.Remove(line.Length - 3);
+
+ //get to the end of the comments
+ while (!sr.ReadLine().TrimEnd().EndsWith("\"\"\""))
+ {
+ //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 == "" && 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:");
+ 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"))
+ {
+ consoleTextBox.printPrompt();
+ consoleTextBox.WriteText("import sys");
+ this.SimEnter();
+ }
+
+ //Browse to the file...
+ OpenFileDialog ofd = new OpenFileDialog();
+ ofd.InitialDirectory = Paths.MiscDirs.vs_Projects;
+ ofd.Filter = "Python files (*.py)|*.py|All files (*.*)|*.*";
+ 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?";
+ string caption = "Append Folder Path";
+ 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)) + "\")");
+ 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?";
+ 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 + "\")");
+ this.SimEnter();
+ }
+ }
+ }
+
+ WalkPythonFile(ofd.FileName);
+ }
+ catch (Exception e)
+ {
+ // Let the user know what went wrong.
+ consoleTextBox.WriteText("The file could not be read:");
+ 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 = "Python files (*.py)|*.py|All files (*.*)|*.*";
+ ofd.ShowDialog();
+
+ DoIPExecuteFile(ofd.FileName);
+
+ }
+ catch (Exception ex)
+ {
+ consoleTextBox.WriteText("The file could not be read:");
+ 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"))
+ {
+ consoleTextBox.printPrompt();
+ consoleTextBox.WriteText("import sys");
+ this.SimEnter();
+ }
+
+ //Browse to the file...
+ OpenFileDialog ofd = new OpenFileDialog();
+ ofd.InitialDirectory = Paths.MiscDirs.vs_Projects;
+ ofd.Filter = "Python files (*.py)|*.py|All files (*.*)|*.*";
+ ofd.ShowDialog();
+
+ try
+ {
+ string filetext = File.ReadAllText(ofd.FileName);
+ //tabs create a problem when trying to remove comments
+ filetext = filetext.Replace("\t", " ");
+
+ // 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 != "")
+ {
+ //catch """ comments
+ if (line.StartsWith("\"\"\"") || line.StartsWith(" \"\"\"") || line.StartsWith(" \"\"\"") || line.StartsWith(" \"\"\""))
+ {
+ //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("\"\"\""))
+ {
+ //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)
+ {
+ //remove """ and reassign line
+ line = line.Remove(line.Length - 3);
+
+ //get to the end of the comments
+ while (!sr.ReadLine().TrimEnd().EndsWith("\"\"\""))
+ {
+ //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:");
+ 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 != "")
+ {
+ return true;
+ }
+ else if (line.StartsWith("\"\"\"") || line.StartsWith(" \"\"\"") || line.StartsWith(" \"\"\"") || line.StartsWith(" \"\"\""))
+ {
+ if (line.TrimEnd().EndsWith("\"\"\"") && line.IndexOf("\"\"\"") != line.Length - 3)
+ {
+ 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"))
+ {
+ consoleTextBox.printPrompt();
+ consoleTextBox.WriteText("import sys");
+ this.SimEnter();
+ }
+ else
+ consoleTextBox.printPrompt();
+
+
+ try
+ {
+ switch (arg)
+ {
+ case "misc":
+ {
+ while (SCEMiscDirs.MoveNext())
+ {
+ //consoleTextBox.printPrompt();
+ consoleTextBox.WriteText("sys.path.append(\"" + SCEMiscDirs.Current + "\")");
+ this.SimEnter();
+ }
+ break;
+ }
+ case "python24":
+ {
+ while (SCEPython24Dirs.MoveNext())
+ {
+ //consoleTextBox.printPrompt();
+ consoleTextBox.WriteText("sys.path.append(\"" + SCEPython24Dirs.Current + "\")");
+ this.SimEnter();
+ }
+ break;
+ }
+ case "ironpython":
+ {
+ while (SCEIronPythonDirs.MoveNext())
+ {
+ //consoleTextBox.printPrompt();
+ consoleTextBox.WriteText("sys.path.append(\"" + SCEIronPythonDirs.Current + "\")");
+ this.SimEnter();
+ }
+ break;
+ }
+ case "all":
+ {
+ while (SCEAll.MoveNext())
+ {
+ //consoleTextBox.printPrompt();
+ consoleTextBox.WriteText("sys.path.append(\"" + SCEAll.Current + "\")");
+ this.SimEnter();
+ }
+ break;
+ }
+ case "paths":
+ {
+ while (SCEAll.MoveNext())
+ {
+ //consoleTextBox.printPrompt();
+ consoleTextBox.WriteText("sys.path.append(\"" + SCEAll.Current + "\")");
+ this.SimEnter();
+ }
+ break;
+ }
+ default:
+ consoleTextBox.WriteText("Invalid arg. Only: -misc, -python24, -ironpython, -all");
+ break;
+ }
+ }
+ catch (Exception e)
+ {
+ // Let the user know what went wrong.
+ consoleTextBox.WriteText("ImportPaths error: ");
+ 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":
+ PythonDictionary IPDict = new PythonDictionary();
+ IPDict = (PythonDictionary)inobject;
+ MessageBox.Show(IPDict.ToString());
+ break;
+ case "IronPython.Runtime.List":
+ List IPList = new List();
+ IPList = (List)inobject;
+ MessageBox.Show(IPList.ToString());
+ break;
+ case "System.String":
+ MessageBox.Show(inobject.ToString());
+ break;
+ case "System.Int32":
+ MessageBox.Show(Convert.ToString(inobject));
+ break;
+ case "System.Collections.Specialized.StringCollection":
+ StringCollection IPSC = new StringCollection();
+ IPSC = (StringCollection)inobject;
+ StringEnumerator SCE = IPSC.GetEnumerator();
+ string output = "";
+ while (SCE.MoveNext())
+ output += SCE.Current.ToString();
+ MessageBox.Show(output);
+ break;
+ default:
+ MessageBox.Show(inobject.GetType().ToString() + " not yet implemented.");
+ 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);
+}
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/Paths.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/Paths.cs (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/Paths.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,249 @@
+//---------------------------------------------------------------------------------
+//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";
+
+ /// <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";
+
+ /// <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";
+
+ /*
+ /// <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";
+
+ /// <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";
+
+ /// <summary>
+ /// default: "C:\Python24\libs"
+ /// </summary>
+ public static string Python24_libs = @"C:\Python24\libs";
+
+ /// <summary>
+ /// default: "C:\Python24\DLLs"
+ /// </summary>
+ public static string Python24_DLLs = @"C:\Python24\DLLs";
+
+ /// <summary>
+ /// Some useful programs written in Python.
+ /// default: "C:\Python24\Tools"
+ /// </summary>
+ public static string Python24_Tools = @"C:\Python24\Tools";
+
+ /// <summary>
+ /// Some useful programs written in Python.
+ /// default: "C:\Python24\Tools\Scripts"
+ /// </summary>
+ public static string Python24_Tools_Scripts = @"C:\Python24\Tools\Scripts";
+
+ /*
+ /// <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";
+
+ /// <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";
+
+ /// <summary>
+ /// default: "C:\Python25\libs"
+ /// </summary>
+ public static string Python25_libs = @"C:\Python25\libs";
+
+ /// <summary>
+ /// default: "C:\Python25\DLLs"
+ /// </summary>
+ public static string Python25_DLLs = @"C:\Python25\DLLs";
+
+ /// <summary>
+ /// Some useful programs written in Python.
+ /// default: "C:\Python25\Tools"
+ /// </summary>
+ public static string Python25_Tools = @"C:\Python25\Tools";
+
+ /// <summary>
+ /// Some useful programs written in Python.
+ /// default: "C:\Python25\Tools\Scripts"
+ /// </summary>
+ public static string Python25_Tools_Scripts = @"C:\Python25\Tools\Scripts";
+
+ /*
+ /// <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";
+
+ /// <summary>
+ /// IronPython Paths
+ /// </summary>
+ static IronPythonDirs()
+ {
+
+ }
+ }
+
+ }
+
+}
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.Designer.cs (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.Designer.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,63 @@
+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
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.cs (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,39 @@
+#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;
+ }
+ }
+}
Added: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.resx (rev 0)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/TextWindow.resx 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,120 @@
+<?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/Maestro.Base/UI/ResourceHeaderXmlDialog.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/ResourceHeaderXmlDialog.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Maestro.Base/UI/ResourceHeaderXmlDialog.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -85,7 +85,7 @@
}
catch (Exception ex)
{
- MessageService.ShowError(ex);
+ MessageService.ShowError(ex.ToString());
return;
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/GlobalAssemblyInfo.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/GlobalAssemblyInfo.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/GlobalAssemblyInfo.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -20,16 +20,19 @@
[assembly: System.Runtime.InteropServices.ComVisible(false)]
[assembly: AssemblyCompany("ic#code")]
[assembly: AssemblyProduct("SharpDevelop")]
-[assembly: AssemblyCopyright("2000-2010 AlphaSierraPapa")]
+[assembly: AssemblyCopyright("2000-2012 AlphaSierraPapa")]
[assembly: AssemblyVersion(RevisionClass.FullVersion)]
[assembly: NeutralResourcesLanguage("en-US")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2243:AttributeStringLiteralsShouldParseCorrectly",
+ Justification = "AssemblyInformationalVersion does not need to be a parsable version")]
+
internal static class RevisionClass
{
- public const string Major = "3";
- public const string Minor = "2";
+ public const string Major = "4";
+ public const string Minor = "1";
public const string Build = "0";
- public const string Revision = "5777";
+ public const string Revision = "8000";
public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Configuration/AssemblyInfo.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Configuration/AssemblyInfo.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Configuration/AssemblyInfo.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3763 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Reflection;
@@ -19,3 +15,5 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
+
+[assembly:InternalsVisibleTo("ICSharpCode.Core.Tests,PublicKey=002400000480000094000000060200000024000052534131000400000100010063D5DB5957250F41969C79E88CBD8806165CA7D96D468A9D60F11704A8B0698684B5ACC16FC82E6CEDE459E1D6ED7384B044C47A67D68BAE1E08182473168E2AD92C6FABE32B9217EA59D05BB9A101318AEEC9F767991D2AE8D987B60C591B6020D2816C395DB7F3045A1C77C2B074C508C2B4F25DCD969688DA94EBC83F5F9B")]
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/ICSharpCode.Core.csproj
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/ICSharpCode.Core.csproj 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/ICSharpCode.Core.csproj 2012-02-15 17:39:10 UTC (rev 6516)
@@ -3,7 +3,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
+ <ProductVersion>8.0.50215</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</ProjectGuid>
<RootNamespace>ICSharpCode.Core</RootNamespace>
@@ -21,27 +21,8 @@
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
- <FileUpgradeFlags>
- </FileUpgradeFlags>
- <UpgradeBackupLocation>
- </UpgradeBackupLocation>
- <OldToolsVersion>3.5</OldToolsVersion>
+ <SourceAnalysisOverrideSettingsFile>C:\Users\daniel\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
- <PublishUrl>publish\</PublishUrl>
- <Install>true</Install>
- <InstallFrom>Disk</InstallFrom>
- <UpdateEnabled>false</UpdateEnabled>
- <UpdateMode>Foreground</UpdateMode>
- <UpdateInterval>7</UpdateInterval>
- <UpdateIntervalUnits>Days</UpdateIntervalUnits>
- <UpdatePeriodically>false</UpdatePeriodically>
- <UpdateRequired>false</UpdateRequired>
- <MapFileExtensions>true</MapFileExtensions>
- <ApplicationRevision>0</ApplicationRevision>
- <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
- <IsWebBootstrapper>false</IsWebBootstrapper>
- <UseApplicationTrust>false</UseApplicationTrust>
- <BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -70,6 +51,9 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
@@ -79,6 +63,8 @@
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\AddInTree\AddIn\AddIn.cs" />
<Compile Include="Src\AddInTree\AddIn\AddInLoadException.cs" />
+ <Compile Include="Src\AddInTree\AddIn\AssemblyLocator.cs" />
+ <Compile Include="Src\AddInTree\AddIn\BuildItemArgs.cs" />
<Compile Include="Src\AddInTree\AddIn\Codon.cs" />
<Compile Include="Src\AddInTree\AddIn\ComplexCondition.cs" />
<Compile Include="Src\AddInTree\AddIn\Condition.cs" />
@@ -105,9 +91,13 @@
<Compile Include="Src\AddInTree\AddIn\DefaultDoozers\ToolBarItem\ToolBarItemDoozer.cs" />
<Compile Include="Src\AddInTree\AddInTree.cs" />
<Compile Include="Src\AddInTree\AddInTreeNode.cs" />
+ <Compile Include="Src\AddInTree\TopologicalSort.cs" />
<Compile Include="Src\AddInTree\TreePathNotFoundException.cs" />
<Compile Include="Src\CoreException.cs" />
+ <Compile Include="Src\Services\AnalyticsMonitor\AnalyticsMonitorService.cs" />
+ <Compile Include="Src\Services\AnalyticsMonitor\IAnalyticsMonitor.cs" />
<Compile Include="Src\Services\ApplicationStateInfoService.cs" />
+ <Compile Include="Src\Services\FileUtility\FileName.cs" />
<Compile Include="Src\Services\FileUtility\FileNameEventHandler.cs" />
<Compile Include="Src\Services\FileUtility\FileUtility.cs" />
<Compile Include="Src\Services\FileUtility\FileUtility.Minimal.cs" />
@@ -119,10 +109,13 @@
<Compile Include="Src\Services\PropertyService\Properties.cs" />
<Compile Include="Src\Services\PropertyService\PropertyChangedEvent.cs" />
<Compile Include="Src\Services\PropertyService\PropertyService.cs" />
+ <Compile Include="Src\Services\RegistryService\RegistryService.cs" />
<Compile Include="Src\Services\ResourceService\ResourceNotFoundException.cs" />
<Compile Include="Src\Services\ResourceService\ResourceService.cs" />
<Compile Include="Src\Services\ServiceManager.cs" />
+ <Compile Include="Src\Services\ServiceNotFoundException.cs" />
<Compile Include="Src\Services\StringParser\IStringTagProvider.cs" />
+ <Compile Include="Src\Services\StringParser\PropertyObjectTagProvider.cs" />
<Compile Include="Src\Services\StringParser\StringParser.cs" />
<Compile Include="Src\Util\AbstractCommand.cs" />
<Compile Include="Src\Util\CallbackOnDispose.cs" />
@@ -136,7 +129,6 @@
<Compile Include="Src\AddInTree\CoreStartup.cs" />
<Compile Include="Src\AddInTree\AddInManager.cs" />
<Compile Include="Src\AddInTree\AddIn\DefaultDoozers\StringDoozer.cs" />
- <Compile Include="Src\Util\AppDomainLaunchHelper.cs" />
<Compile Include="Src\AddInTree\AddIn\DefaultDoozers\ToolBarItem\AbstractTextBoxCommand.cs" />
<Compile Include="Src\AddInTree\AddIn\DefaultDoozers\ToolBarItem\ITextBoxCommand.cs" />
</ItemGroup>
@@ -145,26 +137,5 @@
<Link>Src\AddInTree\AddIn\AddIn.xsd</Link>
</Content>
</ItemGroup>
- <ItemGroup>
- <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5 SP1</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
- <Visible>False</Visible>
- <ProductName>Windows Installer 3.1</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <PropertyGroup>
- <PreBuildEvent>
- </PreBuildEvent>
- </PropertyGroup>
</Project>
\ No newline at end of file
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddIn.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddIn.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddIn.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,13 +1,10 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3671 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.IO;
+using System.Reflection;
using System.Xml;
namespace ICSharpCode.Core
@@ -29,36 +26,68 @@
public object CreateObject(string className)
{
+ Type t = FindType(className);
+ if (t != null)
+ return Activator.CreateInstance(t);
+ else
+ return null;
+ }
+
+ public Type FindType(string className)
+ {
LoadDependencies();
foreach (Runtime runtime in runtimes) {
- object o = runtime.CreateInstance(className);
- if (o != null) {
- return o;
+ Type t = runtime.FindType(className);
+ if (t != null) {
+ return t;
}
}
if (hasShownErrorMessage) {
- LoggingService.Error("Cannot create object: " + className);
+ LoggingService.Error("Cannot find class: " + className);
} else {
hasShownErrorMessage = true;
- MessageService.ShowError("Cannot create object: " + className + "\nFuture missing objects will not cause an error message.");
+ MessageService.ShowError("Cannot find class: " + className + "\nFuture missing objects will not cause an error message.");
}
return null;
}
+ public Stream GetManifestResourceStream(string resourceName)
+ {
+ LoadDependencies();
+ foreach (Runtime runtime in runtimes) {
+ Assembly assembly = runtime.LoadedAssembly;
+ if (assembly != null) {
+ Stream s = assembly.GetManifestResourceStream(resourceName);
+ if (s != null) {
+ return s;
+ }
+ }
+ }
+ return null;
+ }
+
public void LoadRuntimeAssemblies()
{
LoadDependencies();
foreach (Runtime runtime in runtimes) {
- runtime.Load();
+ if (runtime.IsActive)
+ runtime.Load();
}
}
- bool dependenciesLoaded;
+ volatile bool dependenciesLoaded;
void LoadDependencies()
{
+ // Thread-safe dependency loading:
+ // Because the methods being called should be thread-safe, there's
+ // no problem when we load dependencies multiple times concurrently.
+ // However, we need to make sure we don't return before the dependencies are ready,
+ // so "bool dependenciesLoaded" must be volatile and set only at the very end of this method.
if (!dependenciesLoaded) {
- dependenciesLoaded = true;
+ LoggingService.Info("Loading addin " + this.Name);
+
+ AssemblyLocator.Init();
foreach (AddInReference r in manifest.Dependencies) {
if (r.RequirePreload) {
bool found = false;
@@ -73,6 +102,7 @@
}
}
}
+ dependenciesLoaded = true;
}
}
@@ -89,9 +119,7 @@
/// Action to be set to AddInAction.CustomError.
/// </summary>
public string CustomErrorMessage {
- get {
- return customErrorMessage;
- }
+ get { return customErrorMessage; }
internal set {
if (value != null) {
Enabled = false;
@@ -105,78 +133,51 @@
/// Action to execute when the application is restarted.
/// </summary>
public AddInAction Action {
- get {
- return action;
- }
- set {
- action = value;
- }
+ get { return action; }
+ set { action = value; }
}
public List<Runtime> Runtimes {
- get {
- return runtimes;
- }
+ get { return runtimes; }
}
public Version Version {
- get {
- return manifest.PrimaryVersion;
- }
+ get { return manifest.PrimaryVersion; }
}
public string FileName {
- get {
- return addInFileName;
- }
+ get { return addInFileName; }
+ set { addInFileName = value; }
}
public string Name {
- get {
- return properties["name"];
- }
+ get { return properties["name"]; }
}
public AddInManifest Manifest {
- get {
- return manifest;
- }
+ get { return manifest; }
}
public Dictionary<string, ExtensionPath> Paths {
- get {
- return paths;
- }
+ get { return paths; }
}
public Properties Properties {
- get {
- return properties;
- }
+ get { return properties; }
}
public List<string> BitmapResources {
- get {
- return bitmapResources;
- }
- set {
- bitmapResources = value;
- }
+ get { return bitmapResources; }
+ set { bitmapResources = value; }
}
public List<string> StringResources {
- get {
- return stringResources;
- }
- set {
- stringResources = value;
- }
+ get { return stringResources; }
+ set { stringResources = value; }
}
public bool Enabled {
- get {
- return enabled;
- }
+ get { return enabled; }
set {
enabled = value;
this.Action = value ? AddInAction.Enable : AddInAction.Disable;
@@ -226,6 +227,7 @@
}
string fileName = Path.Combine(hintPath, reader.GetAttribute(0));
XmlReaderSettings xrs = new XmlReaderSettings();
+ xrs.NameTable = reader.NameTable; // share the name table
xrs.ConformanceLevel = ConformanceLevel.Fragment;
using (XmlReader includeReader = XmlTextReader.Create(fileName, xrs)) {
SetupAddIn(includeReader, addIn, Path.GetDirectoryName(fileName));
@@ -259,42 +261,60 @@
return paths[pathName];
}
- public static AddIn Load(TextReader textReader)
+ public static AddIn Load(TextReader textReader, string hintPath = null, XmlNameTable nameTable = null)
{
- return Load(textReader, null);
- }
-
- public static AddIn Load(TextReader textReader, string hintPath)
- {
- AddIn addIn = new AddIn();
- using (XmlTextReader reader = new XmlTextReader(textReader)) {
- while (reader.Read()){
- if (reader.IsStartElement()) {
- switch (reader.LocalName) {
- case "AddIn":
- addIn.properties = Properties.ReadFromAttributes(reader);
- SetupAddIn(reader, addIn, hintPath);
- break;
- default:
- throw new AddInLoadException("Unknown add-in file.");
+ if (nameTable == null)
+ nameTable = new NameTable();
+ try {
+ AddIn addIn = new AddIn();
+ using (XmlTextReader reader = new XmlTextReader(textReader, nameTable)) {
+ while (reader.Read()){
+ if (reader.IsStartElement()) {
+ switch (reader.LocalName) {
+ case "AddIn":
+ addIn.properties = Properties.ReadFromAttributes(reader);
+ SetupAddIn(reader, addIn, hintPath);
+ break;
+ default:
+ throw new AddInLoadException("Unknown add-in file.");
+ }
}
}
}
+ return addIn;
+ } catch (XmlException ex) {
+ throw new AddInLoadException(ex.Message, ex);
}
- return addIn;
}
- public static AddIn Load(string fileName)
+ public static AddIn Load(string fileName, XmlNameTable nameTable = null)
{
try {
using (TextReader textReader = File.OpenText(fileName)) {
- AddIn addIn = Load(textReader, Path.GetDirectoryName(fileName));
+ AddIn addIn = Load(textReader, Path.GetDirectoryName(fileName), nameTable);
addIn.addInFileName = fileName;
return addIn;
}
+ } catch (AddInLoadException) {
+ throw;
} catch (Exception e) {
throw new AddInLoadException("Can't load " + fileName, e);
}
}
+
+ /// <summary>
+ /// Gets whether the AddIn is a preinstalled component of the host application.
+ /// </summary>
+ public bool IsPreinstalled {
+ get {
+ if (FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, this.FileName)) {
+ string hidden = this.Properties["addInManagerHidden"];
+ return string.Equals(hidden, "true", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(hidden, "preinstalled", StringComparison.OrdinalIgnoreCase);
+ } else {
+ return false;
+ }
+ }
+ }
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddInLoadException.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddInLoadException.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddInLoadException.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Daniel Grunwald" email="daniel at danielgrunwald.de"/>
-// <version>$Revision: 1624 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Runtime.Serialization;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddInReference.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddInReference.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddInReference.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Daniel Grunwald" email="daniel at danielgrunwald.de"/>
-// <version>$Revision: 5352 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
@@ -98,15 +94,6 @@
} else {
reference.maximumVersion = reference.minimumVersion = ParseVersion(version, hintPath);
}
-
- if (reference.Name == "SharpDevelop") {
- // HACK: SD 3.0 AddIns work with SharpDevelop 3.1
- // Because some 3.0 AddIns restrict themselves to SD 3.0, we extend the
- // supported SD range.
- if (reference.maximumVersion == new Version("3.0") || reference.maximumVersion == new Version("3.1")) {
- reference.maximumVersion = new Version(RevisionClass.MainVersion);
- }
- }
}
reference.requirePreload = string.Equals(properties["requirePreload"], "true", StringComparison.OrdinalIgnoreCase);
return reference;
@@ -121,7 +108,7 @@
if (version.StartsWith("@")) {
if (version == "@SharpDevelopCoreVersion") {
if (entryVersion == null)
- entryVersion = new Version(RevisionClass.FullVersion);
+ entryVersion = new Version(RevisionClass.Major + "." + RevisionClass.Minor + "." + RevisionClass.Build + "." + RevisionClass.Revision);
return entryVersion;
}
if (hintPath != null) {
Added: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AssemblyLocator.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AssemblyLocator.cs (rev 0)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AssemblyLocator.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,46 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+
+namespace ICSharpCode.Core
+{
+ // Based on http://ayende.com/Blog/archive/2006/05/22/SolvingTheAssemblyLoadContextProblem.aspx
+ // This class ensures that assemblies loaded into the LoadFrom context are also available
+ // in the Load context.
+ static class AssemblyLocator
+ {
+ static Dictionary<string, Assembly> assemblies = new Dictionary<string, Assembly>();
+ static bool initialized;
+
+ public static void Init()
+ {
+ lock (assemblies) {
+ if (initialized)
+ return;
+ initialized = true;
+ AppDomain.CurrentDomain.AssemblyLoad += CurrentDomain_AssemblyLoad;
+ AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
+ }
+ }
+
+ static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
+ {
+ lock (assemblies) {
+ Assembly assembly = null;
+ assemblies.TryGetValue(args.Name, out assembly);
+ return assembly;
+ }
+ }
+
+ static void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
+ {
+ Assembly assembly = args.LoadedAssembly;
+ lock (assemblies) {
+ assemblies[assembly.FullName] = assembly;
+ }
+ }
+ }
+}
Added: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/BuildItemArgs.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/BuildItemArgs.cs (rev 0)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/BuildItemArgs.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,78 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Argument class used for <see cref="IDoozer.BuildItem"/>.
+ /// </summary>
+ public class BuildItemArgs
+ {
+ object caller;
+ Codon codon;
+ IEnumerable<ICondition> conditions;
+ AddInTreeNode subItemNode;
+
+ public BuildItemArgs(object caller, Codon codon, IEnumerable<ICondition> conditions, AddInTreeNode subItemNode)
+ {
+ if (codon == null)
+ throw new ArgumentNullException("codon");
+ this.caller = caller;
+ this.codon = codon;
+ this.conditions = conditions ?? Enumerable.Empty<ICondition>();
+ this.subItemNode = subItemNode;
+ }
+
+ /// <summary>
+ /// The caller passed to <see cref="AddInTree.BuildItem(string,object)"/>.
+ /// </summary>
+ public object Caller {
+ get { return caller; }
+ }
+
+ /// <summary>
+ /// The codon to build.
+ /// </summary>
+ public Codon Codon {
+ get { return codon; }
+ }
+
+ /// <summary>
+ /// The addin containing the codon.
+ /// </summary>
+ public AddIn AddIn {
+ get { return codon.AddIn; }
+ }
+
+ /// <summary>
+ /// The conditions applied to this item.
+ /// </summary>
+ public IEnumerable<ICondition> Conditions {
+ get { return conditions; }
+ }
+
+ /// <summary>
+ /// The addin tree node containing the sub-items.
+ /// Returns null if no sub-items exist.
+ /// </summary>
+ public AddInTreeNode SubItemNode {
+ get { return subItemNode; }
+ }
+
+ /// <summary>
+ /// Builds the sub-items.
+ /// Conditions on this node are also applied to the sub-nodes.
+ /// </summary>
+ public List<T> BuildSubItems<T>()
+ {
+ if (subItemNode == null)
+ return new List<T>();
+ else
+ return subItemNode.BuildChildItems<T>(caller, conditions);
+ }
+ }
+}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Codon.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Codon.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Codon.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,13 +1,10 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 2059 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Linq;
namespace ICSharpCode.Core
{
@@ -41,26 +38,14 @@
public string InsertAfter {
get {
- if (!properties.Contains("insertafter")) {
- return "";
- }
return properties["insertafter"];
}
- set {
- properties["insertafter"] = value;
- }
}
public string InsertBefore {
get {
- if (!properties.Contains("insertbefore")) {
- return "";
- }
return properties["insertbefore"];
}
- set {
- properties["insertbefore"] = value;
- }
}
public string this[string key] {
@@ -102,25 +87,27 @@
// properties.BinarySerialize(writer);
// }
//
- public object BuildItem(object owner, ArrayList subItems)
+
+ internal object BuildItem(BuildItemArgs args)
{
IDoozer doozer;
if (!AddInTree.Doozers.TryGetValue(Name, out doozer))
- throw new CoreException("Doozer " + Name + " not found!");
+ throw new CoreException("Doozer " + Name + " not found! " + ToString());
- if (!doozer.HandleConditions && conditions.Length > 0) {
- ConditionFailedAction action = GetFailedAction(owner);
+ if (!doozer.HandleConditions) {
+ ConditionFailedAction action = Condition.GetFailedAction(args.Conditions, args.Caller);
if (action != ConditionFailedAction.Nothing) {
return null;
}
}
- return doozer.BuildItem(owner, this, subItems);
+ return doozer.BuildItem(args);
}
public override string ToString()
{
- return String.Format("[Codon: name = {0}, addIn={1}]",
+ return String.Format("[Codon: name = {0}, id = {1}, addIn={2}]",
name,
+ Id,
addIn.FileName);
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ComplexCondition.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ComplexCondition.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ComplexCondition.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 1965 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Diagnostics;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Condition.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Condition.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Condition.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 2085 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
@@ -53,14 +49,13 @@
action = properties.Get("action", ConditionFailedAction.Exclude);
}
- public bool IsValid(object caller)
+ public bool IsValid(object owner)
{
try {
- return AddInTree.ConditionEvaluators[name].IsValid(caller, this);
+ return AddInTree.ConditionEvaluators[name].IsValid(owner, this);
} catch (KeyNotFoundException) {
throw new CoreException("Condition evaluator " + name + " not found!");
}
-
}
public static ICondition Read(XmlReader reader)
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/CompareConditionEvaluator.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/CompareConditionEvaluator.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/CompareConditionEvaluator.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3863 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/LazyConditionEvaluator.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/LazyConditionEvaluator.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/LazyConditionEvaluator.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 1965 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/OwnerStateConditionEvaluator.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/OwnerStateConditionEvaluator.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/OwnerStateConditionEvaluator.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 1965 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
@@ -32,8 +28,8 @@
int conditionInt = Int32.Parse(conditionEnum.ToString("D"));
return (stateInt & conditionInt) > 0;
- } catch (Exception) {
- throw new ApplicationException("can't parse '" + condition.Properties["state"] + "'. Not a valid value.");
+ } catch (Exception ex) {
+ throw new CoreException("can't parse '" + condition.Properties["state"] + "'. Not a valid value.", ex);
}
}
return false;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ClassDoozer.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ClassDoozer.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ClassDoozer.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 934 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
@@ -33,8 +29,9 @@
}
}
- public object BuildItem(object caller, Codon codon, ArrayList subItems)
+ public object BuildItem(BuildItemArgs args)
{
+ Codon codon = args.Codon;
return codon.AddIn.CreateObject(codon.Properties["class"]);
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/FileFilterDoozer.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/FileFilterDoozer.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/FileFilterDoozer.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 915 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
@@ -21,7 +17,7 @@
/// </attribute>
/// <usage>Only in /SharpDevelop/Workbench/FileFilter</usage>
/// <returns>
- /// String in the format "name|extensions".
+ /// <see cref="FileFilterDescriptor"/> in the format "name|extensions".
/// </returns>
public class FileFilterDoozer : IDoozer
{
@@ -35,9 +31,41 @@
}
}
- public object BuildItem(object caller, Codon codon, ArrayList subItems)
+ public object BuildItem(BuildItemArgs args)
{
- return StringParser.Parse(codon.Properties["name"]) + "|" + codon.Properties["extensions"];
+ Codon codon = args.Codon;
+ return new FileFilterDescriptor {
+ Name = StringParser.Parse(codon.Properties["name"]),
+ Extensions = codon.Properties["extensions"],
+ MimeType = codon.Properties["mimeType"]
+ };
}
}
+
+ public sealed class FileFilterDescriptor
+ {
+ public string Name { get; set; }
+ public string Extensions { get; set; }
+ public string MimeType { get; set; }
+
+ /// <summary>
+ /// Gets whether this descriptor matches the specified file extension.
+ /// </summary>
+ /// <param name="extension">File extension starting with '.'</param>
+ public bool ContainsExtension(string extension)
+ {
+ if (string.IsNullOrEmpty(extension))
+ return false;
+ int index = this.Extensions.IndexOf("*" + extension, StringComparison.OrdinalIgnoreCase);
+ if (index < 0 || index + extension.Length > this.Extensions.Length)
+ return false;
+ return index + extension.Length < this.Extensions.Length
+ || this.Extensions[index + extension.Length] == ';';
+ }
+
+ public override string ToString()
+ {
+ return Name + "|" + Extensions;
+ }
+ }
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/Icon/IconDescriptor.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/Icon/IconDescriptor.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/Icon/IconDescriptor.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 1965 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/Icon/IconDoozer.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/Icon/IconDoozer.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/Icon/IconDoozer.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 1965 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
@@ -41,9 +37,9 @@
}
}
- public object BuildItem(object caller, Codon codon, ArrayList subItems)
+ public object BuildItem(BuildItemArgs args)
{
- return new IconDescriptor(codon);
+ return new IconDescriptor(args.Codon);
}
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/IncludeDoozer.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/IncludeDoozer.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/IncludeDoozer.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,12 +1,9 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Daniel Grunwald" email="daniel at danielgrunwald.de"/>
-// <version>$Revision: 1185 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
+using System.Collections.Generic;
namespace ICSharpCode.Core
{
@@ -36,47 +33,48 @@
/// </summary>
public bool HandleConditions {
get {
- return false;
+ return true;
}
}
- public object BuildItem(object caller, Codon codon, ArrayList subItems)
+ public object BuildItem(BuildItemArgs args)
{
+ Codon codon = args.Codon;
string item = codon.Properties["item"];
string path = codon.Properties["path"];
if (item != null && item.Length > 0) {
// include item
- return AddInTree.BuildItem(item, caller);
+ return AddInTree.BuildItem(item, args.Caller, args.Conditions);
} else if (path != null && path.Length > 0) {
// include path (=multiple items)
- return new IncludeReturnItem(caller, path);
+ return new IncludeReturnItem(args.Caller, path, args.Conditions);
} else {
- MessageService.ShowMessage("<Include> requires the attribute 'item' (to include one item) or the attribute 'path' (to include multiple items)");
- return null;
+ throw new CoreException("<Include> requires the attribute 'item' (to include one item) or the attribute 'path' (to include multiple items)");
}
}
- class IncludeReturnItem : IBuildItemsModifier
+ sealed class IncludeReturnItem : IBuildItemsModifier
{
string path;
object caller;
+ IEnumerable<ICondition> additionalConditions;
- public IncludeReturnItem(object caller, string path)
+ public IncludeReturnItem(object caller, string path, IEnumerable<ICondition> additionalConditions)
{
this.caller = caller;
this.path = path;
+ this.additionalConditions = additionalConditions;
}
public void Apply(IList items)
{
- AddInTreeNode node;
- try {
- node = AddInTree.GetTreeNode(path);
- foreach (object o in node.BuildChildItems(caller)) {
+ AddInTreeNode node = AddInTree.GetTreeNode(path, false);
+ if (node != null) {
+ foreach (object o in node.BuildChildItems<object>(caller, additionalConditions)) {
items.Add(o);
}
- } catch (TreePathNotFoundException) {
- MessageService.ShowError("IncludeDoozer: AddinTree-Path not found: " + path);
+ } else {
+ throw new CoreException("IncludeDoozer: AddinTree-Path not found: " + path);
}
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/LazyDoozer.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/LazyDoozer.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/LazyDoozer.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 915 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
@@ -55,14 +51,14 @@
}
}
- public object BuildItem(object caller, Codon codon, ArrayList subItems)
+ public object BuildItem(BuildItemArgs args)
{
IDoozer doozer = (IDoozer)addIn.CreateObject(className);
if (doozer == null) {
return null;
}
AddInTree.Doozers[name] = doozer;
- return doozer.BuildItem(caller, codon, subItems);
+ return doozer.BuildItem(args);
}
public override string ToString()
@@ -71,6 +67,5 @@
className,
name);
}
-
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/AbstractCheckableMenuCommand.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/AbstractCheckableMenuCommand.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/AbstractCheckableMenuCommand.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 1965 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/AbstractMenuCommand.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/AbstractMenuCommand.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/AbstractMenuCommand.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 1965 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/ICheckableMenuCommand.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/ICheckableMenuCommand.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/ICheckableMenuCommand.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 1965 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/IMenuCommand.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/IMenuCommand.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/IMenuCommand.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 1965 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/MenuItemDoozer.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/MenuItemDoozer.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/MenuItemDoozer.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3287 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
@@ -33,6 +29,11 @@
/// <attribute name="class" use="optional">
/// Command class that is run when item is clicked.
/// </attribute>
+ /// <attribute name="command" use="optional">
+ /// A WPF routed command that is executed when item is clicked.
+ /// Currently, this property is supported only for WPF Menus.
+ /// Only one of the "class" and "command" attributes can be used on a menu entry.
+ /// </attribute>
/// <attribute name="link" use="optional">
/// Only for the type "Item"/"Command". Opens a webpage instead of running a command when
/// clicking the item.
@@ -60,9 +61,9 @@
}
}
- public object BuildItem(object caller, Codon codon, ArrayList subItems)
+ public object BuildItem(BuildItemArgs args)
{
- return new MenuItemDescriptor(caller, codon, subItems);
+ return new MenuItemDescriptor(args.Caller, args.Codon, args.BuildSubItems<object>());
}
}
@@ -78,6 +79,8 @@
public MenuItemDescriptor(object caller, Codon codon, IList subItems)
{
+ if (codon == null)
+ throw new ArgumentNullException("codon");
this.Caller = caller;
this.Codon = codon;
this.SubItems = subItems;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/StringDoozer.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/StringDoozer.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/StringDoozer.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Daniel Grunwald" email="daniel at danielgrunwald.de"/>
-// <version>$Revision: 1048 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
@@ -31,9 +27,9 @@
}
}
- public object BuildItem(object caller, Codon codon, ArrayList subItems)
+ public object BuildItem(BuildItemArgs args)
{
- return StringParser.Parse(codon.Properties["text"]);
+ return StringParser.Parse(args.Codon.Properties["text"]);
}
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/AbstractComboBoxCommand.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/AbstractComboBoxCommand.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/AbstractComboBoxCommand.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 1965 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
@@ -12,6 +8,7 @@
public abstract class AbstractComboBoxCommand : AbstractCommand, IComboBoxCommand
{
bool isEnabled = true;
+ object comboBox;
public virtual bool IsEnabled {
get {
@@ -22,10 +19,21 @@
}
}
+ public virtual object ComboBox {
+ get { return comboBox; }
+ set {
+ comboBox = value;
+ OnComboBoxChanged();
+ }
+ }
+
+ protected virtual void OnComboBoxChanged()
+ {
+ }
+
public override void Run()
{
}
-
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/AbstractTextBoxCommand.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/AbstractTextBoxCommand.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/AbstractTextBoxCommand.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="John Simons" email="johnsimons007 at yahoo.com.au"/>
-// <version>$Revision: 1965 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/IComboBoxCommand.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/IComboBoxCommand.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/IComboBoxCommand.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 1965 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
@@ -15,5 +11,10 @@
get;
set;
}
+
+ object ComboBox {
+ get;
+ set;
+ }
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/ITextBoxCommand.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/ITextBoxCommand.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/ITextBoxCommand.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="John Simons" email="johnsimons007 at yahoo.com.au"/>
-// <version>$Revision: 1965 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/ToolBarItemDoozer.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/ToolBarItemDoozer.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/ToolBarItemDoozer.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3287 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
@@ -34,6 +30,9 @@
/// Command class that is run when item is clicked; or class that manages
/// the ComboBox/DropDownButton. Required for everything except "Separator".
/// </attribute>
+ /// <attribute name="shortcut" use="optional">
+ /// Shortcut that activates the command (e.g. "Control|S").
+ /// </attribute>
/// <usage>Any toolbar strip paths, e.g. /SharpDevelop/Workbench/ToolBar</usage>
/// <children childTypes="MenuItem">A drop down button has menu items as sub elements.</children>
/// <returns>
@@ -52,9 +51,9 @@
}
}
- public object BuildItem(object caller, Codon codon, ArrayList subItems)
+ public object BuildItem(BuildItemArgs args)
{
- return new ToolbarItemDescriptor(caller, codon, subItems);
+ return new ToolbarItemDescriptor(args.Caller, args.Codon, args.BuildSubItems<object>());
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ExtensionPath.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ExtensionPath.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ExtensionPath.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,25 +1,22 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 1965 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Xml;
namespace ICSharpCode.Core
{
/// <summary>
- /// Description of Path.
+ /// Represents all contributions to a Path in a single .addin file.
/// </summary>
public class ExtensionPath
{
- string name;
- AddIn addIn;
- List<Codon> codons = new List<Codon>();
-
+ string name;
+ AddIn addIn;
+ List<List<Codon>> codons = new List<List<Codon>>();
+
public AddIn AddIn {
get {
return addIn;
@@ -31,27 +28,50 @@
return name;
}
}
- public List<Codon> Codons {
+
+ public IEnumerable<Codon> Codons {
get {
- return codons;
+ return
+ from list in codons
+ from c in list
+ select c;
}
}
-
+
+ /// <summary>
+ /// Gets the codons separated by the groups they were created in.
+ /// i.e. if two addins add the codons to the same path they will be in diffrent group.
+ /// if the same addin adds the codon in diffrent path elements they will be in diffrent groups.
+ /// </summary>
+ public IEnumerable<IEnumerable<Codon>> GroupedCodons {
+ get {
+ return codons.AsReadOnly();
+ }
+ }
+
public ExtensionPath(string name, AddIn addIn)
{
this.addIn = addIn;
this.name = name;
}
-
+
public static void SetUp(ExtensionPath extensionPath, XmlReader reader, string endElement)
{
+ extensionPath.DoSetUp(reader, endElement);
+ }
+
+ void DoSetUp(XmlReader reader, string endElement)
+ {
Stack<ICondition> conditionStack = new Stack<ICondition>();
+ List<Codon> innerCodons = new List<Codon>();
while (reader.Read()) {
switch (reader.NodeType) {
case XmlNodeType.EndElement:
if (reader.LocalName == "Condition" || reader.LocalName == "ComplexCondition") {
conditionStack.Pop();
} else if (reader.LocalName == endElement) {
+ if (innerCodons.Count > 0)
+ this.codons.Add(innerCodons);
return;
}
break;
@@ -62,22 +82,18 @@
} else if (elementName == "ComplexCondition") {
conditionStack.Push(Condition.ReadComplexCondition(reader));
} else {
- Codon newCodon = new Codon(extensionPath.AddIn, elementName, Properties.ReadFromAttributes(reader), conditionStack.ToArray());
- extensionPath.codons.Add(newCodon);
+ Codon newCodon = new Codon(this.AddIn, elementName, Properties.ReadFromAttributes(reader), conditionStack.ToArray());
+ innerCodons.Add(newCodon);
if (!reader.IsEmptyElement) {
- ExtensionPath subPath = extensionPath.AddIn.GetExtensionPath(extensionPath.Name + "/" + newCodon.Id);
- //foreach (ICondition condition in extensionPath.conditionStack) {
- // subPath.conditionStack.Push(condition);
- //}
- SetUp(subPath, reader, elementName);
- //foreach (ICondition condition in extensionPath.conditionStack) {
- // subPath.conditionStack.Pop();
- //}
+ ExtensionPath subPath = this.AddIn.GetExtensionPath(this.Name + "/" + newCodon.Id);
+ subPath.DoSetUp(reader, elementName);
}
}
break;
}
}
+ if (innerCodons.Count > 0)
+ this.codons.Add(innerCodons);
}
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IBuildItemsModifier.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IBuildItemsModifier.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IBuildItemsModifier.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Daniel Grunwald" email="daniel at danielgrunwald.de"/>
-// <version>$Revision: 1185 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ICondition.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ICondition.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ICondition.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 1751 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
@@ -37,6 +33,6 @@
/// <summary>
/// Returns true, when the condition is valid otherwise false.
/// </summary>
- bool IsValid(object caller);
+ bool IsValid(object owner);
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IConditionEvaluator.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IConditionEvaluator.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IConditionEvaluator.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 915 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
@@ -14,6 +10,6 @@
/// </summary>
public interface IConditionEvaluator
{
- bool IsValid(object caller, Condition condition);
+ bool IsValid(object owner, Condition condition);
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IDoozer.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IDoozer.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IDoozer.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 2318 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
@@ -25,10 +21,11 @@
/// <summary>
/// Construct the item.
/// </summary>
- /// <param name="caller">The caller passed to <see cref="AddInTree.BuildItem"/>.</param>
- /// <param name="codon">The codon to build.</param>
- /// <param name="subItems">The list of objects created by (other) doozers for the sub items.</param>
- /// <returns>The constructed item.</returns>
- object BuildItem(object caller, Codon codon, ArrayList subItems);
+ /// <returns>
+ /// The constructed item.
+ /// May return an object implementing <see cref="IBuildItemsModifier"/> for returning
+ /// multiple arguments.
+ /// </returns>
+ object BuildItem(BuildItemArgs args);
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Manifest.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Manifest.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Manifest.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,12 +1,9 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Daniel Grunwald" email="daniel at danielgrunwald.de"/>
-// <version>$Revision: 915 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Xml;
namespace ICSharpCode.Core
@@ -40,15 +37,15 @@
}
}
- public List<AddInReference> Dependencies {
+ public ReadOnlyCollection<AddInReference> Dependencies {
get {
- return dependencies;
+ return dependencies.AsReadOnly();
}
}
- public List<AddInReference> Conflicts {
+ public ReadOnlyCollection<AddInReference> Conflicts {
get {
- return conflicts;
+ return conflicts.AsReadOnly();
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Runtime.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Runtime.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Runtime.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,14 +1,11 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 2564 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
+using System.Threading;
using System.Xml;
namespace ICSharpCode.Core
@@ -22,80 +19,95 @@
IList<LazyLoadDoozer> definedDoozers = new List<LazyLoadDoozer>();
IList<LazyConditionEvaluator> definedConditionEvaluators = new List<LazyConditionEvaluator>();
ICondition[] conditions;
+ IList<AddIn> addIns;
bool isActive = true;
bool isAssemblyLoaded;
+ readonly object lockObj = new object(); // used to protect mutable parts of runtime
public bool IsActive {
get {
- if (conditions != null) {
- isActive = Condition.GetFailedAction(conditions, this) == ConditionFailedAction.Nothing;
- conditions = null;
+ lock (lockObj) {
+ if (conditions != null) {
+ isActive = Condition.GetFailedAction(conditions, this) == ConditionFailedAction.Nothing;
+ conditions = null;
+ }
+ return isActive;
}
- return isActive;
}
}
public Runtime(string assembly, string hintPath)
+ : this(assembly, hintPath, AddInTree.AddIns)
{
+ }
+
+ public Runtime(string assembly, string hintPath, IList<AddIn> addIns)
+ {
this.assembly = assembly;
this.hintPath = hintPath;
+ this.addIns = addIns;
}
public string Assembly {
- get {
- return assembly;
- }
+ get { return assembly; }
}
-
+
/// <summary>
/// Force loading the runtime assembly now.
/// </summary>
public void Load()
{
- if (!isAssemblyLoaded) {
- LoggingService.Info("Loading addin " + assembly);
-
- isAssemblyLoaded = true;
-
- try {
- if (assembly[0] == ':') {
- loadedAssembly = System.Reflection.Assembly.Load(assembly.Substring(1));
- } else if (assembly[0] == '$') {
- int pos = assembly.IndexOf('/');
- if (pos < 0)
- throw new ApplicationException("Expected '/' in path beginning with '$'!");
- string referencedAddIn = assembly.Substring(1, pos - 1);
- foreach (AddIn addIn in AddInTree.AddIns) {
- if (addIn.Enabled && addIn.Manifest.Identities.ContainsKey(referencedAddIn)) {
- string assemblyFile = Path.Combine(Path.GetDirectoryName(addIn.FileName),
- assembly.Substring(pos + 1));
- loadedAssembly = System.Reflection.Assembly.LoadFrom(assemblyFile);
- break;
+ lock (lockObj) {
+ if (!isAssemblyLoaded) {
+ if (!this.IsActive)
+ throw new InvalidOperationException("Cannot load inactive AddIn runtime");
+
+ isAssemblyLoaded = true;
+
+ try {
+ if (assembly[0] == ':') {
+ loadedAssembly = LoadAssembly(assembly.Substring(1));
+ } else if (assembly[0] == '$') {
+ int pos = assembly.IndexOf('/');
+ if (pos < 0)
+ throw new CoreException("Expected '/' in path beginning with '$'!");
+ string referencedAddIn = assembly.Substring(1, pos - 1);
+ foreach (AddIn addIn in addIns) {
+ if (addIn.Enabled && addIn.Manifest.Identities.ContainsKey(referencedAddIn)) {
+ string assemblyFile = Path.Combine(Path.GetDirectoryName(addIn.FileName),
+ assembly.Substring(pos + 1));
+ loadedAssembly = LoadAssemblyFrom(assemblyFile);
+ break;
+ }
}
+ if (loadedAssembly == null) {
+ throw new FileNotFoundException("Could not find referenced AddIn " + referencedAddIn);
+ }
+ } else {
+ loadedAssembly = LoadAssemblyFrom(Path.Combine(hintPath, assembly));
}
- if (loadedAssembly == null) {
- throw new FileNotFoundException("Could not find referenced AddIn " + referencedAddIn);
- }
- } else {
- loadedAssembly = System.Reflection.Assembly.LoadFrom(Path.Combine(hintPath, assembly));
+
+ #if DEBUG
+ // preload assembly to provoke FileLoadException if dependencies are missing
+ loadedAssembly.GetExportedTypes();
+ #endif
+ } catch (FileNotFoundException ex) {
+ ShowError("The addin '" + assembly + "' could not be loaded:\n" + ex.ToString());
+ } catch (FileLoadException ex) {
+ ShowError("The addin '" + assembly + "' could not be loaded:\n" + ex.ToString());
}
-
- #if DEBUG
- // preload assembly to provoke FileLoadException if dependencies are missing
- loadedAssembly.GetExportedTypes();
- #endif
- } catch (FileNotFoundException ex) {
- MessageService.ShowError("The addin '" + assembly + "' could not be loaded:\n" + ex.ToString());
- } catch (FileLoadException ex) {
- MessageService.ShowError("The addin '" + assembly + "' could not be loaded:\n" + ex.ToString());
}
}
}
public Assembly LoadedAssembly {
get {
- Load(); // load the assembly, if not already done
- return loadedAssembly;
+ if (this.IsActive) {
+ Load(); // load the assembly, if not already done
+ return loadedAssembly;
+ } else {
+ return null;
+ }
}
}
@@ -111,16 +123,12 @@
}
}
- public object CreateInstance(string instance)
+ public Type FindType(string className)
{
- if (IsActive) {
- Assembly asm = LoadedAssembly;
- if (asm == null)
- return null;
- return asm.CreateInstance(instance);
- } else {
+ Assembly asm = LoadedAssembly;
+ if (asm == null)
return null;
- }
+ return asm.GetType(className);
}
internal static void ReadSection(XmlReader reader, AddIn addIn, string hintPath)
@@ -204,5 +212,20 @@
runtime.definedConditionEvaluators = (runtime.definedConditionEvaluators as List<LazyConditionEvaluator>).AsReadOnly();
return runtime;
}
+
+ protected virtual Assembly LoadAssembly(string assemblyString)
+ {
+ return System.Reflection.Assembly.Load(assemblyString);
+ }
+
+ protected virtual Assembly LoadAssemblyFrom(string assemblyFile)
+ {
+ return System.Reflection.Assembly.LoadFrom(assemblyFile);
+ }
+
+ protected virtual void ShowError(string message)
+ {
+ MessageService.ShowError(message);
+ }
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInManager.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInManager.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInManager.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Daniel Grunwald" email="daniel at danielgrunwald.de"/>
-// <version>$Revision: 2318 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
@@ -264,7 +260,7 @@
/// </summary>
/// <param name="addIns">
/// The list of AddIns to add. (use <see cref="AddIn"/> instances
- /// created by <see cref="AddIn.Load(TextReader)"/>).
+ /// created by <see cref="AddIn.Load(TextReader,string,XmlNameTable)"/>).
/// </param>
public static void AddExternalAddIns(IList<AddIn> addIns)
{
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInTree.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInTree.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInTree.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,12 +1,9 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 4498 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
+using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Resources;
@@ -21,21 +18,21 @@
static List<AddIn> addIns = new List<AddIn>();
static AddInTreeNode rootNode = new AddInTreeNode();
- static Dictionary<string, IDoozer> doozers = new Dictionary<string, IDoozer>();
- static Dictionary<string, IConditionEvaluator> conditionEvaluators = new Dictionary<string, IConditionEvaluator>();
+ static ConcurrentDictionary<string, IDoozer> doozers = new ConcurrentDictionary<string, IDoozer>();
+ static ConcurrentDictionary<string, IConditionEvaluator> conditionEvaluators = new ConcurrentDictionary<string, IConditionEvaluator>();
static AddInTree()
{
- doozers.Add("Class", new ClassDoozer());
- doozers.Add("FileFilter", new FileFilterDoozer());
- doozers.Add("String", new StringDoozer());
- doozers.Add("Icon", new IconDoozer());
- doozers.Add("MenuItem", new MenuItemDoozer());
- doozers.Add("ToolbarItem", new ToolbarItemDoozer());
- doozers.Add("Include", new IncludeDoozer());
+ doozers.TryAdd("Class", new ClassDoozer());
+ doozers.TryAdd("FileFilter", new FileFilterDoozer());
+ doozers.TryAdd("String", new StringDoozer());
+ doozers.TryAdd("Icon", new IconDoozer());
+ doozers.TryAdd("MenuItem", new MenuItemDoozer());
+ doozers.TryAdd("ToolbarItem", new ToolbarItemDoozer());
+ doozers.TryAdd("Include", new IncludeDoozer());
- conditionEvaluators.Add("Compare", new CompareConditionEvaluator());
- conditionEvaluators.Add("Ownerstate", new OwnerStateConditionEvaluator());
+ conditionEvaluators.TryAdd("Compare", new CompareConditionEvaluator());
+ conditionEvaluators.TryAdd("Ownerstate", new OwnerStateConditionEvaluator());
ApplicationStateInfoService.RegisterStateGetter("Installed 3rd party AddIns", GetInstalledThirdPartyAddInsListAsString);
}
@@ -45,11 +42,9 @@
System.Text.StringBuilder sb = new System.Text.StringBuilder();
foreach (AddIn addIn in AddIns) {
// Skip preinstalled AddIns (show only third party AddIns)
- if (FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, addIn.FileName)) {
- string hidden = addIn.Properties["addInManagerHidden"];
- if (string.Equals(hidden, "true", StringComparison.OrdinalIgnoreCase) || string.Equals(hidden, "preinstalled", StringComparison.OrdinalIgnoreCase))
- continue;
- }
+ if (addIn.IsPreinstalled)
+ continue;
+
if (sb.Length > 0) sb.Append(", ");
sb.Append("[");
sb.Append(addIn.Name);
@@ -82,7 +77,7 @@
/// <summary>
/// Gets a dictionary of registered doozers.
/// </summary>
- public static Dictionary<string, IDoozer> Doozers {
+ public static ConcurrentDictionary<string, IDoozer> Doozers {
get {
return doozers;
}
@@ -91,7 +86,7 @@
/// <summary>
/// Gets a dictionary of registered condition evaluators.
/// </summary>
- public static Dictionary<string, IConditionEvaluator> ConditionEvaluators {
+ public static ConcurrentDictionary<string, IConditionEvaluator> ConditionEvaluators {
get {
return conditionEvaluators;
}
@@ -102,21 +97,7 @@
/// </summary>
public static bool ExistsTreeNode(string path)
{
- if (path == null || path.Length == 0) {
- return true;
- }
-
- string[] splittedPath = path.Split('/');
- AddInTreeNode curPath = rootNode;
- int i = 0;
- while (i < splittedPath.Length) {
- // curPath = curPath.ChildNodes[splittedPath[i]] - check if child path exists
- if (!curPath.ChildNodes.TryGetValue(splittedPath[i], out curPath)) {
- return false;
- }
- ++i;
- }
- return true;
+ return GetTreeNode(path, false) != null;
}
/// <summary>
@@ -145,16 +126,13 @@
}
string[] splittedPath = path.Split('/');
AddInTreeNode curPath = rootNode;
- int i = 0;
- while (i < splittedPath.Length) {
+ for (int i = 0; i < splittedPath.Length; i++) {
if (!curPath.ChildNodes.TryGetValue(splittedPath[i], out curPath)) {
if (throwOnNotFound)
throw new TreePathNotFoundException(path);
else
return null;
}
- // curPath = curPath.ChildNodes[splittedPath[i]]; already done by TryGetValue
- ++i;
}
return curPath;
}
@@ -168,11 +146,16 @@
/// exist or does not point to an item.</exception>
public static object BuildItem(string path, object caller)
{
+ return BuildItem(path, caller, null);
+ }
+
+ public static object BuildItem(string path, object caller, IEnumerable<ICondition> additionalConditions)
+ {
int pos = path.LastIndexOf('/');
string parent = path.Substring(0, pos);
string child = path.Substring(pos + 1);
AddInTreeNode node = GetTreeNode(parent);
- return node.BuildChildItem(child, caller, new ArrayList(BuildItems<object>(path, caller, false)));
+ return node.BuildChildItem(child, caller, additionalConditions);
}
/// <summary>
@@ -225,9 +208,8 @@
static void AddExtensionPath(ExtensionPath path)
{
AddInTreeNode treePath = CreatePath(rootNode, path.Name);
- foreach (Codon codon in path.Codons) {
- treePath.Codons.Add(codon);
- }
+ foreach (IEnumerable<Codon> innerCodons in path.GroupedCodons)
+ treePath.AddCodons(innerCodons);
}
/// <summary>
@@ -246,16 +228,12 @@
foreach (Runtime runtime in addIn.Runtimes) {
if (runtime.IsActive) {
foreach (LazyLoadDoozer doozer in runtime.DefinedDoozers) {
- if (AddInTree.Doozers.ContainsKey(doozer.Name)) {
+ if (!doozers.TryAdd(doozer.Name, doozer))
throw new AddInLoadException("Duplicate doozer: " + doozer.Name);
- }
- AddInTree.Doozers.Add(doozer.Name, doozer);
}
foreach (LazyConditionEvaluator condition in runtime.DefinedConditionEvaluators) {
- if (AddInTree.ConditionEvaluators.ContainsKey(condition.Name)) {
+ if (!conditionEvaluators.TryAdd(condition.Name, condition))
throw new AddInLoadException("Duplicate condition evaluator: " + condition.Name);
- }
- AddInTree.ConditionEvaluators.Add(condition.Name, condition);
}
}
}
@@ -354,10 +332,11 @@
List<AddIn> list = new List<AddIn>();
Dictionary<string, Version> dict = new Dictionary<string, Version>();
Dictionary<string, AddIn> addInDict = new Dictionary<string, AddIn>();
+ var nameTable = new System.Xml.NameTable();
foreach (string fileName in addInFiles) {
AddIn addIn;
try {
- addIn = AddIn.Load(fileName);
+ addIn = AddIn.Load(fileName, nameTable);
} catch (AddInLoadException ex) {
LoggingService.Error(ex);
if (ex.InnerException != null) {
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInTreeNode.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInTreeNode.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInTreeNode.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,13 +1,11 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3287 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
namespace ICSharpCode.Core
{
@@ -16,9 +14,10 @@
/// </summary>
public sealed class AddInTreeNode
{
+ readonly object lockObj = new object();
Dictionary<string, AddInTreeNode> childNodes = new Dictionary<string, AddInTreeNode>();
- List<Codon> codons = new List<Codon>();
- bool isSorted = false;
+ ReadOnlyCollection<Codon> codons;
+ List<IEnumerable<Codon>> codonInput;
/// <summary>
/// A dictionary containing the child paths.
@@ -29,126 +28,50 @@
}
}
- /// <summary>
- /// A list of child <see cref="Codon"/>s.
- /// </summary>
- public List<Codon> Codons {
- get {
- return codons;
+ public void AddCodons(IEnumerable<Codon> newCodons)
+ {
+ if (newCodons == null)
+ throw new ArgumentNullException("newCodons");
+ lock (lockObj) {
+ if (codonInput == null) {
+ codonInput = new List<IEnumerable<Codon>>();
+ if (codons != null)
+ codonInput.Add(codons);
+ }
+ codonInput.Add(newCodons);
}
}
-//
-// public void BinarySerialize(BinaryWriter writer)
-// {
-// if (!isSorted) {
-// (new SortCodons(this)).Execute();
-// isSorted = true;
-// }
-// writer.Write((ushort)codons.Count);
-// foreach (Codon codon in codons) {
-// codon.BinarySerialize(writer);
-// }
-//
-// writer.Write((ushort)childNodes.Count);
-// foreach (KeyValuePair<string, AddInTreeNode> child in childNodes) {
-// writer.Write(AddInTree.GetNameOffset(child.Key));
-// child.Value.BinarySerialize(writer);
-// }
-// }
-
/// <summary>
- /// Supports sorting codons using InsertBefore/InsertAfter
+ /// A list of child <see cref="Codon"/>s.
/// </summary>
- sealed class TopologicalSort
- {
- List<Codon> codons;
- bool[] visited;
- List<Codon> sortedCodons;
- Dictionary<string, int> indexOfName;
-
- public TopologicalSort(List<Codon> codons)
- {
- this.codons = codons;
- visited = new bool[codons.Count];
- sortedCodons = new List<Codon>(codons.Count);
- indexOfName = new Dictionary<string, int>(codons.Count);
- // initialize visited to false and fill the indexOfName dictionary
- for (int i = 0; i < codons.Count; ++i) {
- visited[i] = false;
- indexOfName[codons[i].Id] = i;
- }
- }
-
- void InsertEdges()
- {
- // add the InsertBefore to the corresponding InsertAfter
- for (int i = 0; i < codons.Count; ++i) {
- string before = codons[i].InsertBefore;
- if (before != null && before != "") {
- if (indexOfName.ContainsKey(before)) {
- string after = codons[indexOfName[before]].InsertAfter;
- if (after == null || after == "") {
- codons[indexOfName[before]].InsertAfter = codons[i].Id;
- } else {
- codons[indexOfName[before]].InsertAfter = after + ',' + codons[i].Id;
- }
+ public ReadOnlyCollection<Codon> Codons {
+ get {
+ lock (lockObj) {
+ if (codons == null) {
+ if (codonInput == null) {
+ codons = new ReadOnlyCollection<Codon>(new Codon[0]);
} else {
- LoggingService.WarnFormatted("Codon ({0}) specified in the insertbefore of the {1} codon does not exist!", before, codons[i]);
+ codons = TopologicalSort.Sort(codonInput).AsReadOnly();
+ codonInput = null;
}
}
+ return codons;
}
}
-
- public List<Codon> Execute()
- {
- InsertEdges();
-
- // Visit all codons
- for (int i = 0; i < codons.Count; ++i) {
- Visit(i);
- }
- return sortedCodons;
- }
-
- void Visit(int codonIndex)
- {
- if (visited[codonIndex]) {
- return;
- }
- string[] after = codons[codonIndex].InsertAfter.Split(new char[] {','});
- foreach (string s in after) {
- if (s == null || s.Length == 0) {
- continue;
- }
- if (indexOfName.ContainsKey(s)) {
- Visit(indexOfName[s]);
- } else {
- LoggingService.WarnFormatted("Codon ({0}) specified in the insertafter of the {1} codon does not exist!", codons[codonIndex].InsertAfter, codons[codonIndex]);
- }
- }
- sortedCodons.Add(codons[codonIndex]);
- visited[codonIndex] = true;
- }
}
/// <summary>
/// Builds the child items in this path. Ensures that all items have the type T.
/// </summary>
/// <param name="caller">The owner used to create the objects.</param>
- public List<T> BuildChildItems<T>(object caller)
+ /// <param name="additionalConditions">Additional conditions applied to the node.</param>
+ public List<T> BuildChildItems<T>(object caller, IEnumerable<ICondition> additionalConditions = null)
{
+ var codons = this.Codons;
List<T> items = new List<T>(codons.Count);
- if (!isSorted) {
- codons = (new TopologicalSort(codons)).Execute();
- isSorted = true;
- }
foreach (Codon codon in codons) {
- ArrayList subItems = null;
- if (childNodes.ContainsKey(codon.Id)) {
- subItems = childNodes[codon.Id].BuildChildItems(caller);
- }
- object result = codon.BuildItem(caller, subItems);
+ object result = BuildChildItem(codon, caller, additionalConditions);
if (result == null)
continue;
IBuildItemsModifier mod = result as IBuildItemsModifier;
@@ -158,40 +81,40 @@
items.Add((T)result);
} else {
throw new InvalidCastException("The AddInTreeNode <" + codon.Name + " id='" + codon.Id
- + "' returned an instance of " + result.GetType().FullName
+ + "'> returned an instance of " + result.GetType().FullName
+ " but the type " + typeof(T).FullName + " is expected.");
}
}
return items;
}
+ public object BuildChildItem(Codon codon, object caller, IEnumerable<ICondition> additionalConditions = null)
+ {
+ if (codon == null)
+ throw new ArgumentNullException("codon");
+
+ AddInTreeNode subItemNode;
+ childNodes.TryGetValue(codon.Id, out subItemNode);
+
+ IEnumerable<ICondition> conditions;
+ if (additionalConditions == null)
+ conditions = codon.Conditions;
+ else if (codon.Conditions.Length == 0)
+ conditions = additionalConditions;
+ else
+ conditions = additionalConditions.Concat(codon.Conditions);
+
+ return codon.BuildItem(new BuildItemArgs(caller, codon, conditions, subItemNode));
+ }
+
/// <summary>
/// Builds the child items in this path.
/// </summary>
/// <param name="caller">The owner used to create the objects.</param>
+ [Obsolete("Use the generic BuildChildItems version instead")]
public ArrayList BuildChildItems(object caller)
{
- ArrayList items = new ArrayList(codons.Count);
- if (!isSorted) {
- codons = (new TopologicalSort(codons)).Execute();
- isSorted = true;
- }
- foreach (Codon codon in codons) {
- ArrayList subItems = null;
- if (childNodes.ContainsKey(codon.Id)) {
- subItems = childNodes[codon.Id].BuildChildItems(caller);
- }
- object result = codon.BuildItem(caller, subItems);
- if (result == null)
- continue;
- IBuildItemsModifier mod = result as IBuildItemsModifier;
- if (mod != null) {
- mod.Apply(items);
- } else {
- items.Add(result);
- }
- }
- return items;
+ return new ArrayList(this.BuildChildItems<object>(caller));
}
/// <summary>
@@ -201,15 +124,15 @@
/// The ID of the child item to build.
/// </param>
/// <param name="caller">The owner used to create the objects.</param>
- /// <param name="subItems">The subitems to pass to the doozer</param>
+ /// <param name="additionalConditions">Additional conditions applied to the created object</param>
/// <exception cref="TreePathNotFoundException">
/// Occurs when <paramref name="childItemID"/> does not exist in this path.
/// </exception>
- public object BuildChildItem(string childItemID, object caller, ArrayList subItems)
+ public object BuildChildItem(string childItemID, object caller, IEnumerable<ICondition> additionalConditions = null)
{
- foreach (Codon codon in codons) {
+ foreach (Codon codon in this.Codons) {
if (codon.Id == childItemID) {
- return codon.BuildItem(caller, subItems);
+ return BuildChildItem(codon, caller, additionalConditions);
}
}
throw new TreePathNotFoundException(childItemID);
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/CoreStartup.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/CoreStartup.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/CoreStartup.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Daniel Grunwald" email="daniel at danielgrunwald.de"/>
-// <version>$Revision: 3681 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
@@ -106,13 +102,13 @@
/// <summary>
/// Find AddIns by searching all .addin files recursively in <paramref name="addInDir"/>.
- /// The found AddIns are added to the list of AddIn files to load.
+ /// The AddIns that were found are added to the list of AddIn files to load.
/// </summary>
public void AddAddInsFromDirectory(string addInDir)
{
if (addInDir == null)
throw new ArgumentNullException("addInDir");
- addInFiles.AddRange(FileUtility.SearchDirectory(addInDir, "*.addin"));
+ addInFiles.AddRange(Directory.GetFiles(addInDir, "*.addin", SearchOption.AllDirectories));
}
/// <summary>
@@ -187,7 +183,7 @@
command.Run();
} catch (Exception ex) {
// allow startup to continue if some commands fail
- MessageService.ShowError(ex);
+ MessageService.ShowException(ex);
}
}
}
@@ -205,8 +201,21 @@
dataDirectory ?? Path.Combine(FileUtility.ApplicationRootPath, "data"),
propertiesName);
PropertyService.Load();
- ResourceService.InitializeService(FileUtility.Combine(PropertyService.DataDirectory, "resources"));
- StringParser.Properties["AppName"] = applicationName;
+ ResourceService.InitializeService(Path.Combine(PropertyService.DataDirectory, "resources"));
+ StringParser.RegisterStringTagProvider(new AppNameProvider { appName = applicationName });
}
+
+ sealed class AppNameProvider : IStringTagProvider
+ {
+ internal string appName;
+
+ public string ProvideString(string tag, StringTagPair[] customTags)
+ {
+ if (string.Equals(tag, "AppName", StringComparison.OrdinalIgnoreCase))
+ return appName;
+ else
+ return null;
+ }
+ }
}
}
Added: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/TopologicalSort.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/TopologicalSort.cs (rev 0)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/TopologicalSort.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,83 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Supports sorting codons using InsertBefore/InsertAfter
+ /// </summary>
+ static class TopologicalSort
+ {
+ sealed class Node
+ {
+ internal Codon codon;
+ internal bool visited;
+ internal List<Node> previous = new List<Node>();
+
+ internal void Visit(List<Codon> output)
+ {
+ if (visited)
+ return;
+ visited = true;
+ foreach (Node n in previous)
+ n.Visit(output);
+ output.Add(codon);
+ }
+ }
+
+ public static List<Codon> Sort(IEnumerable<IEnumerable<Codon>> codonInput)
+ {
+ // Step 1: create nodes for graph
+ Dictionary<string, Node> nameToNodeDict = new Dictionary<string, Node>();
+ List<Node> allNodes = new List<Node>();
+ foreach (IEnumerable<Codon> codonList in codonInput) {
+ // create entries to preserve order within
+ Node previous = null;
+ foreach (Codon codon in codonList) {
+ Node node = new Node();
+ node.codon = codon;
+ if (!string.IsNullOrEmpty(codon.Id))
+ nameToNodeDict[codon.Id] = node;
+ // add implicit edges
+ if (previous != null)
+ node.previous.Add(previous);
+
+ allNodes.Add(node);
+ previous = node;
+ }
+ }
+ // Step 2: create edges from InsertBefore/InsertAfter values
+ foreach (Node node in allNodes) {
+ if (!string.IsNullOrEmpty(node.codon.InsertBefore)) {
+ foreach (string beforeReference in node.codon.InsertBefore.Split(',')) {
+ Node referencedNode;
+ if (nameToNodeDict.TryGetValue(beforeReference, out referencedNode)) {
+ referencedNode.previous.Add(node);
+ } else {
+ LoggingService.WarnFormatted("Codon ({0}) specified in the insertbefore of the {1} codon does not exist!", beforeReference, node.codon);
+ }
+ }
+ }
+ if (!string.IsNullOrEmpty(node.codon.InsertAfter)) {
+ foreach (string afterReference in node.codon.InsertAfter.Split(',')) {
+ Node referencedNode;
+ if (nameToNodeDict.TryGetValue(afterReference, out referencedNode)) {
+ node.previous.Add(referencedNode);
+ } else {
+ LoggingService.WarnFormatted("Codon ({0}) specified in the insertafter of the {1} codon does not exist!", afterReference, node.codon);
+ }
+ }
+ }
+ }
+ // Step 3: Perform Topological Sort
+ List<Codon> output = new List<Codon>();
+ foreach (Node node in allNodes) {
+ node.Visit(output);
+ }
+ return output;
+ }
+ }
+}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/TreePathNotFoundException.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/TreePathNotFoundException.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/TreePathNotFoundException.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Daniel Grunwald" email="daniel at danielgrunwald.de"/>
-// <version>$Revision: 2318 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Runtime.Serialization;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/CoreException.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/CoreException.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/CoreException.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Daniel Grunwald" email="daniel at danielgrunwald.de"/>
-// <version>$Revision: 1624 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Runtime.Serialization;
Added: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/AnalyticsMonitor/AnalyticsMonitorService.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/AnalyticsMonitor/AnalyticsMonitorService.cs (rev 0)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/AnalyticsMonitor/AnalyticsMonitorService.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,98 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using ICSharpCode.Core.Services;
+using System;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Allows marking the end-time of feature uses.
+ /// </summary>
+ /// <remarks>Implementations of this interface must be thread-safe.</remarks>
+ public interface IAnalyticsMonitorTrackedFeature
+ {
+ void EndTracking();
+ }
+
+ /// <summary>
+ /// Allows tracking feature use.
+ /// All methods on this class are thread-safe.
+ /// </summary>
+ public static class AnalyticsMonitorService
+ {
+ /// <summary>
+ /// Tracks an exception that has occurred.
+ /// </summary>
+ public static void TrackException(Exception exception)
+ {
+ if (exception == null)
+ throw new ArgumentNullException("exception");
+ IAnalyticsMonitor monitor = ServiceManager.Instance.GetService<IAnalyticsMonitor>();
+ if (monitor != null) {
+ monitor.TrackException(exception);
+ }
+ }
+
+ /// <summary>
+ /// Tracks a feature use.
+ /// </summary>
+ /// <param name="featureName">Name of the feature</param>
+ /// <returns>Object that can be used to 'end' the feature use, if measuring time spans is desired.</returns>
+ public static IAnalyticsMonitorTrackedFeature TrackFeature(string featureName)
+ {
+ return TrackFeature(featureName, null);
+ }
+
+ /// <summary>
+ /// Tracks a feature use.
+ /// </summary>
+ /// <param name="featureName">Name of the feature</param>
+ /// <param name="activationMethod">Method used to 'activate' the feature (e.g. Menu, Toolbar, Shortcut, etc.)</param>
+ /// <returns>Object that can be used to 'end' the feature use, if measuring time spans is desired.</returns>
+ public static IAnalyticsMonitorTrackedFeature TrackFeature(string featureName, string activationMethod)
+ {
+ if (featureName == null)
+ throw new ArgumentNullException("featureName");
+
+ if (activationMethod != null)
+ LoggingService.Debug("Activated feature '" + featureName + "', activation=" + activationMethod);
+ else
+ LoggingService.Debug("Activated feature '" + featureName + "'");
+
+ IAnalyticsMonitor monitor = ServiceManager.Instance.GetService<IAnalyticsMonitor>();
+ if (monitor != null) {
+ return monitor.TrackFeature(featureName, activationMethod) ?? DummyFeature.Instance;
+ } else {
+ return DummyFeature.Instance;
+ }
+ }
+
+ sealed class DummyFeature : IAnalyticsMonitorTrackedFeature
+ {
+ public static readonly DummyFeature Instance = new DummyFeature();
+
+ public void EndTracking()
+ {
+ }
+ }
+
+
+ /// <summary>
+ /// Tracks a feature use.
+ /// </summary>
+ /// <param name="featureClass">Class containing the feature</param>
+ /// <param name="featureName">Name of the feature</param>
+ /// <param name="activationMethod">Method used to 'activate' the feature (e.g. Menu, Toolbar, Shortcut, etc.)</param>
+ /// <returns>Object that can be used to 'end' the feature use, if measuring time spans is desired.</returns>
+ public static IAnalyticsMonitorTrackedFeature TrackFeature(Type featureClass, string featureName = null, string activationMethod = null)
+ {
+ if (featureClass == null)
+ throw new ArgumentNullException("featureClass");
+ if (featureName != null)
+ return TrackFeature(featureClass.FullName + "/" + featureName, activationMethod);
+ else
+ return TrackFeature(featureClass.FullName, activationMethod);
+ }
+ }
+}
Added: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/AnalyticsMonitor/IAnalyticsMonitor.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/AnalyticsMonitor/IAnalyticsMonitor.cs (rev 0)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/AnalyticsMonitor/IAnalyticsMonitor.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,17 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+
+namespace ICSharpCode.Core.Services
+{
+ /// <summary>
+ /// Interface for AnalyticsMonitorService.
+ /// </summary>
+ /// <remarks>Implementations of this interface must be thread-safe.</remarks>
+ public interface IAnalyticsMonitor
+ {
+ void TrackException(Exception exception);
+ IAnalyticsMonitorTrackedFeature TrackFeature(string featureName, string activationMethod);
+ }
+}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ApplicationStateInfoService.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ApplicationStateInfoService.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ApplicationStateInfoService.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Christian Hornung" email="chhornung at googlemail.com"/>
-// <version>$Revision: 3455 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
Added: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileName.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileName.cs (rev 0)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileName.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,108 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Represents a directory path or filename.
+ /// The equality operator is overloaded to compare for path equality (case insensitive, normalizing paths with '..\')
+ /// </summary>
+ public sealed class FileName : IEquatable<FileName>
+ {
+ readonly string normalizedFileName;
+
+ public FileName(string fileName)
+ {
+ if (fileName == null)
+ throw new ArgumentNullException("fileName");
+ if (fileName.Length == 0)
+ throw new ArgumentException("The empty string is not a valid FileName");
+ this.normalizedFileName = FileUtility.NormalizePath(fileName);
+ }
+
+ /// <summary>
+ /// Creates a FileName instance from the string.
+ /// It is valid to pass null or an empty string to this method (in that case, a null reference will be returned).
+ /// </summary>
+ public static FileName Create(string fileName)
+ {
+ if (string.IsNullOrEmpty(fileName))
+ return null;
+ else
+ return new FileName(fileName);
+ }
+
+ public static implicit operator string(FileName fileName)
+ {
+ if (fileName != null)
+ return fileName.normalizedFileName;
+ else
+ return null;
+ }
+
+ public override string ToString()
+ {
+ return normalizedFileName;
+ }
+
+ #region Equals and GetHashCode implementation
+ public override bool Equals(object obj)
+ {
+ return Equals(obj as FileName);
+ }
+
+ public bool Equals(FileName other)
+ {
+ if (other != null)
+ return string.Equals(normalizedFileName, other.normalizedFileName, StringComparison.OrdinalIgnoreCase);
+ else
+ return false;
+ }
+
+ public override int GetHashCode()
+ {
+ return StringComparer.OrdinalIgnoreCase.GetHashCode(normalizedFileName);
+ }
+
+ public static bool operator ==(FileName left, FileName right)
+ {
+ if (ReferenceEquals(left, right))
+ return true;
+ if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
+ return false;
+ return left.Equals(right);
+ }
+
+ public static bool operator !=(FileName left, FileName right)
+ {
+ return !(left == right);
+ }
+
+ [ObsoleteAttribute("Warning: comparing FileName with string results in case-sensitive comparison")]
+ public static bool operator ==(FileName left, string right)
+ {
+ return (string)left == right;
+ }
+
+ [ObsoleteAttribute("Warning: comparing FileName with string results in case-sensitive comparison")]
+ public static bool operator !=(FileName left, string right)
+ {
+ return (string)left != right;
+ }
+
+ [ObsoleteAttribute("Warning: comparing FileName with string results in case-sensitive comparison")]
+ public static bool operator ==(string left, FileName right)
+ {
+ return left == (string)right;
+ }
+
+ [ObsoleteAttribute("Warning: comparing FileName with string results in case-sensitive comparison")]
+ public static bool operator !=(string left, FileName right)
+ {
+ return left != (string)right;
+ }
+ #endregion
+ }
+}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileNameEventHandler.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileNameEventHandler.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileNameEventHandler.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,32 +1,31 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 915 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
namespace ICSharpCode.Core
{
- public delegate void FileNameEventHandler(object sender, FileNameEventArgs e);
-
/// <summary>
- /// Description of FileEventHandler.
+ /// EventArgs with a file name.
/// </summary>
public class FileNameEventArgs : System.EventArgs
{
- string fileName;
+ FileName fileName;
- public string FileName {
+ public FileName FileName {
get {
return fileName;
}
}
- public FileNameEventArgs(string fileName)
+ public FileNameEventArgs(FileName fileName)
{
this.fileName = fileName;
}
+
+ public FileNameEventArgs(string fileName)
+ {
+ this.fileName = FileName.Create(fileName);
+ }
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileUtility.Minimal.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileUtility.Minimal.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileUtility.Minimal.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,11 +1,8 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <author name="Daniel Grunwald"/>
-// <version>$Revision: 3050 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
+using System.IO;
using System.Text;
namespace ICSharpCode.Core
@@ -103,5 +100,15 @@
NormalizePath(fileName2),
StringComparison.OrdinalIgnoreCase);
}
+
+ public static bool IsBaseDirectory(string baseDirectory, string testDirectory)
+ {
+ if (baseDirectory == null || testDirectory == null)
+ return false;
+ baseDirectory = NormalizePath(baseDirectory) + Path.DirectorySeparatorChar;
+ testDirectory = NormalizePath(testDirectory) + Path.DirectorySeparatorChar;
+
+ return testDirectory.StartsWith(baseDirectory, StringComparison.OrdinalIgnoreCase);
+ }
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileUtility.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileUtility.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileUtility.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 5773 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
@@ -144,8 +140,22 @@
}
}
+ static string windowsSdk71InstallRoot = null;
+ /// <summary>
+ /// Location of the .NET 4.0 SDK (Windows SDK 7.1) install root.
+ /// </summary>
+ public static string WindowsSdk71InstallRoot {
+ get {
+ if (windowsSdk71InstallRoot == null) {
+ windowsSdk71InstallRoot = GetPathFromRegistry(@"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1", "InstallationFolder") ?? string.Empty;
+ }
+ return windowsSdk71InstallRoot;
+ }
+ }
+
#endregion
+ [Obsolete("Use System.IO.Path.Combine instead")]
public static string Combine(params string[] paths)
{
if (paths == null || paths.Length == 0) {
@@ -161,9 +171,16 @@
public static bool IsUrl(string path)
{
+ if (path == null)
+ throw new ArgumentNullException("path");
return path.IndexOf("://", StringComparison.Ordinal) > 0;
}
+ public static bool IsEqualFileName(FileName fileName1, FileName fileName2)
+ {
+ return fileName1 == fileName2;
+ }
+
public static string GetCommonBaseDirectory(string dir1, string dir2)
{
if (dir1 == null || dir2 == null) return null;
@@ -198,6 +215,10 @@
/// <returns>The path of the executable, or null if the exe is not found.</returns>
public static string GetSdkPath(string exeName) {
string execPath;
+ if (!string.IsNullOrEmpty(WindowsSdk71InstallRoot)) {
+ execPath = Path.Combine(WindowsSdk71InstallRoot, "bin\\" + exeName);
+ if (File.Exists(execPath)) { return execPath; }
+ }
if (!string.IsNullOrEmpty(WindowsSdk70InstallRoot)) {
execPath = Path.Combine(WindowsSdk70InstallRoot, "bin\\" + exeName);
if (File.Exists(execPath)) { return execPath; }
@@ -227,6 +248,9 @@
/// </summary>
public static string GetRelativePath(string baseDirectoryPath, string absPath)
{
+ if (string.IsNullOrEmpty(baseDirectoryPath)) {
+ return absPath;
+ }
if (IsUrl(absPath) || IsUrl(baseDirectoryPath)){
return absPath;
}
@@ -269,16 +293,6 @@
return NormalizePath(Path.Combine(baseDirectoryPath, relPath));
}
- public static bool IsBaseDirectory(string baseDirectory, string testDirectory)
- {
- if (baseDirectory == null || testDirectory == null)
- return false;
- baseDirectory = NormalizePath(baseDirectory) + Path.DirectorySeparatorChar;
- testDirectory = NormalizePath(testDirectory) + Path.DirectorySeparatorChar;
-
- return testDirectory.StartsWith(baseDirectory, StringComparison.OrdinalIgnoreCase);
- }
-
public static string RenameBaseDirectory(string fileName, string oldDirectory, string newDirectory)
{
fileName = NormalizePath(fileName);
@@ -454,7 +468,7 @@
public static bool TestFileExists(string filename)
{
if (!File.Exists(filename)) {
- MessageService.ShowWarning(StringParser.Parse("${res:Fileutility.CantFindFileError}", new string[,] { {"FILE", filename} }));
+ MessageService.ShowWarning(StringParser.Parse("${res:Fileutility.CantFindFileError}", new StringTagPair("FILE", filename)));
return false;
}
return true;
@@ -536,32 +550,39 @@
}
// Observe SAVE functions
- public static FileOperationResult ObservedSave(FileOperationDelegate saveFile, string fileName, string message, FileErrorPolicy policy)
+ public static FileOperationResult ObservedSave(FileOperationDelegate saveFile, string fileName, string message, FileErrorPolicy policy = FileErrorPolicy.Inform)
{
System.Diagnostics.Debug.Assert(IsValidPath(fileName));
try {
saveFile();
RaiseFileSaved(new FileNameEventArgs(fileName));
return FileOperationResult.OK;
- } catch (Exception e) {
- switch (policy) {
- case FileErrorPolicy.Inform:
- ServiceManager.MessageService.InformSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", e);
- break;
- case FileErrorPolicy.ProvideAlternative:
- ChooseSaveErrorResult r = ServiceManager.MessageService.ChooseSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", e, false);
- if (r.IsRetry) {
- return ObservedSave(saveFile, fileName, message, policy);
- } else if (r.IsIgnore) {
- return FileOperationResult.Failed;
- }
- break;
- }
+ } catch (IOException e) {
+ return ObservedSaveHandleException(e, saveFile, fileName, message, policy);
+ } catch (UnauthorizedAccessException e) {
+ return ObservedSaveHandleException(e, saveFile, fileName, message, policy);
}
+ }
+
+ static FileOperationResult ObservedSaveHandleException(Exception e, FileOperationDelegate saveFile, string fileName, string message, FileErrorPolicy policy)
+ {
+ switch (policy) {
+ case FileErrorPolicy.Inform:
+ ServiceManager.Instance.MessageService.InformSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", e);
+ break;
+ case FileErrorPolicy.ProvideAlternative:
+ ChooseSaveErrorResult r = ServiceManager.Instance.MessageService.ChooseSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", e, false);
+ if (r.IsRetry) {
+ return ObservedSave(saveFile, fileName, message, policy);
+ } else if (r.IsIgnore) {
+ return FileOperationResult.Failed;
+ }
+ break;
+ }
return FileOperationResult.Failed;
}
- public static FileOperationResult ObservedSave(FileOperationDelegate saveFile, string fileName, FileErrorPolicy policy)
+ public static FileOperationResult ObservedSave(FileOperationDelegate saveFile, string fileName, FileErrorPolicy policy = FileErrorPolicy.Inform)
{
return ObservedSave(saveFile,
fileName,
@@ -569,13 +590,8 @@
policy);
}
- public static FileOperationResult ObservedSave(FileOperationDelegate saveFile, string fileName)
+ public static FileOperationResult ObservedSave(NamedFileOperationDelegate saveFileAs, string fileName, string message, FileErrorPolicy policy = FileErrorPolicy.Inform)
{
- return ObservedSave(saveFile, fileName, FileErrorPolicy.Inform);
- }
-
- public static FileOperationResult ObservedSave(NamedFileOperationDelegate saveFileAs, string fileName, string message, FileErrorPolicy policy)
- {
System.Diagnostics.Debug.Assert(IsValidPath(fileName));
try {
string directory = Path.GetDirectoryName(fileName);
@@ -585,27 +601,34 @@
saveFileAs(fileName);
RaiseFileSaved(new FileNameEventArgs(fileName));
return FileOperationResult.OK;
- } catch (Exception e) {
- switch (policy) {
- case FileErrorPolicy.Inform:
- ServiceManager.MessageService.InformSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", e);
- break;
- case FileErrorPolicy.ProvideAlternative:
- ChooseSaveErrorResult r = ServiceManager.MessageService.ChooseSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", e, true);
- if (r.IsRetry) {
- return ObservedSave(saveFileAs, fileName, message, policy);
- } else if (r.IsIgnore) {
- return FileOperationResult.Failed;
- } else if (r.IsSaveAlternative) {
- return ObservedSave(saveFileAs, r.AlternativeFileName, message, policy);
- }
- break;
- }
+ } catch (IOException e) {
+ return ObservedSaveHandleError(e, saveFileAs, fileName, message, policy);
+ } catch (UnauthorizedAccessException e) {
+ return ObservedSaveHandleError(e, saveFileAs, fileName, message, policy);
}
+ }
+
+ static FileOperationResult ObservedSaveHandleError(Exception e, NamedFileOperationDelegate saveFileAs, string fileName, string message, FileErrorPolicy policy)
+ {
+ switch (policy) {
+ case FileErrorPolicy.Inform:
+ ServiceManager.Instance.MessageService.InformSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", e);
+ break;
+ case FileErrorPolicy.ProvideAlternative:
+ ChooseSaveErrorResult r = ServiceManager.Instance.MessageService.ChooseSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileSaving}", e, true);
+ if (r.IsRetry) {
+ return ObservedSave(saveFileAs, fileName, message, policy);
+ } else if (r.IsIgnore) {
+ return FileOperationResult.Failed;
+ } else if (r.IsSaveAlternative) {
+ return ObservedSave(saveFileAs, r.AlternativeFileName, message, policy);
+ }
+ break;
+ }
return FileOperationResult.Failed;
}
- public static FileOperationResult ObservedSave(NamedFileOperationDelegate saveFileAs, string fileName, FileErrorPolicy policy)
+ public static FileOperationResult ObservedSave(NamedFileOperationDelegate saveFileAs, string fileName, FileErrorPolicy policy = FileErrorPolicy.Inform)
{
return ObservedSave(saveFileAs,
fileName,
@@ -613,11 +636,6 @@
policy);
}
- public static FileOperationResult ObservedSave(NamedFileOperationDelegate saveFileAs, string fileName)
- {
- return ObservedSave(saveFileAs, fileName, FileErrorPolicy.Inform);
- }
-
// Observe LOAD functions
public static FileOperationResult ObservedLoad(FileOperationDelegate loadFile, string fileName, string message, FileErrorPolicy policy)
{
@@ -625,24 +643,31 @@
loadFile();
OnFileLoaded(new FileNameEventArgs(fileName));
return FileOperationResult.OK;
- } catch (Exception e) {
- switch (policy) {
- case FileErrorPolicy.Inform:
- ServiceManager.MessageService.InformSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileLoading}", e);
- break;
- case FileErrorPolicy.ProvideAlternative:
- ChooseSaveErrorResult r = ServiceManager.MessageService.ChooseSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileLoading}", e, false);
- if (r.IsRetry)
- return ObservedLoad(loadFile, fileName, message, policy);
- else if (r.IsIgnore)
- return FileOperationResult.Failed;
- break;
- }
+ } catch (IOException e) {
+ return ObservedLoadHandleException(e, loadFile, fileName, message, policy);
+ } catch (UnauthorizedAccessException e) {
+ return ObservedLoadHandleException(e, loadFile, fileName, message, policy);
}
+ }
+
+ static FileOperationResult ObservedLoadHandleException(Exception e, FileOperationDelegate loadFile, string fileName, string message, FileErrorPolicy policy)
+ {
+ switch (policy) {
+ case FileErrorPolicy.Inform:
+ ServiceManager.Instance.MessageService.InformSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileLoading}", e);
+ break;
+ case FileErrorPolicy.ProvideAlternative:
+ ChooseSaveErrorResult r = ServiceManager.Instance.MessageService.ChooseSaveError(fileName, message, "${res:FileUtilityService.ErrorWhileLoading}", e, false);
+ if (r.IsRetry)
+ return ObservedLoad(loadFile, fileName, message, policy);
+ else if (r.IsIgnore)
+ return FileOperationResult.Failed;
+ break;
+ }
return FileOperationResult.Failed;
}
- public static FileOperationResult ObservedLoad(FileOperationDelegate loadFile, string fileName, FileErrorPolicy policy)
+ public static FileOperationResult ObservedLoad(FileOperationDelegate loadFile, string fileName, FileErrorPolicy policy = FileErrorPolicy.Inform)
{
return ObservedLoad(loadFile,
fileName,
@@ -650,17 +675,12 @@
policy);
}
- public static FileOperationResult ObservedLoad(FileOperationDelegate loadFile, string fileName)
+ public static FileOperationResult ObservedLoad(NamedFileOperationDelegate saveFileAs, string fileName, string message, FileErrorPolicy policy = FileErrorPolicy.Inform)
{
- return ObservedLoad(loadFile, fileName, FileErrorPolicy.Inform);
- }
-
- public static FileOperationResult ObservedLoad(NamedFileOperationDelegate saveFileAs, string fileName, string message, FileErrorPolicy policy)
- {
return ObservedLoad(new FileOperationDelegate(delegate { saveFileAs(fileName); }), fileName, message, policy);
}
- public static FileOperationResult ObservedLoad(NamedFileOperationDelegate saveFileAs, string fileName, FileErrorPolicy policy)
+ public static FileOperationResult ObservedLoad(NamedFileOperationDelegate saveFileAs, string fileName, FileErrorPolicy policy = FileErrorPolicy.Inform)
{
return ObservedLoad(saveFileAs,
fileName,
@@ -668,11 +688,6 @@
policy);
}
- public static FileOperationResult ObservedLoad(NamedFileOperationDelegate saveFileAs, string fileName)
- {
- return ObservedLoad(saveFileAs, fileName, FileErrorPolicy.Inform);
- }
-
static void OnFileLoaded(FileNameEventArgs e)
{
if (FileLoaded != null) {
@@ -687,7 +702,7 @@
}
}
- public static event FileNameEventHandler FileLoaded;
- public static event FileNameEventHandler FileSaved;
+ public static event EventHandler<FileNameEventArgs> FileLoaded;
+ public static event EventHandler<FileNameEventArgs> FileSaved;
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/ILoggingService.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/ILoggingService.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/ILoggingService.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <author name="Daniel Grunwald"/>
-// <version>$Revision: 3287 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/LoggingService.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/LoggingService.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/LoggingService.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Daniel Grunwald" email="daniel at danielgrunwald.de"/>
-// <version>$Revision: 3287 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.Core.Services;
@@ -17,96 +13,96 @@
{
public static void Debug(object message)
{
- ServiceManager.LoggingService.Debug(message);
+ ServiceManager.Instance.LoggingService.Debug(message);
}
public static void DebugFormatted(string format, params object[] args)
{
- ServiceManager.LoggingService.DebugFormatted(format, args);
+ ServiceManager.Instance.LoggingService.DebugFormatted(format, args);
}
public static void Info(object message)
{
- ServiceManager.LoggingService.Info(message);
+ ServiceManager.Instance.LoggingService.Info(message);
}
public static void InfoFormatted(string format, params object[] args)
{
- ServiceManager.LoggingService.InfoFormatted(format, args);
+ ServiceManager.Instance.LoggingService.InfoFormatted(format, args);
}
public static void Warn(object message)
{
- ServiceManager.LoggingService.Warn(message);
+ ServiceManager.Instance.LoggingService.Warn(message);
}
public static void Warn(object message, Exception exception)
{
- ServiceManager.LoggingService.Warn(message, exception);
+ ServiceManager.Instance.LoggingService.Warn(message, exception);
}
public static void WarnFormatted(string format, params object[] args)
{
- ServiceManager.LoggingService.WarnFormatted(format, args);
+ ServiceManager.Instance.LoggingService.WarnFormatted(format, args);
}
public static void Error(object message)
{
- ServiceManager.LoggingService.Error(message);
+ ServiceManager.Instance.LoggingService.Error(message);
}
public static void Error(object message, Exception exception)
{
- ServiceManager.LoggingService.Error(message, exception);
+ ServiceManager.Instance.LoggingService.Error(message, exception);
}
public static void ErrorFormatted(string format, params object[] args)
{
- ServiceManager.LoggingService.ErrorFormatted(format, args);
+ ServiceManager.Instance.LoggingService.ErrorFormatted(format, args);
}
public static void Fatal(object message)
{
- ServiceManager.LoggingService.Fatal(message);
+ ServiceManager.Instance.LoggingService.Fatal(message);
}
public static void Fatal(object message, Exception exception)
{
- ServiceManager.LoggingService.Fatal(message, exception);
+ ServiceManager.Instance.LoggingService.Fatal(message, exception);
}
public static void FatalFormatted(string format, params object[] args)
{
- ServiceManager.LoggingService.FatalFormatted(format, args);
+ ServiceManager.Instance.LoggingService.FatalFormatted(format, args);
}
public static bool IsDebugEnabled {
get {
- return ServiceManager.LoggingService.IsDebugEnabled;
+ return ServiceManager.Instance.LoggingService.IsDebugEnabled;
}
}
public static bool IsInfoEnabled {
get {
- return ServiceManager.LoggingService.IsInfoEnabled;
+ return ServiceManager.Instance.LoggingService.IsInfoEnabled;
}
}
public static bool IsWarnEnabled {
get {
- return ServiceManager.LoggingService.IsWarnEnabled;
+ return ServiceManager.Instance.LoggingService.IsWarnEnabled;
}
}
public static bool IsErrorEnabled {
get {
- return ServiceManager.LoggingService.IsErrorEnabled;
+ return ServiceManager.Instance.LoggingService.IsErrorEnabled;
}
}
public static bool IsFatalEnabled {
get {
- return ServiceManager.LoggingService.IsFatalEnabled;
+ return ServiceManager.Instance.LoggingService.IsFatalEnabled;
}
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/TextWriterLoggingService.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/TextWriterLoggingService.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/TextWriterLoggingService.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <author name="Daniel Grunwald"/>
-// <version>$Revision$</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.IO;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/IMessageService.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/IMessageService.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/IMessageService.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,29 +1,26 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <author name="Daniel Grunwald"/>
-// <version>$Revision: 3772 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
namespace ICSharpCode.Core.Services
{
/// <summary>
- /// Description of IMessageService.
+ /// Interface for the MessageService.
/// </summary>
public interface IMessageService
{
/// <summary>
/// Shows an error.
- /// If <paramref name="ex"/> is null, the message is shown inside
- /// a message box.
- /// Otherwise, the custom error reporter is used to display
- /// the exception error.
/// </summary>
- void ShowError(Exception ex, string message);
+ void ShowError(string message);
/// <summary>
+ /// Shows an exception.
+ /// </summary>
+ void ShowException(Exception ex, string message);
+
+ /// <summary>
/// Shows a warning message.
/// </summary>
void ShowWarning(string message);
@@ -74,10 +71,15 @@
private ChooseSaveErrorResult() {}
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification="ChooseSaveErrorResult is immutable")]
public readonly static ChooseSaveErrorResult Retry = new ChooseSaveErrorResult { IsRetry = true };
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification="ChooseSaveErrorResult is immutable")]
public readonly static ChooseSaveErrorResult Ignore = new ChooseSaveErrorResult { IsIgnore = true };
+
public static ChooseSaveErrorResult SaveAlternative(string alternativeFileName)
{
+ if (alternativeFileName == null)
+ throw new ArgumentNullException("alternativeFileName");
return new ChooseSaveErrorResult { AlternativeFileName = alternativeFileName };
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/MessageService.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/MessageService.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/MessageService.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3772 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Text;
@@ -19,22 +15,11 @@
public static class MessageService
{
/// <summary>
- /// Delegate used for custom error callbacks.
+ /// Shows an exception error.
/// </summary>
- public delegate void ShowErrorDelegate(Exception ex, string message);
-
- /// <summary>
- /// Gets/Sets the custom error reporter callback delegate.
- /// If this property is null, the default messagebox is used.
- /// </summary>
- public static ShowErrorDelegate CustomErrorReporter { get; set; }
-
- /// <summary>
- /// Shows an exception error using the <see cref="CustomErrorReporter"/>.
- /// </summary>
- public static void ShowError(Exception ex)
+ public static void ShowException(Exception ex)
{
- ShowError(ex, null);
+ ShowException(ex, null);
}
/// <summary>
@@ -42,7 +27,8 @@
/// </summary>
public static void ShowError(string message)
{
- ShowError(null, message);
+ LoggingService.Error(message);
+ ServiceManager.Instance.MessageService.ShowError(message);
}
/// <summary>
@@ -51,33 +37,46 @@
/// <see cref="StringParser"/>,
/// then through <see cref="string.Format(string, object)"/>, using the formatitems as arguments.
/// </summary>
- public static void ShowErrorFormatted(string formatstring, params string[] formatitems)
+ public static void ShowErrorFormatted(string formatstring, params object[] formatitems)
{
- ShowError(null, Format(formatstring, formatitems));
+ ShowError(Format(formatstring, formatitems));
}
/// <summary>
- /// Shows an error.
- /// If <paramref name="ex"/> is null, the message is shown inside
- /// a message box.
- /// Otherwise, the custom error reporter is used to display
- /// the exception error.
+ /// Shows an exception.
/// </summary>
- public static void ShowError(Exception ex, string message)
+ public static void ShowException(Exception ex, string message)
{
- if (message == null) message = string.Empty;
-
- if (ex != null) {
- LoggingService.Error(message, ex);
- LoggingService.Warn("Stack trace of last error log:\n" + Environment.StackTrace);
- if (CustomErrorReporter != null) {
- CustomErrorReporter(ex, message);
- return;
- }
- } else {
- LoggingService.Error(message);
+ LoggingService.Error(message, ex);
+ LoggingService.Warn("Stack trace of last exception log:\n" + Environment.StackTrace);
+ ServiceManager.Instance.MessageService.ShowException(ex, message);
+ }
+
+ /// <summary>
+ /// Shows an exception.
+ /// </summary>
+ public static void ShowHandledException(Exception ex)
+ {
+ ShowHandledException(ex, null);
+ }
+
+ /// <summary>
+ /// Shows an exception.
+ /// </summary>
+ public static void ShowHandledException(Exception ex, string message)
+ {
+ LoggingService.Error(message, ex);
+ LoggingService.Warn("Stack trace of last exception log:\n" + Environment.StackTrace);
+ message = GetMessage(message, ex);
+ ServiceManager.Instance.MessageService.ShowError(message);
+ }
+
+ static string GetMessage(string message, Exception ex)
+ {
+ if (message == null) {
+ return ex.Message;
}
- ServiceManager.MessageService.ShowError(ex, message);
+ return message + "\r\n\r\n" + ex.Message;
}
/// <summary>
@@ -86,7 +85,7 @@
public static void ShowWarning(string message)
{
LoggingService.Warn(message);
- ServiceManager.MessageService.ShowWarning(message);
+ ServiceManager.Instance.MessageService.ShowWarning(message);
}
/// <summary>
@@ -95,7 +94,7 @@
/// <see cref="StringParser"/>,
/// then through <see cref="string.Format(string, object)"/>, using the formatitems as arguments.
/// </summary>
- public static void ShowWarningFormatted(string formatstring, params string[] formatitems)
+ public static void ShowWarningFormatted(string formatstring, params object[] formatitems)
{
ShowWarning(Format(formatstring, formatitems));
}
@@ -106,15 +105,15 @@
/// </summary>
public static bool AskQuestion(string question, string caption)
{
- return ServiceManager.MessageService.AskQuestion(question, caption);
+ return ServiceManager.Instance.MessageService.AskQuestion(question, caption);
}
- public static bool AskQuestionFormatted(string caption, string formatstring, params string[] formatitems)
+ public static bool AskQuestionFormatted(string caption, string formatstring, params object[] formatitems)
{
return AskQuestion(Format(formatstring, formatitems), caption);
}
- public static bool AskQuestionFormatted(string formatstring, params string[] formatitems)
+ public static bool AskQuestionFormatted(string formatstring, params object[] formatitems)
{
return AskQuestion(Format(formatstring, formatitems));
}
@@ -125,7 +124,7 @@
/// </summary>
public static bool AskQuestion(string question)
{
- return AskQuestion(StringParser.Parse(question), StringParser.Parse("${res:Global.QuestionText}"));
+ return AskQuestion(question, StringParser.Parse("${res:Global.QuestionText}"));
}
/// <summary>
@@ -145,7 +144,7 @@
/// <returns>The number of the button that was clicked, or -1 if the dialog was closed without clicking a button.</returns>
public static int ShowCustomDialog(string caption, string dialogText, int acceptButtonIndex, int cancelButtonIndex, params string[] buttontexts)
{
- return ServiceManager.MessageService.ShowCustomDialog(caption, dialogText, acceptButtonIndex, cancelButtonIndex, buttontexts);
+ return ServiceManager.Instance.MessageService.ShowCustomDialog(caption, dialogText, acceptButtonIndex, cancelButtonIndex, buttontexts);
}
/// <summary>
@@ -162,7 +161,7 @@
public static string ShowInputBox(string caption, string dialogText, string defaultValue)
{
- return ServiceManager.MessageService.ShowInputBox(caption, dialogText, defaultValue);
+ return ServiceManager.Instance.MessageService.ShowInputBox(caption, dialogText, defaultValue);
}
static string defaultMessageBoxTitle = "MessageBox";
@@ -191,12 +190,12 @@
ShowMessage(message, DefaultMessageBoxTitle);
}
- public static void ShowMessageFormatted(string formatstring, params string[] formatitems)
+ public static void ShowMessageFormatted(string formatstring, params object[] formatitems)
{
ShowMessage(Format(formatstring, formatitems));
}
- public static void ShowMessageFormatted(string caption, string formatstring, params string[] formatitems)
+ public static void ShowMessageFormatted(string caption, string formatstring, params object[] formatitems)
{
ShowMessage(Format(formatstring, formatitems), caption);
}
@@ -204,16 +203,18 @@
public static void ShowMessage(string message, string caption)
{
LoggingService.Info(message);
- ServiceManager.MessageService.ShowMessage(message, caption);
+ ServiceManager.Instance.MessageService.ShowMessage(message, caption);
}
- static string Format(string formatstring, string[] formatitems)
+ static string Format(string formatstring, object[] formatitems)
{
try {
return String.Format(StringParser.Parse(formatstring), formatitems);
- } catch (FormatException) {
+ } catch (FormatException ex) {
+ LoggingService.Warn(ex);
+
StringBuilder b = new StringBuilder(StringParser.Parse(formatstring));
- foreach(string formatitem in formatitems) {
+ foreach(object formatitem in formatitems) {
b.Append("\nItem: ");
b.Append(formatitem);
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/TextWriterMessageService.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/TextWriterMessageService.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/TextWriterMessageService.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <author name="Daniel Grunwald"/>
-// <version>$Revision$</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.IO;
@@ -25,8 +21,13 @@
this.writer = writer;
}
- public void ShowError(Exception ex, string message)
+ public void ShowError(string message)
{
+ writer.WriteLine(message);
+ }
+
+ public void ShowException(Exception ex, string message)
+ {
if (message != null) {
writer.WriteLine(message);
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/Properties.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/Properties.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/Properties.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 5740 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
@@ -155,7 +151,11 @@
if (reader.HasAttributes) {
for (int i = 0; i < reader.AttributeCount; i++) {
reader.MoveToAttribute(i);
- properties[reader.Name] = reader.Value;
+ // some values are frequently repeated (e.g. type="MenuItem"),
+ // so we also use the NameTable for attribute values
+ // (XmlReader itself only uses it for attribute names)
+ string val = reader.NameTable.Add(reader.Value);
+ properties[reader.Name] = val;
}
reader.MoveToElement(); //Moves the reader back to the element node.
}
@@ -270,8 +270,14 @@
public void Save(string fileName)
{
- using (XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.UTF8)) {
- writer.Formatting = Formatting.Indented;
+ XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.UTF8);
+ writer.Formatting = Formatting.Indented;
+ Save(writer);
+ }
+
+ public void Save(XmlWriter writer)
+ {
+ using (writer) {
writer.WriteStartElement("Properties");
WriteProperties(writer);
writer.WriteEndElement();
@@ -292,7 +298,13 @@
if (!File.Exists(fileName)) {
return null;
}
- using (XmlTextReader reader = new XmlTextReader(fileName)) {
+ XmlTextReader reader = new XmlTextReader(fileName);
+ return Load(reader);
+ }
+
+ public static Properties Load(XmlReader reader)
+ {
+ using (reader) {
while (reader.Read()){
if (reader.IsStartElement()) {
switch (reader.LocalName) {
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/PropertyChangedEvent.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/PropertyChangedEvent.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/PropertyChangedEvent.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 915 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/PropertyService.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/PropertyService.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/PropertyService.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 4029 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.IO;
@@ -23,20 +19,20 @@
static Properties properties;
- public static bool Initialized
+ public static bool Initialized {
+ get { return properties != null; }
+ }
+
+ public static void InitializeServiceForUnitTests()
{
- get
- {
- return properties != null;
- }
+ properties = null;
+ InitializeService(null, null, null);
}
public static void InitializeService(string configDirectory, string dataDirectory, string propertiesName)
{
if (properties != null)
throw new InvalidOperationException("Service is already initialized.");
- if (configDirectory == null || dataDirectory == null || propertiesName == null)
- throw new ArgumentNullException();
properties = new Properties();
PropertyService.configDirectory = configDirectory;
PropertyService.dataDirectory = dataDirectory;
@@ -76,12 +72,14 @@
{
if (properties == null)
throw new InvalidOperationException("Service is not initialized.");
+ if (string.IsNullOrEmpty(configDirectory) || string.IsNullOrEmpty(propertyXmlRootNodeName))
+ throw new InvalidOperationException("No file name was specified on service creation");
if (!Directory.Exists(configDirectory)) {
Directory.CreateDirectory(configDirectory);
}
if (!LoadPropertiesFromStream(Path.Combine(configDirectory, propertyFileName))) {
- LoadPropertiesFromStream(FileUtility.Combine(DataDirectory, "options", propertyFileName));
+ LoadPropertiesFromStream(Path.Combine(DataDirectory, "options", propertyFileName));
}
}
@@ -111,6 +109,8 @@
public static void Save()
{
+ if (string.IsNullOrEmpty(configDirectory) || string.IsNullOrEmpty(propertyXmlRootNodeName))
+ throw new InvalidOperationException("No file name was specified on service creation");
using (MemoryStream ms = new MemoryStream()) {
XmlTextWriter writer = new XmlTextWriter(ms, Encoding.UTF8);
writer.Formatting = Formatting.Indented;
Added: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/RegistryService/RegistryService.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/RegistryService/RegistryService.cs (rev 0)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/RegistryService/RegistryService.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,58 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Globalization;
+using Microsoft.Win32;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// RegistryService.
+ /// </summary>
+ public static class RegistryService
+ {
+ /// <summary>
+ /// Gets the registry value.
+ /// </summary>
+ /// <param name="hive">Registry hive.</param>
+ /// <param name="key">Registry key.</param>
+ /// <param name="value">Registry value.</param>
+ /// <param name="kind">Registry kind.</param>
+ /// <param name="data">Data.</param>
+ /// <returns>True, if the data was found, False otherwise.</returns>
+ public static bool GetRegistryValue<T>(RegistryHive hive, string key, string value, RegistryValueKind kind, out T data)
+ {
+ data = default(T);
+
+ try {
+ using (RegistryKey baseKey = RegistryKey.OpenRemoteBaseKey(hive, String.Empty))
+ {
+ if (baseKey != null)
+ {
+ using (RegistryKey registryKey = baseKey.OpenSubKey(key, RegistryKeyPermissionCheck.ReadSubTree))
+ {
+ if (registryKey != null)
+ {
+ RegistryValueKind kindFound = registryKey.GetValueKind(value);
+ if (kindFound == kind)
+ {
+ object regValue = registryKey.GetValue(value, null);
+ if (regValue != null)
+ {
+ data = (T)Convert.ChangeType(regValue, typeof(T), CultureInfo.InvariantCulture);
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return false;
+ } catch {
+ return false;
+ }
+ }
+ }
+}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ResourceService/ResourceNotFoundException.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ResourceService/ResourceNotFoundException.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ResourceService/ResourceNotFoundException.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 1624 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Runtime.Serialization;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ResourceService/ResourceService.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ResourceService/ResourceService.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ResourceService/ResourceService.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3287 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
@@ -46,10 +42,14 @@
return PropertyService.Get(uiLanguageProperty, Thread.CurrentThread.CurrentUICulture.Name);
}
set {
- PropertyService.Set(uiLanguageProperty, value);
+ if (Language != value) {
+ PropertyService.Set(uiLanguageProperty, value);
+ }
}
}
+ static readonly object loadLock = new object();
+
/// <summary>English strings (list of resource managers)</summary>
static List<ResourceManager> strings = new List<ResourceManager>();
/// <summary>Neutral/English images (list of resource managers)</summary>
@@ -166,8 +166,9 @@
{
if (e.Key == uiLanguageProperty && e.NewValue != e.OldValue) {
LoadLanguageResources((string)e.NewValue);
- if (LanguageChanged != null)
- LanguageChanged(null, e);
+ EventHandler handler = LanguageChanged;
+ if (handler != null)
+ handler(null, e);
}
}
@@ -178,33 +179,35 @@
static void LoadLanguageResources(string language)
{
- if (ClearCaches != null)
- ClearCaches(null, EventArgs.Empty);
-
- try {
- Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(language);
- } catch (Exception) {
+ lock (loadLock) {
try {
- Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(language.Split('-')[0]);
- } catch (Exception) {}
+ Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(language);
+ } catch (Exception) {
+ try {
+ Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(language.Split('-')[0]);
+ } catch (Exception) {}
+ }
+
+ localStrings = Load(stringResources, language);
+ if (localStrings == null && language.IndexOf('-') > 0) {
+ localStrings = Load(stringResources, language.Split('-')[0]);
+ }
+
+ localIcons = Load(imageResources, language);
+ if (localIcons == null && language.IndexOf('-') > 0) {
+ localIcons = Load(imageResources, language.Split('-')[0]);
+ }
+
+ localStringsResMgrs.Clear();
+ localIconsResMgrs.Clear();
+ currentLanguage = language;
+ foreach (ResourceAssembly ra in resourceAssemblies) {
+ ra.Load();
+ }
}
-
- localStrings = Load(stringResources, language);
- if (localStrings == null && language.IndexOf('-') > 0) {
- localStrings = Load(stringResources, language.Split('-')[0]);
- }
-
- localIcons = Load(imageResources, language);
- if (localIcons == null && language.IndexOf('-') > 0) {
- localIcons = Load(imageResources, language.Split('-')[0]);
- }
-
- localStringsResMgrs.Clear();
- localIconsResMgrs.Clear();
- currentLanguage = language;
- foreach (ResourceAssembly ra in resourceAssemblies) {
- ra.Load();
- }
+ EventHandler handler = ClearCaches;
+ if (handler != null)
+ handler(null, EventArgs.Empty);
}
static Hashtable Load(string fileName)
@@ -241,68 +244,72 @@
/// </exception>
public static string GetString(string name)
{
- if (localStrings != null && localStrings[name] != null) {
- return localStrings[name].ToString();
- }
-
- string s = null;
- foreach (ResourceManager resourceManger in localStringsResMgrs) {
- try {
- s = resourceManger.GetString(name);
+ lock (loadLock) {
+ if (localStrings != null && localStrings[name] != null) {
+ return localStrings[name].ToString();
}
- catch (Exception) { }
-
- if (s != null) {
- break;
- }
- }
-
- if (s == null) {
- foreach (ResourceManager resourceManger in strings) {
+
+ string s = null;
+ foreach (ResourceManager resourceManger in localStringsResMgrs) {
try {
s = resourceManger.GetString(name);
}
catch (Exception) { }
-
+
if (s != null) {
break;
}
}
+
+ if (s == null) {
+ foreach (ResourceManager resourceManger in strings) {
+ try {
+ s = resourceManger.GetString(name);
+ }
+ catch (Exception) { }
+
+ if (s != null) {
+ break;
+ }
+ }
+ }
+ if (s == null) {
+ throw new ResourceNotFoundException("string >" + name + "<");
+ }
+
+ return s;
}
- if (s == null) {
- throw new ResourceNotFoundException("string >" + name + "<");
- }
-
- return s;
}
public static object GetImageResource(string name)
{
- object iconobj = null;
- if (localIcons != null && localIcons[name] != null) {
- iconobj = localIcons[name];
- } else {
- foreach (ResourceManager resourceManger in localIconsResMgrs) {
- iconobj = resourceManger.GetObject(name);
- if (iconobj != null) {
- break;
- }
- }
-
- if (iconobj == null) {
- foreach (ResourceManager resourceManger in icons) {
- try {
- iconobj = resourceManger.GetObject(name);
- }
- catch (Exception) { }
-
+ lock (loadLock) {
+ object iconobj = null;
+ if (localIcons != null && localIcons[name] != null) {
+ iconobj = localIcons[name];
+ } else {
+ foreach (ResourceManager resourceManger in localIconsResMgrs) {
+ iconobj = resourceManger.GetObject(name);
if (iconobj != null) {
break;
}
}
+
+ if (iconobj == null) {
+ foreach (ResourceManager resourceManger in icons) {
+ try {
+ iconobj = resourceManger.GetObject(name);
+ }
+ catch (Exception) { }
+
+ if (iconobj != null) {
+ break;
+ }
+ }
+ }
}
+ return iconobj;
}
- return iconobj;
}
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ServiceManager.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ServiceManager.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ServiceManager.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <author name="Daniel Grunwald"/>
-// <version>$Revision: 3411 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
@@ -12,30 +8,93 @@
namespace ICSharpCode.Core.Services
{
/// <summary>
+ /// Maintains a list of services that can be shutdown in the reverse order of their initialization.
/// Maintains references to the core service implementations.
/// </summary>
- public static class ServiceManager
+ public abstract class ServiceManager : IServiceProvider
{
- static ILoggingService loggingService = new TextWriterLoggingService(new DebugTextWriter());
+ volatile static ServiceManager instance = new DefaultServiceManager();
- public static ILoggingService LoggingService {
- get { return loggingService; }
+ /// <summary>
+ /// Gets the static ServiceManager instance.
+ /// </summary>
+ public static ServiceManager Instance {
+ get { return instance; }
set {
if (value == null)
throw new ArgumentNullException();
- loggingService = value;
+ instance = value;
}
}
+ /// <summary>
+ /// Gets a service. Returns null if service is not found.
+ /// </summary>
+ public abstract object GetService(Type serviceType);
+
+ /// <summary>
+ /// Gets a service. Returns null if service is not found.
+ /// </summary>
+ public T GetService<T>() where T : class
+ {
+ return GetService(typeof(T)) as T;
+ }
+
+ /// <summary>
+ /// Gets a service. Throws an exception if service is not found.
+ /// </summary>
+ public object GetRequiredService(Type serviceType)
+ {
+ object service = GetService(serviceType);
+ if (service == null)
+ throw new ServiceNotFoundException();
+ return service;
+ }
+
+ /// <summary>
+ /// Gets a service. Throws an exception if service is not found.
+ /// </summary>
+ public T GetRequiredService<T>() where T : class
+ {
+ return (T)GetRequiredService(typeof(T));
+ }
+
+ /// <summary>
+ /// Gets the logging service.
+ /// </summary>
+ public virtual ILoggingService LoggingService {
+ get { return (ILoggingService)GetRequiredService(typeof(ILoggingService)); }
+ }
+
+ /// <summary>
+ /// Gets the message service.
+ /// </summary>
+ public virtual IMessageService MessageService {
+ get { return (IMessageService)GetRequiredService(typeof(IMessageService)); }
+ }
+ }
+
+ sealed class DefaultServiceManager : ServiceManager
+ {
+ static ILoggingService loggingService = new TextWriterLoggingService(new DebugTextWriter());
static IMessageService messageService = new TextWriterMessageService(Console.Out);
- public static IMessageService MessageService {
+ public override ILoggingService LoggingService {
+ get { return loggingService; }
+ }
+
+ public override IMessageService MessageService {
get { return messageService; }
- set {
- if (value == null)
- throw new ArgumentNullException();
- messageService = value;
- }
}
+
+ public override object GetService(Type serviceType)
+ {
+ if (serviceType == typeof(ILoggingService))
+ return loggingService;
+ else if (serviceType == typeof(IMessageService))
+ return messageService;
+ else
+ return null;
+ }
}
}
Added: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ServiceNotFoundException.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ServiceNotFoundException.cs (rev 0)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ServiceNotFoundException.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,35 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Runtime.Serialization;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Is thrown when the ServiceManager cannot find a required service.
+ /// </summary>
+ [Serializable()]
+ public class ServiceNotFoundException : CoreException
+ {
+ public ServiceNotFoundException() : base()
+ {
+ }
+
+ public ServiceNotFoundException(Type serviceType) : base("Required service not found: " + serviceType.FullName)
+ {
+ }
+
+ public ServiceNotFoundException(string message) : base(message)
+ {
+ }
+
+ public ServiceNotFoundException(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+
+ protected ServiceNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }
+ }
+}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/IStringTagProvider.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/IStringTagProvider.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/IStringTagProvider.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 1965 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
@@ -11,10 +7,6 @@
{
public interface IStringTagProvider
{
- string[] Tags {
- get;
- }
-
- string Convert(string tag);
+ string ProvideString(string tag, StringTagPair[] customTags);
}
}
Added: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/PropertyObjectTagProvider.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/PropertyObjectTagProvider.cs (rev 0)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/PropertyObjectTagProvider.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,37 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Reflection;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Provides properties by using Reflection on an object.
+ /// </summary>
+ public sealed class PropertyObjectTagProvider : IStringTagProvider
+ {
+ readonly object obj;
+
+ public PropertyObjectTagProvider(object obj)
+ {
+ if (obj == null)
+ throw new ArgumentNullException("obj");
+ this.obj = obj;
+ }
+
+ public string ProvideString(string tag, StringTagPair[] customTags)
+ {
+ Type type = obj.GetType();
+ PropertyInfo prop = type.GetProperty(tag);
+ if (prop != null) {
+ return prop.GetValue(obj, null).ToString();
+ }
+ FieldInfo field = type.GetField(tag);
+ if (field != null) {
+ return field.GetValue(obj).ToString();
+ }
+ return null;
+ }
+ }
+}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/StringParser.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/StringParser.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/StringParser.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,13 +1,10 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3863 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
-using System.Collections.Generic;
+using System.Collections.Concurrent;
using System.Diagnostics;
+using System.Globalization;
using System.Reflection;
using System.Text;
@@ -21,45 +18,24 @@
/// </summary>
public static class StringParser
{
- readonly static Dictionary<string, string> properties;
- readonly static Dictionary<string, IStringTagProvider> stringTagProviders;
- readonly static Dictionary<string, object> propertyObjects;
+ readonly static ConcurrentDictionary<string, IStringTagProvider> prefixedStringTagProviders
+ = InitializePrefixedStringTagProviders();
- public static Dictionary<string, string> Properties {
- get {
- return properties;
- }
- }
+ // not really a stack - we only use Add and GetEnumerator
+ readonly static ConcurrentStack<IStringTagProvider> stringTagProviders = new ConcurrentStack<IStringTagProvider>();
- public static Dictionary<string, object> PropertyObjects {
- get {
- return propertyObjects;
- }
- }
-
- static StringParser()
+ static ConcurrentDictionary<string, IStringTagProvider> InitializePrefixedStringTagProviders()
{
- properties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
- stringTagProviders = new Dictionary<string, IStringTagProvider>(StringComparer.OrdinalIgnoreCase);
- propertyObjects = new Dictionary<string, object>();
+ var dict = new ConcurrentDictionary<string, IStringTagProvider>(StringComparer.OrdinalIgnoreCase);
// entryAssembly == null might happen in unit test mode
Assembly entryAssembly = Assembly.GetEntryAssembly();
if (entryAssembly != null) {
string exeName = entryAssembly.Location;
- propertyObjects["exe"] = FileVersionInfo.GetVersionInfo(exeName);
+ dict["exe"] = new PropertyObjectTagProvider(FileVersionInfo.GetVersionInfo(exeName));
}
- properties["USER"] = Environment.UserName;
- properties["Version"] = RevisionClass.FullVersion;
- // Maybe test for Mono?
- if (IntPtr.Size == 4) {
- properties["Platform"] = "Win32";
- } else if (IntPtr.Size == 8) {
- properties["Platform"] = "Win64";
- } else {
- properties["Platform"] = "unknown";
- }
+ return dict;
}
/// <summary>
@@ -67,32 +43,42 @@
/// </summary>
public static string Parse(string input)
{
- return Parse(input, null);
+ return Parse(input, (StringTagPair[])null);
}
/// <summary>
/// Parses an array and replaces the elements in the existing array.
/// </summary>
+ [Obsolete("Call Parse(string) in a loop / consider using LINQ Select instead")]
public static void Parse(string[] inputs)
{
for (int i = 0; i < inputs.Length; ++i) {
- inputs[i] = Parse(inputs[i], null);
+ inputs[i] = Parse(inputs[i]);
}
}
public static void RegisterStringTagProvider(IStringTagProvider tagProvider)
{
- foreach (string str in tagProvider.Tags) {
- stringTagProviders[str] = tagProvider;
- }
+ if (tagProvider == null)
+ throw new ArgumentNullException("tagProvider");
+ stringTagProviders.Push(tagProvider);
}
+ public static void RegisterStringTagProvider(string prefix, IStringTagProvider tagProvider)
+ {
+ if (prefix == null)
+ throw new ArgumentNullException("prefix");
+ if (tagProvider == null)
+ throw new ArgumentNullException("tagProvider");
+ prefixedStringTagProviders[prefix] = tagProvider;
+ }
+
//readonly static Regex pattern = new Regex(@"\$\{([^\}]*)\}", RegexOptions.Compiled | RegexOptions.CultureInvariant);
/// <summary>
/// Expands ${xyz} style property values.
/// </summary>
- public static string Parse(string input, string[,] customTags)
+ public static string Parse(string input, params StringTagPair[] customTags)
{
if (input == null)
return null;
@@ -143,83 +129,109 @@
return output.ToString();
}
- static string GetValue(string propertyName, string[,] customTags)
+ /// <summary>
+ /// For new code, please use the overload taking StringTagPair[]!
+ /// </summary>
+ [Obsolete("Please use the overload taking StringTagPair[]!")]
+ public static string Parse(string input, string[,] customTags)
{
-
- // most properties start with res: in lowercase,
- // so we can save 2 string allocations here, in addition to all the jumps
- // All other prefixed properties {prefix:Key} shoulg get handled in the switch below.
- if (propertyName.StartsWith("res:", StringComparison.OrdinalIgnoreCase)) {
- try {
- return Parse(ResourceService.GetString(propertyName.Substring(4)), customTags);
- } catch (ResourceNotFoundException) {
- return null;
- }
+ if (customTags == null)
+ return Parse(input);
+ if (customTags.GetLength(1) != 2)
+ throw new ArgumentException("incorrect dimension");
+ StringTagPair[] pairs = new StringTagPair[customTags.GetLength(0)];
+ for (int i = 0; i < pairs.Length; i++) {
+ pairs[i] = new StringTagPair(customTags[i, 0], customTags[i, 1]);
}
- if (propertyName.StartsWith("DATE:", StringComparison.OrdinalIgnoreCase))
- {
- try {
- return DateTime.Now.ToString(propertyName.Split(':')[1]);
- } catch (Exception ex) {
- return ex.Message;
- }
- }
- if (propertyName.Equals("DATE", StringComparison.OrdinalIgnoreCase))
- return DateTime.Today.ToShortDateString();
- if (propertyName.Equals("TIME", StringComparison.OrdinalIgnoreCase))
- return DateTime.Now.ToShortTimeString();
- if (propertyName.Equals("ProductName", StringComparison.OrdinalIgnoreCase))
- return MessageService.ProductName;
- if (propertyName.Equals("GUID", StringComparison.OrdinalIgnoreCase))
- return Guid.NewGuid().ToString().ToUpperInvariant();
+ return Parse(input, pairs);
+ }
+
+ /// <summary>
+ /// Evaluates a property using the StringParser. Equivalent to StringParser.Parse("${" + propertyName + "}");
+ /// </summary>
+ public static string GetValue(string propertyName, params StringTagPair[] customTags)
+ {
+ if (propertyName == null)
+ throw new ArgumentNullException("propertyName");
if (customTags != null) {
- for (int j = 0; j < customTags.GetLength(0); ++j) {
- if (propertyName.Equals(customTags[j, 0], StringComparison.OrdinalIgnoreCase)) {
- return customTags[j, 1];
+ foreach (StringTagPair pair in customTags) {
+ if (propertyName.Equals(pair.Tag, StringComparison.OrdinalIgnoreCase)) {
+ return pair.Value;
}
}
}
- if (properties.ContainsKey(propertyName)) {
- return properties[propertyName];
- }
-
- if (stringTagProviders.ContainsKey(propertyName)) {
- return stringTagProviders[propertyName].Convert(propertyName);
- }
-
int k = propertyName.IndexOf(':');
- if (k <= 0)
+ if (k <= 0) {
+ // it's property without prefix
+
+ if (propertyName.Equals("DATE", StringComparison.OrdinalIgnoreCase))
+ return DateTime.Today.ToShortDateString();
+ if (propertyName.Equals("TIME", StringComparison.OrdinalIgnoreCase))
+ return DateTime.Now.ToShortTimeString();
+ if (propertyName.Equals("ProductName", StringComparison.OrdinalIgnoreCase))
+ return MessageService.ProductName;
+ if (propertyName.Equals("GUID", StringComparison.OrdinalIgnoreCase))
+ return Guid.NewGuid().ToString().ToUpperInvariant();
+ if (propertyName.Equals("USER", StringComparison.OrdinalIgnoreCase))
+ return Environment.UserName;
+ if (propertyName.Equals("Version", StringComparison.OrdinalIgnoreCase))
+ return RevisionClass.FullVersion;
+ if (propertyName.Equals("CONFIGDIRECTORY", StringComparison.OrdinalIgnoreCase))
+ return PropertyService.ConfigDirectory;
+
+ foreach (IStringTagProvider provider in stringTagProviders) {
+ string result = provider.ProvideString(propertyName, customTags);
+ if (result != null)
+ return result;
+ }
+
return null;
- string prefix = propertyName.Substring(0, k);
- propertyName = propertyName.Substring(k + 1);
- switch (prefix.ToUpperInvariant()) {
- case "SDKTOOLPATH":
- return FileUtility.GetSdkPath(propertyName);
- case "ADDINPATH":
- foreach (AddIn addIn in AddInTree.AddIns) {
- if (addIn.Manifest.Identities.ContainsKey(propertyName)) {
- return System.IO.Path.GetDirectoryName(addIn.FileName);
- }
- }
- return null;
- case "ENV":
- return Environment.GetEnvironmentVariable(propertyName);
- case "RES":
+ } else {
+ // it's a prefixed property
+
+
+ // res: properties are quite common, so optimize by testing for them first
+ // before allocaing the prefix/propertyName strings
+ // All other prefixed properties {prefix:Key} shoulg get handled in the switch below.
+ if (propertyName.StartsWith("res:", StringComparison.OrdinalIgnoreCase)) {
try {
- return Parse(ResourceService.GetString(propertyName), customTags);
+ return Parse(ResourceService.GetString(propertyName.Substring(4)), customTags);
} catch (ResourceNotFoundException) {
return null;
}
- case "PROPERTY":
- return GetProperty(propertyName);
- default:
- if (propertyObjects.ContainsKey(prefix)) {
- return Get(propertyObjects[prefix], propertyName);
- } else {
+ }
+
+ string prefix = propertyName.Substring(0, k);
+ propertyName = propertyName.Substring(k + 1);
+ switch (prefix.ToUpperInvariant()) {
+ case "SDKTOOLPATH":
+ return FileUtility.GetSdkPath(propertyName);
+ case "ADDINPATH":
+ foreach (AddIn addIn in AddInTree.AddIns) {
+ if (addIn.Manifest.Identities.ContainsKey(propertyName)) {
+ return System.IO.Path.GetDirectoryName(addIn.FileName);
+ }
+ }
return null;
- }
+ case "DATE":
+ try {
+ return DateTime.Now.ToString(propertyName, CultureInfo.CurrentCulture);
+ } catch (Exception ex) {
+ return ex.Message;
+ }
+ case "ENV":
+ return Environment.GetEnvironmentVariable(propertyName);
+ case "PROPERTY":
+ return GetProperty(propertyName);
+ default:
+ IStringTagProvider provider;
+ if (prefixedStringTagProviders.TryGetValue(prefix, out provider))
+ return provider.ProvideString(propertyName, customTags);
+ else
+ return null;
+ }
}
}
@@ -254,19 +266,29 @@
return PropertyService.Get(propertyName, defaultValue);
}
}
+ }
+
+ public struct StringTagPair
+ {
+ readonly string tag;
+ readonly string value;
- static string Get(object obj, string name)
+ public string Tag {
+ get { return tag; }
+ }
+
+ public string Value {
+ get { return value; }
+ }
+
+ public StringTagPair(string tag, string value)
{
- Type type = obj.GetType();
- PropertyInfo prop = type.GetProperty(name);
- if (prop != null) {
- return prop.GetValue(obj, null).ToString();
- }
- FieldInfo field = type.GetField(name);
- if (field != null) {
- return field.GetValue(obj).ToString();
- }
- return null;
+ if (tag == null)
+ throw new ArgumentNullException("tag");
+ if (value == null)
+ throw new ArgumentNullException("value");
+ this.tag = tag;
+ this.value = value;
}
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/AbstractCommand.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/AbstractCommand.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/AbstractCommand.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 1965 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
Deleted: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/AppDomainLaunchHelper.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/AppDomainLaunchHelper.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/AppDomainLaunchHelper.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,54 +0,0 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Daniel Grunwald" email="daniel at danielgrunwald.de"/>
-// <version>$Revision: 3746 $</version>
-// </file>
-
-using System;
-using System.Globalization;
-using System.Reflection;
-
-namespace ICSharpCode.Core
-{
- /// <summary>
- /// Because AddIn assemblies are loaded into the LoadFrom context, creating AppDomains in them that
- /// use an arbitrary ApplicationBase path does not work correctly.
- /// This class contains a static method that helps launching a static method on a type in a new AppDomain.
- /// </summary>
- /// <example>
- /// <code>
- /// public static class CurrentClass { // is NOT MarshalByRef
- /// public static ResultClass[] GetResults()
- /// {
- /// AppDomainSetup setup = new AppDomainSetup();
- /// setup.ApplicationBase = myApplicationBase;
- /// AppDomain domain = AppDomain.CreateDomain("Display name for domain", AppDomain.CurrentDomain.Evidence, setup);
- /// try {
- /// return (ResultClass[])AppDomainLaunchHelper.LaunchInAppDomain(domain, typeof(CurrentClass), "GetResultsDirectly", requestObject);
- /// } finally {
- /// AppDomain.Unload(domain);
- /// }
- /// }
- /// public static ResultClass[] GetResultsDirectly(Request requestObject) { ... }
- /// }
- /// [Serializable] class Request { ... } // must be serializable !!!
- /// [Serializable] class ResultClass { ... } // must be serializable !!!
- /// </code></example>
- [Obsolete("This class is broken, serialization does not work and addin dependencies are not loaded in the AppDomain")]
- public class AppDomainLaunchHelper : MarshalByRefObject
- {
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
- object LaunchMethod(string assemblyFile, string typeName, string methodName, object[] arguments)
- {
- Type t = Assembly.LoadFrom(assemblyFile).GetType(typeName);
- return t.InvokeMember(methodName, (BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod), null, null, arguments, CultureInfo.InvariantCulture);
- }
-
- public static object LaunchInAppDomain(AppDomain domain, Type type, string methodName, params object[] arguments)
- {
- AppDomainLaunchHelper h = (AppDomainLaunchHelper)domain.CreateInstanceFromAndUnwrap(typeof(AppDomainLaunchHelper).Assembly.Location, typeof(AppDomainLaunchHelper).FullName);
- return h.LaunchMethod(type.Assembly.Location, type.FullName, methodName, arguments);
- }
- }
-}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/CallbackOnDispose.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/CallbackOnDispose.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/CallbackOnDispose.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,24 +1,20 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Daniel Grunwald"/>
-// <version>$Revision$</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
+using System.Diagnostics;
using System.Threading;
namespace ICSharpCode.Core
{
/// <summary>
- /// Invokes a callback when this class is dispsed.
+ /// Invokes a callback when this class is disposed.
/// </summary>
- sealed class CallbackOnDispose : IDisposable
+ public sealed class CallbackOnDispose : IDisposable
{
- // TODO: in 4.0, use System.Action and make this class public
- System.Threading.ThreadStart callback;
+ Action callback;
- public CallbackOnDispose(System.Threading.ThreadStart callback)
+ public CallbackOnDispose(Action callback)
{
if (callback == null)
throw new ArgumentNullException("callback");
@@ -27,9 +23,20 @@
public void Dispose()
{
- System.Threading.ThreadStart action = Interlocked.Exchange(ref callback, null);
- if (action != null)
+ Action action = Interlocked.Exchange(ref callback, null);
+ if (action != null) {
action();
+ #if DEBUG
+ GC.SuppressFinalize(this);
+ #endif
+ }
}
+
+ #if DEBUG
+ ~CallbackOnDispose()
+ {
+ Debug.Fail("CallbackOnDispose was finalized without being disposed.");
+ }
+ #endif
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/DebugTextWriter.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/DebugTextWriter.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/DebugTextWriter.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <author name="Daniel Grunwald"/>
-// <version>$Revision: 3287 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Diagnostics;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/ICommand.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/ICommand.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/ICommand.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 1965 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ICSharpCode.Core.WinForms.csproj
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ICSharpCode.Core.WinForms.csproj 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ICSharpCode.Core.WinForms.csproj 2012-02-15 17:39:10 UTC (rev 6516)
@@ -18,27 +18,7 @@
<AssemblyOriginatorKeyFile>..\ICSharpCode.SharpDevelop.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
- <FileUpgradeFlags>
- </FileUpgradeFlags>
- <UpgradeBackupLocation>
- </UpgradeBackupLocation>
- <OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
- <PublishUrl>publish\</PublishUrl>
- <Install>true</Install>
- <InstallFrom>Disk</InstallFrom>
- <UpdateEnabled>false</UpdateEnabled>
- <UpdateMode>Foreground</UpdateMode>
- <UpdateInterval>7</UpdateInterval>
- <UpdateIntervalUnits>Days</UpdateIntervalUnits>
- <UpdatePeriodically>false</UpdatePeriodically>
- <UpdateRequired>false</UpdateRequired>
- <MapFileExtensions>true</MapFileExtensions>
- <ApplicationRevision>0</ApplicationRevision>
- <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
- <IsWebBootstrapper>false</IsWebBootstrapper>
- <UseApplicationTrust>false</UseApplicationTrust>
- <BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
@@ -61,10 +41,10 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<OutputPath>bin\Debug\</OutputPath>
</PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
@@ -96,6 +76,7 @@
<Compile Include="MessageService\CustomDialog.cs">
<SubType>Form</SubType>
</Compile>
+ <Compile Include="MessageService\IDialogMessageService.cs" />
<Compile Include="MessageService\InputBox.cs">
<SubType>Form</SubType>
</Compile>
@@ -144,21 +125,4 @@
<Private>False</Private>
</ProjectReference>
</ItemGroup>
- <ItemGroup>
- <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5 SP1</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
- <Visible>False</Visible>
- <ProductName>Windows Installer 3.1</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- </ItemGroup>
</Project>
\ No newline at end of file
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/IStatusUpdate.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/IStatusUpdate.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/IStatusUpdate.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3702 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/ISubmenuBuilder.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/ISubmenuBuilder.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/ISubmenuBuilder.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3702 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows.Forms;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/Menu.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/Menu.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/Menu.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3702 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuCheckBox.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuCheckBox.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuCheckBox.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3702 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows.Forms;
@@ -23,7 +19,7 @@
try {
menuCommand = (ICheckableMenuCommand)codon.AddIn.CreateObject(codon.Properties["class"]);
} catch (Exception e) {
- MessageService.ShowError(e, "Can't create menu command : " + codon.Id);
+ MessageService.ShowException(e, "Can't create menu command : " + codon.Id);
}
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuCommand.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuCommand.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuCommand.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3763 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Drawing;
@@ -37,16 +33,28 @@
}
// HACK: find a better way to allow the host app to process link commands
- public static Converter<string, ICommand> LinkCommandCreator;
+ public static Func<string, ICommand> LinkCommandCreator { get; set; }
+ /// <summary>
+ /// Callback that creates ICommand instances when the new syntax for known WPF commands (command="Copy") is used.
+ /// </summary>
+ public static Func<AddIn, string, ICommand> KnownCommandCreator { get; set; }
+
void CreateCommand()
{
try {
string link = codon.Properties["link"];
+ string command = codon.Properties["command"];
if (link != null && link.Length > 0) {
- if (LinkCommandCreator == null)
+ var callback = LinkCommandCreator;
+ if (callback == null)
throw new NotSupportedException("MenuCommand.LinkCommandCreator is not set, cannot create LinkCommands.");
- menuCommand = LinkCommandCreator(codon.Properties["link"]);
+ menuCommand = callback(link);
+ } else if (command != null && command.Length > 0) {
+ var callback = KnownCommandCreator;
+ if (callback == null)
+ throw new NotSupportedException("MenuCommand.KnownCommandCreator is not set, cannot create commands.");
+ menuCommand = callback(codon.AddIn, command);
} else {
menuCommand = (ICommand)codon.AddIn.CreateObject(codon.Properties["class"]);
}
@@ -54,7 +62,7 @@
menuCommand.Owner = caller;
}
} catch (Exception e) {
- MessageService.ShowError(e, "Can't create menu command : " + codon.Id);
+ MessageService.ShowException(e, "Can't create menu command : " + codon.Id);
}
}
@@ -72,7 +80,7 @@
shortCut |= (System.Windows.Forms.Keys)Enum.Parse(typeof(System.Windows.Forms.Keys), key);
}
} catch (Exception ex) {
- MessageService.ShowError(ex);
+ MessageService.ShowException(ex);
return System.Windows.Forms.Keys.None;
}
}
@@ -115,7 +123,7 @@
if (GetVisible() && Enabled) {
ICommand cmd = Command;
if (cmd != null) {
- LoggingService.Info("Run command " + cmd.GetType().FullName);
+ AnalyticsMonitorService.TrackFeature(cmd.GetType().FullName, "Menu");
cmd.Run();
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuSeparator.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuSeparator.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuSeparator.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3702 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows.Forms;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuService.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuService.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuService.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3702 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
@@ -30,7 +26,7 @@
((IStatusUpdate)item).UpdateStatus();
} else {
ISubmenuBuilder submenuBuilder = (ISubmenuBuilder)item;
- collection.AddRange(submenuBuilder.BuildSubmenu(null, descriptor.Caller));
+ collection.AddRange(submenuBuilder.BuildSubmenu(descriptor.Codon, descriptor.Caller));
}
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/CustomDialog.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/CustomDialog.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/CustomDialog.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Daniel Grunwald" email="daniel at danielgrunwald.de"/>
-// <version>$Revision: 3794 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Drawing;
Added: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/IDialogMessageService.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/IDialogMessageService.cs (rev 0)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/IDialogMessageService.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -0,0 +1,20 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.ComponentModel;
+using System.Windows.Forms;
+
+using ICSharpCode.Core.Services;
+
+namespace ICSharpCode.Core.WinForms
+{
+ /// <summary>
+ /// Message service that sets an owner for dialog boxes.
+ /// </summary>
+ public interface IDialogMessageService : IMessageService
+ {
+ IWin32Window DialogOwner { set; get; }
+ ISynchronizeInvoke DialogSynchronizeInvoke { set; get; }
+ }
+}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/InputBox.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/InputBox.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/InputBox.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Daniel Grunwald" email="daniel at danielgrunwald.de"/>
-// <version>$Revision: 3702 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Drawing;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/SaveErrorChooseDialog.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/SaveErrorChooseDialog.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/SaveErrorChooseDialog.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3702 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Drawing;
@@ -12,7 +8,7 @@
namespace ICSharpCode.Core.WinForms
{
- sealed class SaveErrorChooseDialog : System.Windows.Forms.Form
+ sealed class SaveErrorChooseDialog : System.Windows.Forms.Form
{
Button retryButton;
Button ignoreButton;
@@ -31,12 +27,13 @@
this.InitializeComponents(chooseLocationEnabled);
RightToLeftConverter.ConvertRecursive(this);
- displayMessage = StringParser.Parse(message, new string[,] {
- {"FileName", fileName},
- {"Path", Path.GetDirectoryName(fileName)},
- {"FileNameWithoutPath", Path.GetFileName(fileName)},
- {"Exception", exceptionGot.GetType().FullName},
- });
+ displayMessage = StringParser.Parse(
+ message,
+ new StringTagPair("FileName", fileName),
+ new StringTagPair("Path", Path.GetDirectoryName(fileName)),
+ new StringTagPair("FileNameWithoutPath", Path.GetFileName(fileName)),
+ new StringTagPair("Exception", exceptionGot.GetType().FullName)
+ );
descriptionTextBox.Lines = StringParser.Parse(this.displayMessage).Split('\n');
@@ -51,7 +48,7 @@
/// <summary>
/// This method was autogenerated - do not change the contents manually
/// </summary>
- private void InitializeComponents(bool chooseLocationEnabled)
+ private void InitializeComponents(bool chooseLocationEnabled)
{
//
// Set up generated class SaveErrorChooseDialog
@@ -73,8 +70,8 @@
this.descriptionLabel.Location = new Point(8, 8);
this.descriptionLabel.Size = new Size(584, 24);
this.descriptionLabel.TabIndex = 3;
- this.descriptionLabel.Anchor = (System.Windows.Forms.AnchorStyles.Top
- | (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right));
+ this.descriptionLabel.Anchor = (System.Windows.Forms.AnchorStyles.Top
+ | (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right));
this.descriptionLabel.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
this.descriptionLabel.Text = StringParser.Parse("${res:ICSharpCode.Core.Services.ErrorDialogs.DescriptionLabel}");
this.Controls.Add(descriptionLabel);
@@ -87,9 +84,9 @@
this.descriptionTextBox.Size = new Size(584, 237);
this.descriptionTextBox.Location = new Point(8, 40);
this.descriptionTextBox.TabIndex = 2;
- this.descriptionTextBox.Anchor = (System.Windows.Forms.AnchorStyles.Top
- | (System.Windows.Forms.AnchorStyles.Bottom
- | (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
+ this.descriptionTextBox.Anchor = (System.Windows.Forms.AnchorStyles.Top
+ | (System.Windows.Forms.AnchorStyles.Bottom
+ | (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.descriptionTextBox.ReadOnly = true;
this.descriptionTextBox.Name = "descriptionTextBox";
this.Controls.Add(descriptionTextBox);
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/SaveErrorInformDialog.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/SaveErrorInformDialog.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/SaveErrorInformDialog.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3702 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Drawing;
@@ -32,12 +28,13 @@
this.InitializeComponent2();
RightToLeftConverter.ConvertRecursive(this);
- displayMessage = StringParser.Parse(message, new string[,] {
- {"FileName", fileName},
- {"Path", Path.GetDirectoryName(fileName)},
- {"FileNameWithoutPath", Path.GetFileName(fileName)},
- {"Exception", exceptionGot.GetType().FullName},
- });
+ displayMessage = StringParser.Parse(
+ message,
+ new StringTagPair("FileName", fileName),
+ new StringTagPair("Path", Path.GetDirectoryName(fileName)),
+ new StringTagPair("FileNameWithoutPath", Path.GetFileName(fileName)),
+ new StringTagPair("Exception", exceptionGot.GetType().FullName)
+ );
descriptionTextBox.Lines = this.displayMessage.Split('\n');
this.exceptionGot = exceptionGot;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/WinFormsMessageService.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/WinFormsMessageService.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/WinFormsMessageService.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <author name="Daniel Grunwald"/>
-// <version>$Revision$</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.ComponentModel;
@@ -18,26 +14,19 @@
/// All text displayed using the MessageService is passed to the
/// <see cref="StringParser"/> to replace ${res} markers.
/// </summary>
- public sealed class WinFormsMessageService : IMessageService
+ public class WinFormsMessageService : IDialogMessageService
{
/// <summary>
/// Gets/Sets the form used as owner for shown message boxes.
/// </summary>
- public static IWin32Window DialogOwner { get; set; }
+ public IWin32Window DialogOwner { get; set; }
/// <summary>
/// Gets/Sets the object used to synchronize message boxes shown on other threads.
/// </summary>
- public static ISynchronizeInvoke DialogSynchronizeInvoke { get; set; }
+ public ISynchronizeInvoke DialogSynchronizeInvoke { get; set; }
- /// <summary>
- /// Gets the message service instance.
- /// </summary>
- public static readonly WinFormsMessageService Instance = new WinFormsMessageService();
-
- private WinFormsMessageService() {}
-
- static void BeginInvoke(MethodInvoker method)
+ void BeginInvoke(MethodInvoker method)
{
ISynchronizeInvoke si = DialogSynchronizeInvoke;
if (si == null || !si.InvokeRequired)
@@ -46,7 +35,7 @@
si.BeginInvoke(method, null);
}
- static void Invoke(MethodInvoker method)
+ void Invoke(MethodInvoker method)
{
ISynchronizeInvoke si = DialogSynchronizeInvoke;
if (si == null || !si.InvokeRequired)
@@ -55,17 +44,25 @@
si.Invoke(method, null);
}
- public void ShowError(Exception ex, string message)
+ public virtual void ShowException(Exception ex, string message)
{
- string msg = message + "\n\n";
-
if (ex != null) {
- msg += "Exception occurred: " + ex.ToString();
+ message += "\n\nException occurred: " + ex.ToString();
}
+ ShowError(message);
+ }
+
+ public void ShowError(string message)
+ {
+ message = StringParser.Parse(message);
+ string caption = StringParser.Parse("${res:Global.ErrorText}");
BeginInvoke(
delegate {
- MessageBox.Show(DialogOwner, StringParser.Parse(msg), StringParser.Parse("${res:Global.ErrorText}"), MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBox.Show(DialogOwner,
+ message, caption,
+ MessageBoxButtons.OK, MessageBoxIcon.Warning,
+ MessageBoxDefaultButton.Button1, GetOptions(message, caption));
});
}
@@ -202,4 +199,4 @@
return r;
}
}
-}
\ No newline at end of file
+}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Properties/AssemblyInfo.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Properties/AssemblyInfo.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Properties/AssemblyInfo.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Daniel Grunwald"/>
-// <version>$Revision: 3763 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Reflection;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarCheckBox.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarCheckBox.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarCheckBox.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3702 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows.Forms;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarComboBox.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarComboBox.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarComboBox.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3702 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows.Forms;
@@ -49,7 +45,8 @@
this.codon = codon;
menuCommand = (IComboBoxCommand)codon.AddIn.CreateObject(codon.Properties["class"]);
- menuCommand.Owner = this;
+ menuCommand.ComboBox = this;
+ menuCommand.Owner = caller;
if (menuCommand == null) {
throw new NullReferenceException("Can't create combobox menu command");
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarCommand.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarCommand.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarCommand.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3763 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows.Forms;
@@ -45,7 +41,7 @@
}
if (menuCommand != null) {
menuCommand.Owner = caller;
- LoggingService.Info("Run command " + menuCommand.GetType().FullName);
+ AnalyticsMonitorService.TrackFeature(menuCommand.GetType().FullName, "Toolbar");
menuCommand.Run();
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarDropDownButton.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarDropDownButton.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarDropDownButton.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3702 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarLabel.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarLabel.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarLabel.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="John Simons" email="johnsimons007 at yahoo.com.au"/>
-// <version>$Revision: 3702 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows.Forms;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarSeparator.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarSeparator.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarSeparator.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3702 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows.Forms;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarService.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarService.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarService.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3702 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
@@ -29,7 +25,7 @@
collection.Add((ToolStripItem)item);
} else {
ISubmenuBuilder submenuBuilder = (ISubmenuBuilder)item;
- collection.AddRange(submenuBuilder.BuildSubmenu(null, owner));
+ collection.AddRange(submenuBuilder.BuildSubmenu(descriptor.Codon, owner));
}
}
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarSplitButton.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarSplitButton.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarSplitButton.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="John Simons" email="johnsimons007 at yahoo.com.au"/>
-// <version>$Revision: 3702 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarTextBox.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarTextBox.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarTextBox.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="John Simons" email="johnsimons007 at yahoo.com.au"/>
-// <version>$Revision: 3702 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows.Forms;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/ClipboardWrapper.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/ClipboardWrapper.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/ClipboardWrapper.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Daniel Grunwald" email="daniel at danielgrunwald.de"/>
-// <version>$Revision: 3702 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Runtime.InteropServices;
@@ -16,6 +12,8 @@
/// </summary>
public static class ClipboardWrapper
{
+ [Obsolete("Avoid using this property: it is problematic because it requires exclusive clipboard access. " +
+ "The Clipboard.ContainsText() implementation in WPF is much better than the one in WinForms.")]
public static bool ContainsText {
get {
try {
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/NativeMethods.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/NativeMethods.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/NativeMethods.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <author name="Daniel Grunwald"/>
-// <version>$Revision: 3722 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Runtime.InteropServices;
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/RightToLeftConverter.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/RightToLeftConverter.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/RightToLeftConverter.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Mike Krüger" email="mike at icsharpcode.net"/>
-// <version>$Revision: 3702 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Drawing;
@@ -12,22 +8,12 @@
namespace ICSharpCode.Core.WinForms
{
/// <summary>
- /// Description of RightToLeftConverter.
+ /// Allows converting forms to right-to-left layout.
/// </summary>
public static class RightToLeftConverter
{
- public static string[] RightToLeftLanguages = new string[] {"ar", "he", "fa", "urdu"};
+ public static bool IsRightToLeft { get; set; }
- public static bool IsRightToLeft {
- get {
- foreach (string language in RightToLeftLanguages) {
- if (ResourceService.Language.StartsWith(language))
- return true;
- }
- return false;
- }
- }
-
static AnchorStyles Mirror(AnchorStyles anchor)
{
bool right = (anchor & AnchorStyles.Right) == AnchorStyles.Right;
@@ -57,17 +43,19 @@
/// </summary>
static void Mirror(Control control)
{
- switch (control.Dock) {
- case DockStyle.Left:
- control.Dock = DockStyle.Right;
- break;
- case DockStyle.Right:
- control.Dock = DockStyle.Left;
- break;
- case DockStyle.None:
- control.Anchor = Mirror(control.Anchor);
- control.Location = MirrorLocation(control);
- break;
+ if (!(control.Parent is SplitContainer)) {
+ switch (control.Dock) {
+ case DockStyle.Left:
+ control.Dock = DockStyle.Right;
+ break;
+ case DockStyle.Right:
+ control.Dock = DockStyle.Left;
+ break;
+ case DockStyle.None:
+ control.Anchor = Mirror(control.Anchor);
+ control.Location = MirrorLocation(control);
+ break;
+ }
}
// Panels with RightToLeft = No won't have their children mirrored
if (control.RightToLeft != RightToLeft.Yes)
Modified: trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/WinFormsResourceService.cs
===================================================================
--- trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/WinFormsResourceService.cs 2012-02-15 15:24:46 UTC (rev 6515)
+++ trunk/Tools/Maestro/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/WinFormsResourceService.cs 2012-02-15 17:39:10 UTC (rev 6516)
@@ -1,9 +1,5 @@
-// <file>
-// <copyright see="prj:///doc/copyright.txt"/>
-// <license see="prj:///doc/license.txt"/>
-// <owner name="Daniel Grunwald"/>
-// <version>$Revision: 3722 $</version>
-// </file>
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
More information about the mapguide-commits
mailing list