Browse Source

fix samples/EmbeddedImageAddIn and samples/HtmlSyntaxColorizer

pull/297/head
Siegfried Pammer 12 years ago
parent
commit
06bd0bf97e
  1. 2
      samples/EmbeddedImageAddIn/EmbeddedImageAddIn.addin
  2. 8
      samples/EmbeddedImageAddIn/EmbeddedImageAddIn.csproj
  3. 6
      samples/EmbeddedImageAddIn/EmbeddedImageAddIn.sln
  4. 9
      samples/EmbeddedImageAddIn/EmbeddedImageTextEditorExtension.cs
  5. 12
      samples/EmbeddedImageAddIn/InsertImageCommand.cs
  6. 9
      samples/HtmlSyntaxColorizer/HtmlSyntaxColorizer.csproj
  7. 6
      samples/HtmlSyntaxColorizer/HtmlSyntaxColorizer.sln
  8. 2
      samples/HtmlSyntaxColorizer/HtmlWriter.cs
  9. 6
      samples/HtmlSyntaxColorizer/app.config

2
samples/EmbeddedImageAddIn/EmbeddedImageAddIn.addin

@ -11,7 +11,7 @@
</Runtime> </Runtime>
<Path name="/SharpDevelop/Workbench/LanguageBindings"> <Path name="/SharpDevelop/Workbench/LanguageBindings">
<Class id="EmbeddedImage" class="EmbeddedImageAddIn.EmbeddedImageLanguageBinding"/> <Class id="EmbeddedImage" class="EmbeddedImageAddIn.EmbeddedImageTextEditorExtension"/>
</Path> </Path>
<Path name="/SharpDevelop/Workbench/MainMenu/Edit/Insert"> <Path name="/SharpDevelop/Workbench/MainMenu/Edit/Insert">

8
samples/EmbeddedImageAddIn/EmbeddedImageAddIn.csproj

@ -7,12 +7,13 @@
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>EmbeddedImageAddIn</RootNamespace> <RootNamespace>EmbeddedImageAddIn</RootNamespace>
<AssemblyName>EmbeddedImageAddIn</AssemblyName> <AssemblyName>EmbeddedImageAddIn</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<OutputPath>..\..\AddIns\Samples\EmbeddedImage\</OutputPath> <OutputPath>..\..\AddIns\Samples\EmbeddedImage\</OutputPath>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib> <NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' "> <PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@ -44,6 +45,9 @@
<HintPath>..\..\bin\ICSharpCode.Core.dll</HintPath> <HintPath>..\..\bin\ICSharpCode.Core.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="ICSharpCode.NRefactory">
<HintPath>..\..\bin\ICSharpCode.NRefactory.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpDevelop"> <Reference Include="ICSharpCode.SharpDevelop">
<HintPath>..\..\bin\ICSharpCode.SharpDevelop.dll</HintPath> <HintPath>..\..\bin\ICSharpCode.SharpDevelop.dll</HintPath>
<Private>False</Private> <Private>False</Private>
@ -70,7 +74,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Configuration\AssemblyInfo.cs" /> <Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="EmbeddedImageLanguageBinding.cs" /> <Compile Include="EmbeddedImageTextEditorExtension.cs" />
<Compile Include="ImageCache.cs" /> <Compile Include="ImageCache.cs" />
<Compile Include="ImageElement.cs" /> <Compile Include="ImageElement.cs" />
<Compile Include="ImageElementGenerator.cs" /> <Compile Include="ImageElementGenerator.cs" />

