Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 06bd0bf

Browse files
fix samples/EmbeddedImageAddIn and samples/HtmlSyntaxColorizer
1 parent d2f52ab commit 06bd0bf

9 files changed

Lines changed: 37 additions & 23 deletions

samples/EmbeddedImageAddIn/EmbeddedImageAddIn.addin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</Runtime>
1212

1313
<Path name="/SharpDevelop/Workbench/LanguageBindings">
14-
<Class id="EmbeddedImage" class="EmbeddedImageAddIn.EmbeddedImageLanguageBinding"/>
14+
<Class id="EmbeddedImage" class="EmbeddedImageAddIn.EmbeddedImageTextEditorExtension"/>
1515
</Path>
1616

1717
<Path name="/SharpDevelop/Workbench/MainMenu/Edit/Insert">

samples/EmbeddedImageAddIn/EmbeddedImageAddIn.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
<OutputType>Library</OutputType>
88
<RootNamespace>EmbeddedImageAddIn</RootNamespace>
99
<AssemblyName>EmbeddedImageAddIn</AssemblyName>
10-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
10+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1111
<OutputPath>..\..\AddIns\Samples\EmbeddedImage\</OutputPath>
1212
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
1313
<NoStdLib>False</NoStdLib>
1414
<WarningLevel>4</WarningLevel>
1515
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
16+
<TargetFrameworkProfile />
1617
</PropertyGroup>
1718
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
1819
<PlatformTarget>x86</PlatformTarget>
@@ -44,6 +45,9 @@
4445
<HintPath>..\..\bin\ICSharpCode.Core.dll</HintPath>
4546
<Private>False</Private>
4647
</Reference>
48+
<Reference Include="ICSharpCode.NRefactory">
49+
<HintPath>..\..\bin\ICSharpCode.NRefactory.dll</HintPath>
50+
</Reference>
4751
<Reference Include="ICSharpCode.SharpDevelop">
4852
<HintPath>..\..\bin\ICSharpCode.SharpDevelop.dll</HintPath>
4953
<Private>False</Private>
@@ -70,7 +74,7 @@
7074
</ItemGroup>
7175
<ItemGroup>
7276
<Compile Include="Configuration\AssemblyInfo.cs" />
73-
<Compile Include="EmbeddedImageLanguageBinding.cs" />
77+
<Compile Include="EmbeddedImageTextEditorExtension.cs" />
7478
<Compile Include="ImageCache.cs" />
7579
<Compile Include="ImageElement.cs" />
7680
<Compile Include="ImageElementGenerator.cs" />
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 11.00
33
# Visual Studio 2010
4-
# SharpDevelop 4.0.0.7002
4+
# SharpDevelop 5.0
55
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmbeddedImageAddIn", "EmbeddedImageAddIn.csproj", "{1F60F9B0-E2FE-462F-9758-2E834D845438}"
66
EndProject
77
Global
@@ -10,9 +10,9 @@ Global
1010
Release|x86 = Release|x86
1111
EndGlobalSection
1212
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13-
{1F60F9B0-E2FE-462F-9758-2E834D845438}.Debug|x86.Build.0 = Debug|x86
1413
{1F60F9B0-E2FE-462F-9758-2E834D845438}.Debug|x86.ActiveCfg = Debug|x86
15-
{1F60F9B0-E2FE-462F-9758-2E834D845438}.Release|x86.Build.0 = Release|x86
14+
{1F60F9B0-E2FE-462F-9758-2E834D845438}.Debug|x86.Build.0 = Debug|x86
1615
{1F60F9B0-E2FE-462F-9758-2E834D845438}.Release|x86.ActiveCfg = Release|x86
16+
{1F60F9B0-E2FE-462F-9758-2E834D845438}.Release|x86.Build.0 = Release|x86
1717
EndGlobalSection
1818
EndGlobal

samples/EmbeddedImageAddIn/EmbeddedImageLanguageBinding.cs renamed to samples/EmbeddedImageAddIn/EmbeddedImageTextEditorExtension.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@
44
using System;
55
using System.IO;
66
using ICSharpCode.AvalonEdit.Rendering;
7-
using ICSharpCode.SharpDevelop;
87
using ICSharpCode.SharpDevelop.Editor;
98

109
namespace EmbeddedImageAddIn
1110
{
1211
// SharpDevelop creates one instance of EmbeddedImageLanguageBinding for each text editor.
13-
public class EmbeddedImageLanguageBinding : DefaultLanguageBinding
12+
public class EmbeddedImageTextEditorExtension : ITextEditorExtension
1413
{
1514
TextView textView;
1615
ImageElementGenerator g;
1716

18-
public override void Attach(ITextEditor editor)
17+
public void Attach(ITextEditor editor)
1918
{
20-
base.Attach(editor);
2119
// ITextEditor is SharpDevelop's abstraction of the text editor.
2220
// We use GetService() to get the underlying AvalonEdit instance.
2321
textView = editor.GetService(typeof(TextView)) as TextView;
@@ -27,12 +25,11 @@ public override void Attach(ITextEditor editor)
2725
}
2826
}
2927

30-
public override void Detach()
28+
public void Detach()
3129
{
3230
if (textView != null) {
3331
textView.ElementGenerators.Remove(g);
3432
}
35-
base.Detach();
3633
}
3734
}
3835
}

