Browse Source

Compile AvalonEdit for .NET 4.0 and make use of SetCurrentValue.

pull/1/head
Daniel Grunwald 15 years ago
parent
commit
9ff81633e2
  1. 5
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/ICSharpCode.AvalonEdit.Tests.csproj
  2. 11
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj
  3. 15
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs
  4. 25
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/TextFormatterFactory.cs

5
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit.Tests/ICSharpCode.AvalonEdit.Tests.csproj

@ -7,7 +7,7 @@
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.AvalonEdit</RootNamespace> <RootNamespace>ICSharpCode.AvalonEdit</RootNamespace>
<AssemblyName>ICSharpCode.AvalonEdit.Tests</AssemblyName> <AssemblyName>ICSharpCode.AvalonEdit.Tests</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<SourceAnalysisOverrideSettingsFile>"C:\Program Files\SharpDevelop\3.0\bin\..\AddIns\AddIns\Misc\SourceAnalysis\Settings.SourceAnalysis"</SourceAnalysisOverrideSettingsFile> <SourceAnalysisOverrideSettingsFile>"C:\Program Files\SharpDevelop\3.0\bin\..\AddIns\AddIns\Misc\SourceAnalysis\Settings.SourceAnalysis"</SourceAnalysisOverrideSettingsFile>
<SignAssembly>True</SignAssembly> <SignAssembly>True</SignAssembly>
@ -61,6 +61,9 @@
<Reference Include="System.Core"> <Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq"> <Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>

