[mapguide-commits] r4847 - in sandbox/maestro-2.5: . Thirdparty
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/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/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
Thirdparty/TF.NET
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Tue May 11 05:13:33 EDT 2010
Author: jng
Date: 2010-05-11 05:13:32 -0400 (Tue, 11 May 2010)
New Revision: 4847
Added:
sandbox/maestro-2.5/Thirdparty/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/GlobalAssemblyInfo.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ICSharpCode.Core.WinForms.csproj
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/IStatusUpdate.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/ISubmenuBuilder.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/Menu.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuCheckBox.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuCommand.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuSeparator.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuService.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/CustomDialog.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/InputBox.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/SaveErrorChooseDialog.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/SaveErrorInformDialog.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/WinFormsMessageService.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Properties/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Properties/AssemblyInfo.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarCheckBox.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarComboBox.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarCommand.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarDropDownButton.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarLabel.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarSeparator.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarService.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarSplitButton.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarTextBox.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/ClipboardWrapper.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/NativeMethods.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/RightToLeftConverter.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/WinFormsResourceService.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Configuration/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Configuration/AssemblyInfo.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/ICSharpCode.Core.csproj
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/ICSharpCode.Core.csproj.user
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddIn.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddInLoadException.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddInReference.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Codon.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ComplexCondition.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Condition.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/CompareConditionEvaluator.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/LazyConditionEvaluator.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/OwnerStateConditionEvaluator.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ClassDoozer.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/FileFilterDoozer.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/Icon/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/Icon/IconDescriptor.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/Icon/IconDoozer.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/IncludeDoozer.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/LazyDoozer.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/AbstractCheckableMenuCommand.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/AbstractMenuCommand.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/ICheckableMenuCommand.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/IMenuCommand.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/MenuItemDoozer.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/StringDoozer.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/AbstractComboBoxCommand.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/AbstractTextBoxCommand.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/IComboBoxCommand.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/ITextBoxCommand.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/ToolBarItemDoozer.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ExtensionPath.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IBuildItemsModifier.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ICondition.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IConditionEvaluator.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IDoozer.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Manifest.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Runtime.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInManager.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInTree.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInTreeNode.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/CoreStartup.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/TreePathNotFoundException.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/CoreException.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ApplicationStateInfoService.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileNameEventHandler.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileUtility.Minimal.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileUtility.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/ILoggingService.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/LoggingService.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/TextWriterLoggingService.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/IMessageService.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/MessageService.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/TextWriterMessageService.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/Properties.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/PropertyChangedEvent.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/PropertyService.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ResourceService/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ResourceService/ResourceNotFoundException.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ResourceService/ResourceService.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ServiceManager.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/IStringTagProvider.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/StringParser.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/AbstractCommand.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/AppDomainLaunchHelper.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/CallbackOnDispose.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/DebugTextWriter.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/ICommand.cs
sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.SharpDevelop.snk
sandbox/maestro-2.5/Thirdparty/TF.NET/
sandbox/maestro-2.5/Thirdparty/TF.NET/Homepage.txt
sandbox/maestro-2.5/Thirdparty/TF.NET/License.txt
sandbox/maestro-2.5/Thirdparty/TF.NET/Topology.IO.MapGuide.dll
sandbox/maestro-2.5/Thirdparty/TF.NET/Topology.dll
Log:
Add the following 3rd party components
- SharpDevelop Core (3.2)
- TopologyFramework (1.0.8)
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/GlobalAssemblyInfo.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/GlobalAssemblyInfo.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/GlobalAssemblyInfo.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,36 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Daniel Grunwald" email="daniel at danielgrunwald.de"/>
+// <version>$Revision: 1040 $</version>
+// </file>
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////
+// //
+// DO NOT EDIT GlobalAssemblyInfo.cs, it is recreated using AssemblyInfo.template whenever //
+// StartUp is compiled. //
+// //
+/////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////
+
+using System.Resources;
+using System.Reflection;
+
+[assembly: System.Runtime.InteropServices.ComVisible(false)]
+[assembly: AssemblyCompany("ic#code")]
+[assembly: AssemblyProduct("SharpDevelop")]
+[assembly: AssemblyCopyright("2000-2010 AlphaSierraPapa")]
+[assembly: AssemblyVersion(RevisionClass.FullVersion)]
+[assembly: NeutralResourcesLanguage("en-US")]
+
+internal static class RevisionClass
+{
+ public const string Major = "3";
+ public const string Minor = "2";
+ public const string Build = "0";
+ public const string Revision = "5777";
+
+ public const string MainVersion = Major + "." + Minor;
+ public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Configuration/AssemblyInfo.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Configuration/AssemblyInfo.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Configuration/AssemblyInfo.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,21 @@
+// <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>
+
+using System;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly: CLSCompliant(true)]
+[assembly: StringFreezing()]
+
+[assembly: Dependency("System.Xml", LoadHint.Always)]
+
+[assembly: AssemblyTitle("ICSharpCode.Core")]
+[assembly: AssemblyDescription("The ICSharpCode Core containing the AddInTree and service Subsystem")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/ICSharpCode.Core.csproj
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/ICSharpCode.Core.csproj (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/ICSharpCode.Core.csproj 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,131 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50215</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</ProjectGuid>
+ <RootNamespace>ICSharpCode.Core</RootNamespace>
+ <AssemblyName>ICSharpCode.Core</AssemblyName>
+ <OutputTarget>Library</OutputTarget>
+ <NoStdLib>False</NoStdLib>
+ <NoConfig>False</NoConfig>
+ <OutputType>Library</OutputType>
+ <SignAssembly>true</SignAssembly>
+ <AssemblyOriginatorKeyFile>..\..\ICSharpCode.SharpDevelop.snk</AssemblyOriginatorKeyFile>
+ <BaseAddress>83886080</BaseAddress>
+ <RunPostBuildEvent>Always</RunPostBuildEvent>
+ <DelaySign>False</DelaySign>
+ <AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
+ <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+ <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
+ <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <Optimize>False</Optimize>
+ <DebugType>Full</DebugType>
+ <DocumentationFile>..\..\..\..\bin\ICSharpCode.Core.xml</DocumentationFile>
+ <NoWarn>1591</NoWarn>
+ <DefineConstants>DEBUG</DefineConstants>
+ <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
+ <OutputPath>..\..\..\..\bin\</OutputPath>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugSymbols>False</DebugSymbols>
+ <Optimize>True</Optimize>
+ <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
+ <OutputPath>..\..\..\..\bin\</OutputPath>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
+ <RegisterForComInterop>False</RegisterForComInterop>
+ <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <FileAlignment>4096</FileAlignment>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Configuration\AssemblyInfo.cs" />
+ <Compile Include="Src\AddInTree\AddIn\AddIn.cs" />
+ <Compile Include="Src\AddInTree\AddIn\AddInLoadException.cs" />
+ <Compile Include="Src\AddInTree\AddIn\Codon.cs" />
+ <Compile Include="Src\AddInTree\AddIn\ComplexCondition.cs" />
+ <Compile Include="Src\AddInTree\AddIn\Condition.cs" />
+ <Compile Include="Src\AddInTree\AddIn\ExtensionPath.cs" />
+ <Compile Include="Src\AddInTree\AddIn\IConditionEvaluator.cs" />
+ <Compile Include="Src\AddInTree\AddIn\ICondition.cs" />
+ <Compile Include="Src\AddInTree\AddIn\IDoozer.cs" />
+ <Compile Include="Src\AddInTree\AddIn\Runtime.cs" />
+ <Compile Include="Src\AddInTree\AddIn\DefaultConditionEvaluators\CompareConditionEvaluator.cs" />
+ <Compile Include="Src\AddInTree\AddIn\DefaultConditionEvaluators\LazyConditionEvaluator.cs" />
+ <Compile Include="Src\AddInTree\AddIn\DefaultConditionEvaluators\OwnerStateConditionEvaluator.cs" />
+ <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\ClassDoozer.cs" />
+ <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\FileFilterDoozer.cs" />
+ <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\Icon\IconDescriptor.cs" />
+ <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\Icon\IconDoozer.cs" />
+ <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\LazyDoozer.cs" />
+ <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\MenuItem\AbstractCheckableMenuCommand.cs" />
+ <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\MenuItem\AbstractMenuCommand.cs" />
+ <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\MenuItem\ICheckableMenuCommand.cs" />
+ <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\MenuItem\IMenuCommand.cs" />
+ <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\MenuItem\MenuItemDoozer.cs" />
+ <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\ToolBarItem\AbstractComboBoxCommand.cs" />
+ <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\ToolBarItem\IComboBoxCommand.cs" />
+ <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\TreePathNotFoundException.cs" />
+ <Compile Include="Src\CoreException.cs" />
+ <Compile Include="Src\Services\ApplicationStateInfoService.cs" />
+ <Compile Include="Src\Services\FileUtility\FileNameEventHandler.cs" />
+ <Compile Include="Src\Services\FileUtility\FileUtility.cs" />
+ <Compile Include="Src\Services\FileUtility\FileUtility.Minimal.cs" />
+ <Compile Include="Src\Services\LoggingService\TextWriterLoggingService.cs" />
+ <Compile Include="Src\Services\LoggingService\ILoggingService.cs" />
+ <Compile Include="Src\Services\MessageService\TextWriterMessageService.cs" />
+ <Compile Include="Src\Services\MessageService\IMessageService.cs" />
+ <Compile Include="Src\Services\MessageService\MessageService.cs" />
+ <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\ResourceService\ResourceNotFoundException.cs" />
+ <Compile Include="Src\Services\ResourceService\ResourceService.cs" />
+ <Compile Include="Src\Services\ServiceManager.cs" />
+ <Compile Include="Src\Services\StringParser\IStringTagProvider.cs" />
+ <Compile Include="Src\Services\StringParser\StringParser.cs" />
+ <Compile Include="Src\Util\AbstractCommand.cs" />
+ <Compile Include="Src\Util\CallbackOnDispose.cs" />
+ <Compile Include="Src\Util\DebugTextWriter.cs" />
+ <Compile Include="Src\Util\ICommand.cs" />
+ <Compile Include="Src\AddInTree\AddIn\IBuildItemsModifier.cs" />
+ <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\IncludeDoozer.cs" />
+ <Compile Include="Src\Services\LoggingService\LoggingService.cs" />
+ <Compile Include="Src\AddInTree\AddIn\Manifest.cs" />
+ <Compile Include="Src\AddInTree\AddIn\AddInReference.cs" />
+ <Compile Include="Src\AddInTree\CoreStartup.cs" />
+ <Compile Include="Src\AddInTree\AddInManager.cs" />
+ <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\StringDoozer.cs" />
+ <Compile Include="..\..\GlobalAssemblyInfo.cs">
+ <Link>Configuration\GlobalAssemblyInfo.cs</Link>
+ </Compile>
+ <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>
+ <ItemGroup>
+ <Folder Include="Src\Services\LoggingService" />
+ <Folder Include="Src\Services\ResourceService" />
+ <Content Include="..\..\..\..\data\schemas\AddIn.xsd">
+ <Link>Src\AddInTree\AddIn\AddIn.xsd</Link>
+ </Content>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <PropertyGroup>
+ <PreBuildEvent>..\src\Tools\UpdateAssemblyInfo\bin\Debug\UpdateAssemblyInfo.exe</PreBuildEvent>
+ </PropertyGroup>
+</Project>
\ No newline at end of file
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/ICSharpCode.Core.csproj.user
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/ICSharpCode.Core.csproj.user (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/ICSharpCode.Core.csproj.user 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,7 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <LastOpenVersion>8.0.50215</LastOpenVersion>
+ <ProjectView>ShowAllFiles</ProjectView>
+ <ProjectTrust>0</ProjectTrust>
+ </PropertyGroup>
+</Project>
\ No newline at end of file
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddIn.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddIn.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddIn.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,300 @@
+// <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>
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Xml;
+
+namespace ICSharpCode.Core
+{
+ public sealed class AddIn
+ {
+ Properties properties = new Properties();
+ List<Runtime> runtimes = new List<Runtime>();
+ List<string> bitmapResources = new List<string>();
+ List<string> stringResources = new List<string>();
+
+ internal string addInFileName = null;
+ AddInManifest manifest = new AddInManifest();
+ Dictionary<string, ExtensionPath> paths = new Dictionary<string, ExtensionPath>();
+ AddInAction action = AddInAction.Disable;
+ bool enabled;
+
+ static bool hasShownErrorMessage = false;
+
+ public object CreateObject(string className)
+ {
+ LoadDependencies();
+ foreach (Runtime runtime in runtimes) {
+ object o = runtime.CreateInstance(className);
+ if (o != null) {
+ return o;
+ }
+ }
+ if (hasShownErrorMessage) {
+ LoggingService.Error("Cannot create object: " + className);
+ } else {
+ hasShownErrorMessage = true;
+ MessageService.ShowError("Cannot create object: " + className + "\nFuture missing objects will not cause an error message.");
+ }
+ return null;
+ }
+
+ public void LoadRuntimeAssemblies()
+ {
+ LoadDependencies();
+ foreach (Runtime runtime in runtimes) {
+ runtime.Load();
+ }
+ }
+
+ bool dependenciesLoaded;
+
+ void LoadDependencies()
+ {
+ if (!dependenciesLoaded) {
+ dependenciesLoaded = true;
+ foreach (AddInReference r in manifest.Dependencies) {
+ if (r.RequirePreload) {
+ bool found = false;
+ foreach (AddIn addIn in AddInTree.AddIns) {
+ if (addIn.Manifest.Identities.ContainsKey(r.Name)) {
+ found = true;
+ addIn.LoadRuntimeAssemblies();
+ }
+ }
+ if (!found) {
+ throw new AddInLoadException("Cannot load run-time dependency for " + r.ToString());
+ }
+ }
+ }
+ }
+ }
+
+ public override string ToString()
+ {
+ return "[AddIn: " + Name + "]";
+ }
+
+ string customErrorMessage;
+
+ /// <summary>
+ /// Gets the message of a custom load error. Used only when AddInAction is set to CustomError.
+ /// Settings this property to a non-null value causes Enabled to be set to false and
+ /// Action to be set to AddInAction.CustomError.
+ /// </summary>
+ public string CustomErrorMessage {
+ get {
+ return customErrorMessage;
+ }
+ internal set {
+ if (value != null) {
+ Enabled = false;
+ Action = AddInAction.CustomError;
+ }
+ customErrorMessage = value;
+ }
+ }
+
+ /// <summary>
+ /// Action to execute when the application is restarted.
+ /// </summary>
+ public AddInAction Action {
+ get {
+ return action;
+ }
+ set {
+ action = value;
+ }
+ }
+
+ public List<Runtime> Runtimes {
+ get {
+ return runtimes;
+ }
+ }
+
+ public Version Version {
+ get {
+ return manifest.PrimaryVersion;
+ }
+ }
+
+ public string FileName {
+ get {
+ return addInFileName;
+ }
+ }
+
+ public string Name {
+ get {
+ return properties["name"];
+ }
+ }
+
+ public AddInManifest Manifest {
+ get {
+ return manifest;
+ }
+ }
+
+ public Dictionary<string, ExtensionPath> Paths {
+ get {
+ return paths;
+ }
+ }
+
+ public Properties Properties {
+ get {
+ return properties;
+ }
+ }
+
+ public List<string> BitmapResources {
+ get {
+ return bitmapResources;
+ }
+ set {
+ bitmapResources = value;
+ }
+ }
+
+ public List<string> StringResources {
+ get {
+ return stringResources;
+ }
+ set {
+ stringResources = value;
+ }
+ }
+
+ public bool Enabled {
+ get {
+ return enabled;
+ }
+ set {
+ enabled = value;
+ this.Action = value ? AddInAction.Enable : AddInAction.Disable;
+ }
+ }
+
+ internal AddIn()
+ {
+ }
+
+ static void SetupAddIn(XmlReader reader, AddIn addIn, string hintPath)
+ {
+ while (reader.Read()) {
+ if (reader.NodeType == XmlNodeType.Element && reader.IsStartElement()) {
+ switch (reader.LocalName) {
+ case "StringResources":
+ case "BitmapResources":
+ if (reader.AttributeCount != 1) {
+ throw new AddInLoadException("BitmapResources requires ONE attribute.");
+ }
+
+ string filename = StringParser.Parse(reader.GetAttribute("file"));
+
+ if(reader.LocalName == "BitmapResources")
+ {
+ addIn.BitmapResources.Add(filename);
+ }
+ else
+ {
+ addIn.StringResources.Add(filename);
+ }
+ break;
+ case "Runtime":
+ if (!reader.IsEmptyElement) {
+ Runtime.ReadSection(reader, addIn, hintPath);
+ }
+ break;
+ case "Include":
+ if (reader.AttributeCount != 1) {
+ throw new AddInLoadException("Include requires ONE attribute.");
+ }
+ if (!reader.IsEmptyElement) {
+ throw new AddInLoadException("Include nodes must be empty!");
+ }
+ if (hintPath == null) {
+ throw new AddInLoadException("Cannot use include nodes when hintPath was not specified (e.g. when AddInManager reads a .addin file)!");
+ }
+ string fileName = Path.Combine(hintPath, reader.GetAttribute(0));
+ XmlReaderSettings xrs = new XmlReaderSettings();
+ xrs.ConformanceLevel = ConformanceLevel.Fragment;
+ using (XmlReader includeReader = XmlTextReader.Create(fileName, xrs)) {
+ SetupAddIn(includeReader, addIn, Path.GetDirectoryName(fileName));
+ }
+ break;
+ case "Path":
+ if (reader.AttributeCount != 1) {
+ throw new AddInLoadException("Import node requires ONE attribute.");
+ }
+ string pathName = reader.GetAttribute(0);
+ ExtensionPath extensionPath = addIn.GetExtensionPath(pathName);
+ if (!reader.IsEmptyElement) {
+ ExtensionPath.SetUp(extensionPath, reader, "Path");
+ }
+ break;
+ case "Manifest":
+ addIn.Manifest.ReadManifestSection(reader, hintPath);
+ break;
+ default:
+ throw new AddInLoadException("Unknown root path node:" + reader.LocalName);
+ }
+ }
+ }
+ }
+
+ public ExtensionPath GetExtensionPath(string pathName)
+ {
+ if (!paths.ContainsKey(pathName)) {
+ return paths[pathName] = new ExtensionPath(pathName, this);
+ }
+ return paths[pathName];
+ }
+
+ public static AddIn Load(TextReader textReader)
+ {
+ 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.");
+ }
+ }
+ }
+ }
+ return addIn;
+ }
+
+ public static AddIn Load(string fileName)
+ {
+ try {
+ using (TextReader textReader = File.OpenText(fileName)) {
+ AddIn addIn = Load(textReader, Path.GetDirectoryName(fileName));
+ addIn.addInFileName = fileName;
+ return addIn;
+ }
+ } catch (Exception e) {
+ throw new AddInLoadException("Can't load " + fileName, e);
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddInLoadException.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddInLoadException.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddInLoadException.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,35 @@
+// <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>
+
+using System;
+using System.Runtime.Serialization;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Exception used when loading an AddIn fails.
+ /// </summary>
+ [Serializable]
+ public class AddInLoadException : CoreException
+ {
+ public AddInLoadException() : base()
+ {
+ }
+
+ public AddInLoadException(string message) : base(message)
+ {
+ }
+
+ public AddInLoadException(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+
+ protected AddInLoadException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddInReference.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddInReference.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/AddInReference.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,197 @@
+// <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>
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Represents a versioned reference to an AddIn. Used by <see cref="AddInManifest"/>.
+ /// </summary>
+ public class AddInReference : ICloneable
+ {
+ string name;
+ Version minimumVersion;
+ Version maximumVersion;
+ bool requirePreload;
+
+ public Version MinimumVersion {
+ get {
+ return minimumVersion;
+ }
+ }
+
+ public Version MaximumVersion {
+ get {
+ return maximumVersion;
+ }
+ }
+
+ public bool RequirePreload {
+ get { return requirePreload; }
+ }
+
+
+ public string Name {
+ get {
+ return name;
+ }
+ set {
+ if (value == null) throw new ArgumentNullException("name");
+ if (value.Length == 0) throw new ArgumentException("name cannot be an empty string", "name");
+ name = value;
+ }
+ }
+
+ /// <returns>Returns true when the reference is valid.</returns>
+ public bool Check(Dictionary<string, Version> addIns, out Version versionFound)
+ {
+ if (addIns.TryGetValue(name, out versionFound)) {
+ return CompareVersion(versionFound, minimumVersion) >= 0
+ && CompareVersion(versionFound, maximumVersion) <= 0;
+ } else {
+ return false;
+ }
+ }
+
+ /// <summary>
+ /// Compares two versions and ignores unspecified fields (unlike Version.CompareTo)
+ /// </summary>
+ /// <returns>-1 if a < b, 0 if a == b, 1 if a > b</returns>
+ int CompareVersion(Version a, Version b)
+ {
+ if (a.Major != b.Major) {
+ return a.Major > b.Major ? 1 : -1;
+ }
+ if (a.Minor != b.Minor) {
+ return a.Minor > b.Minor ? 1 : -1;
+ }
+ if (a.Build < 0 || b.Build < 0)
+ return 0;
+ if (a.Build != b.Build) {
+ return a.Build > b.Build ? 1 : -1;
+ }
+ if (a.Revision < 0 || b.Revision < 0)
+ return 0;
+ if (a.Revision != b.Revision) {
+ return a.Revision > b.Revision ? 1 : -1;
+ }
+ return 0;
+ }
+
+ public static AddInReference Create(Properties properties, string hintPath)
+ {
+ AddInReference reference = new AddInReference(properties["addin"]);
+ string version = properties["version"];
+ if (version != null && version.Length > 0) {
+ int pos = version.IndexOf('-');
+ if (pos > 0) {
+ reference.minimumVersion = ParseVersion(version.Substring(0, pos), hintPath);
+ reference.maximumVersion = ParseVersion(version.Substring(pos + 1), hintPath);
+ } 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;
+ }
+
+ static Version entryVersion;
+
+ internal static Version ParseVersion(string version, string hintPath)
+ {
+ if (version == null || version.Length == 0)
+ return new Version(0,0,0,0);
+ if (version.StartsWith("@")) {
+ if (version == "@SharpDevelopCoreVersion") {
+ if (entryVersion == null)
+ entryVersion = new Version(RevisionClass.FullVersion);
+ return entryVersion;
+ }
+ if (hintPath != null) {
+ string fileName = Path.Combine(hintPath, version.Substring(1));
+ try {
+ FileVersionInfo info = FileVersionInfo.GetVersionInfo(fileName);
+ return new Version(info.FileMajorPart, info.FileMinorPart, info.FileBuildPart, info.FilePrivatePart);
+ } catch (FileNotFoundException ex) {
+ throw new AddInLoadException("Cannot get version '" + version + "': " + ex.Message);
+ }
+ }
+ return new Version(0,0,0,0);
+ } else {
+ return new Version(version);
+ }
+ }
+
+ public AddInReference(string name) : this(name, new Version(0,0,0,0), new Version(int.MaxValue, int.MaxValue)) { }
+
+ public AddInReference(string name, Version specificVersion) : this(name, specificVersion, specificVersion) { }
+
+ public AddInReference(string name, Version minimumVersion, Version maximumVersion)
+ {
+ this.Name = name;
+ if (minimumVersion == null) throw new ArgumentNullException("minimumVersion");
+ if (maximumVersion == null) throw new ArgumentNullException("maximumVersion");
+
+ this.minimumVersion = minimumVersion;
+ this.maximumVersion = maximumVersion;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (!(obj is AddInReference)) return false;
+ AddInReference b = (AddInReference)obj;
+ return name == b.name && minimumVersion == b.minimumVersion && maximumVersion == b.maximumVersion;
+ }
+
+ public override int GetHashCode()
+ {
+ return name.GetHashCode() ^ minimumVersion.GetHashCode() ^ maximumVersion.GetHashCode();
+ }
+
+ public override string ToString()
+ {
+ if (minimumVersion.ToString() == "0.0.0.0") {
+ if (maximumVersion.Major == int.MaxValue) {
+ return name;
+ } else {
+ return name + ", version <" + maximumVersion.ToString();
+ }
+ } else {
+ if (maximumVersion.Major == int.MaxValue) {
+ return name + ", version >" + minimumVersion.ToString();
+ } else if (minimumVersion == maximumVersion) {
+ return name + ", version " + minimumVersion.ToString();
+ } else {
+ return name + ", version " + minimumVersion.ToString() + "-" + maximumVersion.ToString();
+ }
+ }
+ }
+
+ public AddInReference Clone()
+ {
+ return new AddInReference(name, minimumVersion, maximumVersion);
+ }
+
+ object ICloneable.Clone()
+ {
+ return Clone();
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Codon.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Codon.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Codon.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,127 @@
+// <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>
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Represents a node in the add in tree that can produce an item.
+ /// </summary>
+ public class Codon
+ {
+ AddIn addIn;
+ string name;
+ Properties properties;
+ ICondition[] conditions;
+
+ public string Name {
+ get {
+ return name;
+ }
+ }
+
+ public AddIn AddIn {
+ get {
+ return addIn;
+ }
+ }
+
+ public string Id {
+ get {
+ return properties["id"];
+ }
+ }
+
+ 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] {
+ get {
+ return properties[key];
+ }
+ }
+
+ public Properties Properties {
+ get {
+ return properties;
+ }
+ }
+
+ public ICondition[] Conditions {
+ get {
+ return conditions;
+ }
+ }
+
+ public Codon(AddIn addIn, string name, Properties properties, ICondition[] conditions)
+ {
+ this.addIn = addIn;
+ this.name = name;
+ this.properties = properties;
+ this.conditions = conditions;
+ }
+
+ public ConditionFailedAction GetFailedAction(object caller)
+ {
+ return Condition.GetFailedAction(conditions, caller);
+ }
+
+//
+// public void BinarySerialize(BinaryWriter writer)
+// {
+// writer.Write(AddInTree.GetNameOffset(name));
+// writer.Write(AddInTree.GetAddInOffset(addIn));
+// properties.BinarySerialize(writer);
+// }
+//
+ public object BuildItem(object owner, ArrayList subItems)
+ {
+ IDoozer doozer;
+ if (!AddInTree.Doozers.TryGetValue(Name, out doozer))
+ throw new CoreException("Doozer " + Name + " not found!");
+
+ if (!doozer.HandleConditions && conditions.Length > 0) {
+ ConditionFailedAction action = GetFailedAction(owner);
+ if (action != ConditionFailedAction.Nothing) {
+ return null;
+ }
+ }
+ return doozer.BuildItem(owner, this, subItems);
+ }
+
+ public override string ToString()
+ {
+ return String.Format("[Codon: name = {0}, addIn={1}]",
+ name,
+ addIn.FileName);
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ComplexCondition.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ComplexCondition.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ComplexCondition.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,159 @@
+// <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>
+
+using System;
+using System.Diagnostics;
+using System.Text;
+using System.Xml;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Negates a condition
+ /// </summary>
+ public class NegatedCondition : ICondition
+ {
+ ICondition condition;
+
+ public string Name {
+ get {
+ return "Not " + condition.Name;
+ }
+ }
+
+ ConditionFailedAction action = ConditionFailedAction.Exclude;
+ public ConditionFailedAction Action {
+ get {
+ return action;
+ }
+ set {
+ action = value;
+ }
+ }
+
+ public NegatedCondition(ICondition condition)
+ {
+ Debug.Assert(condition != null);
+ this.condition = condition;
+ }
+
+ public bool IsValid(object owner)
+ {
+ return !condition.IsValid(owner);
+ }
+
+ public static ICondition Read(XmlReader reader)
+ {
+ return new NegatedCondition(Condition.ReadConditionList(reader, "Not")[0]);
+ }
+ }
+
+ /// <summary>
+ /// Gives back the and result of two conditions.
+ /// </summary>
+ public class AndCondition : ICondition
+ {
+ ICondition[] conditions;
+
+ public string Name {
+ get {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < conditions.Length; ++i) {
+ sb.Append(conditions[i].Name);
+ if (i + 1 < conditions.Length) {
+ sb.Append(" And ");
+ }
+ }
+ return sb.ToString();
+ }
+ }
+
+ ConditionFailedAction action = ConditionFailedAction.Exclude;
+ public ConditionFailedAction Action {
+ get {
+ return action;
+ }
+ set {
+ action = value;
+ }
+ }
+
+ public AndCondition(ICondition[] conditions)
+ {
+ Debug.Assert(conditions.Length >= 1);
+ this.conditions = conditions;
+ }
+
+ public bool IsValid(object owner)
+ {
+ foreach (ICondition condition in conditions) {
+ if (!condition.IsValid(owner)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static ICondition Read(XmlReader reader)
+ {
+ return new AndCondition(Condition.ReadConditionList(reader, "And"));
+ }
+ }
+
+ /// <summary>
+ /// Gives back the or result of two conditions.
+ /// </summary>
+ public class OrCondition : ICondition
+ {
+ ICondition[] conditions;
+
+
+ public string Name {
+ get {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < conditions.Length; ++i) {
+ sb.Append(conditions[i].Name);
+ if (i + 1 < conditions.Length) {
+ sb.Append(" Or ");
+ }
+ }
+ return sb.ToString();
+ }
+ }
+
+ ConditionFailedAction action = ConditionFailedAction.Exclude;
+ public ConditionFailedAction Action {
+ get {
+ return action;
+ }
+ set {
+ action = value;
+ }
+ }
+
+ public OrCondition(ICondition[] conditions)
+ {
+ Debug.Assert(conditions.Length >= 1);
+ this.conditions = conditions;
+ }
+
+ public bool IsValid(object owner)
+ {
+ foreach (ICondition condition in conditions) {
+ if (condition.IsValid(owner)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static ICondition Read(XmlReader reader)
+ {
+ return new OrCondition(Condition.ReadConditionList(reader, "Or"));
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Condition.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Condition.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Condition.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,156 @@
+// <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>
+
+using System;
+using System.Collections.Generic;
+using System.Xml;
+
+namespace ICSharpCode.Core
+{
+
+ public class Condition : ICondition
+ {
+ string name;
+ Properties properties;
+ ConditionFailedAction action;
+ /// <summary>
+ /// Returns the action which occurs, when this condition fails.
+ /// </summary>
+ public ConditionFailedAction Action {
+ get {
+ return action;
+ }
+ set {
+ action = value;
+ }
+ }
+ public string Name {
+ get {
+ return name;
+ }
+ }
+
+ public string this[string key] {
+ get {
+ return properties[key];
+ }
+ }
+
+ public Properties Properties {
+ get {
+ return properties;
+ }
+ }
+
+ public Condition(string name, Properties properties)
+ {
+ this.name = name;
+ this.properties = properties;
+ action = properties.Get("action", ConditionFailedAction.Exclude);
+ }
+
+ public bool IsValid(object caller)
+ {
+ try {
+ return AddInTree.ConditionEvaluators[name].IsValid(caller, this);
+ } catch (KeyNotFoundException) {
+ throw new CoreException("Condition evaluator " + name + " not found!");
+ }
+
+ }
+
+ public static ICondition Read(XmlReader reader)
+ {
+ Properties properties = Properties.ReadFromAttributes(reader);
+ string conditionName = properties["name"];
+ return new Condition(conditionName, properties);
+ }
+
+ public static ICondition ReadComplexCondition(XmlReader reader)
+ {
+ Properties properties = Properties.ReadFromAttributes(reader);
+ reader.Read();
+ ICondition condition = null;
+ while (reader.Read()) {
+ switch (reader.NodeType) {
+ case XmlNodeType.Element:
+ switch (reader.LocalName) {
+ case "And":
+ condition = AndCondition.Read(reader);
+ goto exit;
+ case "Or":
+ condition = OrCondition.Read(reader);
+ goto exit;
+ case "Not":
+ condition = NegatedCondition.Read(reader);
+ goto exit;
+ default:
+ throw new AddInLoadException("Invalid element name '" + reader.LocalName
+ + "', the first entry in a ComplexCondition " +
+ "must be <And>, <Or> or <Not>");
+ }
+ }
+ }
+ exit:
+ if (condition != null) {
+ ConditionFailedAction action = properties.Get("action", ConditionFailedAction.Exclude);
+ condition.Action = action;
+ }
+ return condition;
+ }
+
+ public static ICondition[] ReadConditionList(XmlReader reader, string endElement)
+ {
+ List<ICondition> conditions = new List<ICondition>();
+ while (reader.Read()) {
+ switch (reader.NodeType) {
+ case XmlNodeType.EndElement:
+ if (reader.LocalName == endElement) {
+ return conditions.ToArray();
+ }
+ break;
+ case XmlNodeType.Element:
+ switch (reader.LocalName) {
+ case "And":
+ conditions.Add(AndCondition.Read(reader));
+ break;
+ case "Or":
+ conditions.Add(OrCondition.Read(reader));
+ break;
+ case "Not":
+ conditions.Add(NegatedCondition.Read(reader));
+ break;
+ case "Condition":
+ conditions.Add(Condition.Read(reader));
+ break;
+ default:
+ throw new AddInLoadException("Invalid element name '" + reader.LocalName
+ + "', entries in a <" + endElement + "> " +
+ "must be <And>, <Or>, <Not> or <Condition>");
+ }
+ break;
+ }
+ }
+ return conditions.ToArray();
+ }
+
+ public static ConditionFailedAction GetFailedAction(IEnumerable<ICondition> conditionList, object caller)
+ {
+ ConditionFailedAction action = ConditionFailedAction.Nothing;
+ foreach (ICondition condition in conditionList) {
+ if (!condition.IsValid(caller)) {
+ if (condition.Action == ConditionFailedAction.Disable) {
+ action = ConditionFailedAction.Disable;
+ } else {
+ return ConditionFailedAction.Exclude;
+ }
+ }
+ }
+ return action;
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/CompareConditionEvaluator.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/CompareConditionEvaluator.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/CompareConditionEvaluator.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,48 @@
+// <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>
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Compares two strings.
+ /// The strings are passed through the StringParser, so it is possible to compare
+ /// SharpDevelop properties.<br/>
+ /// Useful if you want to run a command only when a setting is active to prevent
+ /// loading your addin if that setting isn't set.
+ /// </summary>
+ /// <attribute name="string">
+ /// The first string.
+ /// </attribute>
+ /// <attribute name="equals">
+ /// The second string.
+ /// </attribute>
+ /// <attribute name="comparisonType">
+ /// The mode of the comparison: a field of the System.StringComparison enumeration. The default is
+ /// 'OrdinalIgnoreCase'.
+ /// </attribute>
+ /// <example title="Check the value of a property in the PropertyService">
+ /// <Condition name = "Compare" string = "${property:SharpDevelop.FiletypesRegisterStartup}" equals = "True">
+ /// </example>
+ public class CompareConditionEvaluator : IConditionEvaluator
+ {
+ public bool IsValid(object caller, Condition condition)
+ {
+ string comparisonTypeText = condition.Properties["comparisonType"];
+ StringComparison comparisonType;
+ if (string.IsNullOrEmpty(comparisonTypeText))
+ comparisonType = StringComparison.OrdinalIgnoreCase;
+ else
+ comparisonType = (StringComparison)Enum.Parse(typeof(StringComparison), comparisonTypeText);
+
+ return string.Equals(StringParser.Parse(condition.Properties["string"]),
+ StringParser.Parse(condition.Properties["equals"]),
+ comparisonType);
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/LazyConditionEvaluator.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/LazyConditionEvaluator.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/LazyConditionEvaluator.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,58 @@
+// <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>
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Condition evaluator that lazy-loads another condition evaluator and executes it.
+ /// </summary>
+ public class LazyConditionEvaluator : IConditionEvaluator
+ {
+ AddIn addIn;
+ string name;
+ string className;
+
+ public string Name {
+ get {
+ return name;
+ }
+ }
+
+ public string ClassName {
+ get {
+ return className;
+ }
+ }
+
+ public LazyConditionEvaluator(AddIn addIn, Properties properties)
+ {
+ this.addIn = addIn;
+ this.name = properties["name"];
+ this.className = properties["class"];
+ }
+
+ public bool IsValid(object caller, Condition condition)
+ {
+ IConditionEvaluator evaluator = (IConditionEvaluator)addIn.CreateObject(className);
+ if (evaluator == null) {
+ return false;
+ }
+ AddInTree.ConditionEvaluators[name] = evaluator;
+ return evaluator.IsValid(caller, condition);
+ }
+
+ public override string ToString()
+ {
+ return String.Format("[LazyLoadConditionEvaluator: className = {0}, name = {1}]",
+ className,
+ name);
+ }
+
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/OwnerStateConditionEvaluator.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/OwnerStateConditionEvaluator.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultConditionEvaluators/OwnerStateConditionEvaluator.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,42 @@
+// <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>
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ public interface IOwnerState {
+ System.Enum InternalState {
+ get;
+ }
+ }
+
+ /// <summary>
+ /// Condition evaluator that compares the state of the caller/owner with a specified value.
+ /// The caller/owner has to implement <see cref="IOwnerState"/>.
+ /// </summary>
+ public class OwnerStateConditionEvaluator : IConditionEvaluator
+ {
+ public bool IsValid(object caller, Condition condition)
+ {
+ if (caller is IOwnerState) {
+ try {
+ System.Enum state = ((IOwnerState)caller).InternalState;
+ System.Enum conditionEnum = (System.Enum)Enum.Parse(state.GetType(), condition.Properties["ownerstate"]);
+
+ int stateInt = Int32.Parse(state.ToString("D"));
+ 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.");
+ }
+ }
+ return false;
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ClassDoozer.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ClassDoozer.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ClassDoozer.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,41 @@
+// <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>
+
+using System;
+using System.Collections;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Creates object instances by invocating a type's parameterless constructor
+ /// via System.Reflection.
+ /// </summary>
+ /// <attribute name="class" use="required">
+ /// The fully qualified type name of the class to create an instace of.
+ /// </attribute>
+ /// <usage>Everywhere where objects are expected.</usage>
+ /// <returns>
+ /// Any kind of object.
+ /// </returns>
+ public class ClassDoozer : IDoozer
+ {
+ /// <summary>
+ /// Gets if the doozer handles codon conditions on its own.
+ /// If this property return false, the item is excluded when the condition is not met.
+ /// </summary>
+ public bool HandleConditions {
+ get {
+ return false;
+ }
+ }
+
+ public object BuildItem(object caller, Codon codon, ArrayList subItems)
+ {
+ return codon.AddIn.CreateObject(codon.Properties["class"]);
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/FileFilterDoozer.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/FileFilterDoozer.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/FileFilterDoozer.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,43 @@
+// <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>
+
+using System;
+using System.Collections;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Creates file filter entries for OpenFileDialogs or SaveFileDialogs.
+ /// </summary>
+ /// <attribute name="name" use="required">
+ /// The name of the file filter entry.
+ /// </attribute>
+ /// <attribute name="extensions" use="required">
+ /// The extensions associated with this file filter entry.
+ /// </attribute>
+ /// <usage>Only in /SharpDevelop/Workbench/FileFilter</usage>
+ /// <returns>
+ /// String in the format "name|extensions".
+ /// </returns>
+ public class FileFilterDoozer : IDoozer
+ {
+ /// <summary>
+ /// Gets if the doozer handles codon conditions on its own.
+ /// If this property return false, the item is excluded when the condition is not met.
+ /// </summary>
+ public bool HandleConditions {
+ get {
+ return false;
+ }
+ }
+
+ public object BuildItem(object caller, Codon codon, ArrayList subItems)
+ {
+ return StringParser.Parse(codon.Properties["name"]) + "|" + codon.Properties["extensions"];
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/Icon/IconDescriptor.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/Icon/IconDescriptor.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/Icon/IconDescriptor.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,45 @@
+// <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>
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ public class IconDescriptor
+ {
+ Codon codon;
+
+ public string Id {
+ get {
+ return codon.Id;
+ }
+ }
+
+ public string Language {
+ get {
+ return codon.Properties["language"];
+ }
+ }
+
+ public string Resource {
+ get {
+ return codon.Properties["resource"];
+ }
+ }
+
+ public string[] Extensions {
+ get {
+ return codon.Properties["extensions"].Split(';');
+ }
+ }
+
+ public IconDescriptor(Codon codon)
+ {
+ this.codon = codon;
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/Icon/IconDoozer.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/Icon/IconDoozer.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/Icon/IconDoozer.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,49 @@
+// <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>
+
+using System;
+using System.Collections;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Creates associations between file types or node types in the project browser and
+ /// icons in the resource service.
+ /// </summary>
+ /// <attribute name="resource" use="required">
+ /// The name of a bitmap resource in the resource service.
+ /// </attribute>
+ /// <attribute name="language">
+ /// This attribute is specified when a project icon association should be created.
+ /// It specifies the language of the project types that use the icon.
+ /// </attribute>
+ /// <attribute name="extensions">
+ /// This attribute is specified when a file icon association should be created.
+ /// It specifies the semicolon-separated list of file types that use the icon.
+ /// </attribute>
+ /// <usage>Only in /Workspace/Icons</usage>
+ /// <returns>
+ /// An IconDescriptor object that exposes the attributes.
+ /// </returns>
+ public class IconDoozer : IDoozer
+ {
+ /// <summary>
+ /// Gets if the doozer handles codon conditions on its own.
+ /// If this property return false, the item is excluded when the condition is not met.
+ /// </summary>
+ public bool HandleConditions {
+ get {
+ return false;
+ }
+ }
+
+ public object BuildItem(object caller, Codon codon, ArrayList subItems)
+ {
+ return new IconDescriptor(codon);
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/IncludeDoozer.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/IncludeDoozer.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/IncludeDoozer.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,84 @@
+// <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>
+
+using System;
+using System.Collections;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Includes one or multiple items from another location in the addin tree.
+ /// You can use the attribute "item" (to include a single item) OR the
+ /// attribute "path" (to include all items from the target path).
+ /// </summary>
+ /// <attribute name="item">
+ /// When this attribute is used, the include doozer builds the item that is at the
+ /// addin tree location specified by this attribute.
+ /// </attribute>
+ /// <attribute name="path">
+ /// When this attribute is used, the include doozer builds all items inside the
+ /// path addin tree location specified by this attribute and returns an
+ /// <see cref="IBuildItemsModifier"/> which includes all items in the output list.
+ /// </attribute>
+ /// <usage>Everywhere</usage>
+ /// <returns>
+ /// Any object, depending on the included codon(s).
+ /// </returns>
+ public class IncludeDoozer : IDoozer
+ {
+ /// <summary>
+ /// Gets if the doozer handles codon conditions on its own.
+ /// If this property return false, the item is excluded when the condition is not met.
+ /// </summary>
+ public bool HandleConditions {
+ get {
+ return false;
+ }
+ }
+
+ public object BuildItem(object caller, Codon codon, ArrayList subItems)
+ {
+ string item = codon.Properties["item"];
+ string path = codon.Properties["path"];
+ if (item != null && item.Length > 0) {
+ // include item
+ return AddInTree.BuildItem(item, caller);
+ } else if (path != null && path.Length > 0) {
+ // include path (=multiple items)
+ return new IncludeReturnItem(caller, path);
+ } else {
+ MessageService.ShowMessage("<Include> requires the attribute 'item' (to include one item) or the attribute 'path' (to include multiple items)");
+ return null;
+ }
+ }
+
+ class IncludeReturnItem : IBuildItemsModifier
+ {
+ string path;
+ object caller;
+
+ public IncludeReturnItem(object caller, string path)
+ {
+ this.caller = caller;
+ this.path = path;
+ }
+
+ public void Apply(IList items)
+ {
+ AddInTreeNode node;
+ try {
+ node = AddInTree.GetTreeNode(path);
+ foreach (object o in node.BuildChildItems(caller)) {
+ items.Add(o);
+ }
+ } catch (TreePathNotFoundException) {
+ MessageService.ShowError("IncludeDoozer: AddinTree-Path not found: " + path);
+ }
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/LazyDoozer.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/LazyDoozer.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/LazyDoozer.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,76 @@
+// <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>
+
+using System;
+using System.Collections;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// This doozer lazy-loads another doozer when it has to build an item.
+ /// It is used internally to wrap doozers specified in addins.
+ /// </summary>
+ public class LazyLoadDoozer : IDoozer
+ {
+ AddIn addIn;
+ string name;
+ string className;
+
+ public string Name {
+ get {
+ return name;
+ }
+ }
+
+ public string ClassName {
+ get {
+ return className;
+ }
+ }
+
+ public LazyLoadDoozer(AddIn addIn, Properties properties)
+ {
+ this.addIn = addIn;
+ this.name = properties["name"];
+ this.className = properties["class"];
+
+ }
+
+ /// <summary>
+ /// Gets if the doozer handles codon conditions on its own.
+ /// If this property return false, the item is excluded when the condition is not met.
+ /// </summary>
+ public bool HandleConditions {
+ get {
+ IDoozer doozer = (IDoozer)addIn.CreateObject(className);
+ if (doozer == null) {
+ return false;
+ }
+ AddInTree.Doozers[name] = doozer;
+ return doozer.HandleConditions;
+ }
+ }
+
+ public object BuildItem(object caller, Codon codon, ArrayList subItems)
+ {
+ IDoozer doozer = (IDoozer)addIn.CreateObject(className);
+ if (doozer == null) {
+ return null;
+ }
+ AddInTree.Doozers[name] = doozer;
+ return doozer.BuildItem(caller, codon, subItems);
+ }
+
+ public override string ToString()
+ {
+ return String.Format("[LazyLoadDoozer: className = {0}, name = {1}]",
+ className,
+ name);
+ }
+
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/AbstractCheckableMenuCommand.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/AbstractCheckableMenuCommand.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/AbstractCheckableMenuCommand.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,29 @@
+// <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>
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ public abstract class AbstractCheckableMenuCommand : AbstractMenuCommand, ICheckableMenuCommand
+ {
+ bool isChecked = false;
+
+ public virtual bool IsChecked {
+ get {
+ return isChecked;
+ }
+ set {
+ isChecked = value;
+ }
+ }
+ public override void Run()
+ {
+ IsChecked = !IsChecked;
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/AbstractMenuCommand.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/AbstractMenuCommand.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/AbstractMenuCommand.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,25 @@
+// <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>
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ public abstract class AbstractMenuCommand : AbstractCommand, IMenuCommand
+ {
+ bool isEnabled = true;
+
+ public virtual bool IsEnabled {
+ get {
+ return isEnabled;
+ }
+ set {
+ isEnabled = value;
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/ICheckableMenuCommand.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/ICheckableMenuCommand.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/ICheckableMenuCommand.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,19 @@
+// <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>
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ public interface ICheckableMenuCommand : IMenuCommand
+ {
+ bool IsChecked {
+ get;
+ set;
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/IMenuCommand.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/IMenuCommand.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/IMenuCommand.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,19 @@
+// <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>
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ public interface IMenuCommand : ICommand
+ {
+ bool IsEnabled {
+ get;
+ set;
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/MenuItemDoozer.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/MenuItemDoozer.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/MenuItem/MenuItemDoozer.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,86 @@
+// <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>
+
+using System;
+using System.Collections;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Creates menu items from a location in the addin tree.
+ /// </summary>
+ /// <attribute name="label" use="required">
+ /// Label of the menu item.
+ /// </attribute>
+ /// <attribute name="type" use="optional" enum="Separator;CheckBox;Item;Command;Menu;Builder">
+ /// This attribute must be one of these values:
+ /// Separator, CheckBox, Item=Command, Menu (=with subitems),
+ /// Builder (=class implementing ISubmenuBuilder).
+ /// Default: Command.
+ /// </attribute>
+ /// <attribute name="loadclasslazy" use="optional">
+ /// Only for the type "Item"/"Command".
+ /// When set to false, the command class is loaded
+ /// immediately instead of the usual lazy-loading.
+ /// </attribute>
+ /// <attribute name="icon" use="optional">
+ /// Icon of the menu item.
+ /// </attribute>
+ /// <attribute name="class" use="optional">
+ /// Command class that is run when item is clicked.
+ /// </attribute>
+ /// <attribute name="link" use="optional">
+ /// Only for the type "Item"/"Command". Opens a webpage instead of running a command when
+ /// clicking the item.
+ /// </attribute>
+ /// <attribute name="shortcut" use="optional">
+ /// Shortcut that activates the command (e.g. "Control|S").
+ /// </attribute>
+ /// <children childTypes="MenuItem">
+ /// If "type" is "Menu", the item can have sub-menuitems.
+ /// </children>
+ /// <usage>Any menu strip paths or context menu paths, e.g. /SharpDevelop/Workbench/MainMenu</usage>
+ /// <returns>
+ /// A MenuItemDescriptor object.
+ /// </returns>
+ /// <conditions>Conditions are handled by the item, "Exclude" maps to "Visible = false", "Disable" to "Enabled = false"</conditions>
+ public class MenuItemDoozer : IDoozer
+ {
+ /// <summary>
+ /// Gets if the doozer handles codon conditions on its own.
+ /// If this property return false, the item is excluded when the condition is not met.
+ /// </summary>
+ public bool HandleConditions {
+ get {
+ return true;
+ }
+ }
+
+ public object BuildItem(object caller, Codon codon, ArrayList subItems)
+ {
+ return new MenuItemDescriptor(caller, codon, subItems);
+ }
+ }
+
+ /// <summary>
+ /// Represents a menu item. These objects are created by the MenuItemDoozer and
+ /// then converted into GUI-toolkit-specific objects by the MenuService.
+ /// </summary>
+ public sealed class MenuItemDescriptor
+ {
+ public readonly object Caller;
+ public readonly Codon Codon;
+ public readonly IList SubItems;
+
+ public MenuItemDescriptor(object caller, Codon codon, IList subItems)
+ {
+ this.Caller = caller;
+ this.Codon = codon;
+ this.SubItems = subItems;
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/StringDoozer.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/StringDoozer.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/StringDoozer.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,39 @@
+// <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>
+
+using System;
+using System.Collections;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Creates a string.
+ /// </summary>
+ /// <attribute name="text" use="required">
+ /// The string to return.
+ /// </attribute>
+ /// <returns>
+ /// The string specified by 'text', passed through the StringParser.
+ /// </returns>
+ public class StringDoozer : IDoozer
+ {
+ /// <summary>
+ /// Gets if the doozer handles codon conditions on its own.
+ /// If this property return false, the item is excluded when the condition is not met.
+ /// </summary>
+ public bool HandleConditions {
+ get {
+ return false;
+ }
+ }
+
+ public object BuildItem(object caller, Codon codon, ArrayList subItems)
+ {
+ return StringParser.Parse(codon.Properties["text"]);
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/AbstractComboBoxCommand.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/AbstractComboBoxCommand.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/AbstractComboBoxCommand.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +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: 1965 $</version>
+// </file>
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ public abstract class AbstractComboBoxCommand : AbstractCommand, IComboBoxCommand
+ {
+ bool isEnabled = true;
+
+ public virtual bool IsEnabled {
+ get {
+ return isEnabled;
+ }
+ set {
+ isEnabled = value;
+ }
+ }
+
+ public override void Run()
+ {
+
+ }
+
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/AbstractTextBoxCommand.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/AbstractTextBoxCommand.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/AbstractTextBoxCommand.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,30 @@
+// <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>
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ public abstract class AbstractTextBoxCommand : AbstractCommand, ITextBoxCommand
+ {
+ bool isEnabled = true;
+
+ public virtual bool IsEnabled {
+ get {
+ return isEnabled;
+ }
+ set {
+ isEnabled = value;
+ }
+ }
+
+ public override void Run()
+ {
+
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/IComboBoxCommand.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/IComboBoxCommand.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/IComboBoxCommand.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,19 @@
+// <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>
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ public interface IComboBoxCommand : ICommand
+ {
+ bool IsEnabled {
+ get;
+ set;
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/ITextBoxCommand.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/ITextBoxCommand.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/ITextBoxCommand.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,19 @@
+// <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>
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ public interface ITextBoxCommand : ICommand
+ {
+ bool IsEnabled {
+ get;
+ set;
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/ToolBarItemDoozer.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/ToolBarItemDoozer.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/DefaultDoozers/ToolBarItem/ToolBarItemDoozer.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,78 @@
+// <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>
+
+using System;
+using System.Collections;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Creates tool bar items from a location in the addin tree.
+ /// </summary>
+ /// <attribute name="label" use="optional">
+ /// Label of the tool bar item.
+ /// </attribute>
+ /// <attribute name="icon" use="optional">
+ /// Icon of the tool bar item.
+ /// </attribute>
+ /// <attribute name="type" use="optional" enum="Separator;CheckBox;Item;ComboBox;DropDownButton">
+ /// This attribute must be one of these values:
+ /// Separator, CheckBox, Item, ComboBox, DropDownButton
+ /// </attribute>
+ /// <attribute name="loadclasslazy" use="optional">
+ /// Only for the type "Item". When set to false, the command class is loaded
+ /// immediately instead of the usual lazy-loading.
+ /// </attribute>
+ /// <attribute name="tooltip" use="optional">
+ /// Tooltip of the tool bar item.
+ /// </attribute>
+ /// <attribute name="class">
+ /// Command class that is run when item is clicked; or class that manages
+ /// the ComboBox/DropDownButton. Required for everything except "Separator".
+ /// </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>
+ /// A ToolStrip* object, depending on the type attribute.
+ /// </returns>
+ /// <conditions>Conditions are handled by the item, "Exclude" maps to "Visible = false", "Disable" to "Enabled = false"</conditions>
+ public class ToolbarItemDoozer : IDoozer
+ {
+ /// <summary>
+ /// Gets if the doozer handles codon conditions on its own.
+ /// If this property return false, the item is excluded when the condition is not met.
+ /// </summary>
+ public bool HandleConditions {
+ get {
+ return true;
+ }
+ }
+
+ public object BuildItem(object caller, Codon codon, ArrayList subItems)
+ {
+ return new ToolbarItemDescriptor(caller, codon, subItems);
+ }
+ }
+
+ /// <summary>
+ /// Represents a toolbar item. These objects are created by the ToolbarItemDoozer and
+ /// then converted into GUI-toolkit-specific objects by the ToolbarService.
+ /// </summary>
+ public sealed class ToolbarItemDescriptor
+ {
+ public readonly object Caller;
+ public readonly Codon Codon;
+ public readonly IList SubItems;
+
+ public ToolbarItemDescriptor(object caller, Codon codon, IList subItems)
+ {
+ this.Caller = caller;
+ this.Codon = codon;
+ this.SubItems = subItems;
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ExtensionPath.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ExtensionPath.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ExtensionPath.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,83 @@
+// <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>
+
+using System;
+using System.Collections.Generic;
+using System.Xml;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Description of Path.
+ /// </summary>
+ public class ExtensionPath
+ {
+ string name;
+ AddIn addIn;
+ List<Codon> codons = new List<Codon>();
+
+ public AddIn AddIn {
+ get {
+ return addIn;
+ }
+ }
+
+ public string Name {
+ get {
+ return name;
+ }
+ }
+ public List<Codon> Codons {
+ get {
+ return codons;
+ }
+ }
+
+ public ExtensionPath(string name, AddIn addIn)
+ {
+ this.addIn = addIn;
+ this.name = name;
+ }
+
+ public static void SetUp(ExtensionPath extensionPath, XmlReader reader, string endElement)
+ {
+ Stack<ICondition> conditionStack = new Stack<ICondition>();
+ while (reader.Read()) {
+ switch (reader.NodeType) {
+ case XmlNodeType.EndElement:
+ if (reader.LocalName == "Condition" || reader.LocalName == "ComplexCondition") {
+ conditionStack.Pop();
+ } else if (reader.LocalName == endElement) {
+ return;
+ }
+ break;
+ case XmlNodeType.Element:
+ string elementName = reader.LocalName;
+ if (elementName == "Condition") {
+ conditionStack.Push(Condition.Read(reader));
+ } 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);
+ 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();
+ //}
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IBuildItemsModifier.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IBuildItemsModifier.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IBuildItemsModifier.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,26 @@
+// <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>
+
+using System;
+using System.Collections;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// When a <see cref="IDoozer">doozer</see> returns an object implementing
+ /// this interface, the <see cref="Apply"/> method is called on the list of items
+ /// that has been built.
+ /// This interface can be used to support special <see cref="IDoozer">doozers</see>
+ /// that do not simply build one item but want to modify the list of items built so far.
+ /// Example use is the <see cref="IncludeDoozer"/> which uses this interface to return
+ /// multiple items instead of one.
+ /// </summary>
+ public interface IBuildItemsModifier
+ {
+ void Apply(IList items);
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ICondition.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ICondition.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/ICondition.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,42 @@
+// <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>
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Default actions, when a condition is failed.
+ /// </summary>
+ public enum ConditionFailedAction {
+ Nothing,
+ Exclude,
+ Disable
+ }
+
+ /// <summary>
+ /// Interface for single condition or complex condition.
+ /// </summary>
+ public interface ICondition
+ {
+ string Name {
+ get;
+ }
+ /// <summary>
+ /// Returns the action which occurs, when this condition fails.
+ /// </summary>
+ ConditionFailedAction Action {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Returns true, when the condition is valid otherwise false.
+ /// </summary>
+ bool IsValid(object caller);
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IConditionEvaluator.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IConditionEvaluator.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IConditionEvaluator.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,19 @@
+// <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>
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Interface for classes that can evaluate conditions defined in the addin tree.
+ /// </summary>
+ public interface IConditionEvaluator
+ {
+ bool IsValid(object caller, Condition condition);
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IDoozer.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IDoozer.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/IDoozer.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,34 @@
+// <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>
+
+using System;
+using System.Collections;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Interface for classes that can build objects out of codons.
+ /// </summary>
+ /// <remarks>http://en.wikipedia.org/wiki/Fraggle_Rock#Doozers</remarks>
+ public interface IDoozer
+ {
+ /// <summary>
+ /// Gets if the doozer handles codon conditions on its own.
+ /// If this property return false, the item is excluded when the condition is not met.
+ /// </summary>
+ bool HandleConditions { get; }
+
+ /// <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);
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Manifest.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Manifest.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Manifest.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,110 @@
+// <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>
+
+using System;
+using System.Collections.Generic;
+using System.Xml;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Stores information about the manifest of an AddIn.
+ /// </summary>
+ public class AddInManifest
+ {
+ List<AddInReference> dependencies = new List<AddInReference>();
+ List<AddInReference> conflicts = new List<AddInReference>();
+ Dictionary<string, Version> identities = new Dictionary<string, Version>();
+ Version primaryVersion;
+ string primaryIdentity;
+
+ public string PrimaryIdentity {
+ get {
+ return primaryIdentity;
+ }
+ }
+
+ public Version PrimaryVersion {
+ get {
+ return primaryVersion;
+ }
+ }
+
+ public Dictionary<string, Version> Identities {
+ get {
+ return identities;
+ }
+ }
+
+ public List<AddInReference> Dependencies {
+ get {
+ return dependencies;
+ }
+ }
+
+ public List<AddInReference> Conflicts {
+ get {
+ return conflicts;
+ }
+ }
+
+ void AddIdentity(string name, string version, string hintPath)
+ {
+ if (name.Length == 0)
+ throw new AddInLoadException("Identity needs a name");
+ foreach (char c in name) {
+ if (!char.IsLetterOrDigit(c) && c != '.' && c != '_') {
+ throw new AddInLoadException("Identity name contains invalid character: '" + c + "'");
+ }
+ }
+ Version v = AddInReference.ParseVersion(version, hintPath);
+ if (primaryVersion == null) {
+ primaryVersion = v;
+ }
+ if (primaryIdentity == null) {
+ primaryIdentity = name;
+ }
+ identities.Add(name, v);
+ }
+
+ public void ReadManifestSection(XmlReader reader, string hintPath)
+ {
+ if (reader.AttributeCount != 0) {
+ throw new AddInLoadException("Manifest node cannot have attributes.");
+ }
+ if (reader.IsEmptyElement) {
+ throw new AddInLoadException("Manifest node cannot be empty.");
+ }
+ while (reader.Read()) {
+ switch (reader.NodeType) {
+ case XmlNodeType.EndElement:
+ if (reader.LocalName == "Manifest") {
+ return;
+ }
+ break;
+ case XmlNodeType.Element:
+ string nodeName = reader.LocalName;
+ Properties properties = Properties.ReadFromAttributes(reader);
+ switch (nodeName) {
+ case "Identity":
+ AddIdentity(properties["name"], properties["version"], hintPath);
+ break;
+ case "Dependency":
+ dependencies.Add(AddInReference.Create(properties, hintPath));
+ break;
+ case "Conflict":
+ conflicts.Add(AddInReference.Create(properties, hintPath));
+ break;
+ default:
+ throw new AddInLoadException("Unknown node in Manifest section:" + nodeName);
+ }
+ break;
+ }
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Runtime.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Runtime.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddIn/Runtime.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,208 @@
+// <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>
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using System.Xml;
+
+namespace ICSharpCode.Core
+{
+ public class Runtime
+ {
+ string hintPath;
+ string assembly;
+ Assembly loadedAssembly = null;
+
+ IList<LazyLoadDoozer> definedDoozers = new List<LazyLoadDoozer>();
+ IList<LazyConditionEvaluator> definedConditionEvaluators = new List<LazyConditionEvaluator>();
+ ICondition[] conditions;
+ bool isActive = true;
+ bool isAssemblyLoaded;
+
+ public bool IsActive {
+ get {
+ if (conditions != null) {
+ isActive = Condition.GetFailedAction(conditions, this) == ConditionFailedAction.Nothing;
+ conditions = null;
+ }
+ return isActive;
+ }
+ }
+
+ public Runtime(string assembly, string hintPath)
+ {
+ this.assembly = assembly;
+ this.hintPath = hintPath;
+ }
+
+ public string 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;
+ }
+ }
+ 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) {
+ 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;
+ }
+ }
+
+ public IList<LazyLoadDoozer> DefinedDoozers {
+ get {
+ return definedDoozers;
+ }
+ }
+
+ public IList<LazyConditionEvaluator> DefinedConditionEvaluators {
+ get {
+ return definedConditionEvaluators;
+ }
+ }
+
+ public object CreateInstance(string instance)
+ {
+ if (IsActive) {
+ Assembly asm = LoadedAssembly;
+ if (asm == null)
+ return null;
+ return asm.CreateInstance(instance);
+ } else {
+ return null;
+ }
+ }
+
+ internal static void ReadSection(XmlReader reader, AddIn addIn, string hintPath)
+ {
+ Stack<ICondition> conditionStack = new Stack<ICondition>();
+ while (reader.Read()) {
+ switch (reader.NodeType) {
+ case XmlNodeType.EndElement:
+ if (reader.LocalName == "Condition" || reader.LocalName == "ComplexCondition") {
+ conditionStack.Pop();
+ } else if (reader.LocalName == "Runtime") {
+ return;
+ }
+ break;
+ case XmlNodeType.Element:
+ switch (reader.LocalName) {
+ case "Condition":
+ conditionStack.Push(Condition.Read(reader));
+ break;
+ case "ComplexCondition":
+ conditionStack.Push(Condition.ReadComplexCondition(reader));
+ break;
+ case "Import":
+ addIn.Runtimes.Add(Runtime.Read(addIn, reader, hintPath, conditionStack));
+ break;
+ case "DisableAddIn":
+ if (Condition.GetFailedAction(conditionStack, addIn) == ConditionFailedAction.Nothing) {
+ // The DisableAddIn node not was not disabled by a condition
+ addIn.CustomErrorMessage = reader.GetAttribute("message");
+ }
+ break;
+ default:
+ throw new AddInLoadException("Unknown node in runtime section :" + reader.LocalName);
+ }
+ break;
+ }
+ }
+ }
+
+ internal static Runtime Read(AddIn addIn, XmlReader reader, string hintPath, Stack<ICondition> conditionStack)
+ {
+ if (reader.AttributeCount != 1) {
+ throw new AddInLoadException("Import node requires ONE attribute.");
+ }
+ Runtime runtime = new Runtime(reader.GetAttribute(0), hintPath);
+ if (conditionStack.Count > 0) {
+ runtime.conditions = conditionStack.ToArray();
+ }
+ if (!reader.IsEmptyElement) {
+ while (reader.Read()) {
+ switch (reader.NodeType) {
+ case XmlNodeType.EndElement:
+ if (reader.LocalName == "Import") {
+ return runtime;
+ }
+ break;
+ case XmlNodeType.Element:
+ string nodeName = reader.LocalName;
+ Properties properties = Properties.ReadFromAttributes(reader);
+ switch (nodeName) {
+ case "Doozer":
+ if (!reader.IsEmptyElement) {
+ throw new AddInLoadException("Doozer nodes must be empty!");
+ }
+ runtime.definedDoozers.Add(new LazyLoadDoozer(addIn, properties));
+ break;
+ case "ConditionEvaluator":
+ if (!reader.IsEmptyElement) {
+ throw new AddInLoadException("ConditionEvaluator nodes must be empty!");
+ }
+ runtime.definedConditionEvaluators.Add(new LazyConditionEvaluator(addIn, properties));
+ break;
+ default:
+ throw new AddInLoadException("Unknown node in Import section:" + nodeName);
+ }
+ break;
+ }
+ }
+ }
+ runtime.definedDoozers = (runtime.definedDoozers as List<LazyLoadDoozer>).AsReadOnly();
+ runtime.definedConditionEvaluators = (runtime.definedConditionEvaluators as List<LazyConditionEvaluator>).AsReadOnly();
+ return runtime;
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInManager.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInManager.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInManager.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,423 @@
+// <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>
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using System.Xml;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Specifies the action to be taken for a specific <see cref="AddIn"/>.
+ /// </summary>
+ public enum AddInAction
+ {
+ /// <summary>
+ /// Enable the <see cref="AddIn"/>.
+ /// </summary>
+ Enable,
+ /// <summary>
+ /// Disable the <see cref="AddIn"/>.
+ /// </summary>
+ Disable,
+ /// <summary>
+ /// Install the <see cref="AddIn"/>.
+ /// </summary>
+ Install,
+ /// <summary>
+ /// Uninstall the <see cref="AddIn"/>.
+ /// </summary>
+ Uninstall,
+ /// <summary>
+ /// Update the <see cref="AddIn"/>.
+ /// </summary>
+ Update,
+ /// <summary>
+ /// The <see cref="AddIn"/> is disabled because it has been installed
+ /// twice (duplicate identity).
+ /// </summary>
+ InstalledTwice,
+ /// <summary>
+ /// Tells that the <see cref="AddIn"/> cannot be loaded because not all dependencies are satisfied.
+ /// </summary>
+ DependencyError,
+ /// <summary>
+ /// A custom error has occurred (e.g. the AddIn disabled itself using a condition).
+ /// </summary>
+ CustomError
+ }
+
+ /// <summary>
+ /// Manages all actions performed on <see cref="AddIn"/>s.
+ /// An AddInManager GUI can use the methods here to install/update/uninstall
+ /// <see cref="AddIn"/>s.
+ ///
+ /// There are three types of AddIns:
+ /// - Preinstalled AddIns (added by host application) -> can only be disabled
+ /// - External AddIns -> can be added, disabled and removed
+ /// Removing external AddIns only removes the reference to the .addin file
+ /// but does not delete the AddIn.
+ /// - User AddIns -> are installed to UserAddInPath, can be installed, disabled
+ /// and uninstalled
+ /// </summary>
+ public static class AddInManager
+ {
+ static string configurationFileName;
+ static string addInInstallTemp;
+ static string userAddInPath;
+
+ /// <summary>
+ /// Gets or sets the user addin path.
+ /// This is the path where user AddIns are installed to.
+ /// This property is normally initialized by <see cref="CoreStartup.ConfigureUserAddIns"/>.
+ /// </summary>
+ public static string UserAddInPath {
+ get {
+ return userAddInPath;
+ }
+ set {
+ userAddInPath = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the addin install temporary directory.
+ /// This is a directory used to store AddIns that should be installed on
+ /// the next start of the application.
+ /// This property is normally initialized by <see cref="CoreStartup.ConfigureUserAddIns"/>.
+ /// </summary>
+ public static string AddInInstallTemp {
+ get {
+ return addInInstallTemp;
+ }
+ set {
+ addInInstallTemp = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the full name of the configuration file.
+ /// In this file, the AddInManager stores the list of disabled AddIns
+ /// and the list of installed external AddIns.
+ /// This property is normally initialized by <see cref="CoreStartup.ConfigureExternalAddIns"/>.
+ /// </summary>
+ public static string ConfigurationFileName {
+ get {
+ return configurationFileName;
+ }
+ set {
+ configurationFileName = value;
+ }
+ }
+
+ /// <summary>
+ /// Installs the AddIns from AddInInstallTemp to the UserAddInPath.
+ /// In case of installation errors, a error message is displayed to the user
+ /// and the affected AddIn is added to the disabled list.
+ /// This method is normally called by <see cref="CoreStartup.ConfigureUserAddIns"/>
+ /// </summary>
+ public static void InstallAddIns(List<string> disabled)
+ {
+ if (!Directory.Exists(addInInstallTemp))
+ return;
+ LoggingService.Info("AddInManager.InstallAddIns started");
+ if (!Directory.Exists(userAddInPath))
+ Directory.CreateDirectory(userAddInPath);
+ string removeFile = Path.Combine(addInInstallTemp, "remove.txt");
+ bool allOK = true;
+ List<string> notRemoved = new List<string>();
+ if (File.Exists(removeFile)) {
+ using (StreamReader r = new StreamReader(removeFile)) {
+ string addInName;
+ while ((addInName = r.ReadLine()) != null) {
+ addInName = addInName.Trim();
+ if (addInName.Length == 0)
+ continue;
+ string targetDir = Path.Combine(userAddInPath, addInName);
+ if (!UninstallAddIn(disabled, addInName, targetDir)) {
+ notRemoved.Add(addInName);
+ allOK = false;
+ }
+ }
+ }
+ if (notRemoved.Count == 0) {
+ LoggingService.Info("Deleting remove.txt");
+ File.Delete(removeFile);
+ } else {
+ LoggingService.Info("Rewriting remove.txt");
+ using (StreamWriter w = new StreamWriter(removeFile)) {
+ notRemoved.ForEach(w.WriteLine);
+ }
+ }
+ }
+ foreach (string sourceDir in Directory.GetDirectories(addInInstallTemp)) {
+ string addInName = Path.GetFileName(sourceDir);
+ string targetDir = Path.Combine(userAddInPath, addInName);
+ if (notRemoved.Contains(addInName)) {
+ LoggingService.Info("Skipping installation of " + addInName + " because deinstallation failed.");
+ continue;
+ }
+ if (UninstallAddIn(disabled, addInName, targetDir)) {
+ LoggingService.Info("Installing " + addInName + "...");
+ Directory.Move(sourceDir, targetDir);
+ } else {
+ allOK = false;
+ }
+ }
+ if (allOK) {
+ try {
+ Directory.Delete(addInInstallTemp, false);
+ } catch (Exception ex) {
+ LoggingService.Warn("Error removing install temp", ex);
+ }
+ }
+ LoggingService.Info("AddInManager.InstallAddIns finished");
+ }
+
+ static bool UninstallAddIn(List<string> disabled, string addInName, string targetDir)
+ {
+ if (Directory.Exists(targetDir)) {
+ LoggingService.Info("Removing " + addInName + "...");
+ try {
+ Directory.Delete(targetDir, true);
+ } catch (Exception ex) {
+ disabled.Add(addInName);
+ MessageService.ShowError("Error removing " + addInName + ":\n" +
+ ex.Message + "\nThe AddIn will be " +
+ "removed on the next start of " + MessageService.ProductName +
+ " and is disabled for now.");
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /// <summary>
+ /// Uninstalls the user addin on next start.
+ /// <see cref="RemoveUserAddInOnNextStart"/> schedules the AddIn for
+ /// deinstallation, you can unschedule it using
+ /// <see cref="AbortRemoveUserAddInOnNextStart"/>
+ /// </summary>
+ /// <param name="identity">The identity of the addin to remove.</param>
+ public static void RemoveUserAddInOnNextStart(string identity)
+ {
+ List<string> removeEntries = new List<string>();
+ string removeFile = Path.Combine(addInInstallTemp, "remove.txt");
+ if (File.Exists(removeFile)) {
+ using (StreamReader r = new StreamReader(removeFile)) {
+ string addInName;
+ while ((addInName = r.ReadLine()) != null) {
+ addInName = addInName.Trim();
+ if (addInName.Length > 0)
+ removeEntries.Add(addInName);
+ }
+ }
+ if (removeEntries.Contains(identity))
+ return;
+ }
+ removeEntries.Add(identity);
+ if (!Directory.Exists(addInInstallTemp))
+ Directory.CreateDirectory(addInInstallTemp);
+ using (StreamWriter w = new StreamWriter(removeFile)) {
+ removeEntries.ForEach(w.WriteLine);
+ }
+ }
+
+ /// <summary>
+ /// Prevents a user AddIn from being uninstalled.
+ /// <see cref="RemoveUserAddInOnNextStart"/> schedules the AddIn for
+ /// deinstallation, you can unschedule it using
+ /// <see cref="AbortRemoveUserAddInOnNextStart"/>
+ /// </summary>
+ /// <param name="identity">The identity of which to abort the removal.</param>
+ public static void AbortRemoveUserAddInOnNextStart(string identity)
+ {
+ string removeFile = Path.Combine(addInInstallTemp, "remove.txt");
+ if (!File.Exists(removeFile)) {
+ return;
+ }
+ List<string> removeEntries = new List<string>();
+ using (StreamReader r = new StreamReader(removeFile)) {
+ string addInName;
+ while ((addInName = r.ReadLine()) != null) {
+ addInName = addInName.Trim();
+ if (addInName.Length > 0)
+ removeEntries.Add(addInName);
+ }
+ }
+ if (removeEntries.Remove(identity)) {
+ using (StreamWriter w = new StreamWriter(removeFile)) {
+ removeEntries.ForEach(w.WriteLine);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Adds the specified external AddIns to the list of registered external
+ /// AddIns.
+ /// </summary>
+ /// <param name="addIns">
+ /// The list of AddIns to add. (use <see cref="AddIn"/> instances
+ /// created by <see cref="AddIn.Load(TextReader)"/>).
+ /// </param>
+ public static void AddExternalAddIns(IList<AddIn> addIns)
+ {
+ List<string> addInFiles = new List<string>();
+ List<string> disabled = new List<string>();
+ LoadAddInConfiguration(addInFiles, disabled);
+
+ foreach (AddIn addIn in addIns) {
+ if (!addInFiles.Contains(addIn.FileName))
+ addInFiles.Add(addIn.FileName);
+ addIn.Enabled = false;
+ addIn.Action = AddInAction.Install;
+ AddInTree.InsertAddIn(addIn);
+ }
+
+ SaveAddInConfiguration(addInFiles, disabled);
+ }
+
+ /// <summary>
+ /// Removes the specified external AddIns from the list of registered external
+ /// AddIns.
+ /// </summary>
+ /// The list of AddIns to remove.
+ /// (use external AddIns from the <see cref="AddInTree.AddIns"/> collection).
+ public static void RemoveExternalAddIns(IList<AddIn> addIns)
+ {
+ List<string> addInFiles = new List<string>();
+ List<string> disabled = new List<string>();
+ LoadAddInConfiguration(addInFiles, disabled);
+
+ foreach (AddIn addIn in addIns) {
+ foreach (string identity in addIn.Manifest.Identities.Keys) {
+ disabled.Remove(identity);
+ }
+ addInFiles.Remove(addIn.FileName);
+ addIn.Action = AddInAction.Uninstall;
+ if (!addIn.Enabled) {
+ AddInTree.RemoveAddIn(addIn);
+ }
+ }
+
+ SaveAddInConfiguration(addInFiles, disabled);
+ }
+
+ /// <summary>
+ /// Marks the specified AddIns as enabled (will take effect after
+ /// next application restart).
+ /// </summary>
+ public static void Enable(IList<AddIn> addIns)
+ {
+ List<string> addInFiles = new List<string>();
+ List<string> disabled = new List<string>();
+ LoadAddInConfiguration(addInFiles, disabled);
+
+ foreach (AddIn addIn in addIns) {
+ foreach (string identity in addIn.Manifest.Identities.Keys) {
+ disabled.Remove(identity);
+ }
+ if (addIn.Action == AddInAction.Uninstall) {
+ if (FileUtility.IsBaseDirectory(userAddInPath, addIn.FileName)) {
+ foreach (string identity in addIn.Manifest.Identities.Keys) {
+ AbortRemoveUserAddInOnNextStart(identity);
+ }
+ } else {
+ if (!addInFiles.Contains(addIn.FileName))
+ addInFiles.Add(addIn.FileName);
+ }
+ }
+ addIn.Action = AddInAction.Enable;
+ }
+
+ SaveAddInConfiguration(addInFiles, disabled);
+ }
+
+ /// <summary>
+ /// Marks the specified AddIns as disabled (will take effect after
+ /// next application restart).
+ /// </summary>
+ public static void Disable(IList<AddIn> addIns)
+ {
+ List<string> addInFiles = new List<string>();
+ List<string> disabled = new List<string>();
+ LoadAddInConfiguration(addInFiles, disabled);
+
+ foreach (AddIn addIn in addIns) {
+ string identity = addIn.Manifest.PrimaryIdentity;
+ if (identity == null)
+ throw new ArgumentException("The AddIn cannot be disabled because it has no identity.");
+
+ if (!disabled.Contains(identity))
+ disabled.Add(identity);
+ addIn.Action = AddInAction.Disable;
+ }
+
+ SaveAddInConfiguration(addInFiles, disabled);
+ }
+
+ /// <summary>
+ /// Loads a configuration file.
+ /// The 'file' from XML elements in the form "<AddIn file='full path to .addin file'>" will
+ /// be added to <paramref name="addInFiles"/>, the 'addin' element from
+ /// "<Disable addin='addin identity'>" will be added to <paramref name="disabledAddIns"/>,
+ /// all other XML elements are ignored.
+ /// </summary>
+ /// <param name="addInFiles">File names of external AddIns are added to this collection.</param>
+ /// <param name="disabledAddIns">Identities of disabled addins are added to this collection.</param>
+ public static void LoadAddInConfiguration(List<string> addInFiles, List<string> disabledAddIns)
+ {
+ if (!File.Exists(configurationFileName))
+ return;
+ using (XmlTextReader reader = new XmlTextReader(configurationFileName)) {
+ while (reader.Read()) {
+ if (reader.NodeType == XmlNodeType.Element) {
+ if (reader.Name == "AddIn") {
+ string fileName = reader.GetAttribute("file");
+ if (fileName != null && fileName.Length > 0) {
+ addInFiles.Add(fileName);
+ }
+ } else if (reader.Name == "Disable") {
+ string addIn = reader.GetAttribute("addin");
+ if (addIn != null && addIn.Length > 0) {
+ disabledAddIns.Add(addIn);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Saves the AddIn configuration in the format expected by
+ /// <see cref="LoadAddInConfiguration"/>.
+ /// </summary>
+ /// <param name="addInFiles">List of file names of external AddIns.</param>
+ /// <param name="disabledAddIns">List of Identities of disabled addins.</param>
+ public static void SaveAddInConfiguration(List<string> addInFiles, List<string> disabledAddIns)
+ {
+ using (XmlTextWriter writer = new XmlTextWriter(configurationFileName, Encoding.UTF8)) {
+ writer.Formatting = Formatting.Indented;
+ writer.WriteStartDocument();
+ writer.WriteStartElement("AddInConfiguration");
+ foreach (string file in addInFiles) {
+ writer.WriteStartElement("AddIn");
+ writer.WriteAttributeString("file", file);
+ writer.WriteEndElement();
+ }
+ foreach (string name in disabledAddIns) {
+ writer.WriteStartElement("Disable");
+ writer.WriteAttributeString("addin", name);
+ writer.WriteEndElement();
+ }
+ writer.WriteEndDocument();
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInTree.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInTree.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInTree.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,444 @@
+// <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>
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Resources;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Static class containing the AddInTree. Contains methods for accessing tree nodes and building items.
+ /// </summary>
+ public static class AddInTree
+ {
+ 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 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());
+
+ conditionEvaluators.Add("Compare", new CompareConditionEvaluator());
+ conditionEvaluators.Add("Ownerstate", new OwnerStateConditionEvaluator());
+
+ ApplicationStateInfoService.RegisterStateGetter("Installed 3rd party AddIns", GetInstalledThirdPartyAddInsListAsString);
+ }
+
+ static object GetInstalledThirdPartyAddInsListAsString()
+ {
+ 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 (sb.Length > 0) sb.Append(", ");
+ sb.Append("[");
+ sb.Append(addIn.Name);
+ if (addIn.Version != null) {
+ sb.Append(' ');
+ sb.Append(addIn.Version.ToString());
+ }
+ if (!addIn.Enabled) {
+ sb.Append(", Enabled=");
+ sb.Append(addIn.Enabled);
+ }
+ if (addIn.Action != AddInAction.Enable) {
+ sb.Append(", Action=");
+ sb.Append(addIn.Action.ToString());
+ }
+ sb.Append("]");
+ }
+ return sb.ToString();
+ }
+
+ /// <summary>
+ /// Gets the list of loaded AddIns.
+ /// </summary>
+ public static IList<AddIn> AddIns {
+ get {
+ return addIns.AsReadOnly();
+ }
+ }
+
+ /// <summary>
+ /// Gets a dictionary of registered doozers.
+ /// </summary>
+ public static Dictionary<string, IDoozer> Doozers {
+ get {
+ return doozers;
+ }
+ }
+
+ /// <summary>
+ /// Gets a dictionary of registered condition evaluators.
+ /// </summary>
+ public static Dictionary<string, IConditionEvaluator> ConditionEvaluators {
+ get {
+ return conditionEvaluators;
+ }
+ }
+
+ /// <summary>
+ /// Checks whether the specified path exists in the AddIn tree.
+ /// </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;
+ }
+
+ /// <summary>
+ /// Gets the <see cref="AddInTreeNode"/> representing the specified path.
+ /// This method throws a <see cref="TreePathNotFoundException"/> when the
+ /// path does not exist.
+ /// </summary>
+ public static AddInTreeNode GetTreeNode(string path)
+ {
+ return GetTreeNode(path, true);
+ }
+
+ /// <summary>
+ /// Gets the <see cref="AddInTreeNode"/> representing the specified path.
+ /// </summary>
+ /// <param name="path">The path of the AddIn tree node</param>
+ /// <param name="throwOnNotFound">
+ /// If set to <c>true</c>, this method throws a
+ /// <see cref="TreePathNotFoundException"/> when the path does not exist.
+ /// If set to <c>false</c>, <c>null</c> is returned for non-existing paths.
+ /// </param>
+ public static AddInTreeNode GetTreeNode(string path, bool throwOnNotFound)
+ {
+ if (path == null || path.Length == 0) {
+ return rootNode;
+ }
+ string[] splittedPath = path.Split('/');
+ AddInTreeNode curPath = rootNode;
+ int i = 0;
+ while (i < splittedPath.Length) {
+ 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;
+ }
+
+ /// <summary>
+ /// Builds a single item in the addin tree.
+ /// </summary>
+ /// <param name="path">A path to the item in the addin tree.</param>
+ /// <param name="caller">The owner used to create the objects.</param>
+ /// <exception cref="TreePathNotFoundException">The path does not
+ /// exist or does not point to an item.</exception>
+ public static object BuildItem(string path, object caller)
+ {
+ 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)));
+ }
+
+ /// <summary>
+ /// Builds the items in the path. Ensures that all items have the type T.
+ /// Throws a <see cref="TreePathNotFoundException"/> if the path is not found.
+ /// </summary>
+ /// <param name="path">A path in the addin tree.</param>
+ /// <param name="caller">The owner used to create the objects.</param>
+ public static List<T> BuildItems<T>(string path, object caller)
+ {
+ return BuildItems<T>(path, caller, true);
+ }
+
+ /// <summary>
+ /// Builds the items in the path. Ensures that all items have the type T.
+ /// </summary>
+ /// <param name="path">A path in the addin tree.</param>
+ /// <param name="caller">The owner used to create the objects.</param>
+ /// <param name="throwOnNotFound">If true, throws a <see cref="TreePathNotFoundException"/>
+ /// if the path is not found. If false, an empty ArrayList is returned when the
+ /// path is not found.</param>
+ public static List<T> BuildItems<T>(string path, object caller, bool throwOnNotFound)
+ {
+ AddInTreeNode node = GetTreeNode(path, throwOnNotFound);
+ if (node == null)
+ return new List<T>();
+ else
+ return node.BuildChildItems<T>(caller);
+ }
+
+ static AddInTreeNode CreatePath(AddInTreeNode localRoot, string path)
+ {
+ if (path == null || path.Length == 0) {
+ return localRoot;
+ }
+ string[] splittedPath = path.Split('/');
+ AddInTreeNode curPath = localRoot;
+ int i = 0;
+ while (i < splittedPath.Length) {
+ if (!curPath.ChildNodes.ContainsKey(splittedPath[i])) {
+ curPath.ChildNodes[splittedPath[i]] = new AddInTreeNode();
+ }
+ curPath = curPath.ChildNodes[splittedPath[i]];
+ ++i;
+ }
+
+ return curPath;
+ }
+
+ static void AddExtensionPath(ExtensionPath path)
+ {
+ AddInTreeNode treePath = CreatePath(rootNode, path.Name);
+ foreach (Codon codon in path.Codons) {
+ treePath.Codons.Add(codon);
+ }
+ }
+
+ /// <summary>
+ /// The specified AddIn is added to the <see cref="AddIns"/> collection.
+ /// If the AddIn is enabled, its doozers, condition evaluators and extension
+ /// paths are added to the AddInTree and its resources are added to the
+ /// <see cref="ResourceService"/>.
+ /// </summary>
+ public static void InsertAddIn(AddIn addIn)
+ {
+ if (addIn.Enabled) {
+ foreach (ExtensionPath path in addIn.Paths.Values) {
+ AddExtensionPath(path);
+ }
+
+ foreach (Runtime runtime in addIn.Runtimes) {
+ if (runtime.IsActive) {
+ foreach (LazyLoadDoozer doozer in runtime.DefinedDoozers) {
+ if (AddInTree.Doozers.ContainsKey(doozer.Name)) {
+ 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)) {
+ throw new AddInLoadException("Duplicate condition evaluator: " + condition.Name);
+ }
+ AddInTree.ConditionEvaluators.Add(condition.Name, condition);
+ }
+ }
+ }
+
+ string addInRoot = Path.GetDirectoryName(addIn.FileName);
+ foreach(string bitmapResource in addIn.BitmapResources)
+ {
+ string path = Path.Combine(addInRoot, bitmapResource);
+ ResourceManager resourceManager = ResourceManager.CreateFileBasedResourceManager(Path.GetFileNameWithoutExtension(path), Path.GetDirectoryName(path), null);
+ ResourceService.RegisterNeutralImages(resourceManager);
+ }
+
+ foreach(string stringResource in addIn.StringResources)
+ {
+ string path = Path.Combine(addInRoot, stringResource);
+ ResourceManager resourceManager = ResourceManager.CreateFileBasedResourceManager(Path.GetFileNameWithoutExtension(path), Path.GetDirectoryName(path), null);
+ ResourceService.RegisterNeutralStrings(resourceManager);
+ }
+ }
+ addIns.Add(addIn);
+ }
+
+ /// <summary>
+ /// The specified AddIn is removed to the <see cref="AddIns"/> collection.
+ /// This is only possible for disabled AddIns, enabled AddIns require
+ /// a restart of the application to be removed.
+ /// </summary>
+ /// <exception cref="ArgumentException">Occurs when trying to remove an enabled AddIn.</exception>
+ public static void RemoveAddIn(AddIn addIn)
+ {
+ if (addIn.Enabled) {
+ throw new ArgumentException("Cannot remove enabled AddIns at runtime.");
+ }
+ addIns.Remove(addIn);
+ }
+
+ // As long as the show form takes 10 times of loading the xml representation I'm not implementing
+ // binary serialization.
+// static Dictionary<string, ushort> nameLookupTable = new Dictionary<string, ushort>();
+// static Dictionary<AddIn, ushort> addInLookupTable = new Dictionary<AddIn, ushort>();
+//
+// public static ushort GetAddInOffset(AddIn addIn)
+// {
+// return addInLookupTable[addIn];
+// }
+//
+// public static ushort GetNameOffset(string name)
+// {
+// if (!nameLookupTable.ContainsKey(name)) {
+// nameLookupTable[name] = (ushort)nameLookupTable.Count;
+// }
+// return nameLookupTable[name];
+// }
+//
+// public static void BinarySerialize(string fileName)
+// {
+// for (int i = 0; i < addIns.Count; ++i) {
+// addInLookupTable[addIns] = (ushort)i;
+// }
+// using (BinaryWriter writer = new BinaryWriter(File.OpenWrite(fileName))) {
+// rootNode.BinarySerialize(writer);
+// writer.Write((ushort)addIns.Count);
+// for (int i = 0; i < addIns.Count; ++i) {
+// addIns[i].BinarySerialize(writer);
+// }
+// writer.Write((ushort)nameLookupTable.Count);
+// foreach (string name in nameLookupTable.Keys) {
+// writer.Write(name);
+// }
+// }
+// }
+
+ // used by Load(): disables an addin and removes it from the dictionaries.
+ static void DisableAddin(AddIn addIn, Dictionary<string, Version> dict, Dictionary<string, AddIn> addInDict)
+ {
+ addIn.Enabled = false;
+ addIn.Action = AddInAction.DependencyError;
+ foreach (string name in addIn.Manifest.Identities.Keys) {
+ dict.Remove(name);
+ addInDict.Remove(name);
+ }
+ }
+
+ /// <summary>
+ /// Loads a list of .addin files, ensuring that dependencies are satisfied.
+ /// This method is normally called by <see cref="CoreStartup.RunInitialization"/>.
+ /// </summary>
+ /// <param name="addInFiles">
+ /// The list of .addin file names to load.
+ /// </param>
+ /// <param name="disabledAddIns">
+ /// The list of disabled AddIn identity names.
+ /// </param>
+ public static void Load(List<string> addInFiles, List<string> disabledAddIns)
+ {
+ List<AddIn> list = new List<AddIn>();
+ Dictionary<string, Version> dict = new Dictionary<string, Version>();
+ Dictionary<string, AddIn> addInDict = new Dictionary<string, AddIn>();
+ foreach (string fileName in addInFiles) {
+ AddIn addIn;
+ try {
+ addIn = AddIn.Load(fileName);
+ } catch (AddInLoadException ex) {
+ LoggingService.Error(ex);
+ if (ex.InnerException != null) {
+ MessageService.ShowError("Error loading AddIn " + fileName + ":\n"
+ + ex.InnerException.Message);
+ } else {
+ MessageService.ShowError("Error loading AddIn " + fileName + ":\n"
+ + ex.Message);
+ }
+ addIn = new AddIn();
+ addIn.addInFileName = fileName;
+ addIn.CustomErrorMessage = ex.Message;
+ }
+ if (addIn.Action == AddInAction.CustomError) {
+ list.Add(addIn);
+ continue;
+ }
+ addIn.Enabled = true;
+ if (disabledAddIns != null && disabledAddIns.Count > 0) {
+ foreach (string name in addIn.Manifest.Identities.Keys) {
+ if (disabledAddIns.Contains(name)) {
+ addIn.Enabled = false;
+ break;
+ }
+ }
+ }
+ if (addIn.Enabled) {
+ foreach (KeyValuePair<string, Version> pair in addIn.Manifest.Identities) {
+ if (dict.ContainsKey(pair.Key)) {
+ MessageService.ShowError("Name '" + pair.Key + "' is used by " +
+ "'" + addInDict[pair.Key].FileName + "' and '" + fileName + "'");
+ addIn.Enabled = false;
+ addIn.Action = AddInAction.InstalledTwice;
+ break;
+ } else {
+ dict.Add(pair.Key, pair.Value);
+ addInDict.Add(pair.Key, addIn);
+ }
+ }
+ }
+ list.Add(addIn);
+ }
+ checkDependencies:
+ for (int i = 0; i < list.Count; i++) {
+ AddIn addIn = list[i];
+ if (!addIn.Enabled) continue;
+
+ Version versionFound;
+
+ foreach (AddInReference reference in addIn.Manifest.Conflicts) {
+ if (reference.Check(dict, out versionFound)) {
+ MessageService.ShowError(addIn.Name + " conflicts with " + reference.ToString()
+ + " and has been disabled.");
+ DisableAddin(addIn, dict, addInDict);
+ goto checkDependencies; // after removing one addin, others could break
+ }
+ }
+ foreach (AddInReference reference in addIn.Manifest.Dependencies) {
+ if (!reference.Check(dict, out versionFound)) {
+ if (versionFound != null) {
+ MessageService.ShowError(addIn.Name + " has not been loaded because it requires "
+ + reference.ToString() + ", but version "
+ + versionFound.ToString() + " is installed.");
+ } else {
+ MessageService.ShowError(addIn.Name + " has not been loaded because it requires "
+ + reference.ToString() + ".");
+ }
+ DisableAddin(addIn, dict, addInDict);
+ goto checkDependencies; // after removing one addin, others could break
+ }
+ }
+ }
+ foreach (AddIn addIn in list) {
+ try {
+ InsertAddIn(addIn);
+ } catch (AddInLoadException ex) {
+ LoggingService.Error(ex);
+ MessageService.ShowError("Error loading AddIn " + addIn.FileName + ":\n"
+ + ex.Message);
+ }
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInTreeNode.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInTreeNode.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/AddInTreeNode.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,218 @@
+// <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>
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Represents an extension path in the <see cref="AddInTree"/>.
+ /// </summary>
+ public sealed class AddInTreeNode
+ {
+ Dictionary<string, AddInTreeNode> childNodes = new Dictionary<string, AddInTreeNode>();
+ List<Codon> codons = new List<Codon>();
+ bool isSorted = false;
+
+ /// <summary>
+ /// A dictionary containing the child paths.
+ /// </summary>
+ public Dictionary<string, AddInTreeNode> ChildNodes {
+ get {
+ return childNodes;
+ }
+ }
+
+ /// <summary>
+ /// A list of child <see cref="Codon"/>s.
+ /// </summary>
+ public List<Codon> Codons {
+ get {
+ return codons;
+ }
+ }
+
+//
+// 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
+ /// </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;
+ }
+ } else {
+ LoggingService.WarnFormatted("Codon ({0}) specified in the insertbefore of the {1} codon does not exist!", before, codons[i]);
+ }
+ }
+ }
+ }
+
+ 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)
+ {
+ 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);
+ if (result == null)
+ continue;
+ IBuildItemsModifier mod = result as IBuildItemsModifier;
+ if (mod != null) {
+ mod.Apply(items);
+ } else if (result is T) {
+ items.Add((T)result);
+ } else {
+ throw new InvalidCastException("The AddInTreeNode <" + codon.Name + " id='" + codon.Id
+ + "' returned an instance of " + result.GetType().FullName
+ + " but the type " + typeof(T).FullName + " is expected.");
+ }
+ }
+ return items;
+ }
+
+ /// <summary>
+ /// Builds the child items in this path.
+ /// </summary>
+ /// <param name="caller">The owner used to create the objects.</param>
+ 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;
+ }
+
+ /// <summary>
+ /// Builds a specific child items in this path.
+ /// </summary>
+ /// <param name="childItemID">
+ /// 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>
+ /// <exception cref="TreePathNotFoundException">
+ /// Occurs when <paramref name="childItemID"/> does not exist in this path.
+ /// </exception>
+ public object BuildChildItem(string childItemID, object caller, ArrayList subItems)
+ {
+ foreach (Codon codon in codons) {
+ if (codon.Id == childItemID) {
+ return codon.BuildItem(caller, subItems);
+ }
+ }
+ throw new TreePathNotFoundException(childItemID);
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/CoreStartup.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/CoreStartup.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/CoreStartup.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,212 @@
+// <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>
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Class that helps starting up ICSharpCode.Core.
+ /// </summary>
+ /// <remarks>
+ /// Initializing ICSharpCode.Core requires initializing several static classes
+ /// and the <see cref="AddInTree"/>. <see cref="CoreStartup"/> does this work
+ /// for you, provided you use it like this:
+ /// 1. Create a new CoreStartup instance
+ /// 2. (Optional) Set the values of the properties.
+ /// 3. Call <see cref="StartCoreServices()"/>.
+ /// 4. Add "preinstalled" AddIns using <see cref="AddAddInsFromDirectory"/>
+ /// and <see cref="AddAddInFile"/>.
+ /// 5. (Optional) Call <see cref="ConfigureExternalAddIns"/> to support
+ /// disabling AddIns and installing external AddIns
+ /// 6. (Optional) Call <see cref="ConfigureUserAddIns"/> to support installing
+ /// user AddIns.
+ /// 7. Call <see cref="RunInitialization"/>.
+ /// </remarks>
+ public sealed class CoreStartup
+ {
+ List<string> addInFiles = new List<string>();
+ List<string> disabledAddIns = new List<string>();
+ bool externalAddInsConfigured;
+ string propertiesName;
+ string configDirectory;
+ string dataDirectory;
+ string applicationName;
+
+ /// <summary>
+ /// Sets the name used for the properties (only name, without path or extension).
+ /// Must be set before StartCoreServices() is called.
+ /// </summary>
+ public string PropertiesName {
+ get {
+ return propertiesName;
+ }
+ set {
+ if (value == null || value.Length == 0)
+ throw new ArgumentNullException("value");
+ propertiesName = value;
+ }
+ }
+
+ /// <summary>
+ /// Sets the directory name used for the property service.
+ /// Must be set before StartCoreServices() is called.
+ /// Use null to use the default path "%ApplicationData%\%ApplicationName%",
+ /// where %ApplicationData% is the system setting for
+ /// "c:\documents and settings\username\application data"
+ /// and %ApplicationName% is the application name you used in the
+ /// CoreStartup constructor call.
+ /// </summary>
+ public string ConfigDirectory {
+ get {
+ return configDirectory;
+ }
+ set {
+ configDirectory = value;
+ }
+ }
+
+ /// <summary>
+ /// Sets the data directory used to load resources.
+ /// Must be set before StartCoreServices() is called.
+ /// Use null to use the default path "ApplicationRootPath\data".
+ /// </summary>
+ public string DataDirectory {
+ get {
+ return dataDirectory;
+ }
+ set {
+ dataDirectory = value;
+ }
+ }
+
+ /// <summary>
+ /// Creates a new CoreStartup instance.
+ /// </summary>
+ /// <param name="applicationName">
+ /// The name of your application.
+ /// This is used as default title for message boxes,
+ /// default name for the configuration directory etc.
+ /// </param>
+ public CoreStartup(string applicationName)
+ {
+ if (applicationName == null)
+ throw new ArgumentNullException("applicationName");
+ this.applicationName = applicationName;
+ propertiesName = applicationName + "Properties";
+ MessageService.DefaultMessageBoxTitle = applicationName;
+ MessageService.ProductName = applicationName;
+ }
+
+ /// <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.
+ /// </summary>
+ public void AddAddInsFromDirectory(string addInDir)
+ {
+ if (addInDir == null)
+ throw new ArgumentNullException("addInDir");
+ addInFiles.AddRange(FileUtility.SearchDirectory(addInDir, "*.addin"));
+ }
+
+ /// <summary>
+ /// Add the specified .addin file to the list of AddIn files to load.
+ /// </summary>
+ public void AddAddInFile(string addInFile)
+ {
+ if (addInFile == null)
+ throw new ArgumentNullException("addInFile");
+ addInFiles.Add(addInFile);
+ }
+
+ /// <summary>
+ /// Use the specified configuration file to store information about
+ /// disabled AddIns and external AddIns.
+ /// You have to call this method to support the <see cref="AddInManager"/>.
+ /// </summary>
+ /// <param name="addInConfigurationFile">
+ /// The name of the file used to store the list of disabled AddIns
+ /// and the list of installed external AddIns.
+ /// A good value for this parameter would be
+ /// <c>Path.Combine(<see cref="PropertyService.ConfigDirectory"/>, "AddIns.xml")</c>.
+ /// </param>
+ public void ConfigureExternalAddIns(string addInConfigurationFile)
+ {
+ externalAddInsConfigured = true;
+ AddInManager.ConfigurationFileName = addInConfigurationFile;
+ AddInManager.LoadAddInConfiguration(addInFiles, disabledAddIns);
+ }
+
+ /// <summary>
+ /// Configures user AddIn support.
+ /// </summary>
+ /// <param name="addInInstallTemp">
+ /// The AddIn installation temporary directory.
+ /// ConfigureUserAddIns will install the AddIns from this directory and
+ /// store the parameter value in <see cref="AddInManager.AddInInstallTemp"/>.
+ /// </param>
+ /// <param name="userAddInPath">
+ /// The path where user AddIns are installed to.
+ /// AddIns from this directory will be loaded.
+ /// </param>
+ public void ConfigureUserAddIns(string addInInstallTemp, string userAddInPath)
+ {
+ if (!externalAddInsConfigured) {
+ throw new InvalidOperationException("ConfigureExternalAddIns must be called before ConfigureUserAddIns");
+ }
+ AddInManager.AddInInstallTemp = addInInstallTemp;
+ AddInManager.UserAddInPath = userAddInPath;
+ if (Directory.Exists(addInInstallTemp)) {
+ AddInManager.InstallAddIns(disabledAddIns);
+ }
+ if (Directory.Exists(userAddInPath)) {
+ AddAddInsFromDirectory(userAddInPath);
+ }
+ }
+
+ /// <summary>
+ /// Initializes the AddIn system.
+ /// This loads the AddIns that were added to the list,
+ /// then it executes the <see cref="ICommand">commands</see>
+ /// in <c>/Workspace/Autostart</c>.
+ /// </summary>
+ public void RunInitialization()
+ {
+ AddInTree.Load(addInFiles, disabledAddIns);
+
+ // run workspace autostart commands
+ LoggingService.Info("Running autostart commands...");
+ foreach (ICommand command in AddInTree.BuildItems<ICommand>("/Workspace/Autostart", null, false)) {
+ try {
+ command.Run();
+ } catch (Exception ex) {
+ // allow startup to continue if some commands fail
+ MessageService.ShowError(ex);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Starts the core services.
+ /// This initializes the PropertyService and ResourceService.
+ /// </summary>
+ public void StartCoreServices()
+ {
+ if (configDirectory == null)
+ configDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
+ applicationName);
+ PropertyService.InitializeService(configDirectory,
+ dataDirectory ?? Path.Combine(FileUtility.ApplicationRootPath, "data"),
+ propertiesName);
+ PropertyService.Load();
+ ResourceService.InitializeService(FileUtility.Combine(PropertyService.DataDirectory, "resources"));
+ StringParser.Properties["AppName"] = applicationName;
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/TreePathNotFoundException.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/TreePathNotFoundException.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/AddInTree/TreePathNotFoundException.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,47 @@
+// <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>
+
+using System;
+using System.Runtime.Serialization;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Is thrown when the AddInTree could not find the requested path.
+ /// </summary>
+ [Serializable()]
+ public class TreePathNotFoundException : CoreException
+ {
+ /// <summary>
+ /// Constructs a new <see cref="TreePathNotFoundException"/>
+ /// </summary>
+ public TreePathNotFoundException(string path) : base("Treepath not found: " + path)
+ {
+ }
+
+ /// <summary>
+ /// Constructs a new <see cref="TreePathNotFoundException"/>
+ /// </summary>
+ public TreePathNotFoundException() : base()
+ {
+ }
+
+ /// <summary>
+ /// Constructs a new <see cref="TreePathNotFoundException"/>
+ /// </summary>
+ public TreePathNotFoundException(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+
+ /// <summary>
+ /// Deserializes a <see cref="TreePathNotFoundException"/>
+ /// </summary>
+ protected TreePathNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/CoreException.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/CoreException.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/CoreException.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,35 @@
+// <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>
+
+using System;
+using System.Runtime.Serialization;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Base class for exceptions thrown by the SharpDevelop core.
+ /// </summary>
+ [Serializable()]
+ public class CoreException : Exception
+ {
+ public CoreException() : base()
+ {
+ }
+
+ public CoreException(string message) : base(message)
+ {
+ }
+
+ public CoreException(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+
+ protected CoreException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ApplicationStateInfoService.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ApplicationStateInfoService.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ApplicationStateInfoService.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,159 @@
+// <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>
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Text;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// This service is used to summarize important information
+ /// about the state of the application when an exception occurs.
+ /// </summary>
+ public static class ApplicationStateInfoService
+ {
+ static readonly Dictionary<string, StateGetter> stateGetters = new Dictionary<string, StateGetter>(StringComparer.InvariantCulture);
+
+ /// <summary>
+ /// Registers a new method to be invoked to get information about the current state of the application.
+ /// </summary>
+ /// <param name="title">The title of the new state entry.</param>
+ /// <param name="stateGetter">The method to be invoked to get the state value.</param>
+ /// <exception cref="ArgumentNullException">The <paramref name="title"/> is null.</exception>
+ /// <exception cref="ArgumentException">A state getter with the specified <paramref name="title"/> is already registered.</exception>
+ public static void RegisterStateGetter(string title, StateGetter stateGetter)
+ {
+ lock(stateGetters) {
+ stateGetters.Add(title, stateGetter);
+ }
+ }
+
+ /// <summary>
+ /// Determines whether a state getter with the specified title is already registered.
+ /// </summary>
+ /// <param name="title">The title to look for.</param>
+ /// <returns><c>true</c>, if a state getter with the specified title is already registered, otherwise <c>false</c>.</returns>
+ public static bool IsRegistered(string title)
+ {
+ lock(stateGetters) {
+ return stateGetters.ContainsKey(title);
+ }
+ }
+
+ /// <summary>
+ /// Unregisters a state getter.
+ /// </summary>
+ /// <param name="title">The title of the state entry to remove.</param>
+ /// <returns><c>true</c> if the specified title was found and removed, otherwise <c>false</c>.</returns>
+ /// <exception cref="ArgumentNullException">The <paramref name="title"/> is null.</exception>
+ public static bool UnregisterStateGetter(string title)
+ {
+ lock(stateGetters) {
+ return stateGetters.Remove(title);
+ }
+ }
+
+ /// <summary>
+ /// Gets a snapshot of the current application state information from all registered state getters.
+ /// </summary>
+ /// <returns>A dictionary with the titles and results of all registered state getters.</returns>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
+ public static IDictionary<string, object> GetCurrentApplicationStateInfo()
+ {
+ Dictionary<string, object> state = new Dictionary<string, object>(stateGetters.Count, stateGetters.Comparer);
+ lock(stateGetters) {
+ foreach (KeyValuePair<string, StateGetter> entry in stateGetters) {
+ try {
+ state.Add(entry.Key, entry.Value());
+ } catch (Exception ex) {
+ state.Add(entry.Key, new StateGetterExceptionInfo(ex));
+ }
+ }
+ }
+ return state;
+ }
+
+ /// <summary>
+ /// Appends the current application state information from all registered state getters
+ /// to the specified <see cref="StringBuilder"/>.
+ /// </summary>
+ /// <param name="sb">The <see cref="StringBuilder"/> to append the state information to.</param>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
+ public static void AppendFormatted(StringBuilder sb)
+ {
+ IFormattable f;
+ Exception e;
+ StateGetterExceptionInfo exceptionInfo;
+
+ foreach (KeyValuePair<string, object> entry in GetCurrentApplicationStateInfo()) {
+ e = null;
+ sb.Append(entry.Key);
+ sb.Append(": ");
+
+ if (entry.Value == null) {
+ sb.AppendLine("<null>");
+ } else {
+ f = entry.Value as IFormattable;
+ if (f != null) {
+ try {
+ sb.AppendLine(f.ToString(null, CultureInfo.InvariantCulture));
+ } catch (Exception ex) {
+ sb.AppendLine("--> Exception thrown by IFormattable.ToString:");
+ e = ex;
+ }
+ } else {
+ exceptionInfo = entry.Value as StateGetterExceptionInfo;
+ if (exceptionInfo != null) {
+ sb.AppendLine("--> Exception thrown by the state getter:");
+ e = exceptionInfo.Exception;
+ } else {
+ try {
+ sb.AppendLine(entry.Value.ToString());
+ } catch (Exception ex) {
+ sb.AppendLine("--> Exception thrown by ToString:");
+ e = ex;
+ }
+ }
+ }
+ }
+
+ if (e != null) {
+ sb.AppendLine(e.ToString());
+ }
+ }
+ }
+
+ sealed class StateGetterExceptionInfo
+ {
+ readonly Exception exception;
+
+ internal StateGetterExceptionInfo(Exception exception)
+ {
+ if (exception == null)
+ throw new ArgumentNullException("exception");
+ this.exception = exception;
+ }
+
+ internal Exception Exception {
+ get { return exception; }
+ }
+
+ public override string ToString()
+ {
+ return "StateGetterExceptionInfo: " + this.exception.ToString();
+ }
+ }
+ }
+
+ /// <summary>
+ /// A delegate used to get information about the current state of the application.
+ /// </summary>
+ public delegate object StateGetter();
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileNameEventHandler.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileNameEventHandler.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileNameEventHandler.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,32 @@
+// <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>
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ public delegate void FileNameEventHandler(object sender, FileNameEventArgs e);
+
+ /// <summary>
+ /// Description of FileEventHandler.
+ /// </summary>
+ public class FileNameEventArgs : System.EventArgs
+ {
+ string fileName;
+
+ public string FileName {
+ get {
+ return fileName;
+ }
+ }
+
+ public FileNameEventArgs(string fileName)
+ {
+ this.fileName = fileName;
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileUtility.Minimal.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileUtility.Minimal.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileUtility.Minimal.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,107 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <author name="Daniel Grunwald"/>
+// <version>$Revision: 3050 $</version>
+// </file>
+
+using System;
+using System.Text;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// A minimal version of FileUtility. Is used by ICSharpCode.SharpDevelop.Dom (which doesn't reference
+ /// ICSharpCode.Core)
+ /// </summary>
+ static partial class FileUtility
+ {
+ /// <summary>
+ /// Gets the normalized version of fileName.
+ /// Slashes are replaced with backslashes, backreferences "." and ".." are 'evaluated'.
+ /// </summary>
+ public static string NormalizePath(string fileName)
+ {
+ if (string.IsNullOrEmpty(fileName)) return fileName;
+
+ int i;
+
+ bool isWeb = false;
+ for (i = 0; i < fileName.Length; i++) {
+ if (fileName[i] == '/' || fileName[i] == '\\')
+ break;
+ if (fileName[i] == ':') {
+ if (i > 1)
+ isWeb = true;
+ break;
+ }
+ }
+
+ char outputSeparator = isWeb ? '/' : System.IO.Path.DirectorySeparatorChar;
+
+ StringBuilder result = new StringBuilder();
+ if (isWeb == false && fileName.StartsWith(@"\\") || fileName.StartsWith("//")) {
+ i = 2;
+ result.Append(outputSeparator);
+ } else {
+ i = 0;
+ }
+ int segmentStartPos = i;
+ for (; i <= fileName.Length; i++) {
+ if (i == fileName.Length || fileName[i] == '/' || fileName[i] == '\\') {
+ int segmentLength = i - segmentStartPos;
+ switch (segmentLength) {
+ case 0:
+ // ignore empty segment (if not in web mode)
+ // On unix, don't ignore empty segment if i==0
+ if (isWeb || (i == 0 && Environment.OSVersion.Platform == PlatformID.Unix)) {
+ result.Append(outputSeparator);
+ }
+ break;
+ case 1:
+ // ignore /./ segment, but append other one-letter segments
+ if (fileName[segmentStartPos] != '.') {
+ if (result.Length > 0) result.Append(outputSeparator);
+ result.Append(fileName[segmentStartPos]);
+ }
+ break;
+ case 2:
+ if (fileName[segmentStartPos] == '.' && fileName[segmentStartPos + 1] == '.') {
+ // remove previous segment
+ int j;
+ for (j = result.Length - 1; j >= 0 && result[j] != outputSeparator; j--);
+ if (j > 0) {
+ result.Length = j;
+ }
+ break;
+ } else {
+ // append normal segment
+ goto default;
+ }
+ default:
+ if (result.Length > 0) result.Append(outputSeparator);
+ result.Append(fileName, segmentStartPos, segmentLength);
+ break;
+ }
+ segmentStartPos = i + 1; // remember start position for next segment
+ }
+ }
+ if (isWeb == false) {
+ if (result.Length > 0 && result[result.Length - 1] == outputSeparator) {
+ result.Length -= 1;
+ }
+ if (result.Length == 2 && result[1] == ':') {
+ result.Append(outputSeparator);
+ }
+ }
+ return result.ToString();
+ }
+
+ public static bool IsEqualFileName(string fileName1, string fileName2)
+ {
+ return string.Equals(NormalizePath(fileName1),
+ NormalizePath(fileName2),
+ StringComparison.OrdinalIgnoreCase);
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileUtility.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileUtility.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/FileUtility/FileUtility.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,693 @@
+// <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>
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using System.Text.RegularExpressions;
+
+using ICSharpCode.Core.Services;
+using Microsoft.Win32;
+
+namespace ICSharpCode.Core
+{
+ public enum FileErrorPolicy {
+ Inform,
+ ProvideAlternative
+ }
+
+ public enum FileOperationResult {
+ OK,
+ Failed,
+ SavedAlternatively
+ }
+
+ public delegate void FileOperationDelegate();
+
+ public delegate void NamedFileOperationDelegate(string fileName);
+
+ /// <summary>
+ /// A utility class related to file utilities.
+ /// </summary>
+ public static partial class FileUtility
+ {
+ readonly static char[] separators = { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar, Path.VolumeSeparatorChar };
+ static string applicationRootPath = AppDomain.CurrentDomain.BaseDirectory;
+ const string fileNameRegEx = @"^([a-zA-Z]:)?[^:]+$";
+
+ public static string ApplicationRootPath {
+ get {
+ return applicationRootPath;
+ }
+ set {
+ applicationRootPath = value;
+ }
+ }
+
+ static string GetPathFromRegistry(string key, string valueName)
+ {
+ using (RegistryKey installRootKey = Registry.LocalMachine.OpenSubKey(key)) {
+ if (installRootKey != null) {
+ object o = installRootKey.GetValue(valueName);
+ if (o != null) {
+ string r = o.ToString();
+ if (!string.IsNullOrEmpty(r))
+ return r;
+ }
+ }
+ }
+ return null;
+ }
+
+ #region InstallRoot Properties
+
+ static string netFrameworkInstallRoot = null;
+ /// <summary>
+ /// Gets the installation root of the .NET Framework (@"C:\Windows\Microsoft.NET\Framework\")
+ /// </summary>
+ public static string NetFrameworkInstallRoot {
+ get {
+ if (netFrameworkInstallRoot == null) {
+ netFrameworkInstallRoot = GetPathFromRegistry(@"SOFTWARE\Microsoft\.NETFramework", "InstallRoot") ?? string.Empty;
+ }
+ return netFrameworkInstallRoot;
+ }
+ }
+
+ static string netSdk20InstallRoot = null;
+ /// <summary>
+ /// Location of the .NET 2.0 SDK install root.
+ /// </summary>
+ public static string NetSdk20InstallRoot {
+ get {
+ if (netSdk20InstallRoot == null) {
+ netSdk20InstallRoot = GetPathFromRegistry(@"SOFTWARE\Microsoft\.NETFramework", "sdkInstallRootv2.0") ?? string.Empty;
+ }
+ return netSdk20InstallRoot;
+ }
+ }
+
+ static string windowsSdk60InstallRoot = null;
+ /// <summary>
+ /// Location of the .NET 3.0 SDK (Windows SDK 6.0) install root.
+ /// </summary>
+ public static string WindowsSdk60InstallRoot {
+ get {
+ if (windowsSdk60InstallRoot == null) {
+ windowsSdk60InstallRoot = GetPathFromRegistry(@"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0", "InstallationFolder") ?? string.Empty;
+ }
+ return windowsSdk60InstallRoot;
+ }
+ }
+
+ static string windowsSdk60aInstallRoot = null;
+ /// <summary>
+ /// Location of the Windows SDK Components in Visual Studio 2008 (.NET 3.5; Windows SDK 6.0a).
+ /// </summary>
+ public static string WindowsSdk60aInstallRoot {
+ get {
+ if (windowsSdk60aInstallRoot == null) {
+ windowsSdk60aInstallRoot = GetPathFromRegistry(@"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0a", "InstallationFolder") ?? string.Empty;
+ }
+ return windowsSdk60aInstallRoot;
+ }
+ }
+
+ static string windowsSdk61InstallRoot = null;
+ /// <summary>
+ /// Location of the .NET 3.5 SDK (Windows SDK 6.1) install root.
+ /// </summary>
+ public static string WindowsSdk61InstallRoot {
+ get {
+ if (windowsSdk61InstallRoot == null) {
+ windowsSdk61InstallRoot = GetPathFromRegistry(@"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.1", "InstallationFolder") ?? string.Empty;
+ }
+ return windowsSdk61InstallRoot;
+ }
+ }
+
+ static string windowsSdk70InstallRoot = null;
+ /// <summary>
+ /// Location of the .NET 3.5 SP1 SDK (Windows SDK 7.0) install root.
+ /// </summary>
+ public static string WindowsSdk70InstallRoot {
+ get {
+ if (windowsSdk70InstallRoot == null) {
+ windowsSdk70InstallRoot = GetPathFromRegistry(@"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0", "InstallationFolder") ?? string.Empty;
+ }
+ return windowsSdk70InstallRoot;
+ }
+ }
+
+ #endregion
+
+ public static string Combine(params string[] paths)
+ {
+ if (paths == null || paths.Length == 0) {
+ return String.Empty;
+ }
+
+ string result = paths[0];
+ for (int i = 1; i < paths.Length; i++) {
+ result = Path.Combine(result, paths[i]);
+ }
+ return result;
+ }
+
+ public static bool IsUrl(string path)
+ {
+ return path.IndexOf("://", StringComparison.Ordinal) > 0;
+ }
+
+ public static string GetCommonBaseDirectory(string dir1, string dir2)
+ {
+ if (dir1 == null || dir2 == null) return null;
+ if (IsUrl(dir1) || IsUrl(dir2)) return null;
+
+ dir1 = NormalizePath(dir1);
+ dir2 = NormalizePath(dir2);
+
+ string[] aPath = dir1.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
+ string[] bPath = dir2.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
+ StringBuilder result = new StringBuilder();
+ int indx = 0;
+ for(; indx < Math.Min(bPath.Length, aPath.Length); ++indx) {
+ if (bPath[indx].Equals(aPath[indx], StringComparison.OrdinalIgnoreCase)) {
+ if (result.Length > 0) result.Append(Path.DirectorySeparatorChar);
+ result.Append(aPath[indx]);
+ } else {
+ break;
+ }
+ }
+ if (indx == 0)
+ return null;
+ else
+ return result.ToString();
+ }
+
+ /// <summary>
+ /// Searches all the .net sdk bin folders and return the path of the
+ /// exe from the latest sdk.
+ /// </summary>
+ /// <param name="exeName">The EXE to search for.</param>
+ /// <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(WindowsSdk70InstallRoot)) {
+ execPath = Path.Combine(WindowsSdk70InstallRoot, "bin\\" + exeName);
+ if (File.Exists(execPath)) { return execPath; }
+ }
+ if (!string.IsNullOrEmpty(WindowsSdk61InstallRoot)) {
+ execPath = Path.Combine(WindowsSdk61InstallRoot, "bin\\" + exeName);
+ if (File.Exists(execPath)) { return execPath; }
+ }
+ if (!string.IsNullOrEmpty(WindowsSdk60aInstallRoot)) {
+ execPath = Path.Combine(WindowsSdk60aInstallRoot, "bin\\" + exeName);
+ if (File.Exists(execPath)) { return execPath; }
+ }
+ if (!string.IsNullOrEmpty(WindowsSdk60InstallRoot)) {
+ execPath = Path.Combine(WindowsSdk60InstallRoot, "bin\\" + exeName);
+ if (File.Exists(execPath)) { return execPath; }
+ }
+ if (!string.IsNullOrEmpty(NetSdk20InstallRoot)) {
+ execPath = Path.Combine(NetSdk20InstallRoot, "bin\\" + exeName);
+ if (File.Exists(execPath)) { return execPath; }
+ }
+ return null;
+ }
+
+ /// <summary>
+ /// Converts a given absolute path and a given base path to a path that leads
+ /// from the base path to the absoulte path. (as a relative path)
+ /// </summary>
+ public static string GetRelativePath(string baseDirectoryPath, string absPath)
+ {
+ if (IsUrl(absPath) || IsUrl(baseDirectoryPath)){
+ return absPath;
+ }
+
+ baseDirectoryPath = NormalizePath(baseDirectoryPath);
+ absPath = NormalizePath(absPath);
+
+ string[] bPath = baseDirectoryPath.Split(separators);
+ string[] aPath = absPath.Split(separators);
+ int indx = 0;
+ for(; indx < Math.Min(bPath.Length, aPath.Length); ++indx){
+ if(!bPath[indx].Equals(aPath[indx], StringComparison.OrdinalIgnoreCase))
+ break;
+ }
+
+ if (indx == 0) {
+ return absPath;
+ }
+
+ StringBuilder erg = new StringBuilder();
+
+ if(indx == bPath.Length) {
+// erg.Append('.');
+// erg.Append(Path.DirectorySeparatorChar);
+ } else {
+ for (int i = indx; i < bPath.Length; ++i) {
+ erg.Append("..");
+ erg.Append(Path.DirectorySeparatorChar);
+ }
+ }
+ erg.Append(String.Join(Path.DirectorySeparatorChar.ToString(), aPath, indx, aPath.Length-indx));
+ return erg.ToString();
+ }
+
+ /// <summary>
+ /// Combines baseDirectoryPath with relPath and normalizes the resulting path.
+ /// </summary>
+ public static string GetAbsolutePath(string baseDirectoryPath, string relPath)
+ {
+ 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);
+ oldDirectory = NormalizePath(oldDirectory.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar));
+ newDirectory = NormalizePath(newDirectory.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar));
+ if (IsBaseDirectory(oldDirectory, fileName)) {
+ if (fileName.Length == oldDirectory.Length) {
+ return newDirectory;
+ }
+ return Path.Combine(newDirectory, fileName.Substring(oldDirectory.Length + 1));
+ }
+ return fileName;
+ }
+
+ public static void DeepCopy(string sourceDirectory, string destinationDirectory, bool overwrite)
+ {
+ if (!Directory.Exists(destinationDirectory)) {
+ Directory.CreateDirectory(destinationDirectory);
+ }
+ foreach (string fileName in Directory.GetFiles(sourceDirectory)) {
+ File.Copy(fileName, Path.Combine(destinationDirectory, Path.GetFileName(fileName)), overwrite);
+ }
+ foreach (string directoryName in Directory.GetDirectories(sourceDirectory)) {
+ DeepCopy(directoryName, Path.Combine(destinationDirectory, Path.GetFileName(directoryName)), overwrite);
+ }
+ }
+
+ public static List<string> SearchDirectory(string directory, string filemask, bool searchSubdirectories, bool ignoreHidden)
+ {
+ List<string> collection = new List<string>();
+ SearchDirectory(directory, filemask, collection, searchSubdirectories, ignoreHidden);
+ return collection;
+ }
+
+ public static List<string> SearchDirectory(string directory, string filemask, bool searchSubdirectories)
+ {
+ return SearchDirectory(directory, filemask, searchSubdirectories, true);
+ }
+
+ public static List<string> SearchDirectory(string directory, string filemask)
+ {
+ return SearchDirectory(directory, filemask, true, true);
+ }
+
+ /// <summary>
+ /// Finds all files which are valid to the mask <paramref name="filemask"/> in the path
+ /// <paramref name="directory"/> and all subdirectories
+ /// (if <paramref name="searchSubdirectories"/> is true).
+ /// The found files are added to the List<string>
+ /// <paramref name="collection"/>.
+ /// If <paramref name="ignoreHidden"/> is true, hidden files and folders are ignored.
+ /// </summary>
+ static void SearchDirectory(string directory, string filemask, List<string> collection, bool searchSubdirectories, bool ignoreHidden)
+ {
+ // If Directory.GetFiles() searches the 8.3 name as well as the full name so if the filemask is
+ // "*.xpt" it will return "Template.xpt~"
+ try {
+ bool isExtMatch = Regex.IsMatch(filemask, @"^\*\..{3}$");
+ string ext = null;
+ string[] file = Directory.GetFiles(directory, filemask);
+ if (isExtMatch) ext = filemask.Remove(0,1);
+
+ foreach (string f in file) {
+ if (ignoreHidden && (File.GetAttributes(f) & FileAttributes.Hidden) == FileAttributes.Hidden) {
+ continue;
+ }
+ if (isExtMatch && Path.GetExtension(f) != ext) continue;
+
+ collection.Add(f);
+ }
+
+ if (searchSubdirectories) {
+ string[] dir = Directory.GetDirectories(directory);
+ foreach (string d in dir) {
+ if (ignoreHidden && (File.GetAttributes(d) & FileAttributes.Hidden) == FileAttributes.Hidden) {
+ continue;
+ }
+ SearchDirectory(d, filemask, collection, searchSubdirectories, ignoreHidden);
+ }
+ }
+ } catch (UnauthorizedAccessException) {
+ // Ignore exception when access to a directory is denied.
+ // Fixes SD2-893.
+ }
+ }
+
+ // This is an arbitrary limitation built into the .NET Framework.
+ // Windows supports paths up to 32k length.
+ public static readonly int MaxPathLength = 260;
+
+ /// <summary>
+ /// This method checks if a path (full or relative) is valid.
+ /// </summary>
+ public static bool IsValidPath(string fileName)
+ {
+ // Fixme: 260 is the hardcoded maximal length for a path on my Windows XP system
+ // I can't find a .NET property or method for determining this variable.
+
+ if (fileName == null || fileName.Length == 0 || fileName.Length >= MaxPathLength) {
+ return false;
+ }
+
+ // platform independend : check for invalid path chars
+
+ if (fileName.IndexOfAny(Path.GetInvalidPathChars()) >= 0) {
+ return false;
+ }
+ if (fileName.IndexOf('?') >= 0 || fileName.IndexOf('*') >= 0) {
+ return false;
+ }
+
+ if (!Regex.IsMatch(fileName, fileNameRegEx)) {
+ return false;
+ }
+
+ if(fileName[fileName.Length-1] == ' ') {
+ return false;
+ }
+
+ if(fileName[fileName.Length-1] == '.') {
+ return false;
+ }
+
+ // platform dependend : Check for invalid file names (DOS)
+ // this routine checks for follwing bad file names :
+ // CON, PRN, AUX, NUL, COM1-9 and LPT1-9
+
+ string nameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);
+ if (nameWithoutExtension != null) {
+ nameWithoutExtension = nameWithoutExtension.ToUpperInvariant();
+ }
+
+ if (nameWithoutExtension == "CON" ||
+ nameWithoutExtension == "PRN" ||
+ nameWithoutExtension == "AUX" ||
+ nameWithoutExtension == "NUL") {
+ return false;
+ }
+
+ char ch = nameWithoutExtension.Length == 4 ? nameWithoutExtension[3] : '\0';
+
+ return !((nameWithoutExtension.StartsWith("COM") ||
+ nameWithoutExtension.StartsWith("LPT")) &&
+ Char.IsDigit(ch));
+ }
+
+ /// <summary>
+ /// Checks that a single directory name (not the full path) is valid.
+ /// </summary>
+ [ObsoleteAttribute("Use IsValidDirectoryEntryName instead")]
+ public static bool IsValidDirectoryName(string name)
+ {
+ return IsValidDirectoryEntryName(name);
+ }
+
+ /// <summary>
+ /// Checks that a single directory name (not the full path) is valid.
+ /// </summary>
+ public static bool IsValidDirectoryEntryName(string name)
+ {
+ if (!IsValidPath(name)) {
+ return false;
+ }
+ if (name.IndexOfAny(new char[]{Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar,Path.VolumeSeparatorChar}) >= 0) {
+ return false;
+ }
+ if (name.Trim(' ').Length == 0) {
+ return false;
+ }
+ return true;
+ }
+
+ public static bool TestFileExists(string filename)
+ {
+ if (!File.Exists(filename)) {
+ MessageService.ShowWarning(StringParser.Parse("${res:Fileutility.CantFindFileError}", new string[,] { {"FILE", filename} }));
+ return false;
+ }
+ return true;
+ }
+
+ public static bool IsDirectory(string filename)
+ {
+ if (!Directory.Exists(filename)) {
+ return false;
+ }
+ FileAttributes attr = File.GetAttributes(filename);
+ return (attr & FileAttributes.Directory) != 0;
+ }
+
+ //TODO This code is Windows specific
+ static bool MatchN (string src, int srcidx, string pattern, int patidx)
+ {
+ int patlen = pattern.Length;
+ int srclen = src.Length;
+ char next_char;
+
+ for (;;) {
+ if (patidx == patlen)
+ return (srcidx == srclen);
+ next_char = pattern[patidx++];
+ if (next_char == '?') {
+ if (srcidx == src.Length)
+ return false;
+ srcidx++;
+ }
+ else if (next_char != '*') {
+ if ((srcidx == src.Length) || (src[srcidx] != next_char))
+ return false;
+ srcidx++;
+ }
+ else {
+ if (patidx == pattern.Length)
+ return true;
+ while (srcidx < srclen) {
+ if (MatchN(src, srcidx, pattern, patidx))
+ return true;
+ srcidx++;
+ }
+ return false;
+ }
+ }
+ }
+
+ static bool Match(string src, string pattern)
+ {
+ if (pattern[0] == '*') {
+ // common case optimization
+ int i = pattern.Length;
+ int j = src.Length;
+ while (--i > 0) {
+ if (pattern[i] == '*')
+ return MatchN(src, 0, pattern, 0);
+ if (j-- == 0)
+ return false;
+ if ((pattern[i] != src[j]) && (pattern[i] != '?'))
+ return false;
+ }
+ return true;
+ }
+ return MatchN(src, 0, pattern, 0);
+ }
+
+ public static bool MatchesPattern(string filename, string pattern)
+ {
+ filename = filename.ToUpper();
+ pattern = pattern.ToUpper();
+ string[] patterns = pattern.Split(';');
+ foreach (string p in patterns) {
+ if (Match(filename, p)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // Observe SAVE functions
+ public static FileOperationResult ObservedSave(FileOperationDelegate saveFile, string fileName, string message, FileErrorPolicy policy)
+ {
+ 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;
+ }
+ }
+ return FileOperationResult.Failed;
+ }
+
+ public static FileOperationResult ObservedSave(FileOperationDelegate saveFile, string fileName, FileErrorPolicy policy)
+ {
+ return ObservedSave(saveFile,
+ fileName,
+ ResourceService.GetString("ICSharpCode.Services.FileUtilityService.CantSaveFileStandardText"),
+ policy);
+ }
+
+ public static FileOperationResult ObservedSave(FileOperationDelegate saveFile, string fileName)
+ {
+ 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);
+ if (!Directory.Exists(directory)) {
+ Directory.CreateDirectory(directory);
+ }
+ 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;
+ }
+ }
+ return FileOperationResult.Failed;
+ }
+
+ public static FileOperationResult ObservedSave(NamedFileOperationDelegate saveFileAs, string fileName, FileErrorPolicy policy)
+ {
+ return ObservedSave(saveFileAs,
+ fileName,
+ ResourceService.GetString("ICSharpCode.Services.FileUtilityService.CantSaveFileStandardText"),
+ 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)
+ {
+ try {
+ 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;
+ }
+ }
+ return FileOperationResult.Failed;
+ }
+
+ public static FileOperationResult ObservedLoad(FileOperationDelegate loadFile, string fileName, FileErrorPolicy policy)
+ {
+ return ObservedLoad(loadFile,
+ fileName,
+ ResourceService.GetString("ICSharpCode.Services.FileUtilityService.CantLoadFileStandardText"),
+ policy);
+ }
+
+ public static FileOperationResult ObservedLoad(FileOperationDelegate loadFile, string fileName)
+ {
+ 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)
+ {
+ return ObservedLoad(saveFileAs,
+ fileName,
+ ResourceService.GetString("ICSharpCode.Services.FileUtilityService.CantLoadFileStandardText"),
+ policy);
+ }
+
+ public static FileOperationResult ObservedLoad(NamedFileOperationDelegate saveFileAs, string fileName)
+ {
+ return ObservedLoad(saveFileAs, fileName, FileErrorPolicy.Inform);
+ }
+
+ static void OnFileLoaded(FileNameEventArgs e)
+ {
+ if (FileLoaded != null) {
+ FileLoaded(null, e);
+ }
+ }
+
+ public static void RaiseFileSaved(FileNameEventArgs e)
+ {
+ if (FileSaved != null) {
+ FileSaved(null, e);
+ }
+ }
+
+ public static event FileNameEventHandler FileLoaded;
+ public static event FileNameEventHandler FileSaved;
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/ILoggingService.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/ILoggingService.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/ILoggingService.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,33 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <author name="Daniel Grunwald"/>
+// <version>$Revision: 3287 $</version>
+// </file>
+
+using System;
+
+namespace ICSharpCode.Core.Services
+{
+ public interface ILoggingService
+ {
+ void Debug(object message);
+ void DebugFormatted(string format, params object[] args);
+ void Info(object message);
+ void InfoFormatted(string format, params object[] args);
+ void Warn(object message);
+ void Warn(object message, Exception exception);
+ void WarnFormatted(string format, params object[] args);
+ void Error(object message);
+ void Error(object message, Exception exception);
+ void ErrorFormatted(string format, params object[] args);
+ void Fatal(object message);
+ void Fatal(object message, Exception exception);
+ void FatalFormatted(string format, params object[] args);
+ bool IsDebugEnabled { get; }
+ bool IsInfoEnabled { get; }
+ bool IsWarnEnabled { get; }
+ bool IsErrorEnabled { get; }
+ bool IsFatalEnabled { get; }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/LoggingService.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/LoggingService.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/LoggingService.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,113 @@
+// <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>
+
+using System;
+using ICSharpCode.Core.Services;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Class for easy logging.
+ /// </summary>
+ public static class LoggingService
+ {
+ public static void Debug(object message)
+ {
+ ServiceManager.LoggingService.Debug(message);
+ }
+
+ public static void DebugFormatted(string format, params object[] args)
+ {
+ ServiceManager.LoggingService.DebugFormatted(format, args);
+ }
+
+ public static void Info(object message)
+ {
+ ServiceManager.LoggingService.Info(message);
+ }
+
+ public static void InfoFormatted(string format, params object[] args)
+ {
+ ServiceManager.LoggingService.InfoFormatted(format, args);
+ }
+
+ public static void Warn(object message)
+ {
+ ServiceManager.LoggingService.Warn(message);
+ }
+
+ public static void Warn(object message, Exception exception)
+ {
+ ServiceManager.LoggingService.Warn(message, exception);
+ }
+
+ public static void WarnFormatted(string format, params object[] args)
+ {
+ ServiceManager.LoggingService.WarnFormatted(format, args);
+ }
+
+ public static void Error(object message)
+ {
+ ServiceManager.LoggingService.Error(message);
+ }
+
+ public static void Error(object message, Exception exception)
+ {
+ ServiceManager.LoggingService.Error(message, exception);
+ }
+
+ public static void ErrorFormatted(string format, params object[] args)
+ {
+ ServiceManager.LoggingService.ErrorFormatted(format, args);
+ }
+
+ public static void Fatal(object message)
+ {
+ ServiceManager.LoggingService.Fatal(message);
+ }
+
+ public static void Fatal(object message, Exception exception)
+ {
+ ServiceManager.LoggingService.Fatal(message, exception);
+ }
+
+ public static void FatalFormatted(string format, params object[] args)
+ {
+ ServiceManager.LoggingService.FatalFormatted(format, args);
+ }
+
+ public static bool IsDebugEnabled {
+ get {
+ return ServiceManager.LoggingService.IsDebugEnabled;
+ }
+ }
+
+ public static bool IsInfoEnabled {
+ get {
+ return ServiceManager.LoggingService.IsInfoEnabled;
+ }
+ }
+
+ public static bool IsWarnEnabled {
+ get {
+ return ServiceManager.LoggingService.IsWarnEnabled;
+ }
+ }
+
+ public static bool IsErrorEnabled {
+ get {
+ return ServiceManager.LoggingService.IsErrorEnabled;
+ }
+ }
+
+ public static bool IsFatalEnabled {
+ get {
+ return ServiceManager.LoggingService.IsFatalEnabled;
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/TextWriterLoggingService.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/TextWriterLoggingService.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/LoggingService/TextWriterLoggingService.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,123 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <author name="Daniel Grunwald"/>
+// <version>$Revision$</version>
+// </file>
+
+using System;
+using System.IO;
+
+namespace ICSharpCode.Core.Services
+{
+ /// <summary>
+ /// LoggingService implementation that logs into a TextWriter.
+ /// </summary>
+ public class TextWriterLoggingService : ILoggingService
+ {
+ readonly TextWriter writer;
+
+ public TextWriterLoggingService(TextWriter writer)
+ {
+ if (writer == null)
+ throw new ArgumentNullException("writer");
+ this.writer = writer;
+ this.IsFatalEnabled = true;
+ this.IsErrorEnabled = true;
+ this.IsWarnEnabled = true;
+ this.IsInfoEnabled = true;
+ this.IsDebugEnabled = true;
+ }
+
+ void Write(object message, Exception exception)
+ {
+ if (message != null) {
+ writer.WriteLine(message.ToString());
+ }
+ if (exception != null) {
+ writer.WriteLine(exception.ToString());
+ }
+ }
+
+ public bool IsDebugEnabled { get; set; }
+ public bool IsInfoEnabled { get; set; }
+ public bool IsWarnEnabled { get; set; }
+ public bool IsErrorEnabled { get; set; }
+ public bool IsFatalEnabled { get; set; }
+
+ public void Debug(object message)
+ {
+ if (IsDebugEnabled) {
+ Write(message, null);
+ }
+ }
+
+ public void DebugFormatted(string format, params object[] args)
+ {
+ Debug(string.Format(format, args));
+ }
+
+ public void Info(object message)
+ {
+ if (IsInfoEnabled) {
+ Write(message, null);
+ }
+ }
+
+ public void InfoFormatted(string format, params object[] args)
+ {
+ Info(string.Format(format, args));
+ }
+
+ public void Warn(object message)
+ {
+ Warn(message, null);
+ }
+
+ public void Warn(object message, Exception exception)
+ {
+ if (IsWarnEnabled) {
+ Write(message, exception);
+ }
+ }
+
+ public void WarnFormatted(string format, params object[] args)
+ {
+ Warn(string.Format(format, args));
+ }
+
+ public void Error(object message)
+ {
+ Error(message, null);
+ }
+
+ public void Error(object message, Exception exception)
+ {
+ if (IsErrorEnabled) {
+ Write(message, exception);
+ }
+ }
+
+ public void ErrorFormatted(string format, params object[] args)
+ {
+ Error(string.Format(format, args));
+ }
+
+ public void Fatal(object message)
+ {
+ Fatal(message, null);
+ }
+
+ public void Fatal(object message, Exception exception)
+ {
+ if (IsFatalEnabled) {
+ Write(message, exception);
+ }
+ }
+
+ public void FatalFormatted(string format, params object[] args)
+ {
+ Fatal(string.Format(format, args));
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/IMessageService.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/IMessageService.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/IMessageService.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,84 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <author name="Daniel Grunwald"/>
+// <version>$Revision: 3772 $</version>
+// </file>
+
+using System;
+
+namespace ICSharpCode.Core.Services
+{
+ /// <summary>
+ /// Description of IMessageService.
+ /// </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);
+
+ /// <summary>
+ /// Shows a warning message.
+ /// </summary>
+ void ShowWarning(string message);
+
+ /// <summary>
+ /// Asks the user a Yes/No question, using "Yes" as the default button.
+ /// Returns <c>true</c> if yes was clicked, <c>false</c> if no was clicked.
+ /// </summary>
+ bool AskQuestion(string question, string caption);
+
+ /// <summary>
+ /// Shows a custom dialog.
+ /// </summary>
+ /// <param name="caption">The title of the dialog.</param>
+ /// <param name="dialogText">The description shown in the dialog.</param>
+ /// <param name="acceptButtonIndex">
+ /// The number of the button that is the default accept button.
+ /// Use -1 if you don't want to have an accept button.
+ /// </param>
+ /// <param name="cancelButtonIndex">
+ /// The number of the button that is the cancel button.
+ /// Use -1 if you don't want to have a cancel button.
+ /// </param>
+ /// <param name="buttontexts">The captions of the buttons.</param>
+ /// <returns>The number of the button that was clicked, or -1 if the dialog was closed without clicking a button.</returns>
+ int ShowCustomDialog(string caption, string dialogText, int acceptButtonIndex, int cancelButtonIndex, params string[] buttontexts);
+ string ShowInputBox(string caption, string dialogText, string defaultValue);
+ void ShowMessage(string message, string caption);
+
+ /// <summary>
+ /// Show a message informing the user about a save error.
+ /// </summary>
+ void InformSaveError(string fileName, string message, string dialogName, Exception exceptionGot);
+
+ /// <summary>
+ /// Show a message informing the user about a save error,
+ /// and allow him to retry/save under alternative name.
+ /// </summary>
+ ChooseSaveErrorResult ChooseSaveError(string fileName, string message, string dialogName, Exception exceptionGot, bool chooseLocationEnabled);
+ }
+
+ public sealed class ChooseSaveErrorResult
+ {
+ public bool IsRetry { get; private set; }
+ public bool IsIgnore { get; private set; }
+ public bool IsSaveAlternative { get { return AlternativeFileName != null; } }
+ public string AlternativeFileName { get; private set; }
+
+ private ChooseSaveErrorResult() {}
+
+ public readonly static ChooseSaveErrorResult Retry = new ChooseSaveErrorResult { IsRetry = true };
+ public readonly static ChooseSaveErrorResult Ignore = new ChooseSaveErrorResult { IsIgnore = true };
+ public static ChooseSaveErrorResult SaveAlternative(string alternativeFileName)
+ {
+ return new ChooseSaveErrorResult { AlternativeFileName = alternativeFileName };
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/MessageService.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/MessageService.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/MessageService.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,224 @@
+// <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>
+
+using System;
+using System.Text;
+using ICSharpCode.Core.Services;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Class with static methods to show message boxes.
+ /// All text displayed using the MessageService is passed to the
+ /// <see cref="StringParser"/> to replace ${res} markers.
+ /// </summary>
+ public static class MessageService
+ {
+ /// <summary>
+ /// Delegate used for custom error callbacks.
+ /// </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)
+ {
+ ShowError(ex, null);
+ }
+
+ /// <summary>
+ /// Shows an error using a message box.
+ /// </summary>
+ public static void ShowError(string message)
+ {
+ ShowError(null, message);
+ }
+
+ /// <summary>
+ /// Shows an error using a message box.
+ /// <paramref name="formatstring"/> is first passed through the
+ /// <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)
+ {
+ ShowError(null, 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.
+ /// </summary>
+ public static void ShowError(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);
+ }
+ ServiceManager.MessageService.ShowError(ex, message);
+ }
+
+ /// <summary>
+ /// Shows a warning message.
+ /// </summary>
+ public static void ShowWarning(string message)
+ {
+ LoggingService.Warn(message);
+ ServiceManager.MessageService.ShowWarning(message);
+ }
+
+ /// <summary>
+ /// Shows a warning message.
+ /// <paramref name="formatstring"/> is first passed through the
+ /// <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)
+ {
+ ShowWarning(Format(formatstring, formatitems));
+ }
+
+ /// <summary>
+ /// Asks the user a Yes/No question, using "Yes" as the default button.
+ /// Returns <c>true</c> if yes was clicked, <c>false</c> if no was clicked.
+ /// </summary>
+ public static bool AskQuestion(string question, string caption)
+ {
+ return ServiceManager.MessageService.AskQuestion(question, caption);
+ }
+
+ public static bool AskQuestionFormatted(string caption, string formatstring, params string[] formatitems)
+ {
+ return AskQuestion(Format(formatstring, formatitems), caption);
+ }
+
+ public static bool AskQuestionFormatted(string formatstring, params string[] formatitems)
+ {
+ return AskQuestion(Format(formatstring, formatitems));
+ }
+
+ /// <summary>
+ /// Asks the user a Yes/No question, using "Yes" as the default button.
+ /// Returns <c>true</c> if yes was clicked, <c>false</c> if no was clicked.
+ /// </summary>
+ public static bool AskQuestion(string question)
+ {
+ return AskQuestion(StringParser.Parse(question), StringParser.Parse("${res:Global.QuestionText}"));
+ }
+
+ /// <summary>
+ /// Shows a custom dialog.
+ /// </summary>
+ /// <param name="caption">The title of the dialog.</param>
+ /// <param name="dialogText">The description shown in the dialog.</param>
+ /// <param name="acceptButtonIndex">
+ /// The number of the button that is the default accept button.
+ /// Use -1 if you don't want to have an accept button.
+ /// </param>
+ /// <param name="cancelButtonIndex">
+ /// The number of the button that is the cancel button.
+ /// Use -1 if you don't want to have a cancel button.
+ /// </param>
+ /// <param name="buttontexts">The captions of the buttons.</param>
+ /// <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);
+ }
+
+ /// <summary>
+ /// Shows a custom dialog.
+ /// </summary>
+ /// <param name="caption">The title of the dialog.</param>
+ /// <param name="dialogText">The description shown in the dialog.</param>
+ /// <param name="buttontexts">The captions of the buttons.</param>
+ /// <returns>The number of the button that was clicked.</returns>
+ public static int ShowCustomDialog(string caption, string dialogText, params string[] buttontexts)
+ {
+ return ShowCustomDialog(caption, dialogText, -1, -1, buttontexts);
+ }
+
+ public static string ShowInputBox(string caption, string dialogText, string defaultValue)
+ {
+ return ServiceManager.MessageService.ShowInputBox(caption, dialogText, defaultValue);
+ }
+
+ static string defaultMessageBoxTitle = "MessageBox";
+ static string productName = "Application Name";
+
+ /// <summary>
+ /// Gets/Sets the name of the product using ICSharpCode.Core.
+ /// Is used by the string parser as replacement for ${ProductName}.
+ /// </summary>
+ public static string ProductName {
+ get { return productName; }
+ set { productName = value; }
+ }
+
+ /// <summary>
+ /// Gets/Sets the default title for message boxes displayed
+ /// by the message service.
+ /// </summary>
+ public static string DefaultMessageBoxTitle {
+ get { return defaultMessageBoxTitle; }
+ set { defaultMessageBoxTitle = value; }
+ }
+
+ public static void ShowMessage(string message)
+ {
+ ShowMessage(message, DefaultMessageBoxTitle);
+ }
+
+ public static void ShowMessageFormatted(string formatstring, params string[] formatitems)
+ {
+ ShowMessage(Format(formatstring, formatitems));
+ }
+
+ public static void ShowMessageFormatted(string caption, string formatstring, params string[] formatitems)
+ {
+ ShowMessage(Format(formatstring, formatitems), caption);
+ }
+
+ public static void ShowMessage(string message, string caption)
+ {
+ LoggingService.Info(message);
+ ServiceManager.MessageService.ShowMessage(message, caption);
+ }
+
+ static string Format(string formatstring, string[] formatitems)
+ {
+ try {
+ return String.Format(StringParser.Parse(formatstring), formatitems);
+ } catch (FormatException) {
+ StringBuilder b = new StringBuilder(StringParser.Parse(formatstring));
+ foreach(string formatitem in formatitems) {
+ b.Append("\nItem: ");
+ b.Append(formatitem);
+ }
+ return b.ToString();
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/TextWriterMessageService.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/TextWriterMessageService.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/MessageService/TextWriterMessageService.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,81 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <author name="Daniel Grunwald"/>
+// <version>$Revision$</version>
+// </file>
+
+using System;
+using System.IO;
+
+namespace ICSharpCode.Core.Services
+{
+ /// <summary>
+ /// IMessageService implementation that writes messages to a text writer.
+ /// User input is not implemented by this service.
+ /// </summary>
+ public class TextWriterMessageService : IMessageService
+ {
+ readonly TextWriter writer;
+
+ public TextWriterMessageService(TextWriter writer)
+ {
+ if (writer == null)
+ throw new ArgumentNullException("writer");
+ this.writer = writer;
+ }
+
+ public void ShowError(Exception ex, string message)
+ {
+ if (message != null) {
+ writer.WriteLine(message);
+ }
+ if (ex != null) {
+ writer.WriteLine(ex.ToString());
+ }
+ }
+
+ public void ShowWarning(string message)
+ {
+ writer.WriteLine(message);
+ }
+
+ public bool AskQuestion(string question, string caption)
+ {
+ writer.WriteLine(caption + ": " + question);
+ return false;
+ }
+
+ public int ShowCustomDialog(string caption, string dialogText, int acceptButtonIndex, int cancelButtonIndex, params string[] buttontexts)
+ {
+ writer.WriteLine(caption + ": " + dialogText);
+ return cancelButtonIndex;
+ }
+
+ public string ShowInputBox(string caption, string dialogText, string defaultValue)
+ {
+ writer.WriteLine(caption + ": " + dialogText);
+ return defaultValue;
+ }
+
+ public void ShowMessage(string message, string caption)
+ {
+ writer.WriteLine(caption + ": " + message);
+ }
+
+ public void InformSaveError(string fileName, string message, string dialogName, Exception exceptionGot)
+ {
+ writer.WriteLine(dialogName + ": " + message + " (" + fileName + ")");
+ if (exceptionGot != null)
+ writer.WriteLine(exceptionGot.ToString());
+ }
+
+ public ChooseSaveErrorResult ChooseSaveError(string fileName, string message, string dialogName, Exception exceptionGot, bool chooseLocationEnabled)
+ {
+ writer.WriteLine(dialogName + ": " + message + " (" + fileName + ")");
+ if (exceptionGot != null)
+ writer.WriteLine(exceptionGot.ToString());
+ return ChooseSaveErrorResult.Ignore;
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/Properties.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/Properties.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/Properties.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,379 @@
+// <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>
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Globalization;
+using System.IO;
+using System.Text;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// This interface flags an object beeing "mementocapable". This means that the
+ /// state of the object could be saved to an <see cref="Properties"/> object
+ /// and set from a object from the same class.
+ /// This is used to save and restore the state of GUI objects.
+ /// </summary>
+ public interface IMementoCapable
+ {
+ /// <summary>
+ /// Creates a new memento from the state.
+ /// </summary>
+ Properties CreateMemento();
+
+ /// <summary>
+ /// Sets the state to the given memento.
+ /// </summary>
+ void SetMemento(Properties memento);
+ }
+
+ /// <summary>
+ /// Description of PropertyGroup.
+ /// </summary>
+ public class Properties
+ {
+ /// <summary> Needed for support of late deserialization </summary>
+ class SerializedValue {
+ string content;
+
+ public string Content {
+ get { return content; }
+ }
+
+ public T Deserialize<T>()
+ {
+ XmlSerializer serializer = new XmlSerializer(typeof(T));
+ return (T)serializer.Deserialize(new StringReader(content));
+ }
+
+ public SerializedValue(string content)
+ {
+ this.content = content;
+ }
+ }
+
+ Dictionary<string, object> properties = new Dictionary<string, object>();
+
+ public string this[string property] {
+ get {
+ return Convert.ToString(Get(property), CultureInfo.InvariantCulture);
+ }
+ set {
+ Set(property, value);
+ }
+ }
+
+ public string[] Elements
+ {
+ get {
+ lock (properties) {
+ List<string> ret = new List<string>();
+ foreach (KeyValuePair<string, object> property in properties)
+ ret.Add(property.Key);
+ return ret.ToArray();
+ }
+ }
+ }
+
+ public object Get(string property)
+ {
+ lock (properties) {
+ object val;
+ properties.TryGetValue(property, out val);
+ return val;
+ }
+ }
+
+ public void Set<T>(string property, T value)
+ {
+ if (property == null)
+ throw new ArgumentNullException("property");
+ if (value == null)
+ throw new ArgumentNullException("value");
+ T oldValue = default(T);
+ lock (properties) {
+ if (!properties.ContainsKey(property)) {
+ properties.Add(property, value);
+ } else {
+ oldValue = Get<T>(property, value);
+ properties[property] = value;
+ }
+ }
+ OnPropertyChanged(new PropertyChangedEventArgs(this, property, oldValue, value));
+ }
+
+ public bool Contains(string property)
+ {
+ lock (properties) {
+ return properties.ContainsKey(property);
+ }
+ }
+
+ public int Count {
+ get {
+ lock (properties) {
+ return properties.Count;
+ }
+ }
+ }
+
+ public bool Remove(string property)
+ {
+ lock (properties) {
+ return properties.Remove(property);
+ }
+ }
+
+ public override string ToString()
+ {
+ lock (properties) {
+ StringBuilder sb = new StringBuilder();
+ sb.Append("[Properties:{");
+ foreach (KeyValuePair<string, object> entry in properties) {
+ sb.Append(entry.Key);
+ sb.Append("=");
+ sb.Append(entry.Value);
+ sb.Append(",");
+ }
+ sb.Append("}]");
+ return sb.ToString();
+ }
+ }
+
+ public static Properties ReadFromAttributes(XmlReader reader)
+ {
+ Properties properties = new Properties();
+ if (reader.HasAttributes) {
+ for (int i = 0; i < reader.AttributeCount; i++) {
+ reader.MoveToAttribute(i);
+ properties[reader.Name] = reader.Value;
+ }
+ reader.MoveToElement(); //Moves the reader back to the element node.
+ }
+ return properties;
+ }
+
+ internal void ReadProperties(XmlReader reader, string endElement)
+ {
+ if (reader.IsEmptyElement) {
+ return;
+ }
+ while (reader.Read()) {
+ switch (reader.NodeType) {
+ case XmlNodeType.EndElement:
+ if (reader.LocalName == endElement) {
+ return;
+ }
+ break;
+ case XmlNodeType.Element:
+ string propertyName = reader.LocalName;
+ if (propertyName == "Properties") {
+ propertyName = reader.GetAttribute(0);
+ Properties p = new Properties();
+ p.ReadProperties(reader, "Properties");
+ properties[propertyName] = p;
+ } else if (propertyName == "Array") {
+ propertyName = reader.GetAttribute(0);
+ properties[propertyName] = ReadArray(reader);
+ } else if (propertyName == "SerializedValue") {
+ propertyName = reader.GetAttribute(0);
+ properties[propertyName] = new SerializedValue(reader.ReadInnerXml());
+ } else {
+ properties[propertyName] = reader.HasAttributes ? reader.GetAttribute(0) : null;
+ }
+ break;
+ }
+ }
+ }
+
+ ArrayList ReadArray(XmlReader reader)
+ {
+ if (reader.IsEmptyElement)
+ return new ArrayList(0);
+ ArrayList l = new ArrayList();
+ while (reader.Read()) {
+ switch (reader.NodeType) {
+ case XmlNodeType.EndElement:
+ if (reader.LocalName == "Array") {
+ return l;
+ }
+ break;
+ case XmlNodeType.Element:
+ l.Add(reader.HasAttributes ? reader.GetAttribute(0) : null);
+ break;
+ }
+ }
+ return l;
+ }
+
+ public void WriteProperties(XmlWriter writer)
+ {
+ lock (properties) {
+ List<KeyValuePair<string, object>> sortedProperties = new List<KeyValuePair<string, object>>(properties);
+ sortedProperties.Sort((a, b) => StringComparer.OrdinalIgnoreCase.Compare(a.Key, b.Key));
+ foreach (KeyValuePair<string, object> entry in sortedProperties) {
+ object val = entry.Value;
+ if (val is Properties) {
+ writer.WriteStartElement("Properties");
+ writer.WriteAttributeString("name", entry.Key);
+ ((Properties)val).WriteProperties(writer);
+ writer.WriteEndElement();
+ } else if (val is Array || val is ArrayList) {
+ writer.WriteStartElement("Array");
+ writer.WriteAttributeString("name", entry.Key);
+ foreach (object o in (IEnumerable)val) {
+ writer.WriteStartElement("Element");
+ WriteValue(writer, o);
+ writer.WriteEndElement();
+ }
+ writer.WriteEndElement();
+ } else if (TypeDescriptor.GetConverter(val).CanConvertFrom(typeof(string))) {
+ writer.WriteStartElement(entry.Key);
+ WriteValue(writer, val);
+ writer.WriteEndElement();
+ } else if (val is SerializedValue) {
+ writer.WriteStartElement("SerializedValue");
+ writer.WriteAttributeString("name", entry.Key);
+ writer.WriteRaw(((SerializedValue)val).Content);
+ writer.WriteEndElement();
+ } else {
+ writer.WriteStartElement("SerializedValue");
+ writer.WriteAttributeString("name", entry.Key);
+ XmlSerializer serializer = new XmlSerializer(val.GetType());
+ serializer.Serialize(writer, val, null);
+ writer.WriteEndElement();
+ }
+ }
+ }
+ }
+
+ void WriteValue(XmlWriter writer, object val)
+ {
+ if (val != null) {
+ if (val is string) {
+ writer.WriteAttributeString("value", val.ToString());
+ } else {
+ TypeConverter c = TypeDescriptor.GetConverter(val.GetType());
+ writer.WriteAttributeString("value", c.ConvertToInvariantString(val));
+ }
+ }
+ }
+
+ public void Save(string fileName)
+ {
+ using (XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.UTF8)) {
+ writer.Formatting = Formatting.Indented;
+ writer.WriteStartElement("Properties");
+ WriteProperties(writer);
+ writer.WriteEndElement();
+ }
+ }
+
+// public void BinarySerialize(BinaryWriter writer)
+// {
+// writer.Write((byte)properties.Count);
+// foreach (KeyValuePair<string, object> entry in properties) {
+// writer.Write(AddInTree.GetNameOffset(entry.Key));
+// writer.Write(AddInTree.GetNameOffset(entry.Value.ToString()));
+// }
+// }
+
+ public static Properties Load(string fileName)
+ {
+ if (!File.Exists(fileName)) {
+ return null;
+ }
+ using (XmlTextReader reader = new XmlTextReader(fileName)) {
+ while (reader.Read()){
+ if (reader.IsStartElement()) {
+ switch (reader.LocalName) {
+ case "Properties":
+ Properties properties = new Properties();
+ properties.ReadProperties(reader, "Properties");
+ return properties;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public T Get<T>(string property, T defaultValue)
+ {
+ lock (properties) {
+ object o;
+ if (!properties.TryGetValue(property, out o)) {
+ properties.Add(property, defaultValue);
+ return defaultValue;
+ }
+
+ if (o is string && typeof(T) != typeof(string)) {
+ TypeConverter c = TypeDescriptor.GetConverter(typeof(T));
+ try {
+ o = c.ConvertFromInvariantString(o.ToString());
+ } catch (Exception ex) {
+ MessageService.ShowWarning("Error loading property '" + property + "': " + ex.Message);
+ o = defaultValue;
+ }
+ properties[property] = o; // store for future look up
+ } else if (o is ArrayList && typeof(T).IsArray) {
+ ArrayList list = (ArrayList)o;
+ Type elementType = typeof(T).GetElementType();
+ Array arr = System.Array.CreateInstance(elementType, list.Count);
+ TypeConverter c = TypeDescriptor.GetConverter(elementType);
+ try {
+ for (int i = 0; i < arr.Length; ++i) {
+ if (list[i] != null) {
+ arr.SetValue(c.ConvertFromInvariantString(list[i].ToString()), i);
+ }
+ }
+ o = arr;
+ } catch (Exception ex) {
+ MessageService.ShowWarning("Error loading property '" + property + "': " + ex.Message);
+ o = defaultValue;
+ }
+ properties[property] = o; // store for future look up
+ } else if (!(o is string) && typeof(T) == typeof(string)) {
+ TypeConverter c = TypeDescriptor.GetConverter(typeof(T));
+ if (c.CanConvertTo(typeof(string))) {
+ o = c.ConvertToInvariantString(o);
+ } else {
+ o = o.ToString();
+ }
+ } else if (o is SerializedValue) {
+ try {
+ o = ((SerializedValue)o).Deserialize<T>();
+ } catch (Exception ex) {
+ MessageService.ShowWarning("Error loading property '" + property + "': " + ex.Message);
+ o = defaultValue;
+ }
+ properties[property] = o; // store for future look up
+ }
+ try {
+ return (T)o;
+ } catch (NullReferenceException) {
+ // can happen when configuration is invalid -> o is null and a value type is expected
+ return defaultValue;
+ }
+ }
+ }
+
+ protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
+ {
+ if (PropertyChanged != null) {
+ PropertyChanged(this, e);
+ }
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/PropertyChangedEvent.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/PropertyChangedEvent.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/PropertyChangedEvent.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,65 @@
+// <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>
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ public delegate void PropertyChangedEventHandler(object sender, PropertyChangedEventArgs e);
+
+ public class PropertyChangedEventArgs : EventArgs
+ {
+ Properties properties;
+ string key;
+ object newValue;
+ object oldValue;
+
+ /// <returns>
+ /// returns the changed property object
+ /// </returns>
+ public Properties Properties {
+ get {
+ return properties;
+ }
+ }
+
+ /// <returns>
+ /// The key of the changed property
+ /// </returns>
+ public string Key {
+ get {
+ return key;
+ }
+ }
+
+ /// <returns>
+ /// The new value of the property
+ /// </returns>
+ public object NewValue {
+ get {
+ return newValue;
+ }
+ }
+
+ /// <returns>
+ /// The new value of the property
+ /// </returns>
+ public object OldValue {
+ get {
+ return oldValue;
+ }
+ }
+
+ public PropertyChangedEventArgs(Properties properties, string key, object oldValue, object newValue)
+ {
+ this.properties = properties;
+ this.key = key;
+ this.oldValue = oldValue;
+ this.newValue = newValue;
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/PropertyService.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/PropertyService.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/PropertyService/PropertyService.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,155 @@
+// <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>
+
+using System;
+using System.IO;
+using System.Text;
+using System.Threading;
+using System.Xml;
+
+namespace ICSharpCode.Core
+{
+ public static class PropertyService
+ {
+ static string propertyFileName;
+ static string propertyXmlRootNodeName;
+
+ static string configDirectory;
+ static string dataDirectory;
+
+ static Properties properties;
+
+ public static bool Initialized
+ {
+ get
+ {
+ return properties != 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;
+ propertyXmlRootNodeName = propertiesName;
+ propertyFileName = propertiesName + ".xml";
+ properties.PropertyChanged += new PropertyChangedEventHandler(PropertiesPropertyChanged);
+ }
+
+ public static string ConfigDirectory {
+ get {
+ return configDirectory;
+ }
+ }
+
+ public static string DataDirectory {
+ get {
+ return dataDirectory;
+ }
+ }
+
+ public static string Get(string property)
+ {
+ return properties[property];
+ }
+
+ public static T Get<T>(string property, T defaultValue)
+ {
+ return properties.Get(property, defaultValue);
+ }
+
+ public static void Set<T>(string property, T value)
+ {
+ properties.Set(property, value);
+ }
+
+ public static void Load()
+ {
+ if (properties == null)
+ throw new InvalidOperationException("Service is not initialized.");
+ if (!Directory.Exists(configDirectory)) {
+ Directory.CreateDirectory(configDirectory);
+ }
+
+ if (!LoadPropertiesFromStream(Path.Combine(configDirectory, propertyFileName))) {
+ LoadPropertiesFromStream(FileUtility.Combine(DataDirectory, "options", propertyFileName));
+ }
+ }
+
+ public static bool LoadPropertiesFromStream(string fileName)
+ {
+ if (!File.Exists(fileName)) {
+ return false;
+ }
+ try {
+ using (LockPropertyFile()) {
+ using (XmlTextReader reader = new XmlTextReader(fileName)) {
+ while (reader.Read()){
+ if (reader.IsStartElement()) {
+ if (reader.LocalName == propertyXmlRootNodeName) {
+ properties.ReadProperties(reader, propertyXmlRootNodeName);
+ return true;
+ }
+ }
+ }
+ }
+ }
+ } catch (XmlException ex) {
+ MessageService.ShowError("Error loading properties: " + ex.Message + "\nSettings have been restored to default values.");
+ }
+ return false;
+ }
+
+ public static void Save()
+ {
+ using (MemoryStream ms = new MemoryStream()) {
+ XmlTextWriter writer = new XmlTextWriter(ms, Encoding.UTF8);
+ writer.Formatting = Formatting.Indented;
+ writer.WriteStartElement(propertyXmlRootNodeName);
+ properties.WriteProperties(writer);
+ writer.WriteEndElement();
+ writer.Flush();
+
+ ms.Position = 0;
+ string fileName = Path.Combine(configDirectory, propertyFileName);
+ using (LockPropertyFile()) {
+ using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None)) {
+ ms.WriteTo(fs);
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Acquires an exclusive lock on the properties file so that it can be opened safely.
+ /// </summary>
+ public static IDisposable LockPropertyFile()
+ {
+ Mutex mutex = new Mutex(false, "PropertyServiceSave-30F32619-F92D-4BC0-BF49-AA18BF4AC313");
+ mutex.WaitOne();
+ return new CallbackOnDispose(
+ delegate {
+ mutex.ReleaseMutex();
+ mutex.Close();
+ });
+ }
+
+ static void PropertiesPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ if (PropertyChanged != null) {
+ PropertyChanged(null, e);
+ }
+ }
+
+ public static event PropertyChangedEventHandler PropertyChanged;
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ResourceService/ResourceNotFoundException.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ResourceService/ResourceNotFoundException.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ResourceService/ResourceNotFoundException.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,36 @@
+// <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>
+
+using System;
+using System.Runtime.Serialization;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Is thrown when the GlobalResource manager can't find a requested
+ /// resource.
+ /// </summary>
+ [Serializable()]
+ public class ResourceNotFoundException : CoreException
+ {
+ public ResourceNotFoundException(string resource) : base("Resource not found : " + resource)
+ {
+ }
+
+ public ResourceNotFoundException() : base()
+ {
+ }
+
+ public ResourceNotFoundException(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+
+ protected ResourceNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ResourceService/ResourceService.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ResourceService/ResourceService.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ResourceService/ResourceService.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,308 @@
+// <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>
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using System.Resources;
+using System.Threading;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// This Class contains two ResourceManagers, which handle string and image resources
+ /// for the application. It do handle localization strings on this level.
+ /// </summary>
+ public static class ResourceService
+ {
+ const string uiLanguageProperty = "CoreProperties.UILanguage";
+
+ const string stringResources = "StringResources";
+ const string imageResources = "BitmapResources";
+
+ static string resourceDirectory;
+
+ public static void InitializeService(string resourceDirectory)
+ {
+ if (ResourceService.resourceDirectory != null)
+ throw new InvalidOperationException("Service is already initialized.");
+ if (resourceDirectory == null)
+ throw new ArgumentNullException("resourceDirectory");
+
+ ResourceService.resourceDirectory = resourceDirectory;
+
+ PropertyService.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChange);
+ LoadLanguageResources(ResourceService.Language);
+ }
+
+ public static string Language {
+ get {
+ return PropertyService.Get(uiLanguageProperty, Thread.CurrentThread.CurrentUICulture.Name);
+ }
+ set {
+ PropertyService.Set(uiLanguageProperty, value);
+ }
+ }
+
+ /// <summary>English strings (list of resource managers)</summary>
+ static List<ResourceManager> strings = new List<ResourceManager>();
+ /// <summary>Neutral/English images (list of resource managers)</summary>
+ static List<ResourceManager> icons = new List<ResourceManager>();
+
+ /// <summary>Hashtable containing the local strings from the main application.</summary>
+ static Hashtable localStrings = null;
+ static Hashtable localIcons = null;
+
+ /// <summary>Strings resource managers for the current language</summary>
+ static List<ResourceManager> localStringsResMgrs = new List<ResourceManager>();
+ /// <summary>Image resource managers for the current language</summary>
+ static List<ResourceManager> localIconsResMgrs = new List<ResourceManager>();
+
+ /// <summary>List of ResourceAssembly</summary>
+ static List<ResourceAssembly> resourceAssemblies = new List<ResourceAssembly>();
+
+ class ResourceAssembly
+ {
+ Assembly assembly;
+ string baseResourceName;
+ bool isIcons;
+
+ public ResourceAssembly(Assembly assembly, string baseResourceName, bool isIcons)
+ {
+ this.assembly = assembly;
+ this.baseResourceName = baseResourceName;
+ this.isIcons = isIcons;
+ }
+
+ ResourceManager TrySatellite(string language)
+ {
+ // ResourceManager should automatically use satellite assemblies, but it doesn't work
+ // and we have to do it manually.
+ string fileName = Path.GetFileNameWithoutExtension(assembly.Location) + ".resources.dll";
+ fileName = Path.Combine(Path.Combine(Path.GetDirectoryName(assembly.Location), language), fileName);
+ if (File.Exists(fileName)) {
+ LoggingService.Info("Loging resources " + baseResourceName + " loading from satellite " + language);
+ return new ResourceManager(baseResourceName, Assembly.LoadFrom(fileName));
+ } else {
+ return null;
+ }
+ }
+
+ public void Load()
+ {
+ string logMessage = "Loading resources " + baseResourceName + "." + currentLanguage + ": ";
+ ResourceManager manager = null;
+ if (assembly.GetManifestResourceInfo(baseResourceName + "." + currentLanguage + ".resources") != null) {
+ LoggingService.Info(logMessage + " loading from main assembly");
+ manager = new ResourceManager(baseResourceName + "." + currentLanguage, assembly);
+ } else if (currentLanguage.IndexOf('-') > 0
+ && assembly.GetManifestResourceInfo(baseResourceName + "." + currentLanguage.Split('-')[0] + ".resources") != null)
+ {
+ LoggingService.Info(logMessage + " loading from main assembly (no country match)");
+ manager = new ResourceManager(baseResourceName + "." + currentLanguage.Split('-')[0], assembly);
+ } else {
+ // try satellite assembly
+ manager = TrySatellite(currentLanguage);
+ if (manager == null && currentLanguage.IndexOf('-') > 0) {
+ manager = TrySatellite(currentLanguage.Split('-')[0]);
+ }
+ }
+ if (manager == null) {
+ LoggingService.Warn(logMessage + "NOT FOUND");
+ } else {
+ if (isIcons)
+ localIconsResMgrs.Add(manager);
+ else
+ localStringsResMgrs.Add(manager);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Registers string resources in the resource service.
+ /// </summary>
+ /// <param name="baseResourceName">The base name of the resource file embedded in the assembly.</param>
+ /// <param name="assembly">The assembly which contains the resource file.</param>
+ /// <example><c>ResourceService.RegisterStrings("TestAddin.Resources.StringResources", GetType().Assembly);</c></example>
+ public static void RegisterStrings(string baseResourceName, Assembly assembly)
+ {
+ RegisterNeutralStrings(new ResourceManager(baseResourceName, assembly));
+ ResourceAssembly ra = new ResourceAssembly(assembly, baseResourceName, false);
+ resourceAssemblies.Add(ra);
+ ra.Load();
+ }
+
+ public static void RegisterNeutralStrings(ResourceManager stringManager)
+ {
+ strings.Add(stringManager);
+ }
+
+ /// <summary>
+ /// Registers image resources in the resource service.
+ /// </summary>
+ /// <param name="baseResourceName">The base name of the resource file embedded in the assembly.</param>
+ /// <param name="assembly">The assembly which contains the resource file.</param>
+ /// <example><c>ResourceService.RegisterImages("TestAddin.Resources.BitmapResources", GetType().Assembly);</c></example>
+ public static void RegisterImages(string baseResourceName, Assembly assembly)
+ {
+ RegisterNeutralImages(new ResourceManager(baseResourceName, assembly));
+ ResourceAssembly ra = new ResourceAssembly(assembly, baseResourceName, true);
+ resourceAssemblies.Add(ra);
+ ra.Load();
+ }
+
+ public static void RegisterNeutralImages(ResourceManager imageManager)
+ {
+ icons.Add(imageManager);
+ }
+
+ static void OnPropertyChange(object sender, PropertyChangedEventArgs e)
+ {
+ if (e.Key == uiLanguageProperty && e.NewValue != e.OldValue) {
+ LoadLanguageResources((string)e.NewValue);
+ if (LanguageChanged != null)
+ LanguageChanged(null, e);
+ }
+ }
+
+ public static event EventHandler ClearCaches;
+
+ public static event EventHandler LanguageChanged;
+ static string currentLanguage;
+
+ static void LoadLanguageResources(string language)
+ {
+ if (ClearCaches != null)
+ ClearCaches(null, EventArgs.Empty);
+
+ try {
+ 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();
+ }
+ }
+
+ static Hashtable Load(string fileName)
+ {
+ if (File.Exists(fileName)) {
+ Hashtable resources = new Hashtable();
+ ResourceReader rr = new ResourceReader(fileName);
+ foreach (DictionaryEntry entry in rr) {
+ resources.Add(entry.Key, entry.Value);
+ }
+ rr.Close();
+ return resources;
+ }
+ return null;
+ }
+
+ static Hashtable Load(string name, string language)
+ {
+ return Load(resourceDirectory + Path.DirectorySeparatorChar + name + "." + language + ".resources");
+ }
+
+ /// <summary>
+ /// Returns a string from the resource database, it handles localization
+ /// transparent for the user.
+ /// </summary>
+ /// <returns>
+ /// The string in the (localized) resource database.
+ /// </returns>
+ /// <param name="name">
+ /// The name of the requested resource.
+ /// </param>
+ /// <exception cref="ResourceNotFoundException">
+ /// Is thrown when the GlobalResource manager can't find a requested resource.
+ /// </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);
+ }
+ 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;
+ }
+
+ 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) { }
+
+ if (iconobj != null) {
+ break;
+ }
+ }
+ }
+ }
+ return iconobj;
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ServiceManager.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ServiceManager.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/ServiceManager.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,41 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <author name="Daniel Grunwald"/>
+// <version>$Revision: 3411 $</version>
+// </file>
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+
+namespace ICSharpCode.Core.Services
+{
+ /// <summary>
+ /// Maintains references to the core service implementations.
+ /// </summary>
+ public static class ServiceManager
+ {
+ static ILoggingService loggingService = new TextWriterLoggingService(new DebugTextWriter());
+
+ public static ILoggingService LoggingService {
+ get { return loggingService; }
+ set {
+ if (value == null)
+ throw new ArgumentNullException();
+ loggingService = value;
+ }
+ }
+
+ static IMessageService messageService = new TextWriterMessageService(Console.Out);
+
+ public static IMessageService MessageService {
+ get { return messageService; }
+ set {
+ if (value == null)
+ throw new ArgumentNullException();
+ messageService = value;
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/IStringTagProvider.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/IStringTagProvider.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/IStringTagProvider.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,20 @@
+// <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>
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ public interface IStringTagProvider
+ {
+ string[] Tags {
+ get;
+ }
+
+ string Convert(string tag);
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/StringParser.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/StringParser.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Services/StringParser/StringParser.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,272 @@
+// <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>
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Reflection;
+using System.Text;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// This class parses internal ${xyz} tags of #Develop.
+ /// All environment variables are avaible under the name env.[NAME]
+ /// where [NAME] represents the string under which it is avaiable in
+ /// the environment.
+ /// </summary>
+ public static class StringParser
+ {
+ readonly static Dictionary<string, string> properties;
+ readonly static Dictionary<string, IStringTagProvider> stringTagProviders;
+ readonly static Dictionary<string, object> propertyObjects;
+
+ public static Dictionary<string, string> Properties {
+ get {
+ return properties;
+ }
+ }
+
+ public static Dictionary<string, object> PropertyObjects {
+ get {
+ return propertyObjects;
+ }
+ }
+
+ static StringParser()
+ {
+ properties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
+ stringTagProviders = new Dictionary<string, IStringTagProvider>(StringComparer.OrdinalIgnoreCase);
+ propertyObjects = new Dictionary<string, object>();
+
+ // entryAssembly == null might happen in unit test mode
+ Assembly entryAssembly = Assembly.GetEntryAssembly();
+ if (entryAssembly != null) {
+ string exeName = entryAssembly.Location;
+ propertyObjects["exe"] = 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";
+ }
+ }
+
+ /// <summary>
+ /// Expands ${xyz} style property values.
+ /// </summary>
+ public static string Parse(string input)
+ {
+ return Parse(input, null);
+ }
+
+ /// <summary>
+ /// Parses an array and replaces the elements in the existing array.
+ /// </summary>
+ public static void Parse(string[] inputs)
+ {
+ for (int i = 0; i < inputs.Length; ++i) {
+ inputs[i] = Parse(inputs[i], null);
+ }
+ }
+
+ public static void RegisterStringTagProvider(IStringTagProvider tagProvider)
+ {
+ foreach (string str in tagProvider.Tags) {
+ stringTagProviders[str] = 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)
+ {
+ if (input == null)
+ return null;
+ int pos = 0;
+ StringBuilder output = null; // don't use StringBuilder if input is a single property
+ do {
+ int oldPos = pos;
+ pos = input.IndexOf("${", pos, StringComparison.Ordinal);
+ if (pos < 0) {
+ if (output == null) {
+ return input;
+ } else {
+ if (oldPos < input.Length) {
+ // normal text after last property
+ output.Append(input, oldPos, input.Length - oldPos);
+ }
+ return output.ToString();
+ }
+ }
+ if (output == null) {
+ if (pos == 0)
+ output = new StringBuilder();
+ else
+ output = new StringBuilder(input, 0, pos, pos + 16);
+ } else {
+ if (pos > oldPos) {
+ // normal text between two properties
+ output.Append(input, oldPos, pos - oldPos);
+ }
+ }
+ int end = input.IndexOf('}', pos + 1);
+ if (end < 0) {
+ output.Append("${");
+ pos += 2;
+ } else {
+ string property = input.Substring(pos + 2, end - pos - 2);
+ string val = GetValue(property, customTags);
+ if (val == null) {
+ output.Append("${");
+ output.Append(property);
+ output.Append('}');
+ } else {
+ output.Append(val);
+ }
+ pos = end + 1;
+ }
+ } while (pos < input.Length);
+ return output.ToString();
+ }
+
+ static string GetValue(string propertyName, 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 (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();
+
+ if (customTags != null) {
+ for (int j = 0; j < customTags.GetLength(0); ++j) {
+ if (propertyName.Equals(customTags[j, 0], StringComparison.OrdinalIgnoreCase)) {
+ return customTags[j, 1];
+ }
+ }
+ }
+
+ if (properties.ContainsKey(propertyName)) {
+ return properties[propertyName];
+ }
+
+ if (stringTagProviders.ContainsKey(propertyName)) {
+ return stringTagProviders[propertyName].Convert(propertyName);
+ }
+
+ int k = propertyName.IndexOf(':');
+ if (k <= 0)
+ 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":
+ try {
+ return Parse(ResourceService.GetString(propertyName), customTags);
+ } catch (ResourceNotFoundException) {
+ return null;
+ }
+ case "PROPERTY":
+ return GetProperty(propertyName);
+ default:
+ if (propertyObjects.ContainsKey(prefix)) {
+ return Get(propertyObjects[prefix], propertyName);
+ } else {
+ return null;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Allow special syntax to retrieve property values:
+ /// ${property:PropertyName}
+ /// ${property:PropertyName??DefaultValue}
+ /// ${property:ContainerName/PropertyName}
+ /// ${property:ContainerName/PropertyName??DefaultValue}
+ /// A container is a Properties instance stored in the PropertyService. This is
+ /// used by many AddIns to group all their properties into one container.
+ /// </summary>
+ static string GetProperty(string propertyName)
+ {
+ string defaultValue = "";
+ int pos = propertyName.LastIndexOf("??", StringComparison.Ordinal);
+ if (pos >= 0) {
+ defaultValue = propertyName.Substring(pos + 2);
+ propertyName = propertyName.Substring(0, pos);
+ }
+ pos = propertyName.IndexOf('/');
+ if (pos >= 0) {
+ Properties properties = PropertyService.Get(propertyName.Substring(0, pos), new Properties());
+ propertyName = propertyName.Substring(pos + 1);
+ pos = propertyName.IndexOf('/');
+ while (pos >= 0) {
+ properties = properties.Get(propertyName.Substring(0, pos), new Properties());
+ propertyName = propertyName.Substring(pos + 1);
+ }
+ return properties.Get(propertyName, defaultValue);
+ } else {
+ return PropertyService.Get(propertyName, defaultValue);
+ }
+ }
+
+ static string Get(object obj, string name)
+ {
+ 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;
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/AbstractCommand.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/AbstractCommand.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/AbstractCommand.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,47 @@
+// <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>
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Abstract implementation of the <see cref="ICommand"/> interface.
+ /// </summary>
+ public abstract class AbstractCommand : ICommand
+ {
+ object owner = null;
+
+ /// <summary>
+ /// Returns the owner of the command.
+ /// </summary>
+ public virtual object Owner {
+ get {
+ return owner;
+ }
+ set {
+ owner = value;
+ OnOwnerChanged(EventArgs.Empty);
+ }
+ }
+
+ /// <summary>
+ /// Invokes the command.
+ /// </summary>
+ public abstract void Run();
+
+
+ protected virtual void OnOwnerChanged(EventArgs e)
+ {
+ if (OwnerChanged != null) {
+ OwnerChanged(this, e);
+ }
+ }
+
+ public event EventHandler OwnerChanged;
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/AppDomainLaunchHelper.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/AppDomainLaunchHelper.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/AppDomainLaunchHelper.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,54 @@
+// <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);
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/CallbackOnDispose.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/CallbackOnDispose.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/CallbackOnDispose.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,35 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Daniel Grunwald"/>
+// <version>$Revision$</version>
+// </file>
+
+using System;
+using System.Threading;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// Invokes a callback when this class is dispsed.
+ /// </summary>
+ sealed class CallbackOnDispose : IDisposable
+ {
+ // TODO: in 4.0, use System.Action and make this class public
+ System.Threading.ThreadStart callback;
+
+ public CallbackOnDispose(System.Threading.ThreadStart callback)
+ {
+ if (callback == null)
+ throw new ArgumentNullException("callback");
+ this.callback = callback;
+ }
+
+ public void Dispose()
+ {
+ System.Threading.ThreadStart action = Interlocked.Exchange(ref callback, null);
+ if (action != null)
+ action();
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/DebugTextWriter.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/DebugTextWriter.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/DebugTextWriter.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,51 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <author name="Daniel Grunwald"/>
+// <version>$Revision: 3287 $</version>
+// </file>
+
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Text;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// TextWriter that writes into System.Diagnostics.Debug
+ /// </summary>
+ public class DebugTextWriter : TextWriter
+ {
+ public override Encoding Encoding {
+ get {
+ return Encoding.Unicode;
+ }
+ }
+
+ public override void Write(char value)
+ {
+ Debug.Write(value.ToString());
+ }
+
+ public override void Write(char[] buffer, int index, int count)
+ {
+ Debug.Write(new string(buffer, index, count));
+ }
+
+ public override void Write(string value)
+ {
+ Debug.Write(value);
+ }
+
+ public override void WriteLine()
+ {
+ Debug.WriteLine(string.Empty);
+ }
+
+ public override void WriteLine(string value)
+ {
+ Debug.WriteLine(value);
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/ICommand.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/ICommand.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core/Src/Util/ICommand.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,37 @@
+// <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>
+
+using System;
+
+namespace ICSharpCode.Core
+{
+ /// <summary>
+ /// A basic command interface. A command has simply an owner which "runs" the command
+ /// and a Run method which invokes the command.
+ /// </summary>
+ public interface ICommand
+ {
+
+ /// <summary>
+ /// Returns the owner of the command.
+ /// </summary>
+ object Owner {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Invokes the command.
+ /// </summary>
+ void Run();
+
+ /// <summary>
+ /// Is called when the Owner property is changed.
+ /// </summary>
+ event EventHandler OwnerChanged;
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ICSharpCode.Core.WinForms.csproj
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ICSharpCode.Core.WinForms.csproj (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ICSharpCode.Core.WinForms.csproj 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,91 @@
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <ProjectGuid>{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}</ProjectGuid>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <OutputType>Library</OutputType>
+ <RootNamespace>ICSharpCode.Core.WinForms</RootNamespace>
+ <AssemblyName>ICSharpCode.Core.WinForms</AssemblyName>
+ <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <OutputPath>..\..\..\bin\</OutputPath>
+ <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
+ <NoStdLib>False</NoStdLib>
+ <WarningLevel>4</WarningLevel>
+ <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ <SignAssembly>True</SignAssembly>
+ <AssemblyOriginatorKeyFile>..\ICSharpCode.SharpDevelop.snk</AssemblyOriginatorKeyFile>
+ <DelaySign>False</DelaySign>
+ <AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>Full</DebugType>
+ <Optimize>False</Optimize>
+ <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+ <DebugSymbols>False</DebugSymbols>
+ <DebugType>None</DebugType>
+ <Optimize>True</Optimize>
+ <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
+ <DefineConstants>TRACE</DefineConstants>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
+ <RegisterForComInterop>False</RegisterForComInterop>
+ <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
+ <BaseAddress>4194304</BaseAddress>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <FileAlignment>4096</FileAlignment>
+ </PropertyGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="..\GlobalAssemblyInfo.cs">
+ <Link>Properties\GlobalAssemblyInfo.cs</Link>
+ </Compile>
+ <Compile Include="Menu\IStatusUpdate.cs" />
+ <Compile Include="Menu\ISubmenuBuilder.cs" />
+ <Compile Include="Menu\Menu.cs" />
+ <Compile Include="Menu\MenuCheckBox.cs" />
+ <Compile Include="Menu\MenuCommand.cs" />
+ <Compile Include="Menu\MenuSeparator.cs" />
+ <Compile Include="Menu\MenuService.cs" />
+ <Compile Include="MessageService\CustomDialog.cs" />
+ <Compile Include="MessageService\InputBox.cs" />
+ <Compile Include="MessageService\SaveErrorChooseDialog.cs" />
+ <Compile Include="MessageService\SaveErrorInformDialog.cs" />
+ <Compile Include="MessageService\WinFormsMessageService.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="ToolBar\ToolBarCheckBox.cs" />
+ <Compile Include="ToolBar\ToolBarComboBox.cs" />
+ <Compile Include="ToolBar\ToolBarCommand.cs" />
+ <Compile Include="ToolBar\ToolBarDropDownButton.cs" />
+ <Compile Include="ToolBar\ToolBarLabel.cs" />
+ <Compile Include="ToolBar\ToolBarSeparator.cs" />
+ <Compile Include="ToolBar\ToolBarService.cs" />
+ <Compile Include="ToolBar\ToolBarSplitButton.cs" />
+ <Compile Include="ToolBar\ToolBarTextBox.cs" />
+ <Compile Include="Util\ClipboardWrapper.cs" />
+ <Compile Include="Util\NativeMethods.cs" />
+ <Compile Include="Util\RightToLeftConverter.cs" />
+ <Compile Include="WinFormsResourceService.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Core\Project\ICSharpCode.Core.csproj">
+ <Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
+ <Name>ICSharpCode.Core</Name>
+ <Private>False</Private>
+ </ProjectReference>
+ <Folder Include="Menu" />
+ <Folder Include="MessageService" />
+ <Folder Include="ToolBar" />
+ <Folder Include="Util" />
+ </ItemGroup>
+</Project>
\ No newline at end of file
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/IStatusUpdate.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/IStatusUpdate.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/IStatusUpdate.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,17 @@
+// <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>
+
+using System;
+
+namespace ICSharpCode.Core.WinForms
+{
+ public interface IStatusUpdate
+ {
+ void UpdateStatus();
+ void UpdateText();
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/ISubmenuBuilder.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/ISubmenuBuilder.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/ISubmenuBuilder.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,17 @@
+// <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>
+
+using System;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ public interface ISubmenuBuilder
+ {
+ ToolStripItem[] BuildSubmenu(Codon codon, object owner);
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/Menu.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/Menu.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/Menu.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,94 @@
+// <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>
+
+using System;
+using System.Collections;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ public class Menu : ToolStripMenuItem, IStatusUpdate
+ {
+ Codon codon;
+ object caller;
+ IList subItems;
+ bool isInitialized;
+
+ public Menu(Codon codon, object caller, IList subItems)
+ {
+ if (subItems == null) subItems = new ArrayList(); // don't crash when item has no children
+ this.codon = codon;
+ this.caller = caller;
+ this.subItems = subItems;
+ this.RightToLeft = RightToLeft.Inherit;
+
+ UpdateText();
+ }
+
+ public Menu(string text, params ToolStripItem[] subItems)
+ {
+ this.Text = StringParser.Parse(text);
+ this.DropDownItems.AddRange(subItems);
+ }
+
+ void CreateDropDownItems()
+ {
+ DropDownItems.Clear();
+ foreach (object item in subItems) {
+ if (item is ToolStripItem) {
+ DropDownItems.Add((ToolStripItem)item);
+ if (item is IStatusUpdate) {
+ ((IStatusUpdate)item).UpdateStatus();
+ ((IStatusUpdate)item).UpdateText();
+ }
+ } else {
+ ISubmenuBuilder submenuBuilder = (ISubmenuBuilder)item;
+ DropDownItems.AddRange(submenuBuilder.BuildSubmenu(codon, caller));
+ }
+ }
+ }
+ protected override void OnDropDownShow(EventArgs e)
+ {
+ if (codon != null && !this.DropDown.Visible) {
+ CreateDropDownItems();
+ }
+ base.OnDropDownShow(e);
+ }
+
+ public override bool Enabled {
+ get {
+ if (codon == null) {
+ return base.Enabled;
+ }
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+ return failedAction != ConditionFailedAction.Disable;
+ }
+ }
+
+ public virtual void UpdateStatus()
+ {
+ if (codon != null) {
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+ this.Visible = failedAction != ConditionFailedAction.Exclude;
+ if (!isInitialized && failedAction != ConditionFailedAction.Exclude) {
+ isInitialized = true;
+ CreateDropDownItems(); // must be created to support shortcuts
+ if (DropDownItems.Count == 0 && subItems.Count > 0) {
+ DropDownItems.Add(new ToolStripMenuItem());
+ }
+ }
+ }
+ }
+
+ public virtual void UpdateText()
+ {
+ if (codon != null) {
+ Text = StringParser.Parse(codon.Properties["label"]);
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuCheckBox.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuCheckBox.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuCheckBox.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,103 @@
+// <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>
+
+using System;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ public class MenuCheckBox : ToolStripMenuItem , IStatusUpdate
+ {
+ object caller;
+ Codon codon;
+ string description = String.Empty;
+ ICheckableMenuCommand menuCommand = null;
+
+ void CreateMenuCommand()
+ {
+ if (menuCommand == null) {
+ try {
+ menuCommand = (ICheckableMenuCommand)codon.AddIn.CreateObject(codon.Properties["class"]);
+ } catch (Exception e) {
+ MessageService.ShowError(e, "Can't create menu command : " + codon.Id);
+ }
+ }
+ }
+
+ public ICheckableMenuCommand MenuCommand {
+ get {
+ CreateMenuCommand();
+ return menuCommand;
+ }
+ }
+
+ public string Description {
+ get {
+ return description;
+ }
+ set {
+ description = value;
+ }
+ }
+ public MenuCheckBox(string text)
+ {
+ this.RightToLeft = RightToLeft.Inherit;
+ Text = text;
+ }
+ public MenuCheckBox(Codon codon, object caller)
+ {
+ this.RightToLeft = RightToLeft.Inherit;
+ this.caller = caller;
+ this.codon = codon;
+ UpdateText();
+ }
+
+ protected override void OnClick(System.EventArgs e)
+ {
+ base.OnClick(e);
+ if (codon != null) {
+ MenuCommand.Run();
+ Checked = MenuCommand.IsChecked;
+ }
+ }
+
+
+ public override bool Enabled {
+ get {
+ if (codon == null) {
+ return base.Enabled;
+ }
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+ return failedAction != ConditionFailedAction.Disable;
+ }
+ }
+
+ public virtual void UpdateStatus()
+ {
+ if (codon != null) {
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+ this.Visible = failedAction != ConditionFailedAction.Exclude;
+ if (menuCommand == null && !string.IsNullOrEmpty(codon.Properties["checked"])) {
+ Checked = string.Equals(StringParser.Parse(codon.Properties["checked"]),
+ bool.TrueString, StringComparison.OrdinalIgnoreCase);
+ } else {
+ CreateMenuCommand();
+ if (menuCommand != null) {
+ Checked = menuCommand.IsChecked;
+ }
+ }
+ }
+ }
+
+ public virtual void UpdateText()
+ {
+ if (codon != null) {
+ Text = StringParser.Parse(codon.Properties["label"]);
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuCommand.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuCommand.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuCommand.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,174 @@
+// <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>
+
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ public class MenuCommand : ToolStripMenuItem, IStatusUpdate
+ {
+ object caller;
+ Codon codon;
+ ICommand menuCommand = null;
+ string description = "";
+
+ public string Description {
+ get {
+ return description;
+ }
+ set {
+ description = value;
+ }
+ }
+
+ public ICommand Command {
+ get {
+ if (menuCommand == null) {
+ CreateCommand();
+ }
+ return menuCommand;
+ }
+ }
+
+ // HACK: find a better way to allow the host app to process link commands
+ public static Converter<string, ICommand> LinkCommandCreator;
+
+ void CreateCommand()
+ {
+ try {
+ string link = codon.Properties["link"];
+ if (link != null && link.Length > 0) {
+ if (LinkCommandCreator == null)
+ throw new NotSupportedException("MenuCommand.LinkCommandCreator is not set, cannot create LinkCommands.");
+ menuCommand = LinkCommandCreator(codon.Properties["link"]);
+ } else {
+ menuCommand = (ICommand)codon.AddIn.CreateObject(codon.Properties["class"]);
+ }
+ if (menuCommand != null) {
+ menuCommand.Owner = caller;
+ }
+ } catch (Exception e) {
+ MessageService.ShowError(e, "Can't create menu command : " + codon.Id);
+ }
+ }
+
+ public MenuCommand(Codon codon, object caller) : this(codon, caller, false)
+ {
+
+ }
+
+ public static Keys ParseShortcut(string shortcutString)
+ {
+ Keys shortCut = Keys.None;
+ if (shortcutString.Length > 0) {
+ try {
+ foreach (string key in shortcutString.Split('|')) {
+ shortCut |= (System.Windows.Forms.Keys)Enum.Parse(typeof(System.Windows.Forms.Keys), key);
+ }
+ } catch (Exception ex) {
+ MessageService.ShowError(ex);
+ return System.Windows.Forms.Keys.None;
+ }
+ }
+ return shortCut;
+ }
+
+ public MenuCommand(Codon codon, object caller, bool createCommand)
+ {
+ this.RightToLeft = RightToLeft.Inherit;
+ this.caller = caller;
+ this.codon = codon;
+
+ if (createCommand) {
+ CreateCommand();
+ }
+
+ UpdateText();
+ if (codon.Properties.Contains("shortcut")) {
+ ShortcutKeys = ParseShortcut(codon.Properties["shortcut"]);
+ }
+ }
+
+ public MenuCommand(string label, EventHandler handler) : this(label)
+ {
+ this.Click += handler;
+ }
+
+ public MenuCommand(string label)
+ {
+ this.RightToLeft = RightToLeft.Inherit;
+ this.codon = null;
+ this.caller = null;
+ Text = StringParser.Parse(label);
+ }
+
+ protected override void OnClick(System.EventArgs e)
+ {
+ base.OnClick(e);
+ if (codon != null) {
+ if (GetVisible() && Enabled) {
+ ICommand cmd = Command;
+ if (cmd != null) {
+ LoggingService.Info("Run command " + cmd.GetType().FullName);
+ cmd.Run();
+ }
+ }
+ }
+ }
+
+// protected override void OnSelect(System.EventArgs e)
+// {
+// base.OnSelect(e);
+// StatusBarService.SetMessage(description);
+// }
+
+
+ public override bool Enabled {
+ get {
+ if (codon == null) {
+ return base.Enabled;
+ }
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+ bool isEnabled = failedAction != ConditionFailedAction.Disable;
+
+ if (menuCommand != null && menuCommand is IMenuCommand) {
+ isEnabled &= ((IMenuCommand)menuCommand).IsEnabled;
+ }
+ return isEnabled;
+ }
+ }
+
+ bool GetVisible()
+ {
+ if (codon == null)
+ return true;
+ else
+ return codon.GetFailedAction(caller) != ConditionFailedAction.Exclude;
+ }
+
+ public virtual void UpdateStatus()
+ {
+ if (codon != null) {
+ if (Image == null && codon.Properties.Contains("icon")) {
+ try {
+ Image = WinFormsResourceService.GetBitmap(codon.Properties["icon"]);
+ } catch (ResourceNotFoundException) {}
+ }
+ Visible = GetVisible();
+ }
+ }
+
+ public virtual void UpdateText()
+ {
+ if (codon != null) {
+ Text = StringParser.Parse(codon.Properties["label"]);
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuSeparator.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuSeparator.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuSeparator.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,43 @@
+// <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>
+
+using System;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ public class MenuSeparator : ToolStripSeparator, IStatusUpdate
+ {
+ object caller;
+ Codon codon;
+
+ public MenuSeparator()
+ {
+ this.RightToLeft = RightToLeft.Inherit;
+ }
+
+ public MenuSeparator(Codon codon, object caller)
+ {
+ this.RightToLeft = RightToLeft.Inherit;
+ this.caller = caller;
+ this.codon = codon;
+ }
+
+ public virtual void UpdateStatus()
+ {
+ if (codon != null) {
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+ this.Enabled = failedAction != ConditionFailedAction.Disable;
+ this.Visible = failedAction != ConditionFailedAction.Exclude;
+ }
+ }
+
+ public virtual void UpdateText()
+ {
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuService.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuService.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Menu/MenuService.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,183 @@
+// <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>
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ public static class MenuService
+ {
+ public static void AddItemsToMenu(ToolStripItemCollection collection, object owner, string addInTreePath)
+ {
+ AddItemsToMenu(collection, AddInTree.BuildItems<MenuItemDescriptor>(addInTreePath, owner, false));
+ }
+
+ static void AddItemsToMenu(ToolStripItemCollection collection, List<MenuItemDescriptor> descriptors)
+ {
+ foreach (MenuItemDescriptor descriptor in descriptors) {
+ object item = CreateMenuItemFromDescriptor(descriptor);
+ if (item is ToolStripItem) {
+ collection.Add((ToolStripItem)item);
+ if (item is IStatusUpdate)
+ ((IStatusUpdate)item).UpdateStatus();
+ } else {
+ ISubmenuBuilder submenuBuilder = (ISubmenuBuilder)item;
+ collection.AddRange(submenuBuilder.BuildSubmenu(null, descriptor.Caller));
+ }
+ }
+ }
+
+ static object CreateMenuItemFromDescriptor(MenuItemDescriptor descriptor)
+ {
+ Codon codon = descriptor.Codon;
+ string type = codon.Properties.Contains("type") ? codon.Properties["type"] : "Command";
+ bool createCommand = codon.Properties["loadclasslazy"] == "false";
+
+ switch (type) {
+ case "Separator":
+ return new MenuSeparator(codon, descriptor.Caller);
+ case "CheckBox":
+ return new MenuCheckBox(codon, descriptor.Caller);
+ case "Item":
+ case "Command":
+ return new MenuCommand(codon, descriptor.Caller, createCommand);
+ case "Menu":
+ return new Menu(codon, descriptor.Caller, ConvertSubItems(descriptor.SubItems));
+ case "Builder":
+ return codon.AddIn.CreateObject(codon.Properties["class"]);
+ default:
+ throw new System.NotSupportedException("unsupported menu item type : " + type);
+ }
+ }
+
+ internal static ArrayList ConvertSubItems(IList items)
+ {
+ ArrayList r = new ArrayList();
+ if (items != null) {
+ foreach (MenuItemDescriptor descriptor in items) {
+ r.Add(CreateMenuItemFromDescriptor(descriptor));
+ }
+ }
+ return r;
+ }
+
+ public static ContextMenuStrip CreateContextMenu(object owner, string addInTreePath)
+ {
+ if (addInTreePath == null) {
+ return null;
+ }
+ try {
+ List<MenuItemDescriptor> descriptors = AddInTree.BuildItems<MenuItemDescriptor>(addInTreePath, owner, true);
+ ContextMenuStrip contextMenu = new ContextMenuStrip();
+ contextMenu.Items.Add(new ToolStripMenuItem("dummy"));
+ contextMenu.Opening += delegate {
+ contextMenu.Items.Clear();
+ AddItemsToMenu(contextMenu.Items, descriptors);
+ };
+ contextMenu.Opened += ContextMenuOpened;
+ contextMenu.Closed += ContextMenuClosed;
+ return contextMenu;
+ } catch (TreePathNotFoundException) {
+ MessageService.ShowError("Warning tree path '" + addInTreePath +"' not found.");
+ return null;
+ }
+ }
+
+ static bool isContextMenuOpen;
+
+ public static bool IsContextMenuOpen {
+ get {
+ return isContextMenuOpen;
+ }
+ }
+
+ static void ContextMenuOpened(object sender, EventArgs e)
+ {
+ isContextMenuOpen = true;
+ ContextMenuStrip contextMenu = (ContextMenuStrip)sender;
+ foreach (object o in contextMenu.Items) {
+ if (o is IStatusUpdate) {
+ ((IStatusUpdate)o).UpdateStatus();
+ }
+ }
+ }
+
+ static void ContextMenuClosed(object sender, EventArgs e)
+ {
+ isContextMenuOpen = false;
+ }
+
+ public static void ShowContextMenu(object owner, string addInTreePath, Control parent, int x, int y)
+ {
+ ContextMenuStrip menu = CreateContextMenu(owner, addInTreePath);
+ if (menu != null) {
+ menu.Show(parent, new Point(x, y));
+ }
+ }
+
+ class QuickInsertMenuHandler
+ {
+ TextBoxBase targetControl;
+ string text;
+
+ public QuickInsertMenuHandler(TextBoxBase targetControl, string text)
+ {
+ this.targetControl = targetControl;
+ this.text = text;
+ }
+
+ public EventHandler EventHandler {
+ get {
+ return new EventHandler(PopupMenuHandler);
+ }
+ }
+ void PopupMenuHandler(object sender, EventArgs e)
+ {
+ targetControl.SelectedText += text;
+ }
+ }
+
+ class QuickInsertHandler
+ {
+ Control popupControl;
+ ContextMenuStrip quickInsertMenu;
+
+ public QuickInsertHandler(Control popupControl, ContextMenuStrip quickInsertMenu)
+ {
+ this.popupControl = popupControl;
+ this.quickInsertMenu = quickInsertMenu;
+
+ popupControl.Click += new EventHandler(showQuickInsertMenu);
+ }
+
+ void showQuickInsertMenu(object sender, EventArgs e)
+ {
+ Point cords = new Point(popupControl.Width, 0);
+ quickInsertMenu.Show(popupControl, cords);
+ }
+ }
+
+ public static void CreateQuickInsertMenu(TextBoxBase targetControl, Control popupControl, string[,] quickInsertMenuItems)
+ {
+ ContextMenuStrip contextMenu = new ContextMenuStrip();
+ for (int i = 0; i < quickInsertMenuItems.GetLength(0); ++i) {
+ if (quickInsertMenuItems[i, 0] == "-") {
+ contextMenu.Items.Add(new MenuSeparator());
+ } else {
+ MenuCommand cmd = new MenuCommand(quickInsertMenuItems[i, 0],
+ new QuickInsertMenuHandler(targetControl, quickInsertMenuItems[i, 1]).EventHandler);
+ contextMenu.Items.Add(cmd);
+ }
+ }
+ new QuickInsertHandler(popupControl, contextMenu);
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/CustomDialog.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/CustomDialog.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/CustomDialog.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,149 @@
+// <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>
+
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ sealed class CustomDialog : System.Windows.Forms.Form
+ {
+ System.Windows.Forms.Label label;
+ System.Windows.Forms.Panel panel;
+ int acceptButton;
+ int cancelButton;
+ int result = -1;
+
+ /// <summary>
+ /// Gets the index of the button pressed.
+ /// </summary>
+ public int Result {
+ get {
+ return result;
+ }
+ }
+
+ public CustomDialog(string caption, string message, int acceptButton, int cancelButton, string[] buttonLabels)
+ {
+ this.SuspendLayout();
+ MyInitializeComponent();
+
+ this.Icon = null;
+ this.acceptButton = acceptButton;
+ this.cancelButton = cancelButton;
+
+ message = StringParser.Parse(message);
+ this.Text = StringParser.Parse(caption);
+
+ using (Graphics g = this.CreateGraphics()) {
+ Rectangle screen = Screen.PrimaryScreen.WorkingArea;
+ SizeF size = g.MeasureString(message, label.Font, screen.Width - 20);
+ Size clientSize = size.ToSize();
+ Button[] buttons = new Button[buttonLabels.Length];
+ int[] positions = new int[buttonLabels.Length];
+ int pos = 0;
+ for (int i = 0; i < buttons.Length; i++) {
+ Button newButton = new Button();
+ newButton.FlatStyle = FlatStyle.System;
+ newButton.Tag = i;
+ string buttonLabel = StringParser.Parse(buttonLabels[i]);
+ newButton.Text = buttonLabel;
+ newButton.Click += new EventHandler(ButtonClick);
+ SizeF buttonSize = g.MeasureString(buttonLabel, newButton.Font);
+ newButton.Width = Math.Max(newButton.Width, ((int)Math.Ceiling(buttonSize.Width / 8.0) + 1) * 8);
+ positions[i] = pos;
+ buttons[i] = newButton;
+ pos += newButton.Width + 4;
+ }
+ if (acceptButton >= 0) {
+ AcceptButton = buttons[acceptButton];
+ }
+ if (cancelButton >= 0) {
+ CancelButton = buttons[cancelButton];
+ }
+
+ pos += 4; // add space before first button
+ // (we don't start with pos=4 because this space doesn't belong to the button panel)
+
+ if (pos > clientSize.Width) {
+ clientSize.Width = pos;
+ }
+ clientSize.Height += panel.Height + 6;
+ this.ClientSize = clientSize;
+ int start = (clientSize.Width - pos) / 2;
+ for (int i = 0; i < buttons.Length; i++) {
+ buttons[i].Location = new Point(start + positions[i], 4);
+ }
+ panel.Controls.AddRange(buttons);
+ }
+ label.Text = message;
+
+ RightToLeftConverter.ConvertRecursive(this);
+ this.ResumeLayout(false);
+ }
+
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ if (cancelButton == -1 && e.KeyCode == Keys.Escape) {
+ this.Close();
+ }
+ }
+
+ void ButtonClick(object sender, EventArgs e)
+ {
+ result = (int)((Control)sender).Tag;
+ this.Close();
+ }
+
+ /// <summary>
+ /// This method is required for Windows Forms designer support.
+ /// Do not change the method contents inside the source code editor. The Forms designer might
+ /// not be able to load this method if it was changed manually.
+ /// </summary>
+ void MyInitializeComponent()
+ {
+ this.panel = new System.Windows.Forms.Panel();
+ this.label = new System.Windows.Forms.Label();
+ //
+ // panel
+ //
+ this.panel.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.panel.Location = new System.Drawing.Point(4, 80);
+ this.panel.Name = "panel";
+ this.panel.Size = new System.Drawing.Size(266, 32);
+ this.panel.TabIndex = 0;
+ //
+ // label
+ //
+ this.label.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.label.FlatStyle = System.Windows.Forms.FlatStyle.System;
+ this.label.Location = new System.Drawing.Point(4, 4);
+ this.label.Name = "label";
+ this.label.Size = new System.Drawing.Size(266, 76);
+ this.label.TabIndex = 1;
+ this.label.UseMnemonic = false;
+ //
+ // CustomDialog
+ //
+ this.ClientSize = new System.Drawing.Size(274, 112);
+ this.Controls.Add(this.label);
+ this.Controls.Add(this.panel);
+ this.DockPadding.Left = 4;
+ this.DockPadding.Right = 4;
+ this.DockPadding.Top = 4;
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.ShowInTaskbar = false;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "CustomDialog";
+ this.KeyPreview = true;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "CustomDialog";
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/InputBox.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/InputBox.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/InputBox.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,151 @@
+// <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>
+
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ /// <summary>
+ /// Class used to display an input box.
+ /// </summary>
+ sealed class InputBox : System.Windows.Forms.Form
+ {
+ private System.Windows.Forms.Label label;
+ private System.Windows.Forms.Button cancelButton;
+ private System.Windows.Forms.TextBox textBox;
+ private System.Windows.Forms.Button acceptButton;
+
+ public InputBox(string text, string caption, string defaultValue)
+ {
+ //
+ // The InitializeComponent() call is required for Windows Forms designer support.
+ //
+ InitializeComponent();
+
+ text = StringParser.Parse(text);
+ this.Text = StringParser.Parse(caption);
+ acceptButton.Text = StringParser.Parse("${res:Global.OKButtonText}");
+ cancelButton.Text = StringParser.Parse("${res:Global.CancelButtonText}");
+
+ Size size;
+ using (Graphics g = this.CreateGraphics()) {
+ Rectangle screen = Screen.PrimaryScreen.WorkingArea;
+ SizeF sizeF = g.MeasureString(text, label.Font, screen.Width - 20);
+ size = sizeF.ToSize();
+ size.Width += 4;
+ }
+ if (size.Width < 200)
+ size.Width = 200;
+ Size clientSize = this.ClientSize;
+ clientSize.Width += size.Width - label.Width;
+ clientSize.Height += size.Height - label.Height;
+ this.ClientSize = clientSize;
+ label.Text = text;
+ textBox.Text = defaultValue;
+ this.DialogResult = DialogResult.Cancel;
+ RightToLeftConverter.ConvertRecursive(this);
+ }
+
+ #region Windows Forms Designer generated code
+ /// <summary>
+ /// This method is required for Windows Forms designer support.
+ /// Do not change the method contents inside the source code editor. The Forms designer might
+ /// not be able to load this method if it was changed manually.
+ /// </summary>
+ private void InitializeComponent() {
+ this.acceptButton = new System.Windows.Forms.Button();
+ this.textBox = new System.Windows.Forms.TextBox();
+ this.cancelButton = new System.Windows.Forms.Button();
+ this.label = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // acceptButton
+ //
+ this.acceptButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.acceptButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
+ this.acceptButton.Location = new System.Drawing.Point(176, 114);
+ this.acceptButton.Name = "acceptButton";
+ this.acceptButton.TabIndex = 2;
+ this.acceptButton.Text = "OK";
+ this.acceptButton.Click += new System.EventHandler(this.AcceptButtonClick);
+ //
+ // textBox
+ //
+ this.textBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.textBox.Location = new System.Drawing.Point(8, 86);
+ this.textBox.Name = "textBox";
+ this.textBox.Size = new System.Drawing.Size(318, 20);
+ this.textBox.TabIndex = 1;
+ this.textBox.Text = "";
+ //
+ // cancelButton
+ //
+ this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.cancelButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
+ this.cancelButton.Location = new System.Drawing.Point(256, 114);
+ this.cancelButton.Name = "cancelButton";
+ this.cancelButton.TabIndex = 3;
+ this.cancelButton.Text = "Cancel";
+ this.cancelButton.Click += new System.EventHandler(this.CancelButtonClick);
+ //
+ // label
+ //
+ this.label.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.label.Location = new System.Drawing.Point(8, 8);
+ this.label.Name = "label";
+ this.label.Size = new System.Drawing.Size(328, 74);
+ this.label.TabIndex = 0;
+ this.label.UseMnemonic = false;
+ //
+ // InputBox
+ //
+ this.AcceptButton = this.acceptButton;
+ this.CancelButton = this.cancelButton;
+ this.ClientSize = new System.Drawing.Size(338, 144);
+ this.Controls.Add(this.textBox);
+ this.Controls.Add(this.label);
+ this.Controls.Add(this.cancelButton);
+ this.Controls.Add(this.acceptButton);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "InputBox";
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "InputBox";
+ this.ResumeLayout(false);
+ }
+ #endregion
+
+ void CancelButtonClick(object sender, System.EventArgs e)
+ {
+ result = null;
+ this.Close();
+ }
+
+ void AcceptButtonClick(object sender, System.EventArgs e)
+ {
+ this.DialogResult = DialogResult.OK;
+ result = textBox.Text;
+ this.Close();
+ }
+
+ string result;
+
+ public string Result {
+ get {
+ return result;
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/SaveErrorChooseDialog.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/SaveErrorChooseDialog.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/SaveErrorChooseDialog.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,157 @@
+// <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>
+
+using System;
+using System.Drawing;
+using System.IO;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ sealed class SaveErrorChooseDialog : System.Windows.Forms.Form
+ {
+ Button retryButton;
+ Button ignoreButton;
+ Label descriptionLabel;
+ TextBox descriptionTextBox;
+ Button exceptionButton;
+ Button chooseLocationButton;
+
+ string displayMessage;
+ Exception exceptionGot;
+
+ public SaveErrorChooseDialog(string fileName, string message, string dialogName, Exception exceptionGot, bool chooseLocationEnabled)
+ {
+ this.Text = StringParser.Parse(dialogName);
+ // Must be called for initialization
+ 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},
+ });
+
+ descriptionTextBox.Lines = StringParser.Parse(this.displayMessage).Split('\n');
+
+ this.exceptionGot = exceptionGot;
+ }
+
+ void ShowException(object sender, EventArgs e)
+ {
+ MessageService.ShowMessage(exceptionGot.ToString(), StringParser.Parse("${res:ICSharpCode.Core.Services.ErrorDialogs.ExceptionGotDescription}"));
+ }
+
+ /// <summary>
+ /// This method was autogenerated - do not change the contents manually
+ /// </summary>
+ private void InitializeComponents(bool chooseLocationEnabled)
+ {
+ //
+ // Set up generated class SaveErrorChooseDialog
+ //
+ this.ClientSize = new Size(508, 320);
+ this.SuspendLayout();
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "SaveErrorChooseDialog";
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.ShowInTaskbar = false;
+ this.StartPosition = FormStartPosition.CenterScreen;
+
+ //
+ // Set up member descriptionLabel
+ //
+ this.descriptionLabel = new Label();
+ this.descriptionLabel.Name = "descriptionLabel";
+ 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.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
+ this.descriptionLabel.Text = StringParser.Parse("${res:ICSharpCode.Core.Services.ErrorDialogs.DescriptionLabel}");
+ this.Controls.Add(descriptionLabel);
+
+ //
+ // Set up member descriptionTextBox
+ //
+ this.descriptionTextBox = new TextBox();
+ this.descriptionTextBox.Multiline = true;
+ 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.ReadOnly = true;
+ this.descriptionTextBox.Name = "descriptionTextBox";
+ this.Controls.Add(descriptionTextBox);
+
+ //
+ // Set up member retryButton
+ //
+ this.retryButton = new Button();
+ this.retryButton.DialogResult = System.Windows.Forms.DialogResult.Retry;
+ this.retryButton.Name = "retryButton";
+ this.retryButton.TabIndex = 5;
+ this.retryButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
+ this.retryButton.Text = StringParser.Parse("${res:Global.RetryButtonText}");
+ this.retryButton.Size = new Size(110, 27);
+ this.retryButton.Location = new Point(28, 285);
+ this.Controls.Add(retryButton);
+
+ //
+ // Set up member ignoreButton
+ //
+ this.ignoreButton = new Button();
+ this.ignoreButton.Name = "ignoreButton";
+ this.ignoreButton.DialogResult = System.Windows.Forms.DialogResult.Ignore;
+ this.ignoreButton.TabIndex = 4;
+ this.ignoreButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
+ this.ignoreButton.Text = StringParser.Parse("${res:Global.IgnoreButtonText}");
+ this.ignoreButton.Size = new Size(110, 27);
+ this.ignoreButton.Location = new Point(146, 285);
+ this.Controls.Add(ignoreButton);
+
+
+ //
+ // Set up member exceptionButton
+ //
+ this.exceptionButton = new Button();
+ this.exceptionButton.TabIndex = 1;
+ this.exceptionButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
+ this.exceptionButton.Name = "exceptionButton";
+ this.exceptionButton.Text = ResourceService.GetString("ICSharpCode.Core.Services.ErrorDialogs.ShowExceptionButton");
+ this.exceptionButton.Size = new Size(110, 27);
+ this.exceptionButton.Location = new Point(382, 285);
+ this.exceptionButton.Click += new EventHandler(ShowException);
+ this.Controls.Add(exceptionButton);
+
+ if (chooseLocationEnabled) {
+ //
+ // Set up member chooseLocationButton
+ //
+ this.chooseLocationButton = new Button();
+ this.chooseLocationButton.Name = "chooseLocationButton";
+ this.chooseLocationButton.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this.chooseLocationButton.TabIndex = 0;
+ this.chooseLocationButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
+ this.chooseLocationButton.Text = ResourceService.GetString("Global.ChooseLocationButtonText");
+ this.chooseLocationButton.Size = new Size(110, 27);
+ this.chooseLocationButton.Location = new Point(264, 285);
+ }
+
+ this.Controls.Add(chooseLocationButton);
+
+ this.ResumeLayout(false);
+ this.Size = new Size(526, 262);
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/SaveErrorInformDialog.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/SaveErrorInformDialog.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/SaveErrorInformDialog.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,128 @@
+// <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>
+
+using System;
+using System.Drawing;
+using System.IO;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ /// <summary>
+ /// Add summary description for SaveErrorInformDialog
+ /// </summary>
+ sealed class SaveErrorInformDialog : System.Windows.Forms.Form
+ {
+ System.Windows.Forms.Label descriptionLabel;
+ System.Windows.Forms.TextBox descriptionTextBox;
+ System.Windows.Forms.Button exceptionButton;
+ System.Windows.Forms.Button okButton;
+
+ string displayMessage;
+ Exception exceptionGot;
+
+ public SaveErrorInformDialog(string fileName, string message, string dialogName, Exception exceptionGot)
+ {
+ this.Text = StringParser.Parse(dialogName);
+ // Must be called for initialization
+ 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},
+ });
+ descriptionTextBox.Lines = this.displayMessage.Split('\n');
+
+ this.exceptionGot = exceptionGot;
+ }
+
+ void ShowException(object sender, EventArgs e)
+ {
+ MessageService.ShowMessage(exceptionGot.ToString(), "Exception got");
+ }
+
+ /// <summary>
+ /// This method was autogenerated - do not change the contents manually
+ /// </summary>
+ private void InitializeComponent2()
+ {
+ //
+ // Set up generated class SaveErrorInformDialog
+ //
+ this.ClientSize = new Size(508, 320);
+ this.SuspendLayout();
+ //
+ // Set up member descriptionLabel
+ //
+ this.descriptionLabel = new System.Windows.Forms.Label();
+ this.descriptionLabel.Location = new System.Drawing.Point(8, 8);
+ this.descriptionLabel.Size = new System.Drawing.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.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
+ this.descriptionLabel.Text = StringParser.Parse("${res:ICSharpCode.Core.Services.ErrorDialogs.DescriptionLabel}");
+ this.descriptionLabel.Name = "descriptionLabel";
+ this.Controls.Add(descriptionLabel);
+
+ //
+ // Set up member descriptionTextBox
+ //
+ this.descriptionTextBox = new System.Windows.Forms.TextBox();
+ this.descriptionTextBox.Name = "descriptionTextBox";
+ this.descriptionTextBox.Multiline = true;
+ this.descriptionTextBox.Size = new System.Drawing.Size(584, 237);
+ this.descriptionTextBox.Location = new System.Drawing.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.ReadOnly = true;
+ this.Controls.Add(descriptionTextBox);
+
+ //
+ // Set up member exceptionButton
+ //
+ this.exceptionButton = new System.Windows.Forms.Button();
+ this.exceptionButton.TabIndex = 1;
+ this.exceptionButton.Name = "exceptionButton";
+ this.exceptionButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
+ this.exceptionButton.Text = StringParser.Parse("${res:ICSharpCode.Core.Services.ErrorDialogs.ShowExceptionButton}");
+ this.exceptionButton.Size = new System.Drawing.Size(120, 27);
+ this.exceptionButton.Location = new System.Drawing.Point(372, 285);
+ this.exceptionButton.Click += new EventHandler(ShowException);
+ this.Controls.Add(exceptionButton);
+
+ //
+ // Set up member chooseLocationButton
+ //
+ this.okButton = new System.Windows.Forms.Button();
+ this.okButton.Name = "okButton";
+ this.okButton.TabIndex = 0;
+ this.okButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
+ this.okButton.Text = StringParser.Parse("${res:Global.OKButtonText}");
+ this.okButton.Size = new System.Drawing.Size(120, 27);
+ this.okButton.Location = new System.Drawing.Point(244, 285);
+ this.okButton.DialogResult = DialogResult.OK;
+ this.Controls.Add(okButton);
+
+
+ this.MaximizeBox = false;
+ this.Name = "SaveErrorInformDialog";
+ this.MinimizeBox = false;
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.ShowInTaskbar = false;
+ this.StartPosition = FormStartPosition.CenterScreen;
+
+ this.ResumeLayout(false);
+ this.Size = new System.Drawing.Size(526, 262);
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/WinFormsMessageService.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/WinFormsMessageService.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/MessageService/WinFormsMessageService.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,205 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <author name="Daniel Grunwald"/>
+// <version>$Revision$</version>
+// </file>
+
+using System;
+using System.ComponentModel;
+using System.Windows.Forms;
+
+using ICSharpCode.Core.Services;
+
+namespace ICSharpCode.Core.WinForms
+{
+ /// <summary>
+ /// Class with static methods to show message boxes.
+ /// All text displayed using the MessageService is passed to the
+ /// <see cref="StringParser"/> to replace ${res} markers.
+ /// </summary>
+ public sealed class WinFormsMessageService : IMessageService
+ {
+ /// <summary>
+ /// Gets/Sets the form used as owner for shown message boxes.
+ /// </summary>
+ public static 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; }
+
+ /// <summary>
+ /// Gets the message service instance.
+ /// </summary>
+ public static readonly WinFormsMessageService Instance = new WinFormsMessageService();
+
+ private WinFormsMessageService() {}
+
+ static void BeginInvoke(MethodInvoker method)
+ {
+ ISynchronizeInvoke si = DialogSynchronizeInvoke;
+ if (si == null || !si.InvokeRequired)
+ method();
+ else
+ si.BeginInvoke(method, null);
+ }
+
+ static void Invoke(MethodInvoker method)
+ {
+ ISynchronizeInvoke si = DialogSynchronizeInvoke;
+ if (si == null || !si.InvokeRequired)
+ method();
+ else
+ si.Invoke(method, null);
+ }
+
+ public void ShowError(Exception ex, string message)
+ {
+ string msg = message + "\n\n";
+
+ if (ex != null) {
+ msg += "Exception occurred: " + ex.ToString();
+ }
+
+ BeginInvoke(
+ delegate {
+ MessageBox.Show(DialogOwner, StringParser.Parse(msg), StringParser.Parse("${res:Global.ErrorText}"), MessageBoxButtons.OK, MessageBoxIcon.Error);
+ });
+ }
+
+ public void ShowWarning(string message)
+ {
+ message = StringParser.Parse(message);
+
+ string caption = StringParser.Parse("${res:Global.WarningText}");
+ BeginInvoke(
+ delegate {
+ MessageBox.Show(DialogOwner,
+ message, caption,
+ MessageBoxButtons.OK, MessageBoxIcon.Warning,
+ MessageBoxDefaultButton.Button1, GetOptions(message, caption));
+ });
+ }
+
+ public bool AskQuestion(string question, string caption)
+ {
+ DialogResult result = DialogResult.None;
+ Invoke(
+ delegate {
+ result = MessageBox.Show(DialogOwner,
+ StringParser.Parse(question),
+ StringParser.Parse(caption),
+ MessageBoxButtons.YesNo,
+ MessageBoxIcon.Question,
+ MessageBoxDefaultButton.Button1,
+ GetOptions(question, caption));
+ });
+ return result == DialogResult.Yes;
+ }
+
+ static MessageBoxOptions GetOptions(string text, string caption)
+ {
+ return IsRtlText(text) ? MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign : 0;
+ }
+
+ static bool IsRtlText(string text)
+ {
+ if (!RightToLeftConverter.IsRightToLeft)
+ return false;
+ foreach (char c in StringParser.Parse(text)) {
+ if (char.GetUnicodeCategory(c) == System.Globalization.UnicodeCategory.OtherLetter)
+ return true;
+ }
+ return false;
+ }
+
+ public int ShowCustomDialog(string caption, string dialogText, int acceptButtonIndex, int cancelButtonIndex, params string[] buttontexts)
+ {
+ int result = 0;
+ Invoke(
+ delegate {
+ using (CustomDialog messageBox = new CustomDialog(caption, dialogText, acceptButtonIndex, cancelButtonIndex, buttontexts)) {
+ messageBox.ShowDialog(DialogOwner);
+ result = messageBox.Result;
+ }
+ });
+ return result;
+ }
+
+ public string ShowInputBox(string caption, string dialogText, string defaultValue)
+ {
+ string result = null;
+ Invoke(
+ delegate {
+ using (InputBox inputBox = new InputBox(dialogText, caption, defaultValue)) {
+ inputBox.ShowDialog(DialogOwner);
+ result = inputBox.Result;
+ }
+ });
+ return result;
+ }
+
+ public void ShowMessage(string message, string caption)
+ {
+ message = StringParser.Parse(message);
+ BeginInvoke(
+ delegate {
+ MessageBox.Show(DialogOwner,
+ message,
+ StringParser.Parse(caption),
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information,
+ MessageBoxDefaultButton.Button1,
+ GetOptions(message, caption));
+ });
+ }
+
+ public void InformSaveError(string fileName, string message, string dialogName, Exception exceptionGot)
+ {
+ BeginInvoke(
+ delegate {
+ using (SaveErrorInformDialog dlg = new SaveErrorInformDialog(fileName, message, dialogName, exceptionGot)) {
+ dlg.ShowDialog(DialogOwner);
+ }
+ });
+ }
+
+ public ChooseSaveErrorResult ChooseSaveError(string fileName, string message, string dialogName, Exception exceptionGot, bool chooseLocationEnabled)
+ {
+ ChooseSaveErrorResult r = ChooseSaveErrorResult.Ignore;
+ Invoke(
+ delegate {
+ restartlabel:
+ using (SaveErrorChooseDialog dlg = new SaveErrorChooseDialog(fileName, message, dialogName, exceptionGot, chooseLocationEnabled)) {
+ switch (dlg.ShowDialog(DialogOwner)) {
+ case DialogResult.OK:
+ // choose location:
+ using (SaveFileDialog fdiag = new SaveFileDialog()) {
+ fdiag.OverwritePrompt = true;
+ fdiag.AddExtension = true;
+ fdiag.CheckFileExists = false;
+ fdiag.CheckPathExists = true;
+ fdiag.Title = "Choose alternate file name";
+ fdiag.FileName = fileName;
+ if (fdiag.ShowDialog() == DialogResult.OK) {
+ r = ChooseSaveErrorResult.SaveAlternative(fdiag.FileName);
+ break;
+ } else {
+ goto restartlabel;
+ }
+ }
+ case DialogResult.Retry:
+ r = ChooseSaveErrorResult.Retry;
+ break;
+ default:
+ r = ChooseSaveErrorResult.Ignore;
+ break;
+ }
+ }
+ });
+ return r;
+ }
+ }
+}
\ No newline at end of file
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Properties/AssemblyInfo.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Properties/AssemblyInfo.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Properties/AssemblyInfo.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,24 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Daniel Grunwald"/>
+// <version>$Revision: 3763 $</version>
+// </file>
+
+using System;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly: CLSCompliant(true)]
+[assembly: StringFreezing()]
+
+[assembly: Dependency("ICSharpCode.Core", LoadHint.Always)]
+[assembly: Dependency("System.Xml", LoadHint.Always)]
+[assembly: Dependency("System.Drawing", LoadHint.Always)]
+[assembly: Dependency("System.Windows.Forms", LoadHint.Always)]
+
+[assembly: AssemblyTitle("ICSharpCode.Core.WinForms")]
+[assembly: AssemblyDescription("Windows Forms binding for ICSharpCode.Core")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarCheckBox.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarCheckBox.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarCheckBox.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,122 @@
+// <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>
+
+using System;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ public class ToolBarCheckBox : ToolStripButton , IStatusUpdate
+ {
+ object caller;
+ Codon codon;
+ string description = String.Empty;
+ ICheckableMenuCommand menuCommand = null;
+
+ public ICheckableMenuCommand MenuCommand {
+ get {
+ return menuCommand;
+ }
+ }
+
+ public object Caller {
+ get {
+ return caller;
+ }
+ }
+
+ public string Description {
+ get {
+ return description;
+ }
+ set {
+ description = value;
+ }
+ }
+
+ public ToolBarCheckBox(string text)
+ {
+ this.RightToLeft = RightToLeft.Inherit;
+ Text = text;
+ }
+
+ public ToolBarCheckBox(Codon codon, object caller)
+ {
+ this.RightToLeft = RightToLeft.Inherit;
+ this.caller = caller;
+ this.codon = codon;
+ try {
+ menuCommand = (ICheckableMenuCommand)codon.AddIn.CreateObject(codon.Properties["class"]);
+ } catch (Exception) {
+ }
+ if (menuCommand == null) {
+ MessageService.ShowError("Can't create toolbar checkbox : " + codon.Id);
+ }
+ menuCommand.Owner = this;
+
+ if (codon.Properties.Contains("label")){
+ Text = StringParser.Parse(codon.Properties["label"]);
+ }
+ if (Image == null && codon.Properties.Contains("icon")) {
+ Image = WinFormsResourceService.GetBitmap(StringParser.Parse(codon.Properties["icon"]));
+ }
+ UpdateText();
+ UpdateStatus();
+ }
+
+ protected override void OnClick(EventArgs e)
+ {
+ base.OnClick(e);
+ if (menuCommand != null) {
+ menuCommand.Run();
+ Checked = menuCommand.IsChecked;
+ }
+ }
+
+ public override bool Enabled {
+ get {
+ if (codon == null) {
+ return base.Enabled;
+ }
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+ return failedAction != ConditionFailedAction.Disable;
+ }
+ }
+
+ public virtual void UpdateStatus()
+ {
+ if (codon != null) {
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+ bool isVisible = failedAction != ConditionFailedAction.Exclude;
+ if (isVisible != Visible)
+ Visible = isVisible;
+ if (menuCommand != null) {
+ bool isChecked = menuCommand.IsChecked;
+ if (isChecked != Checked)
+ Checked = isChecked;
+ }
+
+ if (this.Visible && codon.Properties.Contains("icon")) {
+ Image = WinFormsResourceService.GetBitmap(StringParser.Parse(codon.Properties["icon"]));
+ }
+ }
+ }
+
+ public virtual void UpdateText()
+ {
+ if (codon != null) {
+ if (codon.Properties.Contains("tooltip")) {
+ ToolTipText = StringParser.Parse(codon.Properties["tooltip"]);
+ }
+
+ if (codon.Properties.Contains("label")){
+ Text = StringParser.Parse(codon.Properties["label"]);
+ }
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarComboBox.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarComboBox.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarComboBox.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,116 @@
+// <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>
+
+using System;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ public class ToolBarComboBox : ToolStripComboBox, IStatusUpdate
+ {
+ object caller;
+ Codon codon;
+ string description = String.Empty;
+ IComboBoxCommand menuCommand = null;
+
+ public object Caller {
+ get {
+ return caller;
+ }
+ }
+
+ public string Description {
+ get {
+ return description;
+ }
+ set {
+ description = value;
+ }
+ }
+
+ public IComboBoxCommand MenuCommand {
+ get {
+ return menuCommand;
+ }
+ }
+
+ public ToolBarComboBox(Codon codon, object caller)
+ {
+ this.RightToLeft = RightToLeft.Inherit;
+ ComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
+ ComboBox.SelectionChangeCommitted += new EventHandler(selectionChanged);
+ ComboBox.KeyDown += new KeyEventHandler(ComboBoxKeyDown);
+
+ this.caller = caller;
+ this.codon = codon;
+
+ menuCommand = (IComboBoxCommand)codon.AddIn.CreateObject(codon.Properties["class"]);
+ menuCommand.Owner = this;
+ if (menuCommand == null) {
+ throw new NullReferenceException("Can't create combobox menu command");
+ }
+ UpdateText();
+ UpdateStatus();
+ }
+
+ void ComboBoxKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.Control) {
+ MenuCommand.Run();
+ }
+ }
+
+ void selectionChanged(object sender, EventArgs e)
+ {
+ MenuCommand.Run();
+ }
+
+ protected override void OnClick(System.EventArgs e)
+ {
+ base.OnClick(e);
+ }
+
+ public override bool Enabled {
+ get {
+ if (codon == null) {
+ return base.Enabled;
+ }
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+
+ bool isEnabled = failedAction != ConditionFailedAction.Disable;
+
+ if (menuCommand != null) {
+ isEnabled &= menuCommand.IsEnabled;
+ }
+
+ return isEnabled;
+ }
+ }
+
+ public virtual void UpdateStatus()
+ {
+ bool isVisible = base.Visible;
+ if (codon != null) {
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+ isVisible &= failedAction != ConditionFailedAction.Exclude;
+ }
+ if (base.Visible != isVisible) {
+ Visible = isVisible;
+ }
+ }
+
+ public virtual void UpdateText()
+ {
+ if (codon.Properties.Contains("label")) {
+ Text = StringParser.Parse(codon.Properties["label"]);
+ }
+ if (codon.Properties.Contains("tooltip")) {
+ ToolTipText = StringParser.Parse(codon.Properties["tooltip"]);
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarCommand.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarCommand.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarCommand.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,83 @@
+// <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>
+
+using System;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ public class ToolBarCommand : ToolStripButton, IStatusUpdate
+ {
+ object caller;
+ Codon codon;
+ ICommand menuCommand = null;
+
+ public ToolBarCommand(Codon codon, object caller, bool createCommand)
+ {
+ this.RightToLeft = RightToLeft.Inherit;
+ this.caller = caller;
+ this.codon = codon;
+
+ if (createCommand) {
+ menuCommand = (ICommand)codon.AddIn.CreateObject(codon.Properties["class"]);
+ }
+
+ if (codon.Properties.Contains("label")){
+ Text = StringParser.Parse(codon.Properties["label"]);
+ }
+ if (Image == null && codon.Properties.Contains("icon")) {
+ Image = WinFormsResourceService.GetBitmap(StringParser.Parse(codon.Properties["icon"]));
+ }
+
+ UpdateStatus();
+ UpdateText();
+ }
+
+ protected override void OnClick(EventArgs e)
+ {
+ base.OnClick(e);
+ if (menuCommand == null) {
+ menuCommand = (ICommand)codon.AddIn.CreateObject(codon.Properties["class"]);
+ }
+ if (menuCommand != null) {
+ menuCommand.Owner = caller;
+ LoggingService.Info("Run command " + menuCommand.GetType().FullName);
+ menuCommand.Run();
+ }
+ }
+
+ public virtual void UpdateStatus()
+ {
+ if (codon != null) {
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+ this.Visible = failedAction != ConditionFailedAction.Exclude;
+ bool isEnabled = failedAction != ConditionFailedAction.Disable;
+ if (isEnabled && menuCommand != null && menuCommand is IMenuCommand) {
+ isEnabled = ((IMenuCommand)menuCommand).IsEnabled;
+ }
+ this.Enabled = isEnabled;
+
+ if (this.Visible && codon.Properties.Contains("icon")) {
+ Image = WinFormsResourceService.GetBitmap(StringParser.Parse(codon.Properties["icon"]));
+ }
+ }
+ }
+
+ public virtual void UpdateText()
+ {
+ if (codon != null) {
+ if (codon.Properties.Contains("tooltip")) {
+ ToolTipText = StringParser.Parse(codon.Properties["tooltip"]);
+ }
+
+ if (codon.Properties.Contains("label")){
+ Text = StringParser.Parse(codon.Properties["label"]);
+ }
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarDropDownButton.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarDropDownButton.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarDropDownButton.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,127 @@
+// <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>
+
+using System;
+using System.Collections;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ public class ToolBarDropDownButton : ToolStripDropDownButton , IStatusUpdate
+ {
+ object caller;
+ Codon codon;
+ ICommand menuBuilder = null;
+ ArrayList subItems;
+
+ public ToolBarDropDownButton(Codon codon, object caller, ArrayList subItems)
+ {
+ this.RightToLeft = RightToLeft.Inherit;
+ this.caller = caller;
+ this.codon = codon;
+ this.subItems = subItems;
+
+ if (codon.Properties.Contains("label")){
+ Text = StringParser.Parse(codon.Properties["label"]);
+ }
+ if (Image == null && codon.Properties.Contains("icon")) {
+ Image = WinFormsResourceService.GetBitmap(StringParser.Parse(codon.Properties["icon"]));
+ }
+ if (menuBuilder == null && codon.Properties.Contains("class")) {
+ menuBuilder = codon.AddIn.CreateObject(StringParser.Parse(codon.Properties["class"])) as ICommand;
+ menuBuilder.Owner = this;
+ }
+
+ UpdateStatus();
+ UpdateText();
+ }
+
+ void CreateDropDownItems()
+ {
+ // let's assume that if a menuBuilder exists,
+ // as in the Search Results panel or the Class
+ // Browser toolbar, it will handle this step.
+ if (menuBuilder != null) {
+ return;
+ }
+
+ // also, let's prevent a null exception
+ // in the event that there are no subitems
+ if (subItems == null || subItems.Count==0) {
+ return;
+ }
+
+ DropDownItems.Clear();
+ foreach (object item in subItems)
+ {
+ if (item is ToolStripItem)
+ {
+ DropDownItems.Add((ToolStripItem)item);
+ if (item is IStatusUpdate)
+ {
+ ((IStatusUpdate)item).UpdateStatus();
+ ((IStatusUpdate)item).UpdateText();
+ }
+ }
+ else
+ {
+ ISubmenuBuilder submenuBuilder = (ISubmenuBuilder)item;
+ DropDownItems.AddRange(submenuBuilder.BuildSubmenu(codon, caller));
+ }
+ }
+ }
+ protected override void OnDropDownShow(EventArgs e)
+ {
+ if (codon != null && !this.DropDown.Visible)
+ {
+ CreateDropDownItems();
+ }
+ base.OnDropDownShow(e);
+ }
+
+ public override bool Enabled {
+ get {
+ if (codon == null) {
+ return base.Enabled;
+ }
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+
+ bool isEnabled = failedAction != ConditionFailedAction.Disable;
+
+ return isEnabled;
+ }
+ }
+
+ public virtual void UpdateStatus()
+ {
+ if (codon != null) {
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+ bool isVisible = failedAction != ConditionFailedAction.Exclude;
+ if (base.Visible != isVisible) {
+ base.Visible = isVisible;
+ }
+
+ if (this.Visible && codon.Properties.Contains("icon")) {
+ Image = WinFormsResourceService.GetBitmap(StringParser.Parse(codon.Properties["icon"]));
+ }
+ }
+ }
+
+ public virtual void UpdateText()
+ {
+ if (codon != null) {
+ if (codon.Properties.Contains("tooltip")) {
+ ToolTipText = StringParser.Parse(codon.Properties["tooltip"]);
+ }
+
+ if (codon.Properties.Contains("label")){
+ Text = StringParser.Parse(codon.Properties["label"]);
+ }
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarLabel.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarLabel.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarLabel.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,74 @@
+// <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>
+
+using System;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ public class ToolBarLabel : ToolStripLabel, IStatusUpdate
+ {
+ object caller;
+ Codon codon;
+ ICommand menuCommand = null;
+
+ public object Caller {
+ get {
+ return caller;
+ }
+ }
+
+ public ToolBarLabel(Codon codon, object caller)
+ {
+ this.RightToLeft = RightToLeft.Inherit;
+ this.caller = caller;
+ this.codon = codon;
+
+ if (codon.Properties.Contains("class"))
+ {
+ menuCommand = (ICommand)codon.AddIn.CreateObject(codon.Properties["class"]);
+ menuCommand.Owner = this;
+ }
+
+ UpdateText();
+ UpdateStatus();
+ }
+
+ public override bool Enabled {
+ get {
+ if (codon == null) {
+ return base.Enabled;
+ }
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+
+ bool isEnabled = failedAction != ConditionFailedAction.Disable;
+
+ return isEnabled;
+ }
+ }
+
+ public virtual void UpdateStatus()
+ {
+ if (codon != null)
+ {
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+ this.Enabled = failedAction != ConditionFailedAction.Disable;
+ this.Visible = failedAction != ConditionFailedAction.Exclude;
+ }
+ }
+
+ public virtual void UpdateText()
+ {
+ if (codon.Properties.Contains("label")) {
+ Text = StringParser.Parse(codon.Properties["label"]);
+ }
+ if (codon.Properties.Contains("tooltip")) {
+ ToolTipText = StringParser.Parse(codon.Properties["tooltip"]);
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarSeparator.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarSeparator.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarSeparator.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,43 @@
+// <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>
+
+using System;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ public class ToolBarSeparator : ToolStripSeparator, IStatusUpdate
+ {
+ object caller;
+ Codon codon;
+
+ public ToolBarSeparator()
+ {
+ this.RightToLeft = RightToLeft.Inherit;
+ }
+
+ public ToolBarSeparator(Codon codon, object caller)
+ {
+ this.RightToLeft = RightToLeft.Inherit;
+ this.caller = caller;
+ this.codon = codon;
+ }
+
+ public virtual void UpdateStatus()
+ {
+ if (codon != null) {
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+ this.Enabled = failedAction != ConditionFailedAction.Disable;
+ this.Visible = failedAction != ConditionFailedAction.Exclude;
+ }
+ }
+
+ public virtual void UpdateText()
+ {
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarService.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarService.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarService.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,139 @@
+// <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>
+
+using System;
+using System.Collections.Generic;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ public static class ToolbarService
+ {
+ public static ToolStripItem[] CreateToolStripItems(string path, object owner, bool throwOnNotFound)
+ {
+ return CreateToolStripItems(owner, AddInTree.GetTreeNode(path, throwOnNotFound));
+ }
+
+ public static ToolStripItem[] CreateToolStripItems(object owner, AddInTreeNode treeNode)
+ {
+ if (treeNode == null)
+ return new ToolStripItem[0];
+ List<ToolStripItem> collection = new List<ToolStripItem>();
+ foreach (ToolbarItemDescriptor descriptor in treeNode.BuildChildItems<ToolbarItemDescriptor>(owner)) {
+ object item = CreateToolbarItemFromDescriptor(descriptor);
+ if (item is ToolStripItem) {
+ collection.Add((ToolStripItem)item);
+ } else {
+ ISubmenuBuilder submenuBuilder = (ISubmenuBuilder)item;
+ collection.AddRange(submenuBuilder.BuildSubmenu(null, owner));
+ }
+ }
+
+ return collection.ToArray();
+ }
+
+ static object CreateToolbarItemFromDescriptor(ToolbarItemDescriptor descriptor)
+ {
+ Codon codon = descriptor.Codon;
+ object caller = descriptor.Caller;
+ string type = codon.Properties.Contains("type") ? codon.Properties["type"] : "Item";
+
+ bool createCommand = codon.Properties["loadclasslazy"] == "false";
+
+ switch (type) {
+ case "Separator":
+ return new ToolBarSeparator(codon, caller);
+ case "CheckBox":
+ return new ToolBarCheckBox(codon, caller);
+ case "Item":
+ return new ToolBarCommand(codon, caller, createCommand);
+ case "ComboBox":
+ return new ToolBarComboBox(codon, caller);
+ case "TextBox":
+ return new ToolBarTextBox(codon, caller);
+ case "Label":
+ return new ToolBarLabel(codon, caller);
+ case "DropDownButton":
+ return new ToolBarDropDownButton(codon, caller, MenuService.ConvertSubItems(descriptor.SubItems));
+ case "SplitButton":
+ return new ToolBarSplitButton(codon, caller, MenuService.ConvertSubItems(descriptor.SubItems));
+ case "Builder":
+ return codon.AddIn.CreateObject(codon.Properties["class"]);
+ default:
+ throw new System.NotSupportedException("unsupported menu item type : " + type);
+ }
+ }
+
+ public static ToolStrip CreateToolStrip(object owner, AddInTreeNode treeNode)
+ {
+ ToolStrip toolStrip = new ToolStrip();
+ toolStrip.Items.AddRange(CreateToolStripItems(owner, treeNode));
+ UpdateToolbar(toolStrip); // setting Visible is only possible after the items have been added
+ new LanguageChangeWatcher(toolStrip);
+ return toolStrip;
+ }
+
+ class LanguageChangeWatcher {
+ ToolStrip toolStrip;
+ public LanguageChangeWatcher(ToolStrip toolStrip) {
+ this.toolStrip = toolStrip;
+ toolStrip.Disposed += Disposed;
+ ResourceService.LanguageChanged += OnLanguageChanged;
+ }
+ void OnLanguageChanged(object sender, EventArgs e) {
+ ToolbarService.UpdateToolbarText(toolStrip);
+ }
+ void Disposed(object sender, EventArgs e) {
+ ResourceService.LanguageChanged -= OnLanguageChanged;
+ }
+ }
+
+ public static ToolStrip CreateToolStrip(object owner, string addInTreePath)
+ {
+ return CreateToolStrip(owner, AddInTree.GetTreeNode(addInTreePath));
+ }
+
+ public static ToolStrip[] CreateToolbars(object owner, string addInTreePath)
+ {
+ AddInTreeNode treeNode;
+ try {
+ treeNode = AddInTree.GetTreeNode(addInTreePath);
+ } catch (TreePathNotFoundException) {
+ return null;
+
+ }
+ List<ToolStrip> toolBars = new List<ToolStrip>();
+ foreach (AddInTreeNode childNode in treeNode.ChildNodes.Values) {
+ toolBars.Add(CreateToolStrip(owner, childNode));
+ }
+ return toolBars.ToArray();
+ }
+
+ public static void UpdateToolbar(ToolStrip toolStrip)
+ {
+ toolStrip.SuspendLayout();
+ foreach (ToolStripItem item in toolStrip.Items) {
+ if (item is IStatusUpdate) {
+ ((IStatusUpdate)item).UpdateStatus();
+ }
+ }
+ toolStrip.ResumeLayout();
+ //toolStrip.Refresh();
+ }
+
+ public static void UpdateToolbarText(ToolStrip toolStrip)
+ {
+ toolStrip.SuspendLayout();
+ foreach (ToolStripItem item in toolStrip.Items) {
+ if (item is IStatusUpdate) {
+ ((IStatusUpdate)item).UpdateText();
+ }
+ }
+ toolStrip.ResumeLayout();
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarSplitButton.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarSplitButton.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarSplitButton.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,175 @@
+// <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>
+
+using System;
+using System.Collections;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ public class ToolBarSplitButton : ToolStripSplitButton , IStatusUpdate
+ {
+ object caller;
+ Codon codon;
+ ArrayList subItems;
+ ICommand menuCommand = null;
+ Image imgButtonEnabled = null;
+ Image imgButtonDisabled = null;
+ bool buttonEnabled = true;
+ bool dropDownEnabled = true;
+
+ public ToolBarSplitButton(Codon codon, object caller, ArrayList subItems)
+ {
+ this.RightToLeft = RightToLeft.Inherit;
+ this.caller = caller;
+ this.codon = codon;
+ this.subItems = subItems;
+
+ if (codon.Properties.Contains("label")){
+ Text = StringParser.Parse(codon.Properties["label"]);
+ }
+ if (imgButtonEnabled == null && codon.Properties.Contains("icon")) {
+ imgButtonEnabled = WinFormsResourceService.GetBitmap(StringParser.Parse(codon.Properties["icon"]));
+ }
+ if (imgButtonDisabled == null && codon.Properties.Contains("disabledIcon")) {
+ imgButtonDisabled = WinFormsResourceService.GetBitmap(StringParser.Parse(codon.Properties["disabledIcon"]));
+ }
+ if (imgButtonDisabled == null) {
+ imgButtonDisabled = imgButtonEnabled;
+ }
+ menuCommand = codon.AddIn.CreateObject(codon.Properties["class"]) as ICommand;
+ menuCommand.Owner = this;
+ UpdateStatus();
+ UpdateText();
+ }
+
+ void CreateDropDownItems()
+ {
+ ToolStripItem[] itemsToAdd = null;
+
+ DropDownItems.Clear();
+ foreach (object item in subItems)
+ {
+ if (item is ToolStripItem)
+ {
+ DropDownItems.Add((ToolStripItem)item);
+ if (item is IStatusUpdate)
+ {
+ ((IStatusUpdate)item).UpdateStatus();
+ ((IStatusUpdate)item).UpdateText();
+ }
+ }
+ else
+ {
+ ISubmenuBuilder submenuBuilder = (ISubmenuBuilder)item;
+ itemsToAdd = submenuBuilder.BuildSubmenu(codon, caller);
+ if (itemsToAdd!=null) {
+ DropDownItems.AddRange(itemsToAdd);
+ }
+ }
+ }
+ }
+ protected override void OnDropDownShow(EventArgs e)
+ {
+ if (!dropDownEnabled) {
+ return;
+ }
+ if (codon != null && !this.DropDown.Visible)
+ {
+ CreateDropDownItems();
+ }
+ base.OnDropDownShow(e);
+ }
+
+ protected override void OnButtonClick(EventArgs e)
+ {
+ if (!buttonEnabled) {
+ return;
+ }
+ base.OnButtonClick(e);
+ menuCommand.Run();
+ }
+
+ public override bool Enabled {
+ get {
+ if (codon == null) {
+ return base.Enabled;
+ }
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+
+ bool isEnabled = failedAction != ConditionFailedAction.Disable;
+
+ if (menuCommand != null && menuCommand is IMenuCommand) {
+
+ // menuCommand.IsEnabled is checked first so that it's get method can set dropDownEnabled as needed
+ isEnabled &= (((IMenuCommand)menuCommand).IsEnabled || dropDownEnabled);
+ }
+
+ return isEnabled;
+ }
+ }
+
+ public bool ButtonEnabled {
+ get {
+ return buttonEnabled;
+ }
+ set {
+ buttonEnabled = value;
+ UpdateButtonImage();
+ }
+ }
+
+ private void UpdateButtonImage()
+ {
+ //LoggingService.Info("UpdatingButtonImage: buttonEnabled=="+buttonEnabled.ToString());
+ Image = buttonEnabled ? imgButtonEnabled : imgButtonDisabled;
+ }
+
+ public bool DropDownEnabled {
+ get {
+ return dropDownEnabled;
+ }
+ set {
+ dropDownEnabled = value;
+ }
+ }
+
+ public virtual void UpdateStatus()
+ {
+ if (codon != null) {
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+ bool isVisible = failedAction != ConditionFailedAction.Exclude;
+ if (base.Visible != isVisible) {
+ base.Visible = isVisible;
+ }
+
+ if (this.Visible) {
+ if (buttonEnabled && imgButtonEnabled!=null) {
+ Image = imgButtonEnabled;
+ } else if (imgButtonDisabled!=null) {
+ Image = imgButtonDisabled;
+ }
+ }
+ base.Enabled = this.Enabled; // fix for SD2-938 suggested by Matt Ward
+ }
+ }
+
+ public virtual void UpdateText()
+ {
+ if (codon != null) {
+ if (codon.Properties.Contains("tooltip")) {
+ ToolTipText = StringParser.Parse(codon.Properties["tooltip"]);
+ }
+
+ if (codon.Properties.Contains("label")){
+ Text = StringParser.Parse(codon.Properties["label"]);
+ }
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarTextBox.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarTextBox.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/ToolBar/ToolBarTextBox.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,105 @@
+// <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>
+
+using System;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ public class ToolBarTextBox : ToolStripTextBox, IStatusUpdate
+ {
+ object caller;
+ Codon codon;
+ string description = String.Empty;
+ ITextBoxCommand menuCommand = null;
+
+ public object Caller {
+ get {
+ return caller;
+ }
+ }
+
+ public string Description {
+ get {
+ return description;
+ }
+ set {
+ description = value;
+ }
+ }
+
+ public ITextBoxCommand MenuCommand {
+ get {
+ return menuCommand;
+ }
+ }
+
+ public ToolBarTextBox(Codon codon, object caller)
+ {
+ this.RightToLeft = RightToLeft.Inherit;
+ this.caller = caller;
+ this.codon = codon;
+
+ TextBox.KeyDown += new KeyEventHandler(TextBox_KeyDown);
+
+ menuCommand = (ITextBoxCommand)codon.AddIn.CreateObject(codon.Properties["class"]);
+ menuCommand.Owner = this;
+ if (menuCommand == null) {
+ throw new NullReferenceException("Can't create textbox toolbox command");
+ }
+ UpdateText();
+ UpdateStatus();
+ }
+
+ void TextBox_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.Enter)
+ {
+ MenuCommand.Run();
+ }
+ }
+
+ public override bool Enabled {
+ get {
+ if (codon == null) {
+ return base.Enabled;
+ }
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+
+ bool isEnabled = failedAction != ConditionFailedAction.Disable;
+
+ if (menuCommand != null) {
+ isEnabled &= menuCommand.IsEnabled;
+ }
+
+ return isEnabled;
+ }
+ }
+
+ public virtual void UpdateStatus()
+ {
+ bool isVisible = base.Visible;
+ if (codon != null) {
+ ConditionFailedAction failedAction = codon.GetFailedAction(caller);
+ isVisible &= failedAction != ConditionFailedAction.Exclude;
+ }
+ if (base.Visible != isVisible) {
+ Visible = isVisible;
+ }
+ }
+
+ public virtual void UpdateText()
+ {
+ if (codon.Properties.Contains("label")) {
+ Text = StringParser.Parse(codon.Properties["label"]);
+ }
+ if (codon.Properties.Contains("tooltip")) {
+ ToolTipText = StringParser.Parse(codon.Properties["tooltip"]);
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/ClipboardWrapper.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/ClipboardWrapper.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/ClipboardWrapper.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,95 @@
+// <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>
+
+using System;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ /// <summary>
+ /// Helper class to access the clipboard without worrying about ExternalExceptions
+ /// </summary>
+ public static class ClipboardWrapper
+ {
+ public static bool ContainsText {
+ get {
+ try {
+ return Clipboard.ContainsText();
+ } catch (ExternalException) {
+ return false;
+ }
+ }
+ }
+
+ public static string GetText()
+ {
+ // retry 2 times should be enough for read access
+ try {
+ return Clipboard.GetText();
+ } catch (ExternalException) {
+ return Clipboard.GetText();
+ }
+ }
+
+ public static void SetText(string text)
+ {
+ DataObject data = new DataObject();
+ data.SetData(DataFormats.UnicodeText, true, text);
+ SetDataObject(data);
+ }
+
+ /// <summary>
+ /// Gets the current clipboard content.
+ /// Can return null!
+ /// </summary>
+ public static IDataObject GetDataObject()
+ {
+ // retry 2 times should be enough for read access
+ try {
+ return Clipboard.GetDataObject();
+ } catch (ExternalException) {
+ try {
+ return Clipboard.GetDataObject();
+ } catch (ExternalException) {
+ return null;
+ }
+ }
+ }
+
+ public static void SetDataObject(object data)
+ {
+ SafeSetClipboard(data);
+ }
+
+ // Code duplication: TextAreaClipboardHandler.cs also has SafeSetClipboard
+ [ThreadStatic] static int SafeSetClipboardDataVersion;
+
+ static void SafeSetClipboard(object dataObject)
+ {
+ // Work around ExternalException bug. (SD2-426)
+ // Best reproducable inside Virtual PC.
+ int version = unchecked(++SafeSetClipboardDataVersion);
+ try {
+ Clipboard.SetDataObject(dataObject, true);
+ } catch (ExternalException) {
+ Timer timer = new Timer();
+ timer.Interval = 100;
+ timer.Tick += delegate {
+ timer.Stop();
+ timer.Dispose();
+ if (SafeSetClipboardDataVersion == version) {
+ try {
+ Clipboard.SetDataObject(dataObject, true, 10, 50);
+ } catch (ExternalException) { }
+ }
+ };
+ timer.Start();
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/NativeMethods.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/NativeMethods.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/NativeMethods.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,19 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <author name="Daniel Grunwald"/>
+// <version>$Revision: 3722 $</version>
+// </file>
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace ICSharpCode.Core.WinForms
+{
+ static class NativeMethods
+ {
+ [DllImport("user32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool DestroyIcon(IntPtr handle);
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/RightToLeftConverter.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/RightToLeftConverter.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/Util/RightToLeftConverter.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,160 @@
+// <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>
+
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ /// <summary>
+ /// Description of RightToLeftConverter.
+ /// </summary>
+ public static class RightToLeftConverter
+ {
+ public static string[] RightToLeftLanguages = new string[] {"ar", "he", "fa", "urdu"};
+
+ 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;
+ bool left = (anchor & AnchorStyles.Left ) == AnchorStyles.Left ;
+ if (right) {
+ anchor = anchor | AnchorStyles.Left;
+ } else {
+ anchor = anchor & ~AnchorStyles.Left;
+ }
+ if (left) {
+ anchor = anchor | AnchorStyles.Right;
+ } else {
+ anchor = anchor & ~AnchorStyles.Right;
+ }
+ return anchor;
+ }
+
+ static Point MirrorLocation(Control control)
+ {
+ return new Point(control.Parent.ClientSize.Width - control.Left - control.Width,
+ control.Top);
+ }
+
+ /// <summary>
+ /// Mirrors a control and its child controls if right to left is activated.
+ /// Call this only for controls that aren't mirrored automatically by .NET!
+ /// </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;
+ }
+ // Panels with RightToLeft = No won't have their children mirrored
+ if (control.RightToLeft != RightToLeft.Yes)
+ return;
+ foreach (Control child in control.Controls) {
+ Mirror(child);
+ }
+ }
+
+ public static void Convert(Control control)
+ {
+ bool isRTL = IsRightToLeft;
+ if (isRTL) {
+ if (control.RightToLeft != RightToLeft.Yes)
+ control.RightToLeft = RightToLeft.Yes;
+ } else {
+ if (control.RightToLeft == RightToLeft.Yes)
+ control.RightToLeft = RightToLeft.No;
+ }
+ ConvertLayout(control);
+ }
+
+ static void ConvertLayout(Control control)
+ {
+ bool isRTL = IsRightToLeft;
+
+ DateTimePicker picker = control as DateTimePicker;
+ Form form = control as Form;
+ ListView listView = control as ListView;
+ ProgressBar pg = control as ProgressBar;
+ TabControl tc = control as TabControl;
+ TrackBar trb = control as TrackBar;
+ TreeView treeView = control as TreeView;
+ if (form != null && form.RightToLeftLayout != isRTL)
+ form.RightToLeftLayout = isRTL;
+ if (listView != null && listView.RightToLeftLayout != isRTL)
+ listView.RightToLeftLayout = isRTL;
+ if (pg != null && pg.RightToLeftLayout != isRTL)
+ pg.RightToLeftLayout = isRTL;
+ if (tc != null && tc.RightToLeftLayout != isRTL)
+ tc.RightToLeftLayout = isRTL;
+ if (trb != null && trb.RightToLeftLayout != isRTL)
+ trb.RightToLeftLayout = isRTL;
+ if (treeView != null && treeView.RightToLeftLayout != isRTL)
+ treeView.RightToLeftLayout = isRTL;
+ }
+
+ static void ConvertLayoutRecursive(Control control)
+ {
+ bool isRTL = IsRightToLeft;
+ if (isRTL == (control.RightToLeft == RightToLeft.Yes)) {
+ ConvertLayout(control);
+ foreach (Control child in control.Controls) {
+ ConvertLayoutRecursive(child);
+ }
+ }
+ }
+
+ public static void ConvertRecursive(Control control)
+ {
+ if (IsRightToLeft == (control.RightToLeft == RightToLeft.Yes)) {
+ // already converted
+ return;
+ }
+ ReConvertRecursive(control);
+ }
+
+ public static void ReConvertRecursive(Control control)
+ {
+ Convert(control);
+ foreach (Control child in control.Controls) {
+ ConvertLayoutRecursive(child);
+ }
+ if (IsRightToLeft) {
+ if (control is Form) {
+ // direct children seem to be mirrored by .NET
+ foreach (Control child in control.Controls) {
+ foreach (Control subChild in child.Controls) {
+ Mirror(subChild);
+ }
+ }
+ } else {
+ foreach (Control child in control.Controls) {
+ Mirror(child);
+ }
+ }
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/WinFormsResourceService.cs
===================================================================
--- sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/WinFormsResourceService.cs (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.Core.WinForms/WinFormsResourceService.cs 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,234 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Daniel Grunwald"/>
+// <version>$Revision: 3722 $</version>
+// </file>
+
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace ICSharpCode.Core.WinForms
+{
+ /// <summary>
+ /// This Class contains two ResourceManagers, which handle string and image resources
+ /// for the application. It do handle localization strings on this level.
+ /// </summary>
+ public static class WinFormsResourceService
+ {
+ static Dictionary<string, Icon> iconCache = new Dictionary<string, Icon>();
+ static Dictionary<string, Bitmap> bitmapCache = new Dictionary<string, Bitmap>();
+
+ static WinFormsResourceService()
+ {
+ ResourceService.ClearCaches += ResourceService_ClearCaches;
+ }
+
+ static void ResourceService_ClearCaches(object sender, EventArgs e)
+ {
+ lock (iconCache) {
+ iconCache.Clear();
+ }
+ lock (bitmapCache) {
+ bitmapCache.Clear();
+ }
+ }
+
+ #region Font loading
+ static Font defaultMonospacedFont;
+
+ public static Font DefaultMonospacedFont {
+ get {
+ if (defaultMonospacedFont == null) {
+ defaultMonospacedFont = LoadDefaultMonospacedFont(FontStyle.Regular);
+ }
+ return defaultMonospacedFont;
+ }
+ }
+
+ /// <summary>
+ /// Loads the default monospaced font (Consolas or Courier New).
+ /// </summary>
+ public static Font LoadDefaultMonospacedFont(FontStyle style)
+ {
+ if (Environment.OSVersion.Platform == PlatformID.Win32NT
+ && Environment.OSVersion.Version.Major >= 6)
+ {
+ return LoadFont("Consolas", 10, style);
+ } else {
+ return LoadFont("Courier New", 10, style);
+ }
+ }
+
+ /// <summary>
+ /// The LoadFont routines provide a safe way to load fonts.
+ /// </summary>
+ /// <param name="fontName">The name of the font to load.</param>
+ /// <param name="size">The size of the font to load.</param>
+ /// <returns>
+ /// The font to load or the menu font, if the requested font couldn't be loaded.
+ /// </returns>
+ public static Font LoadFont(string fontName, int size)
+ {
+ return LoadFont(fontName, size, FontStyle.Regular);
+ }
+
+ /// <summary>
+ /// The LoadFont routines provide a safe way to load fonts.
+ /// </summary>
+ /// <param name="fontName">The name of the font to load.</param>
+ /// <param name="size">The size of the font to load.</param>
+ /// <param name="style">The <see cref="System.Drawing.FontStyle"/> of the font</param>
+ /// <returns>
+ /// The font to load or the menu font, if the requested font couldn't be loaded.
+ /// </returns>
+ public static Font LoadFont(string fontName, int size, FontStyle style)
+ {
+ try {
+ return new Font(fontName, size, style);
+ } catch (Exception ex) {
+ LoggingService.Warn(ex);
+ return SystemInformation.MenuFont;
+ }
+ }
+
+ /// <summary>
+ /// The LoadFont routines provide a safe way to load fonts.
+ /// </summary>
+ /// <param name="fontName">The name of the font to load.</param>
+ /// <param name="size">The size of the font to load.</param>
+ /// <param name="unit">The <see cref="System.Drawing.GraphicsUnit"/> of the font</param>
+ /// <returns>
+ /// The font to load or the menu font, if the requested font couldn't be loaded.
+ /// </returns>
+ public static Font LoadFont(string fontName, int size, GraphicsUnit unit)
+ {
+ return LoadFont(fontName, size, FontStyle.Regular, unit);
+ }
+
+ /// <summary>
+ /// The LoadFont routines provide a safe way to load fonts.
+ /// </summary>
+ /// <param name="fontName">The name of the font to load.</param>
+ /// <param name="size">The size of the font to load.</param>
+ /// <param name="style">The <see cref="System.Drawing.FontStyle"/> of the font</param>
+ /// <param name="unit">The <see cref="System.Drawing.GraphicsUnit"/> of the font</param>
+ /// <returns>
+ /// The font to load or the menu font, if the requested font couldn't be loaded.
+ /// </returns>
+ public static Font LoadFont(string fontName, int size, FontStyle style, GraphicsUnit unit)
+ {
+ try {
+ return new Font(fontName, size, style, unit);
+ } catch (Exception ex) {
+ LoggingService.Warn(ex);
+ return SystemInformation.MenuFont;
+ }
+ }
+
+ /// <summary>
+ /// The LoadFont routines provide a safe way to load fonts.
+ /// </summary>
+ /// <param name="baseFont">The existing font from which to create the new font.</param>
+ /// <param name="newStyle">The new style of the font.</param>
+ /// <returns>
+ /// The font to load or the baseFont (if the requested font couldn't be loaded).
+ /// </returns>
+ public static Font LoadFont(Font baseFont, FontStyle newStyle)
+ {
+ try {
+ return new Font(baseFont, newStyle);
+ } catch (Exception ex) {
+ LoggingService.Warn(ex);
+ return baseFont;
+ }
+ }
+ #endregion
+
+ /// <summary>
+ /// Returns a icon from the resource database, it handles localization
+ /// transparent for the user. In the resource database can be a bitmap
+ /// instead of an icon in the dabase. It is converted automatically.
+ /// </summary>
+ /// <returns>
+ /// The icon in the (localized) resource database, or null, if the icon cannot
+ /// be found.
+ /// </returns>
+ /// <param name="name">
+ /// The name of the requested icon.
+ /// </param>
+ public static Icon GetIcon(string name)
+ {
+ lock (iconCache) {
+ Icon ico;
+ if (iconCache.TryGetValue(name, out ico))
+ return ico;
+
+ object iconobj = ResourceService.GetImageResource(name);
+ if (iconobj == null) {
+ return null;
+ }
+ if (iconobj is Icon) {
+ ico = (Icon)iconobj;
+ } else {
+ ico = BitmapToIcon((Bitmap)iconobj);
+ }
+ iconCache[name] = ico;
+ return ico;
+ }
+ }
+
+ /// <summary>
+ /// Converts a bitmap into an icon.
+ /// </summary>
+ public static Icon BitmapToIcon(Bitmap bmp)
+ {
+ IntPtr hIcon = bmp.GetHicon();
+ try {
+ using (Icon tempIco = Icon.FromHandle(hIcon)) {
+ // Icon.FromHandle creates a Icon object that uses the HIcon but does
+ // not own it. We could leak HIcons on language changes.
+ // We have no idea when we may dispose the icons after a language change
+ // (they could still be used), so we'll have to create an owned icon.
+ // Unfortunately, there's no Icon.FromHandle(IntPtr,bool takeOwnership) method.
+ // We could use reflection to set the ownHandle field; or we create a copy of the icon
+ // and immediately destroy the original
+ return new Icon(tempIco, tempIco.Width, tempIco.Height);
+ } // dispose tempico, doesn't do much because the icon isn't owned
+ } finally {
+ NativeMethods.DestroyIcon(hIcon);
+ }
+ }
+
+ /// <summary>
+ /// Returns a bitmap from the resource database, it handles localization
+ /// transparent for the user.
+ /// The bitmaps are reused, you must not dispose the Bitmap!
+ /// </summary>
+ /// <returns>
+ /// The bitmap in the (localized) resource database.
+ /// </returns>
+ /// <param name="name">
+ /// The name of the requested bitmap.
+ /// </param>
+ /// <exception cref="ResourceNotFoundException">
+ /// Is thrown when the GlobalResource manager can't find a requested resource.
+ /// </exception>
+ public static Bitmap GetBitmap(string name)
+ {
+ lock (bitmapCache) {
+ Bitmap bmp;
+ if (bitmapCache.TryGetValue(name, out bmp))
+ return bmp;
+ bmp = (Bitmap)ResourceService.GetImageResource(name);
+ if (bmp == null) {
+ throw new ResourceNotFoundException(name);
+ }
+ bitmapCache[name] = bmp;
+ return bmp;
+ }
+ }
+ }
+}
Added: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.SharpDevelop.snk
===================================================================
(Binary files differ)
Property changes on: sandbox/maestro-2.5/Thirdparty/SharpDevelop/ICSharpCode.SharpDevelop.snk
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: sandbox/maestro-2.5/Thirdparty/TF.NET/Homepage.txt
===================================================================
--- sandbox/maestro-2.5/Thirdparty/TF.NET/Homepage.txt (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/TF.NET/Homepage.txt 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1 @@
+http://code.google.com/p/tf-net/
\ No newline at end of file
Added: sandbox/maestro-2.5/Thirdparty/TF.NET/License.txt
===================================================================
--- sandbox/maestro-2.5/Thirdparty/TF.NET/License.txt (rev 0)
+++ sandbox/maestro-2.5/Thirdparty/TF.NET/License.txt 2010-05-11 09:13:32 UTC (rev 4847)
@@ -0,0 +1,153 @@
+NetTopologySuite is a collection of .NET classes written in C# that
+implement the fundamental operations required to validate a given
+geo-spatial data set to a known topological specification.
+
+This collection of classes is a porting (with some additions and modifications) of
+JTS Topology Suite (see next license for more informations).
+
+Copyright (C) 2005 Diego Guidi
+
+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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+For more information, contact:
+
+ Diego Guidi
+ via Po 15
+ 61031 Cuccurano di Fano (PU)
+ diegoguidi at libero.it
+ http://blogs.ugidotnet.org/gissharpblog
+
+
+
+
+Copy of JTS license:
+
+The JTS Topology Suite is a collection of Java classes that
+implement the fundamental operations required to validate a given
+geo-spatial data set to a known topological specification.
+Copyright (C) 2001 Vivid Solutions
+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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+For more information, contact:
+
+ Vivid Solutions
+ Suite #1A
+ 2328 Government Street
+ Victoria BC V8T 5G5
+ Canada
+ (250)385-6040
+ www.vividsolutions.com
+
+
+
+
+Copy of SharpMap license:
+
+Copyright 2005, 2006 - Morten Nielsen (www.iter.dk)
+
+This file is part of SharpMap.
+SharpMap 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 of the License, or
+(at your option) any later version.
+
+SharpMap 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 SharpMap; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+
+
+Copy of GeoTools.Net license:
+
+Copyright (C) 2002 Urban Science Applications, Inc. (translated from Java Topology Suite,
+Copyright 2001 Vivid Solutions)
+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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+
+
+
+Copy of RTools.Util license:
+
+Copyright (C) 2003 Ryan Seghers
+This software is provided AS IS. No warranty is granted,
+neither expressed nor implied. USE THIS SOFTWARE AT YOUR OWN RISK.
+NO REPRESENTATION OF MERCHANTABILITY or FITNESS FOR ANY
+PURPOSE is given.
+License to use this software is limited by the following terms:
+1) This code may be used in any program, including programs developed
+ for commercial purposes, provided that this notice is included verbatim.
+Also, in return for using this code, please attempt to make your fixes and
+updates available in some way, such as by sending your updates to the
+author.
+
+
+
+
+Copy of Iesi.Collections license:
+
+The entire code of this directory has been downloaded from the following
+URL: http://www.codeproject.com/csharp/sets.asp#xx1297496xx
+We are using the code here without any change. The author (Jason Smith) is
+stating the license terms in the same URL stated above as follow:
+-------------------------------------------------------------------------
+ Re: Commercial use of library JasonSmith 21:15 5 Dec '05
+
+...
+Use the software however you want. It's free to all, the source code is free
+to all, and if you use it, you own it. Heck, sell it if you can find someone
+dumb enough to pay for it. I don't care how you use it as long as you don't
+come looking for me if something goes wrong.
+
+
+
+
+
+Copy of Iesi.Collections.Generic license:
+
+The entire code of this directory has been downloaded from the following
+URL: http://www.codeproject.com/csharp/GenericISet.asp?df=100&forumid=264315&select=1474616&msg=1474616
+We are using the code here without any change. The author (Kailuo Wang) is
+stating the license terms in the same URL stated above as follow:
+-------------------------------------------------------------------------
+ Re: What about license? Kailuo Wang 04 May '06
+
+You can use it whatever you want.
+It's under the same license as the original Iesi.Collections.
\ No newline at end of file
Added: sandbox/maestro-2.5/Thirdparty/TF.NET/Topology.IO.MapGuide.dll
===================================================================
(Binary files differ)
Property changes on: sandbox/maestro-2.5/Thirdparty/TF.NET/Topology.IO.MapGuide.dll
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: sandbox/maestro-2.5/Thirdparty/TF.NET/Topology.dll
===================================================================
(Binary files differ)
Property changes on: sandbox/maestro-2.5/Thirdparty/TF.NET/Topology.dll
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
More information about the mapguide-commits
mailing list