samples/EmbeddedImageAddIn/InsertImageCommand.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
using System;
55
using System.IO;
66
using ICSharpCode.Core;
7+
using ICSharpCode.SharpDevelop;
78
using ICSharpCode.SharpDevelop.Editor;
8-
using ICSharpCode.SharpDevelop.Gui;
99
using Microsoft.Win32;
1010

1111
namespace EmbeddedImageAddIn
@@ -17,22 +17,22 @@ public class InsertImageCommand : AbstractMenuCommand
1717
{
1818
public override void Run()
1919
{
20-
if (WorkbenchSingleton.Workbench.ActiveViewContent == null)
20+
if (SD.Workbench.ActiveViewContent == null)
2121
return;
22-
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent.GetService(typeof(ITextEditorProvider)) as ITextEditorProvider;
23-
if (provider == null)
22+
ITextEditor editor = SD.Workbench.ActiveViewContent.GetService(typeof(ITextEditor)) as ITextEditor;
23+
if (editor == null)
2424
return;
2525
OpenFileDialog dlg = new OpenFileDialog();
2626
dlg.Filter = "Image files|*.png;*.jpg;*.gif;*.bmp;*.jpeg|All files|*.*";
2727
dlg.CheckFileExists = true;
2828
dlg.DereferenceLinks = true;
29-
string baseDirectory = Path.GetDirectoryName(provider.TextEditor.FileName);
29+
string baseDirectory = Path.GetDirectoryName(editor.FileName);
3030
dlg.InitialDirectory = baseDirectory;
3131
if (dlg.ShowDialog() == true) {
3232
string relativePath = FileUtility.GetRelativePath(baseDirectory, dlg.FileName);
3333
if (!Path.IsPathRooted(relativePath))
3434
relativePath = relativePath.Replace('\\', '/');
35-
provider.TextEditor.Document.Insert(provider.TextEditor.Caret.Offset, "<<IMAGE:" + relativePath + ">>");
35+
editor.Document.Insert(editor.Caret.Offset, "<<IMAGE:" + relativePath + ">>");
3636
}
3737
}
3838
}

samples/HtmlSyntaxColorizer/HtmlSyntaxColorizer.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
<OutputType>Exe</OutputType>
88
<RootNamespace>HtmlSyntaxColorizer</RootNamespace>
99
<AssemblyName>HtmlSyntaxColorizer</AssemblyName>
10-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
10+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
11+
<TargetFrameworkProfile />
1112
</PropertyGroup>
1213
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
1314
<OutputPath>bin\Debug\</OutputPath>
@@ -28,6 +29,9 @@
2829
<Reference Include="ICSharpCode.AvalonEdit">
2930
<HintPath>..\..\bin\ICSharpCode.AvalonEdit.dll</HintPath>
3031
</Reference>
32+
<Reference Include="ICSharpCode.NRefactory">
33+
<HintPath>..\..\bin\ICSharpCode.NRefactory.dll</HintPath>
34+
</Reference>
3135
<Reference Include="System" />
3236
<Reference Include="System.Core">
3337
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -47,4 +51,7 @@
4751
<Compile Include="HtmlWriter.cs" />
4852
<Compile Include="Main.cs" />
4953
</ItemGroup>
54+
<ItemGroup>
55+
<None Include="app.config" />
56+
</ItemGroup>
5057
</Project>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 11.00
33
# Visual Studio 2010
4-
# SharpDevelop 4.0.0.6517
4+
# SharpDevelop 5.0
55
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlSyntaxColorizer", "HtmlSyntaxColorizer.csproj", "{6D17428C-A444-4C26-8FE3-976160F41D97}"
66
EndProject
77
Global
@@ -10,9 +10,9 @@ Global
1010
Release|Any CPU = Release|Any CPU
1111
EndGlobalSection
1212
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13-
{6D17428C-A444-4C26-8FE3-976160F41D97}.Debug|Any CPU.Build.0 = Debug|Any CPU
1413
{6D17428C-A444-4C26-8FE3-976160F41D97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{6D17428C-A444-4C26-8FE3-976160F41D97}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{6D17428C-A444-4C26-8FE3-976160F41D97}.Debug|Any CPU.Build.0 = Debug|Any CPU
1615
{6D17428C-A444-4C26-8FE3-976160F41D97}.Release|Any CPU.ActiveCfg = Release|Any CPU
16+
{6D17428C-A444-4C26-8FE3-976160F41D97}.Release|Any CPU.Build.0 = Release|Any CPU
1717
EndGlobalSection
1818
EndGlobal

samples/HtmlSyntaxColorizer/HtmlWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public string GenerateHtml(string code, IHighlightingDefinition highlightDefinit
9292

9393
public string GenerateHtml(TextDocument document, IHighlightingDefinition highlightDefinition)
9494
{
95-
return GenerateHtml(document, new DocumentHighlighter(document, highlightDefinition.MainRuleSet));
95+
return GenerateHtml(document, new DocumentHighlighter(document, highlightDefinition));
9696
}
9797

9898
public string GenerateHtml(TextDocument document, IHighlighter highlighter)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
</configuration>

0 commit comments

Comments
 (0)