6
samples/EmbeddedImageAddIn/EmbeddedImageAddIn.sln

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 11.00 Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010 # Visual Studio 2010
# SharpDevelop 4.0.0.7002 # SharpDevelop 5.0
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmbeddedImageAddIn", "EmbeddedImageAddIn.csproj", "{1F60F9B0-E2FE-462F-9758-2E834D845438}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmbeddedImageAddIn", "EmbeddedImageAddIn.csproj", "{1F60F9B0-E2FE-462F-9758-2E834D845438}"
EndProject EndProject
Global Global
@ -10,9 +10,9 @@ Global
Release|x86 = Release|x86 Release|x86 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1F60F9B0-E2FE-462F-9758-2E834D845438}.Debug|x86.Build.0 = Debug|x86
{1F60F9B0-E2FE-462F-9758-2E834D845438}.Debug|x86.ActiveCfg = Debug|x86 {1F60F9B0-E2FE-462F-9758-2E834D845438}.Debug|x86.ActiveCfg = Debug|x86
{1F60F9B0-E2FE-462F-9758-2E834D845438}.Release|x86.Build.0 = Release|x86 {1F60F9B0-E2FE-462F-9758-2E834D845438}.Debug|x86.Build.0 = Debug|x86
{1F60F9B0-E2FE-462F-9758-2E834D845438}.Release|x86.ActiveCfg = Release|x86 {1F60F9B0-E2FE-462F-9758-2E834D845438}.Release|x86.ActiveCfg = Release|x86
{1F60F9B0-E2FE-462F-9758-2E834D845438}.Release|x86.Build.0 = Release|x86
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

9
samples/EmbeddedImageAddIn/EmbeddedImageLanguageBinding.cs → samples/EmbeddedImageAddIn/EmbeddedImageTextEditorExtension.cs

@ -4,20 +4,18 @@
using System; using System;
using System.IO; using System.IO;
using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
namespace EmbeddedImageAddIn namespace EmbeddedImageAddIn
{ {
// SharpDevelop creates one instance of EmbeddedImageLanguageBinding for each text editor. // SharpDevelop creates one instance of EmbeddedImageLanguageBinding for each text editor.
public class EmbeddedImageLanguageBinding : DefaultLanguageBinding public class EmbeddedImageTextEditorExtension : ITextEditorExtension
{ {
TextView textView; TextView textView;
ImageElementGenerator g; ImageElementGenerator g;
public override void Attach(ITextEditor editor) public void Attach(ITextEditor editor)
{ {
base.Attach(editor);
// ITextEditor is SharpDevelop's abstraction of the text editor. // ITextEditor is SharpDevelop's abstraction of the text editor.
// We use GetService() to get the underlying AvalonEdit instance. // We use GetService() to get the underlying AvalonEdit instance.
textView = editor.GetService(typeof(TextView)) as TextView; textView = editor.GetService(typeof(TextView)) as TextView;
@ -27,12 +25,11 @@ namespace EmbeddedImageAddIn
} }
} }
public override void Detach() public void Detach()
{ {
if (textView != null) { if (textView != null) {
textView.ElementGenerators.Remove(g); textView.ElementGenerators.Remove(g);
} }
base.Detach();
} }
} }
} }

12
samples/EmbeddedImageAddIn/InsertImageCommand.cs

@ -4,8 +4,8 @@
using System; using System;
using System.IO; using System.IO;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
using Microsoft.Win32; using Microsoft.Win32;
namespace EmbeddedImageAddIn namespace EmbeddedImageAddIn
@ -17,22 +17,22 @@ namespace EmbeddedImageAddIn
{ {
public override void Run() public override void Run()
{ {
if (WorkbenchSingleton.Workbench.ActiveViewContent == null) if (SD.Workbench.ActiveViewContent == null)
return; return;
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent.GetService(typeof(ITextEditorProvider)) as ITextEditorProvider; ITextEditor editor = SD.Workbench.ActiveViewContent.GetService(typeof(ITextEditor)) as ITextEditor;
if (provider == null) if (editor == null)
return; return;
OpenFileDialog dlg = new OpenFileDialog(); OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "Image files|*.png;*.jpg;*.gif;*.bmp;*.jpeg|All files|*.*"; dlg.Filter = "Image files|*.png;*.jpg;*.gif;*.bmp;*.jpeg|All files|*.*";
dlg.CheckFileExists = true; dlg.CheckFileExists = true;
dlg.DereferenceLinks = true; dlg.DereferenceLinks = true;
string baseDirectory = Path.GetDirectoryName(provider.TextEditor.FileName); string baseDirectory = Path.GetDirectoryName(editor.FileName);
dlg.InitialDirectory = baseDirectory; dlg.InitialDirectory = baseDirectory;
if (dlg.ShowDialog() == true) { if (dlg.ShowDialog() == true) {
string relativePath = FileUtility.GetRelativePath(baseDirectory, dlg.FileName); string relativePath = FileUtility.GetRelativePath(baseDirectory, dlg.FileName);
if (!Path.IsPathRooted(relativePath)) if (!Path.IsPathRooted(relativePath))
relativePath = relativePath.Replace('\\', '/'); relativePath = relativePath.Replace('\\', '/');
provider.TextEditor.Document.Insert(provider.TextEditor.Caret.Offset, "<<IMAGE:" + relativePath + ">>"); editor.Document.Insert(editor.Caret.Offset, "<<IMAGE:" + relativePath + ">>");
} }
} }
} }

