Browse Source

fix samples/EmbeddedImageAddIn and samples/HtmlSyntaxColorizer

pull/297/head
Siegfried Pammer 11 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 @@ @@ -11,7 +11,7 @@
</Runtime>
<Path name="/SharpDevelop/Workbench/LanguageBindings">
<Class id="EmbeddedImage" class="EmbeddedImageAddIn.EmbeddedImageLanguageBinding"/>
<Class id="EmbeddedImage" class="EmbeddedImageAddIn.EmbeddedImageTextEditorExtension"/>
</Path>
<Path name="/SharpDevelop/Workbench/MainMenu/Edit/Insert">

8
samples/EmbeddedImageAddIn/EmbeddedImageAddIn.csproj

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

6
samples/EmbeddedImageAddIn/EmbeddedImageAddIn.sln

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# 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}"
EndProject
Global
@ -10,9 +10,9 @@ Global @@ -10,9 +10,9 @@ Global
Release|x86 = Release|x86
EndGlobalSection
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}.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.Build.0 = Release|x86
EndGlobalSection
EndGlobal

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

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

12
samples/EmbeddedImageAddIn/InsertImageCommand.cs

@ -4,8 +4,8 @@ @@ -4,8 +4,8 @@
using System;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
using Microsoft.Win32;
namespace EmbeddedImageAddIn
@ -17,22 +17,22 @@ namespace EmbeddedImageAddIn @@ -17,22 +17,22 @@ namespace EmbeddedImageAddIn
{
public override void Run()
{
if (WorkbenchSingleton.Workbench.ActiveViewContent == null)
if (SD.Workbench.ActiveViewContent == null)
return;
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent.GetService(typeof(ITextEditorProvider)) as ITextEditorProvider;
if (provider == null)
ITextEditor editor = SD.Workbench.ActiveViewContent.GetService(typeof(ITextEditor)) as ITextEditor;
if (editor == null)
return;
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "Image files|*.png;*.jpg;*.gif;*.bmp;*.jpeg|All files|*.*";
dlg.CheckFileExists = true;
dlg.DereferenceLinks = true;
string baseDirectory = Path.GetDirectoryName(provider.TextEditor.FileName);
string baseDirectory = Path.GetDirectoryName(editor.FileName);
dlg.InitialDirectory = baseDirectory;
if (dlg.ShowDialog() == true) {
string relativePath = FileUtility.GetRelativePath(baseDirectory, dlg.FileName);
if (!Path.IsPathRooted(relativePath))
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 @@ @@ -7,7 +7,8 @@
<OutputType>Exe</OutputType>
<RootNamespace>HtmlSyntaxColorizer</RootNamespace>
<AssemblyName>HtmlSyntaxColorizer</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
@ -28,6 +29,9 @@ @@ -28,6 +29,9 @@
<Reference Include="ICSharpCode.AvalonEdit">
<HintPath>..\..\bin\ICSharpCode.AvalonEdit.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.NRefactory">
<HintPath>..\..\bin\ICSharpCode.NRefactory.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@ -47,4 +51,7 @@ @@ -47,4 +51,7 @@
<Compile Include="HtmlWriter.cs" />
<Compile Include="Main.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
</Project>

6
samples/HtmlSyntaxColorizer/HtmlSyntaxColorizer.sln

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# 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}"
EndProject
Global
@ -10,9 +10,9 @@ Global @@ -10,9 +10,9 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
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}.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.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

2
samples/HtmlSyntaxColorizer/HtmlWriter.cs

@ -92,7 +92,7 @@ namespace ICSharpCode.HtmlSyntaxColorizer @@ -92,7 +92,7 @@ namespace ICSharpCode.HtmlSyntaxColorizer
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)

6
samples/HtmlSyntaxColorizer/app.config

@ -0,0 +1,6 @@ @@ -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