11
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<ProjectGuid>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</ProjectGuid> <ProjectGuid>{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -7,7 +7,7 @@
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.AvalonEdit</RootNamespace> <RootNamespace>ICSharpCode.AvalonEdit</RootNamespace>
<AssemblyName>ICSharpCode.AvalonEdit</AssemblyName> <AssemblyName>ICSharpCode.AvalonEdit</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<SourceAnalysisOverrideSettingsFile>"C:\Program Files\SharpDevelop\3.0\bin\..\AddIns\AddIns\Misc\SourceAnalysis\Settings.SourceAnalysis"</SourceAnalysisOverrideSettingsFile> <SourceAnalysisOverrideSettingsFile>"C:\Program Files\SharpDevelop\3.0\bin\..\AddIns\AddIns\Misc\SourceAnalysis\Settings.SourceAnalysis"</SourceAnalysisOverrideSettingsFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
@ -29,14 +29,14 @@
<DebugType>Full</DebugType> <DebugType>Full</DebugType>
<Optimize>False</Optimize> <Optimize>False</Optimize>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE;DOTNET4</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>false</DebugSymbols> <DebugSymbols>false</DebugSymbols>
<DebugType>PdbOnly</DebugType> <DebugType>PdbOnly</DebugType>
<Optimize>True</Optimize> <Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE;DOTNET4</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> <PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop> <RegisterForComInterop>False</RegisterForComInterop>
@ -63,6 +63,9 @@
</Reference> </Reference>
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq"> <Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>

15
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs

@ -58,8 +58,17 @@ namespace ICSharpCode.AvalonEdit
textArea.TextView.Services.AddService(typeof(TextEditor), this); textArea.TextView.Services.AddService(typeof(TextEditor), this);
this.Options = textArea.Options; SetCurrentPropertyValue(OptionsProperty, textArea.Options);
this.Document = new TextDocument(); SetCurrentPropertyValue(DocumentProperty, new TextDocument());
}
void SetCurrentPropertyValue(DependencyProperty property, object value)
{
#if DOTNET4
SetCurrentValue(property, value);
#else
SetValue(property, value);
#endif
} }
#endregion #endregion
@ -431,7 +440,7 @@ namespace ICSharpCode.AvalonEdit
if (e.PropertyName == "IsOriginalFile") { if (e.PropertyName == "IsOriginalFile") {
TextDocument document = this.Document; TextDocument document = this.Document;
if (document != null) { if (document != null) {
this.IsModified = !document.UndoStack.IsOriginalFile; SetCurrentPropertyValue(IsModifiedProperty, Boxes.Box(!document.UndoStack.IsOriginalFile));
} }
return true; return true;
} else { } else {

25
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/TextFormatterFactory.cs

@ -20,6 +20,7 @@ namespace ICSharpCode.AvalonEdit.Utils
/// </summary> /// </summary>
static class TextFormatterFactory static class TextFormatterFactory
{ {
#if !DOTNET4
readonly static DependencyProperty TextFormattingModeProperty; readonly static DependencyProperty TextFormattingModeProperty;
static TextFormatterFactory() static TextFormatterFactory()
@ -30,6 +31,7 @@ namespace ICSharpCode.AvalonEdit.Utils
TextFormattingModeProperty = textOptionsType.GetField("TextFormattingModeProperty").GetValue(null) as DependencyProperty; TextFormattingModeProperty = textOptionsType.GetField("TextFormattingModeProperty").GetValue(null) as DependencyProperty;
} }
} }
#endif
/// <summary> /// <summary>
/// Creates a <see cref="TextFormatter"/> using the formatting mode used by the specified owner object. /// Creates a <see cref="TextFormatter"/> using the formatting mode used by the specified owner object.
@ -38,7 +40,9 @@ namespace ICSharpCode.AvalonEdit.Utils
{ {
if (owner == null) if (owner == null)
throw new ArgumentNullException("owner"); throw new ArgumentNullException("owner");
// return TextFormatter.Create(TextOptions.GetTextFormattingMode(this)); #if DOTNET4
return TextFormatter.Create(TextOptions.GetTextFormattingMode(owner));
#else
if (TextFormattingModeProperty != null) { if (TextFormattingModeProperty != null) {
object formattingMode = owner.GetValue(TextFormattingModeProperty); object formattingMode = owner.GetValue(TextFormattingModeProperty);
return (TextFormatter)typeof(TextFormatter).InvokeMember( return (TextFormatter)typeof(TextFormatter).InvokeMember(
@ -50,6 +54,7 @@ namespace ICSharpCode.AvalonEdit.Utils
} else { } else {
return TextFormatter.Create(); return TextFormatter.Create();
} }
#endif
} }
/// <summary> /// <summary>
@ -58,8 +63,11 @@ namespace ICSharpCode.AvalonEdit.Utils
/// </summary> /// </summary>
public static bool PropertyChangeAffectsTextFormatter(DependencyProperty dp) public static bool PropertyChangeAffectsTextFormatter(DependencyProperty dp)
{ {
// return dp == TextOptions.TextFormattingModeProperty; #if DOTNET4
return dp == TextOptions.TextFormattingModeProperty;
#else
return dp == TextFormattingModeProperty && TextFormattingModeProperty != null; return dp == TextFormattingModeProperty && TextFormattingModeProperty != null;
#endif
} }
/// <summary> /// <summary>
@ -83,6 +91,18 @@ namespace ICSharpCode.AvalonEdit.Utils
emSize = TextBlock.GetFontSize(element); emSize = TextBlock.GetFontSize(element);
if (foreground == null) if (foreground == null)
foreground = TextBlock.GetForeground(element); foreground = TextBlock.GetForeground(element);
#if DOTNET4
return new FormattedText(
text,
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
typeface,
emSize.Value,
foreground,
null,
TextOptions.GetTextFormattingMode(element)
);
#else
if (TextFormattingModeProperty != null) { if (TextFormattingModeProperty != null) {
object formattingMode = element.GetValue(TextFormattingModeProperty); object formattingMode = element.GetValue(TextFormattingModeProperty);
return (FormattedText)Activator.CreateInstance( return (FormattedText)Activator.CreateInstance(
@ -106,6 +126,7 @@ namespace ICSharpCode.AvalonEdit.Utils
foreground foreground
); );
} }
#endif
} }
} }
} }

Loading…
Cancel
Save