9
samples/HtmlSyntaxColorizer/HtmlSyntaxColorizer.csproj

@ -7,7 +7,8 @@
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<RootNamespace>HtmlSyntaxColorizer</RootNamespace> <RootNamespace>HtmlSyntaxColorizer</RootNamespace>
<AssemblyName>HtmlSyntaxColorizer</AssemblyName> <AssemblyName>HtmlSyntaxColorizer</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
@ -28,6 +29,9 @@
<Reference Include="ICSharpCode.AvalonEdit"> <Reference Include="ICSharpCode.AvalonEdit">
<HintPath>..\..\bin\ICSharpCode.AvalonEdit.dll</HintPath> <HintPath>..\..\bin\ICSharpCode.AvalonEdit.dll</HintPath>
</Reference> </Reference>
<Reference Include="ICSharpCode.NRefactory">
<HintPath>..\..\bin\ICSharpCode.NRefactory.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core"> <Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
@ -47,4 +51,7 @@
<Compile Include="HtmlWriter.cs" /> <Compile Include="HtmlWriter.cs" />
<Compile Include="Main.cs" /> <Compile Include="Main.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
</Project> </Project>

6
samples/HtmlSyntaxColorizer/HtmlSyntaxColorizer.sln

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 11.00 Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010 # Visual Studio 2010
# SharpDevelop 4.0.0.6517 # SharpDevelop 5.0
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlSyntaxColorizer", "HtmlSyntaxColorizer.csproj", "{6D17428C-A444-4C26-8FE3-976160F41D97}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlSyntaxColorizer", "HtmlSyntaxColorizer.csproj", "{6D17428C-A444-4C26-8FE3-976160F41D97}"
EndProject EndProject
Global Global
@ -10,9 +10,9 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6D17428C-A444-4C26-8FE3-976160F41D97}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D17428C-A444-4C26-8FE3-976160F41D97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6D17428C-A444-4C26-8FE3-976160F41D97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D17428C-A444-4C26-8FE3-976160F41D97}.Release|Any CPU.Build.0 = Release|Any CPU {6D17428C-A444-4C26-8FE3-976160F41D97}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D17428C-A444-4C26-8FE3-976160F41D97}.Release|Any CPU.ActiveCfg = Release|Any CPU {6D17428C-A444-4C26-8FE3-976160F41D97}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D17428C-A444-4C26-8FE3-976160F41D97}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

2
samples/HtmlSyntaxColorizer/HtmlWriter.cs

@ -92,7 +92,7 @@ namespace ICSharpCode.HtmlSyntaxColorizer
public string GenerateHtml(TextDocument document, IHighlightingDefinition highlightDefinition) public string GenerateHtml(TextDocument document, IHighlightingDefinition highlightDefinition)
{ {
return GenerateHtml(document, new DocumentHighlighter(document, highlightDefinition.MainRuleSet)); return GenerateHtml(document, new DocumentHighlighter(document, highlightDefinition));
} }
public string GenerateHtml(TextDocument document, IHighlighter highlighter) public string GenerateHtml(TextDocument document, IHighlighter highlighter)

6
samples/HtmlSyntaxColorizer/app.config

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
Loading…
Cancel
Save