diff options
author | Lluis Sanchez <lluis@novell.com> | 2010-05-25 17:01:55 +0400 |
---|---|---|
committer | Lluis Sanchez <lluis@novell.com> | 2010-05-25 17:01:55 +0400 |
commit | cd1df7b2a4cb170c95f2ea5b1e9cd0f7d89ba14f (patch) | |
tree | 2d99153a70973deb049e981e08366c81fa98484c | |
parent | d7891dffe05da3eceae63f69ccc3fdf01a5b6c58 (diff) |
Added new sample.
svn path=/trunk/mono-addins/; revision=157842
58 files changed, 1767 insertions, 0 deletions
@@ -1,3 +1,8 @@ +2010-05-25 Lluis Sanchez Gual <lluis@novell.com> + + * Samples/Samples.mdw: + * Samples/TextEditorSWF: Added new sample + 2010-03-24 Lluis Sanchez Gual <lluis@novell.com> * Makefile.am: diff --git a/Samples/Samples.mdw b/Samples/Samples.mdw index 4b3b1c9..2f451b1 100644 --- a/Samples/Samples.mdw +++ b/Samples/Samples.mdw @@ -4,5 +4,6 @@ <Item>TextEditor/TextEditor.sln</Item> <Item>WriterService/WriterService.sln</Item> <Item>HelloWorldWithManifest/HelloWorldWithManifest.sln</Item> + <Item>TextEditorSWF/TextEditorSWF.sln</Item> </Items> </WorkspaceItem>
\ No newline at end of file diff --git a/Samples/TextEditorSWF/ChangeLog b/Samples/TextEditorSWF/ChangeLog new file mode 100644 index 0000000..075f2b0 --- /dev/null +++ b/Samples/TextEditorSWF/ChangeLog @@ -0,0 +1,7 @@ +2010-05-25 Lluis Sanchez Gual <lluis@novell.com> + + * DateAddin: + * TextEditorSWF: + * SnippetsAddin: + * TextEditorSWF.sln: Added new sample + diff --git a/Samples/TextEditorSWF/DateAddin/ChangeLog b/Samples/TextEditorSWF/DateAddin/ChangeLog new file mode 100644 index 0000000..2df2ffc --- /dev/null +++ b/Samples/TextEditorSWF/DateAddin/ChangeLog @@ -0,0 +1,8 @@ +2010-05-25 Lluis Sanchez Gual <lluis@novell.com> + + * Properties: + * MainMenu.addin: + * DateSnippet.cs: + * DateAddin.csproj: + * InsertDateCommand.cs: Added new sample + diff --git a/Samples/TextEditorSWF/DateAddin/DateAddin.csproj b/Samples/TextEditorSWF/DateAddin/DateAddin.csproj new file mode 100755 index 0000000..8cd1230 --- /dev/null +++ b/Samples/TextEditorSWF/DateAddin/DateAddin.csproj @@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.21022</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{D54B7805-BC96-4861-8352-DA403F430CD7}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>DateAddin</RootNamespace>
+ <AssemblyName>DateAddin</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>..\TextEditorSWF\bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ <Reference Include="Mono.Addins, Version=0.5.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\bin\Mono.Addins.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="DateSnippet.cs" />
+ <Compile Include="InsertDateCommand.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\SnippetsAddin\SnippetsAddin.csproj">
+ <Project>{54542FD2-7B2E-4CEB-874C-BB50CF4812FE}</Project>
+ <Name>SnippetsAddin</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\TextEditorSWF\TextEditorSWF.csproj">
+ <Project>{85480AD8-781F-43FC-A48F-91962401DB95}</Project>
+ <Name>TextEditorSWF</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="MainMenu.addin" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file diff --git a/Samples/TextEditorSWF/DateAddin/DateSnippet.cs b/Samples/TextEditorSWF/DateAddin/DateSnippet.cs new file mode 100755 index 0000000..ae6a759 --- /dev/null +++ b/Samples/TextEditorSWF/DateAddin/DateSnippet.cs @@ -0,0 +1,25 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using SnippetsAddin;
+using Mono.Addins;
+
+[assembly: Addin]
+[assembly: AddinDependency ("TextEditor.Core", "1.0")]
+[assembly: AddinDependency ("TextEditor.SnippetsAddin", "1.0")]
+
+namespace DateAddin
+{
+ [Extension]
+ public class DateSnippet: ISnippetProvider
+ {
+ public string GetText (string shortcut)
+ {
+ if (shortcut == "date")
+ return DateTime.Now.ToShortDateString ();
+ else
+ return null;
+ }
+ }
+}
diff --git a/Samples/TextEditorSWF/DateAddin/InsertDateCommand.cs b/Samples/TextEditorSWF/DateAddin/InsertDateCommand.cs new file mode 100755 index 0000000..ef7601d --- /dev/null +++ b/Samples/TextEditorSWF/DateAddin/InsertDateCommand.cs @@ -0,0 +1,19 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using TextEditorSWF.ExtensionModel;
+using TextEditorSWF;
+using System.Windows.Forms;
+
+namespace DateAddin
+{
+ [Command ("Insert Date")]
+ class InsertDateCommand: ICommand
+ {
+ public void Run ()
+ {
+ Program.MainWindow.Editor.SelectedText = DateTime.Now.ToShortDateString ();
+ }
+ }
+}
diff --git a/Samples/TextEditorSWF/DateAddin/MainMenu.addin b/Samples/TextEditorSWF/DateAddin/MainMenu.addin new file mode 100755 index 0000000..e1536c6 --- /dev/null +++ b/Samples/TextEditorSWF/DateAddin/MainMenu.addin @@ -0,0 +1,6 @@ +<ExtensionModel>
+ <Extension path="/TextEditor/MainMenu/Edit">
+ <Separator />
+ <Command id="DateAddin.InsertDateCommand" />
+ </Extension>
+</ExtensionModel>
\ No newline at end of file diff --git a/Samples/TextEditorSWF/DateAddin/Properties/AssemblyInfo.cs b/Samples/TextEditorSWF/DateAddin/Properties/AssemblyInfo.cs new file mode 100755 index 0000000..173b3b2 --- /dev/null +++ b/Samples/TextEditorSWF/DateAddin/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle ("DateAddin")]
+[assembly: AssemblyDescription ("")]
+[assembly: AssemblyConfiguration ("")]
+[assembly: AssemblyCompany ("")]
+[assembly: AssemblyProduct ("DateAddin")]
+[assembly: AssemblyCopyright ("Copyright © 2010")]
+[assembly: AssemblyTrademark ("")]
+[assembly: AssemblyCulture ("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible (false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid ("1ef9e97b-cb49-4c26-8eb0-734c3ecb4eb2")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion ("1.0.0.0")]
+[assembly: AssemblyFileVersion ("1.0.0.0")]
diff --git a/Samples/TextEditorSWF/DateAddin/Properties/ChangeLog b/Samples/TextEditorSWF/DateAddin/Properties/ChangeLog new file mode 100644 index 0000000..976e432 --- /dev/null +++ b/Samples/TextEditorSWF/DateAddin/Properties/ChangeLog @@ -0,0 +1,4 @@ +2010-05-25 Lluis Sanchez Gual <lluis@novell.com> + + * AssemblyInfo.cs: Added new sample + diff --git a/Samples/TextEditorSWF/SnippetsAddin/ChangeLog b/Samples/TextEditorSWF/SnippetsAddin/ChangeLog new file mode 100644 index 0000000..ea738d5 --- /dev/null +++ b/Samples/TextEditorSWF/SnippetsAddin/ChangeLog @@ -0,0 +1,9 @@ +2010-05-25 Lluis Sanchez Gual <lluis@novell.com> + + * Properties: + * StockSnippets.cs: + * SnippetsAddin.cs: + * ISnippetProvider.cs: + * SnippetsAddin.csproj: + * StockSnippetProvider.cs: Added new sample + diff --git a/Samples/TextEditorSWF/SnippetsAddin/ISnippetProvider.cs b/Samples/TextEditorSWF/SnippetsAddin/ISnippetProvider.cs new file mode 100755 index 0000000..6d46990 --- /dev/null +++ b/Samples/TextEditorSWF/SnippetsAddin/ISnippetProvider.cs @@ -0,0 +1,17 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Mono.Addins;
+
+namespace SnippetsAddin
+{
+ /// <summary>
+ /// Extension point for snippet providers.
+ /// </summary>
+ [TypeExtensionPoint]
+ public interface ISnippetProvider
+ {
+ string GetText (string shortcut);
+ }
+}
diff --git a/Samples/TextEditorSWF/SnippetsAddin/Properties/AssemblyInfo.cs b/Samples/TextEditorSWF/SnippetsAddin/Properties/AssemblyInfo.cs new file mode 100755 index 0000000..4acffcd --- /dev/null +++ b/Samples/TextEditorSWF/SnippetsAddin/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle ("SnippetsAddin")]
+[assembly: AssemblyDescription ("")]
+[assembly: AssemblyConfiguration ("")]
+[assembly: AssemblyCompany ("")]
+[assembly: AssemblyProduct ("SnippetsAddin")]
+[assembly: AssemblyCopyright ("Copyright © 2010")]
+[assembly: AssemblyTrademark ("")]
+[assembly: AssemblyCulture ("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible (false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid ("5c440446-9242-4848-af10-5faf2cbad647")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion ("1.0.0.0")]
+[assembly: AssemblyFileVersion ("1.0.0.0")]
diff --git a/Samples/TextEditorSWF/SnippetsAddin/Properties/ChangeLog b/Samples/TextEditorSWF/SnippetsAddin/Properties/ChangeLog new file mode 100644 index 0000000..976e432 --- /dev/null +++ b/Samples/TextEditorSWF/SnippetsAddin/Properties/ChangeLog @@ -0,0 +1,4 @@ +2010-05-25 Lluis Sanchez Gual <lluis@novell.com> + + * AssemblyInfo.cs: Added new sample + diff --git a/Samples/TextEditorSWF/SnippetsAddin/SnippetsAddin.cs b/Samples/TextEditorSWF/SnippetsAddin/SnippetsAddin.cs new file mode 100755 index 0000000..fe8c928 --- /dev/null +++ b/Samples/TextEditorSWF/SnippetsAddin/SnippetsAddin.cs @@ -0,0 +1,55 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using Mono.Addins;
+using TextEditorSWF.ExtensionModel;
+using TextEditorSWF;
+
+[assembly: Addin ("SnippetsAddin","1.0", Namespace="TextEditor")]
+[assembly: AddinDependency ("Core", "1.0")]
+
+namespace SnippetsAddin
+{
+ [Extension]
+ public class SnippetsExtension: EditorExtension
+ {
+ public override void Initialize ()
+ {
+ Program.MainWindow.Editor.KeyPress += new KeyPressEventHandler (EditorKeyPress);
+ }
+
+ void EditorKeyPress (object sender, KeyPressEventArgs e)
+ {
+ if (e.KeyChar != '\t')
+ return;
+ RichTextBox editor = Program.MainWindow.Editor;
+ int p = editor.SelectionStart - 1;
+ string txt = editor.Text;
+ while (p >= 0 && char.IsLetterOrDigit (txt[p]))
+ p--;
+ p++;
+ string word = txt.Substring (p, editor.SelectionStart - p);
+
+ foreach (ISnippetProvider provider in AddinManager.GetExtensionObjects <ISnippetProvider>()) {
+ string fullText = provider.GetText (word);
+ if (fullText != null) {
+ int nextp;
+ int cursorPos = fullText.IndexOf ("<|>");
+ if (cursorPos != -1) {
+ fullText = fullText.Remove (cursorPos, 3);
+ nextp = p + cursorPos;
+ }
+ else
+ nextp = p + fullText.Length;
+
+ editor.Text = txt.Substring (0, p) + fullText + txt.Substring (editor.SelectionStart);
+ editor.SelectionStart = nextp;
+ e.Handled = true;
+ return;
+ }
+ }
+ }
+ }
+}
diff --git a/Samples/TextEditorSWF/SnippetsAddin/SnippetsAddin.csproj b/Samples/TextEditorSWF/SnippetsAddin/SnippetsAddin.csproj new file mode 100755 index 0000000..a30ab50 --- /dev/null +++ b/Samples/TextEditorSWF/SnippetsAddin/SnippetsAddin.csproj @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.21022</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{54542FD2-7B2E-4CEB-874C-BB50CF4812FE}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>SnippetsAddin</RootNamespace>
+ <AssemblyName>SnippetsAddin</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>..\TextEditorSWF\bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>..\TextEditorSWF\bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ <Reference Include="Mono.Addins, Version=0.5.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\bin\Mono.Addins.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="ISnippetProvider.cs" />
+ <Compile Include="StockSnippetProvider.cs" />
+ <Compile Include="SnippetsAddin.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="StockSnippets.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\TextEditorSWF\TextEditorSWF.csproj">
+ <Project>{85480AD8-781F-43FC-A48F-91962401DB95}</Project>
+ <Name>TextEditorSWF</Name>
+ <Private>False</Private>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file diff --git a/Samples/TextEditorSWF/SnippetsAddin/StockSnippetProvider.cs b/Samples/TextEditorSWF/SnippetsAddin/StockSnippetProvider.cs new file mode 100755 index 0000000..dd87846 --- /dev/null +++ b/Samples/TextEditorSWF/SnippetsAddin/StockSnippetProvider.cs @@ -0,0 +1,44 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Mono.Addins;
+using SnippetsAddin;
+
+[assembly: ExtensionPoint ("/TextEditor/StockSnippets", ExtensionAttributeType = typeof (SnippetsAddin.SnippetAttribute))]
+
+namespace SnippetsAddin
+{
+ [Extension]
+ class StockSnippetProvider: ISnippetProvider
+ {
+ public string GetText (string shortcut)
+ {
+ foreach (ExtensionNode<SnippetAttribute> node in AddinManager.GetExtensionNodes ("/TextEditor/StockSnippets")) {
+ if (node.Data.Shortcut == shortcut)
+ return node.Data.Text;
+ }
+ return null;
+ }
+ }
+
+ [AttributeUsage (AttributeTargets.Assembly, AllowMultiple=true)]
+ public class SnippetAttribute : CustomExtensionAttribute
+ {
+ public SnippetAttribute ()
+ {
+ }
+
+ public SnippetAttribute ([NodeAttribute ("Shortcut")] string shortcut, [NodeAttribute ("Text")] string text)
+ {
+ Shortcut = shortcut;
+ Text = Text;
+ }
+
+ [NodeAttribute]
+ public string Shortcut { get; set; }
+
+ [NodeAttribute]
+ public string Text { get; set; }
+ }
+}
diff --git a/Samples/TextEditorSWF/SnippetsAddin/StockSnippets.cs b/Samples/TextEditorSWF/SnippetsAddin/StockSnippets.cs new file mode 100755 index 0000000..ae77d16 --- /dev/null +++ b/Samples/TextEditorSWF/SnippetsAddin/StockSnippets.cs @@ -0,0 +1,5 @@ +using System;
+using SnippetsAddin;
+
+[assembly: Snippet ("for", "for (int n=0; n<len; n++)\n{\n\t<|>\n}")]
+[assembly: Snippet ("foreach", "foreach (var item in col)\n{\n\t<|>\n}")]
diff --git a/Samples/TextEditorSWF/TextEditorSWF.sln b/Samples/TextEditorSWF/TextEditorSWF.sln new file mode 100644 index 0000000..e352dc8 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF.sln @@ -0,0 +1,35 @@ +
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextEditorSWF", "TextEditorSWF\TextEditorSWF.csproj", "{85480AD8-781F-43FC-A48F-91962401DB95}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SnippetsAddin", "SnippetsAddin\SnippetsAddin.csproj", "{54542FD2-7B2E-4CEB-874C-BB50CF4812FE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DateAddin", "DateAddin\DateAddin.csproj", "{D54B7805-BC96-4861-8352-DA403F430CD7}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {54542FD2-7B2E-4CEB-874C-BB50CF4812FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {54542FD2-7B2E-4CEB-874C-BB50CF4812FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {54542FD2-7B2E-4CEB-874C-BB50CF4812FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {54542FD2-7B2E-4CEB-874C-BB50CF4812FE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {85480AD8-781F-43FC-A48F-91962401DB95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {85480AD8-781F-43FC-A48F-91962401DB95}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {85480AD8-781F-43FC-A48F-91962401DB95}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {85480AD8-781F-43FC-A48F-91962401DB95}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D54B7805-BC96-4861-8352-DA403F430CD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D54B7805-BC96-4861-8352-DA403F430CD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D54B7805-BC96-4861-8352-DA403F430CD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D54B7805-BC96-4861-8352-DA403F430CD7}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = TextEditorSWF\TextEditorSWF.csproj
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Samples/TextEditorSWF/TextEditorSWF/ChangeLog b/Samples/TextEditorSWF/TextEditorSWF/ChangeLog new file mode 100644 index 0000000..f87f246 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/ChangeLog @@ -0,0 +1,13 @@ +2010-05-25 Lluis Sanchez Gual <lluis@novell.com> + + * Icons: + * Commands: + * Properties: + * Program.cs: + * TextEditor.cs: + * ExtensionModel: + * TextEditor.resx: + * CommandManager.cs: + * TextEditorSWF.csproj: + * TextEditor.Designer.cs: Added new sample + diff --git a/Samples/TextEditorSWF/TextEditorSWF/CommandManager.cs b/Samples/TextEditorSWF/TextEditorSWF/CommandManager.cs new file mode 100755 index 0000000..cb1272a --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/CommandManager.cs @@ -0,0 +1,46 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using TextEditorSWF.ExtensionModel;
+using Mono.Addins;
+
+namespace TextEditorSWF
+{
+ /// <summary>
+ /// Manages commands, menus and toolbars
+ /// </summary>
+ static class CommandManager
+ {
+ /// <summary>
+ /// Returns the list of items for the main menu
+ /// </summary>
+ public static IEnumerable<ToolStripItem> GetMainMenuItems ()
+ {
+ foreach (IUserInterfaceItem item in AddinManager.GetExtensionNodes ("/TextEditor/MainMenu"))
+ yield return item.CreateMenuItem ();
+ }
+
+ /// <summary>
+ /// Returns the list of items for the main toolbar
+ /// </summary>
+ public static IEnumerable<ToolStripItem> GetToolbarItems ()
+ {
+ foreach (IUserInterfaceItem item in AddinManager.GetExtensionNodes ("/TextEditor/Toolbar"))
+ yield return item.CreateButton ();
+ }
+
+ /// <summary>
+ /// Returns the extension node for the provided command identifier.
+ /// </summary>
+ internal static CommandExtensionNode GetCommand (string id)
+ {
+ foreach (CommandExtensionNode cmd in AddinManager.GetExtensionNodes (typeof (ICommand))) {
+ if (cmd.Id == id)
+ return cmd;
+ }
+ throw new InvalidOperationException ("Unknown command: " + id);
+ }
+ }
+}
diff --git a/Samples/TextEditorSWF/TextEditorSWF/Commands/ChangeLog b/Samples/TextEditorSWF/TextEditorSWF/Commands/ChangeLog new file mode 100644 index 0000000..81ae2fa --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Commands/ChangeLog @@ -0,0 +1,12 @@ +2010-05-25 Lluis Sanchez Gual <lluis@novell.com> + + * NewCommand.cs: + * Toolbar.addin: + * CutCommand.cs: + * ExitCommand.cs: + * CopyCommand.cs: + * SaveCommand.cs: + * OpenCommand.cs: + * MainMenu.addin: + * PasteCommand.cs: Added new sample + diff --git a/Samples/TextEditorSWF/TextEditorSWF/Commands/CopyCommand.cs b/Samples/TextEditorSWF/TextEditorSWF/Commands/CopyCommand.cs new file mode 100755 index 0000000..99b48b8 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Commands/CopyCommand.cs @@ -0,0 +1,20 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using TextEditorSWF.ExtensionModel;
+
+namespace TextEditorSWF.Commands
+{
+ /// <summary>
+ /// The Copy command
+ /// </summary>
+ [Command ("Copy", IconResource = "TextEditorSWF.Icons.copy.png", Id="Copy")]
+ class CopyCommand : ICommand
+ {
+ public void Run ()
+ {
+ Program.MainWindow.Editor.Copy ();
+ }
+ }
+}
diff --git a/Samples/TextEditorSWF/TextEditorSWF/Commands/CutCommand.cs b/Samples/TextEditorSWF/TextEditorSWF/Commands/CutCommand.cs new file mode 100755 index 0000000..25fa947 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Commands/CutCommand.cs @@ -0,0 +1,20 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using TextEditorSWF.ExtensionModel;
+
+namespace TextEditorSWF.Commands
+{
+ /// <summary>
+ /// The cut command.
+ /// </summary>
+ [Command ("Cut", IconResource = "TextEditorSWF.Icons.cut.png", Id = "Cut")]
+ class CutCommand : ICommand
+ {
+ public void Run ()
+ {
+ Program.MainWindow.Editor.Cut ();
+ }
+ }
+}
diff --git a/Samples/TextEditorSWF/TextEditorSWF/Commands/ExitCommand.cs b/Samples/TextEditorSWF/TextEditorSWF/Commands/ExitCommand.cs new file mode 100755 index 0000000..77bf61c --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Commands/ExitCommand.cs @@ -0,0 +1,20 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using TextEditorSWF.ExtensionModel;
+
+namespace TextEditorSWF.Commands
+{
+ /// <summary>
+ /// The exit command.
+ /// </summary>
+ [Command ("Exit", Id = "Exit")]
+ class ExitCommand : ICommand
+ {
+ public void Run ()
+ {
+ Environment.Exit (0);
+ }
+ }
+}
diff --git a/Samples/TextEditorSWF/TextEditorSWF/Commands/MainMenu.addin b/Samples/TextEditorSWF/TextEditorSWF/Commands/MainMenu.addin new file mode 100755 index 0000000..3c35eb0 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Commands/MainMenu.addin @@ -0,0 +1,17 @@ +<ExtensionModel>
+ <!-- Defines the main menu. The extension point is defined in ExtensionPoints.cs -->
+ <Extension path="/TextEditor/MainMenu">
+ <Menu id="File" label="File">
+ <Command id="New" />
+ <Command id="Open" />
+ <Command id="Save" />
+ <Separator id="ExitSeparator"/>
+ <Command id="Exit" />
+ </Menu>
+ <Menu id="Edit" label="Edit">
+ <Command id="Cut" />
+ <Command id="Copy" />
+ <Command id="Paste" />
+ </Menu>
+ </Extension>
+</ExtensionModel>
\ No newline at end of file diff --git a/Samples/TextEditorSWF/TextEditorSWF/Commands/NewCommand.cs b/Samples/TextEditorSWF/TextEditorSWF/Commands/NewCommand.cs new file mode 100755 index 0000000..343f019 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Commands/NewCommand.cs @@ -0,0 +1,20 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using TextEditorSWF.ExtensionModel;
+
+namespace TextEditorSWF.Commands
+{
+ /// <summary>
+ /// The New command.
+ /// </summary>
+ [Command ("New", IconResource = "TextEditorSWF.Icons.new.png", Id = "New")]
+ class NewCommand : ICommand
+ {
+ public void Run ()
+ {
+ Program.MainWindow.NewFile ();
+ }
+ }
+}
diff --git a/Samples/TextEditorSWF/TextEditorSWF/Commands/OpenCommand.cs b/Samples/TextEditorSWF/TextEditorSWF/Commands/OpenCommand.cs new file mode 100755 index 0000000..8da019f --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Commands/OpenCommand.cs @@ -0,0 +1,20 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using TextEditorSWF.ExtensionModel;
+
+namespace TextEditorSWF.Commands
+{
+ /// <summary>
+ /// The Open command.
+ /// </summary>
+ [Command ("Open", IconResource = "TextEditorSWF.Icons.open.png", Id = "Open")]
+ class OpenCommand : ICommand
+ {
+ public void Run ()
+ {
+ Program.MainWindow.OpenFile ();
+ }
+ }
+}
diff --git a/Samples/TextEditorSWF/TextEditorSWF/Commands/PasteCommand.cs b/Samples/TextEditorSWF/TextEditorSWF/Commands/PasteCommand.cs new file mode 100755 index 0000000..3eeee67 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Commands/PasteCommand.cs @@ -0,0 +1,20 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using TextEditorSWF.ExtensionModel;
+
+namespace TextEditorSWF.Commands
+{
+ /// <summary>
+ /// The Paste command.
+ /// </summary>
+ [Command ("Paste", IconResource = "TextEditorSWF.Icons.paste.png", Id = "Paste")]
+ class PasteCommand : ICommand
+ {
+ public void Run ()
+ {
+ Program.MainWindow.Editor.Paste ();
+ }
+ }
+}
diff --git a/Samples/TextEditorSWF/TextEditorSWF/Commands/SaveCommand.cs b/Samples/TextEditorSWF/TextEditorSWF/Commands/SaveCommand.cs new file mode 100755 index 0000000..5a7bbe2 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Commands/SaveCommand.cs @@ -0,0 +1,20 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using TextEditorSWF.ExtensionModel;
+
+namespace TextEditorSWF.Commands
+{
+ /// <summary>
+ /// The Save command.
+ /// </summary>
+ [Command ("Save", IconResource = "TextEditorSWF.Icons.save.png", Id = "Save")]
+ class SaveCommand : ICommand
+ {
+ public void Run ()
+ {
+ Program.MainWindow.SaveFile ();
+ }
+ }
+}
diff --git a/Samples/TextEditorSWF/TextEditorSWF/Commands/Toolbar.addin b/Samples/TextEditorSWF/TextEditorSWF/Commands/Toolbar.addin new file mode 100755 index 0000000..c308e4f --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Commands/Toolbar.addin @@ -0,0 +1,12 @@ +<ExtensionModel>
+ <!-- Defines the main toolbar. The extension point is defined in ExtensionPoints.cs -->
+ <Extension path="/TextEditor/Toolbar">
+ <Button id="New" />
+ <Button id="Open" />
+ <Button id="Save" />
+ <Separator id="EditSeparator"/>
+ <Button id="Cut" />
+ <Button id="Copy" />
+ <Button id="Paste" />
+ </Extension>
+</ExtensionModel>
\ No newline at end of file diff --git a/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/ChangeLog b/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/ChangeLog new file mode 100644 index 0000000..d699c77 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/ChangeLog @@ -0,0 +1,11 @@ +2010-05-25 Lluis Sanchez Gual <lluis@novell.com> + + * ICommand.cs: + * EditorExtension.cs: + * ExtensionPoints.cs: + * MenuExtensionNode.cs: + * IUserInterfaceItem.cs: + * CommandExtensionNode.cs: + * SeparatorExtensionNode.cs: + * InterfaceItemExtensionNode.cs: Added new sample + diff --git a/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/CommandExtensionNode.cs b/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/CommandExtensionNode.cs new file mode 100755 index 0000000..82c7150 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/CommandExtensionNode.cs @@ -0,0 +1,61 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Mono.Addins;
+using System.Drawing;
+using System.IO;
+using System.Windows.Forms;
+
+namespace TextEditorSWF.ExtensionModel
+{
+ /// <summary>
+ /// Extension node for command nodes
+ /// </summary>
+ class CommandExtensionNode : TypeExtensionNode<CommandAttribute>
+ {
+ Bitmap icon;
+
+ /// <summary>
+ /// Icon for the command (cached)
+ /// </summary>
+ public Bitmap Icon
+ {
+ get
+ {
+ if (icon == null && (Data.IconResource != null || Data.IconFile != null)) {
+ Stream s;
+ if (Data.IconResource != null)
+ s = Addin.GetResource (Data.IconResource);
+ else
+ s = File.OpenRead (Addin.GetFilePath (Data.IconFile));
+ using (s)
+ icon = new Bitmap (s);
+ }
+ return icon;
+ }
+ }
+
+ /// <summary>
+ /// Returns a menu item for this command
+ /// </summary>
+ public ToolStripItem CreateMenuItem ()
+ {
+ ICommand cmd = (ICommand) CreateInstance (typeof (ICommand));
+ return new ToolStripMenuItem (Data.Label, Icon, delegate {
+ cmd.Run ();
+ });
+ }
+
+ /// <summary>
+ /// Returns a toolbar item for this command
+ /// </summary>
+ public ToolStripItem CreateButton ()
+ {
+ ICommand cmd = (ICommand) CreateInstance (typeof (ICommand));
+ return new ToolStripButton (null, Icon, delegate {
+ cmd.Run ();
+ });
+ }
+ }
+}
diff --git a/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/EditorExtension.cs b/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/EditorExtension.cs new file mode 100755 index 0000000..875d971 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/EditorExtension.cs @@ -0,0 +1,45 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using Mono.Addins;
+
+namespace TextEditorSWF.ExtensionModel
+{
+ /// <summary>
+ /// Add-ins can create subclasses of EditorExtension to intercept some
+ /// text editor events, such as saving a file, loading, etc.
+ /// </summary>
+ [TypeExtensionPoint]
+ public class EditorExtension
+ {
+ /// <summary>
+ /// Called when the text editor is initialized
+ /// </summary>
+ public virtual void Initialize ()
+ {
+ }
+
+ /// <summary>
+ /// Called when a file is loaded
+ /// </summary>
+ public virtual void OnLoadFile (string file)
+ {
+ }
+
+ /// <summary>
+ /// Called when the current file is saved
+ /// </summary>
+ public virtual void OnSaveFile (string file)
+ {
+ }
+
+ /// <summary>
+ /// Called when a new file is created
+ /// </summary>
+ public virtual void OnCreateFile ()
+ {
+ }
+ }
+}
diff --git a/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/ExtensionPoints.cs b/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/ExtensionPoints.cs new file mode 100755 index 0000000..8102df9 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/ExtensionPoints.cs @@ -0,0 +1,15 @@ +using System;
+using Mono.Addins;
+using TextEditorSWF.ExtensionModel;
+
+// This file defines some data extension points.
+
+// Toolbar extension point
+
+[assembly: ExtensionPoint ("/TextEditor/Toolbar", NodeName = "Button", NodeType = typeof (InterfaceItemExtensionNode))]
+[assembly: ExtensionPoint ("/TextEditor/Toolbar", NodeName = "Separator", NodeType = typeof (SeparatorExtensionNode))]
+
+// Main menu extension point
+
+[assembly: ExtensionPoint ("/TextEditor/MainMenu", NodeName="Menu", NodeType = typeof(MenuExtensionNode))]
+
diff --git a/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/ICommand.cs b/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/ICommand.cs new file mode 100755 index 0000000..81ed66d --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/ICommand.cs @@ -0,0 +1,53 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Mono.Addins;
+
+namespace TextEditorSWF.ExtensionModel
+{
+ /// <summary>
+ /// A user interface command.
+ /// </summary>
+ [TypeExtensionPoint (NodeType=typeof(CommandExtensionNode), ExtensionAttributeType=typeof(CommandAttribute))]
+ public interface ICommand
+ {
+ /// <summary>
+ /// Executes the command
+ /// </summary>
+ void Run ();
+ }
+
+ /// <summary>
+ /// Attribute which can be used to declare new commands
+ /// </summary>
+ public class CommandAttribute : CustomExtensionAttribute
+ {
+ public CommandAttribute ()
+ {
+ }
+
+ public CommandAttribute ([NodeAttribute ("Label")] string label)
+ {
+ Label = label;
+ }
+
+ /// <summary>
+ /// Resource that holds the command icon
+ /// </summary>
+ [NodeAttribute]
+ public string IconResource { get; set; }
+
+ /// <summary>
+ /// File that holds the command icon
+ /// </summary>
+ [NodeAttribute]
+ public string IconFile { get; set; }
+
+ /// <summary>
+ /// Label of the command
+ /// </summary>
+ [NodeAttribute]
+ public string Label { get; set; }
+ }
+}
diff --git a/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/IUserInterfaceItem.cs b/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/IUserInterfaceItem.cs new file mode 100755 index 0000000..506d395 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/IUserInterfaceItem.cs @@ -0,0 +1,24 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+
+namespace TextEditorSWF.ExtensionModel
+{
+ /// <summary>
+ /// An extension node which can be used to create toolbar or menu items.
+ /// </summary>
+ interface IUserInterfaceItem
+ {
+ /// <summary>
+ /// Creates a menu item for the node
+ /// </summary>
+ ToolStripItem CreateMenuItem ();
+
+ /// <summary>
+ /// Creates a toolbar button for the node
+ /// </summary>
+ ToolStripItem CreateButton ();
+ }
+}
diff --git a/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/InterfaceItemExtensionNode.cs b/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/InterfaceItemExtensionNode.cs new file mode 100755 index 0000000..432fab0 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/InterfaceItemExtensionNode.cs @@ -0,0 +1,30 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Mono.Addins;
+using System.Drawing;
+using System.IO;
+using System.Windows.Forms;
+
+namespace TextEditorSWF.ExtensionModel
+{
+ /// <summary>
+ /// Extension node that represents a menu or toolbar item.
+ /// </summary>
+ [ExtensionNode ("Command")]
+ class InterfaceItemExtensionNode : ExtensionNode, IUserInterfaceItem
+ {
+ public ToolStripItem CreateMenuItem ()
+ {
+ CommandExtensionNode cmd = CommandManager.GetCommand (Id);
+ return cmd.CreateMenuItem ();
+ }
+
+ public ToolStripItem CreateButton ()
+ {
+ CommandExtensionNode cmd = CommandManager.GetCommand (Id);
+ return cmd.CreateButton ();
+ }
+ }
+}
diff --git a/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/MenuExtensionNode.cs b/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/MenuExtensionNode.cs new file mode 100755 index 0000000..fbb2cc8 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/MenuExtensionNode.cs @@ -0,0 +1,38 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using Mono.Addins;
+
+namespace TextEditorSWF.ExtensionModel
+{
+ /// <summary>
+ /// A menu or submenu extension node. It can contain command items, separators and other submenus.
+ /// </summary>
+ [ExtensionNode ("Menu")]
+ [ExtensionNodeChild (typeof (InterfaceItemExtensionNode))]
+ [ExtensionNodeChild (typeof (SeparatorExtensionNode))]
+ [ExtensionNodeChild (typeof (MenuExtensionNode))]
+ class MenuExtensionNode : ExtensionNode, IUserInterfaceItem
+ {
+ [NodeAttribute ("label")]
+ public string Label { get; set; }
+
+ public ToolStripItem CreateMenuItem ()
+ {
+ ToolStripMenuItem menu = new ToolStripMenuItem (Label);
+ foreach (IUserInterfaceItem item in ChildNodes)
+ menu.DropDownItems.Add (item.CreateMenuItem ());
+ return menu;
+ }
+
+ public ToolStripItem CreateButton ()
+ {
+ ToolStripDropDownButton menu = new ToolStripDropDownButton (Label);
+ foreach (IUserInterfaceItem item in ChildNodes)
+ menu.DropDownItems.Add (item.CreateMenuItem ());
+ return menu;
+ }
+ }
+}
diff --git a/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/SeparatorExtensionNode.cs b/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/SeparatorExtensionNode.cs new file mode 100755 index 0000000..62dae27 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/ExtensionModel/SeparatorExtensionNode.cs @@ -0,0 +1,26 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using Mono.Addins;
+
+namespace TextEditorSWF.ExtensionModel
+{
+ /// <summary>
+ /// A menu or toolbar separator
+ /// </summary>
+ [ExtensionNode ("Separator")]
+ class SeparatorExtensionNode : ExtensionNode, IUserInterfaceItem
+ {
+ public ToolStripItem CreateMenuItem ()
+ {
+ return new ToolStripSeparator ();
+ }
+
+ public ToolStripItem CreateButton ()
+ {
+ return new ToolStripSeparator ();
+ }
+ }
+}
diff --git a/Samples/TextEditorSWF/TextEditorSWF/Icons/ChangeLog b/Samples/TextEditorSWF/TextEditorSWF/Icons/ChangeLog new file mode 100644 index 0000000..41a03f5 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Icons/ChangeLog @@ -0,0 +1,9 @@ +2010-05-25 Lluis Sanchez Gual <lluis@novell.com> + + * new.png: + * cut.png: + * copy.png: + * save.png: + * open.png: + * paste.png: Added new sample + diff --git a/Samples/TextEditorSWF/TextEditorSWF/Icons/copy.png b/Samples/TextEditorSWF/TextEditorSWF/Icons/copy.png Binary files differnew file mode 100755 index 0000000..f0dcff2 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Icons/copy.png diff --git a/Samples/TextEditorSWF/TextEditorSWF/Icons/cut.png b/Samples/TextEditorSWF/TextEditorSWF/Icons/cut.png Binary files differnew file mode 100755 index 0000000..61def64 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Icons/cut.png diff --git a/Samples/TextEditorSWF/TextEditorSWF/Icons/new.png b/Samples/TextEditorSWF/TextEditorSWF/Icons/new.png Binary files differnew file mode 100755 index 0000000..ef102c5 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Icons/new.png diff --git a/Samples/TextEditorSWF/TextEditorSWF/Icons/open.png b/Samples/TextEditorSWF/TextEditorSWF/Icons/open.png Binary files differnew file mode 100755 index 0000000..1bfd7c3 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Icons/open.png diff --git a/Samples/TextEditorSWF/TextEditorSWF/Icons/paste.png b/Samples/TextEditorSWF/TextEditorSWF/Icons/paste.png Binary files differnew file mode 100755 index 0000000..2af6ad7 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Icons/paste.png diff --git a/Samples/TextEditorSWF/TextEditorSWF/Icons/save.png b/Samples/TextEditorSWF/TextEditorSWF/Icons/save.png Binary files differnew file mode 100755 index 0000000..95bfd53 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Icons/save.png diff --git a/Samples/TextEditorSWF/TextEditorSWF/Program.cs b/Samples/TextEditorSWF/TextEditorSWF/Program.cs new file mode 100755 index 0000000..7beec4f --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Program.cs @@ -0,0 +1,33 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+using Mono.Addins;
+
+// This is the main add-in root
+[assembly:AddinRoot ("Core", "1.0", Namespace="TextEditor")]
+
+namespace TextEditorSWF
+{
+ public static class Program
+ {
+ [STAThread]
+ static void Main ()
+ {
+ // Initialize the add-in engine
+ AddinManager.Initialize (".");
+ AddinManager.Registry.Update ();
+
+ Application.EnableVisualStyles ();
+ Application.SetCompatibleTextRenderingDefault (false);
+ MainWindow = new TextEditor ();
+ MainWindow.Initialize ();
+ Application.Run (MainWindow);
+ }
+
+ /// <summary>
+ /// The main window of the text editor
+ /// </summary>
+ public static TextEditor MainWindow { get; private set; }
+ }
+}
diff --git a/Samples/TextEditorSWF/TextEditorSWF/Properties/AssemblyInfo.cs b/Samples/TextEditorSWF/TextEditorSWF/Properties/AssemblyInfo.cs new file mode 100755 index 0000000..cf88879 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle ("TextEditorSWF")]
+[assembly: AssemblyDescription ("")]
+[assembly: AssemblyConfiguration ("")]
+[assembly: AssemblyCompany ("")]
+[assembly: AssemblyProduct ("TextEditorSWF")]
+[assembly: AssemblyCopyright ("Copyright © 2010")]
+[assembly: AssemblyTrademark ("")]
+[assembly: AssemblyCulture ("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible (false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid ("b8ac4d6f-ebd9-4c59-9321-7ef7b04ec7f5")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion ("1.0.0.0")]
+[assembly: AssemblyFileVersion ("1.0.0.0")]
diff --git a/Samples/TextEditorSWF/TextEditorSWF/Properties/ChangeLog b/Samples/TextEditorSWF/TextEditorSWF/Properties/ChangeLog new file mode 100644 index 0000000..a56e748 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Properties/ChangeLog @@ -0,0 +1,8 @@ +2010-05-25 Lluis Sanchez Gual <lluis@novell.com> + + * Resources.resx: + * AssemblyInfo.cs: + * Settings.settings: + * Settings.Designer.cs: + * Resources.Designer.cs: Added new sample + diff --git a/Samples/TextEditorSWF/TextEditorSWF/Properties/Resources.Designer.cs b/Samples/TextEditorSWF/TextEditorSWF/Properties/Resources.Designer.cs new file mode 100755 index 0000000..f556edd --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Properties/Resources.Designer.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.4927
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace TextEditorSWF.Properties
+{
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute ("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute ()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute ()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute ("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources ()
+ {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute (global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager ("TextEditorSWF.Properties.Resources", typeof (Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute (global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/Samples/TextEditorSWF/TextEditorSWF/Properties/Resources.resx b/Samples/TextEditorSWF/TextEditorSWF/Properties/Resources.resx new file mode 100755 index 0000000..ffecec8 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Properties/Resources.resx @@ -0,0 +1,117 @@ +<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
\ No newline at end of file diff --git a/Samples/TextEditorSWF/TextEditorSWF/Properties/Settings.Designer.cs b/Samples/TextEditorSWF/TextEditorSWF/Properties/Settings.Designer.cs new file mode 100755 index 0000000..fbcf047 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.4927
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace TextEditorSWF.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute ()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute ("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized (new Settings ())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/Samples/TextEditorSWF/TextEditorSWF/Properties/Settings.settings b/Samples/TextEditorSWF/TextEditorSWF/Properties/Settings.settings new file mode 100755 index 0000000..abf36c5 --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/Properties/Settings.settings @@ -0,0 +1,7 @@ +<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
+ <Profiles>
+ <Profile Name="(Default)" />
+ </Profiles>
+ <Settings />
+</SettingsFile>
diff --git a/Samples/TextEditorSWF/TextEditorSWF/TextEditor.Designer.cs b/Samples/TextEditorSWF/TextEditorSWF/TextEditor.Designer.cs new file mode 100755 index 0000000..c43d26b --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/TextEditor.Designer.cs @@ -0,0 +1,84 @@ +namespace TextEditorSWF
+{
+ partial class TextEditor
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose (bool disposing)
+ {
+ if (disposing && (components != null)) {
+ components.Dispose ();
+ }
+ base.Dispose (disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent ()
+ {
+ this.menuStrip = new System.Windows.Forms.MenuStrip ();
+ this.richTextBox = new System.Windows.Forms.RichTextBox ();
+ this.toolStrip = new System.Windows.Forms.ToolStrip ();
+ this.SuspendLayout ();
+ //
+ // menuStrip
+ //
+ this.menuStrip.Location = new System.Drawing.Point (0, 0);
+ this.menuStrip.Name = "menuStrip";
+ this.menuStrip.Size = new System.Drawing.Size (676, 24);
+ this.menuStrip.TabIndex = 0;
+ this.menuStrip.Text = "menuStrip";
+ //
+ // richTextBox
+ //
+ this.richTextBox.AcceptsTab = true;
+ this.richTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.richTextBox.Location = new System.Drawing.Point (0, 49);
+ this.richTextBox.Name = "richTextBox";
+ this.richTextBox.Size = new System.Drawing.Size (676, 391);
+ this.richTextBox.TabIndex = 1;
+ this.richTextBox.Text = "";
+ //
+ // toolStrip
+ //
+ this.toolStrip.Location = new System.Drawing.Point (0, 24);
+ this.toolStrip.Name = "toolStrip";
+ this.toolStrip.Size = new System.Drawing.Size (676, 25);
+ this.toolStrip.TabIndex = 2;
+ this.toolStrip.Text = "toolStrip";
+ //
+ // TextEditor
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF (6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size (676, 440);
+ this.Controls.Add (this.richTextBox);
+ this.Controls.Add (this.toolStrip);
+ this.Controls.Add (this.menuStrip);
+ this.MainMenuStrip = this.menuStrip;
+ this.Name = "TextEditor";
+ this.Text = "Text Editor";
+ this.ResumeLayout (false);
+ this.PerformLayout ();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.MenuStrip menuStrip;
+ private System.Windows.Forms.RichTextBox richTextBox;
+ private System.Windows.Forms.ToolStrip toolStrip;
+ }
+}
+
diff --git a/Samples/TextEditorSWF/TextEditorSWF/TextEditor.cs b/Samples/TextEditorSWF/TextEditorSWF/TextEditor.cs new file mode 100755 index 0000000..b1d28eb --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/TextEditor.cs @@ -0,0 +1,111 @@ +using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using TextEditorSWF.ExtensionModel;
+using Mono.Addins;
+using System.IO;
+
+namespace TextEditorSWF
+{
+ public partial class TextEditor : Form
+ {
+ string currentFile;
+
+ public TextEditor ()
+ {
+ InitializeComponent ();
+
+ // Create the main menu and the toolbar
+
+ foreach (ToolStripItem item in CommandManager.GetMainMenuItems ())
+ menuStrip.Items.Add (item);
+ foreach (ToolStripItem item in CommandManager.GetToolbarItems ())
+ toolStrip.Items.Add (item);
+ }
+
+ internal void Initialize ()
+ {
+ // Initialize the editor extensions. Must be done after setting Program.MainWindow since
+ // extensions may use it
+ foreach (EditorExtension ext in AddinManager.GetExtensionObjects<EditorExtension> ())
+ ext.Initialize ();
+ }
+
+ /// <summary>
+ /// The editor box
+ /// </summary>
+ public RichTextBox Editor
+ {
+ get { return richTextBox; }
+ }
+
+ /// <summary>
+ /// Saves the file to disk, asking for location if the file is unsaved
+ /// </summary>
+ public void SaveFile ()
+ {
+ if (currentFile == null) {
+ SaveFileDialog dlg = new SaveFileDialog ();
+ if (dlg.ShowDialog (this) != DialogResult.OK)
+ return;
+ currentFile = dlg.FileName;
+ dlg.Dispose ();
+ }
+ SaveFile (currentFile);
+ }
+
+ /// <summary>
+ /// Saves the file to the specified location
+ /// </summary>
+ public void SaveFile (string file)
+ {
+ File.WriteAllText (file, richTextBox.Text);
+
+ // Notify editor extensions
+ foreach (EditorExtension ext in AddinManager.GetExtensionObjects<EditorExtension> ())
+ ext.OnSaveFile (file);
+ }
+
+ /// <summary>
+ /// Create a new file
+ /// </summary>
+ public void NewFile ()
+ {
+ richTextBox.Text = "";
+ currentFile = null;
+
+ // Notify editor extensions
+ foreach (EditorExtension ext in AddinManager.GetExtensionObjects<EditorExtension> ())
+ ext.OnCreateFile ();
+ }
+
+ /// <summary>
+ /// Open a new file. Will ask for the file name in a dialog.
+ /// </summary>
+ public void OpenFile ()
+ {
+ OpenFileDialog dlg = new OpenFileDialog ();
+ if (dlg.ShowDialog () == DialogResult.OK)
+ OpenFile (dlg.FileName);
+ dlg.Dispose ();
+ }
+
+ /// <summary>
+ /// Open the specified file in the text editor
+ /// </summary>
+ public void OpenFile (string file)
+ {
+ richTextBox.Text = File.ReadAllText (file);
+ currentFile = file;
+
+ // Notify editor extensions
+ foreach (EditorExtension ext in AddinManager.GetExtensionObjects<EditorExtension> ())
+ ext.OnLoadFile (file);
+ }
+ }
+}
diff --git a/Samples/TextEditorSWF/TextEditorSWF/TextEditor.resx b/Samples/TextEditorSWF/TextEditorSWF/TextEditor.resx new file mode 100755 index 0000000..6d9bd2d --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/TextEditor.resx @@ -0,0 +1,126 @@ +<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+ <metadata name="toolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>132, 17</value>
+ </metadata>
+</root>
\ No newline at end of file diff --git a/Samples/TextEditorSWF/TextEditorSWF/TextEditorSWF.csproj b/Samples/TextEditorSWF/TextEditorSWF/TextEditorSWF.csproj new file mode 100755 index 0000000..0c6864b --- /dev/null +++ b/Samples/TextEditorSWF/TextEditorSWF/TextEditorSWF.csproj @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.21022</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{85480AD8-781F-43FC-A48F-91962401DB95}</ProjectGuid>
+ <OutputType>WinExe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>TextEditorSWF</RootNamespace>
+ <AssemblyName>TextEditorSWF</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Deployment" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ <Reference Include="Mono.Addins, Version=0.5.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\bin\Mono.Addins.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="CommandManager.cs" />
+ <Compile Include="Commands\CopyCommand.cs" />
+ <Compile Include="Commands\CutCommand.cs" />
+ <Compile Include="Commands\ExitCommand.cs" />
+ <Compile Include="Commands\NewCommand.cs" />
+ <Compile Include="Commands\OpenCommand.cs" />
+ <Compile Include="Commands\PasteCommand.cs" />
+ <Compile Include="Commands\SaveCommand.cs" />
+ <Compile Include="ExtensionModel\CommandExtensionNode.cs" />
+ <Compile Include="ExtensionModel\InterfaceItemExtensionNode.cs" />
+ <Compile Include="ExtensionModel\ExtensionPoints.cs" />
+ <Compile Include="ExtensionModel\ICommand.cs" />
+ <Compile Include="ExtensionModel\IUserInterfaceItem.cs" />
+ <Compile Include="ExtensionModel\MenuExtensionNode.cs" />
+ <Compile Include="ExtensionModel\SeparatorExtensionNode.cs" />
+ <Compile Include="ExtensionModel\EditorExtension.cs" />
+ <Compile Include="TextEditor.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="TextEditor.Designer.cs">
+ <DependentUpon>TextEditor.cs</DependentUpon>
+ </Compile>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <EmbeddedResource Include="TextEditor.resx">
+ <DependentUpon>TextEditor.cs</DependentUpon>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Settings.settings</DependentUpon>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Commands\MainMenu.addin" />
+ <EmbeddedResource Include="Commands\Toolbar.addin" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Icons\copy.png" />
+ <EmbeddedResource Include="Icons\cut.png" />
+ <EmbeddedResource Include="Icons\new.png" />
+ <EmbeddedResource Include="Icons\open.png" />
+ <EmbeddedResource Include="Icons\paste.png" />
+ <EmbeddedResource Include="Icons\save.png" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file |