Browse Source

Fixed XamlDesigner sample

pull/1/head
Daniel Grunwald 16 years ago
parent
commit
cef7bd1a6c
  1. 4
      samples/HtmlSyntaxColorizer/HtmlSyntaxColorizer.csproj
  2. 6
      samples/HtmlSyntaxColorizer/HtmlSyntaxColorizer.sln
  3. 1
      samples/XamlDesigner/App.xaml.cs
  4. 17
      samples/XamlDesigner/DocumentView.xaml
  5. 29
      samples/XamlDesigner/DocumentView.xaml.cs
  6. 2
      samples/XamlDesigner/MainWindow.xaml.cs
  7. 16
      samples/XamlDesigner/XamlDesigner.csproj

4
samples/HtmlSyntaxColorizer/HtmlSyntaxColorizer.csproj

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup> <PropertyGroup>
<ProjectGuid>{6D17428C-A444-4C26-8FE3-976160F41D97}</ProjectGuid> <ProjectGuid>{6D17428C-A444-4C26-8FE3-976160F41D97}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -7,7 +7,7 @@
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<RootNamespace>HtmlSyntaxColorizer</RootNamespace> <RootNamespace>HtmlSyntaxColorizer</RootNamespace>
<AssemblyName>HtmlSyntaxColorizer</AssemblyName> <AssemblyName>HtmlSyntaxColorizer</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>

6
samples/HtmlSyntaxColorizer/HtmlSyntaxColorizer.sln

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 10.00 Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2008 # Visual Studio 2010
# SharpDevelop 4.0.0.5490 # SharpDevelop 4.0.0.6517
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

1
samples/XamlDesigner/App.xaml.cs

@ -18,7 +18,6 @@ namespace ICSharpCode.XamlDesigner
{ {
DispatcherUnhandledException += App_DispatcherUnhandledException; DispatcherUnhandledException += App_DispatcherUnhandledException;
Args = e.Args; Args = e.Args;
System.Windows.Forms.Application.EnableVisualStyles();
base.OnStartup(e); base.OnStartup(e);
} }

17
samples/XamlDesigner/DocumentView.xaml

@ -2,22 +2,21 @@
x:Class="ICSharpCode.XamlDesigner.DocumentView" x:Class="ICSharpCode.XamlDesigner.DocumentView"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation" xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Integration="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:TextEditor="clr-namespace:ICSharpCode.TextEditor;assembly=ICSharpCode.TextEditor"
xmlns:Default="clr-namespace:ICSharpCode.XamlDesigner" xmlns:Default="clr-namespace:ICSharpCode.XamlDesigner"
xmlns:DesignerControls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls;assembly=ICSharpCode.WpfDesign.Designer" xmlns:DesignerControls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls;assembly=ICSharpCode.WpfDesign.Designer"
> xmlns:AvalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
>
<DockPanel> <DockPanel>
<DesignerControls:EnumBar Value="{Binding Mode}" <DesignerControls:EnumBar
Value="{Binding Mode}"
DockPanel.Dock="Bottom"/> DockPanel.Dock="Bottom"/>
<Grid> <Grid>
<Integration:WindowsFormsHost Visibility="{Binding InXamlMode, Converter={StaticResource CollapsedWhenFalse}}"> <AvalonEdit:TextEditor
<TextEditor:TextEditorControl x:Name="uxTextEditor" /> x:Name="uxTextEditor"
</Integration:WindowsFormsHost> SyntaxHighlighting="XML"
Visibility="{Binding InXamlMode, Converter={StaticResource CollapsedWhenFalse}}" />
<ContentPresenter Content="{Binding DesignSurface}" <ContentPresenter Content="{Binding DesignSurface}"
Visibility="{Binding InDesignMode, Converter={StaticResource CollapsedWhenFalse}}"/> Visibility="{Binding InDesignMode, Converter={StaticResource CollapsedWhenFalse}}"/>
</Grid> </Grid>
</DockPanel> </DockPanel>
</UserControl> </UserControl>

29
samples/XamlDesigner/DocumentView.xaml.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Windows; using System.Windows;
@ -11,9 +12,10 @@ using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Navigation; using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
using ICSharpCode.WpfDesign.Designer.Services;
using System.Windows.Threading; using System.Windows.Threading;
using ICSharpCode.WpfDesign.Designer.Services;
namespace ICSharpCode.XamlDesigner namespace ICSharpCode.XamlDesigner
{ {
public partial class DocumentView public partial class DocumentView
@ -25,9 +27,21 @@ namespace ICSharpCode.XamlDesigner
Document = doc; Document = doc;
Shell.Instance.Views[doc] = this; Shell.Instance.Views[doc] = this;
uxTextEditor.SetHighlighting("XML"); //uxTextEditor.DataBindings.Add("Text", doc, "Text", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
uxTextEditor.DataBindings.Add("Text", doc, "Text", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
Document.Mode = DocumentMode.Design; Document.Mode = DocumentMode.Design;
Document.PropertyChanged += new PropertyChangedEventHandler(Document_PropertyChanged);
uxTextEditor.TextChanged += new EventHandler(uxTextEditor_TextChanged);
}
void uxTextEditor_TextChanged(object sender, EventArgs e)
{
Document.Text = uxTextEditor.Text;
}
void Document_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "Text" && Document.Text != uxTextEditor.Text)
uxTextEditor.Text = Document.Text;
} }
public Document Document { get; private set; } public Document Document { get; private set; }
@ -35,9 +49,12 @@ namespace ICSharpCode.XamlDesigner
public void JumpToError(XamlError error) public void JumpToError(XamlError error)
{ {
Document.Mode = DocumentMode.Xaml; Document.Mode = DocumentMode.Xaml;
Dispatcher.BeginInvoke(new Action(delegate { try {
uxTextEditor.ActiveTextAreaControl.JumpTo(error.Line - 1, error.Column - 1); uxTextEditor.ScrollTo(error.Line, error.Column);
}), DispatcherPriority.Background); uxTextEditor.CaretOffset = uxTextEditor.Document.GetOffset(error.Line, error.Column);
} catch (ArgumentException) {
// invalid line number
}
} }
} }
} }

2
samples/XamlDesigner/MainWindow.xaml.cs

@ -148,9 +148,11 @@ namespace ICSharpCode.XamlDesigner
Height = r.Height; Height = r.Height;
} }
uxDockingManager.Loaded += delegate {
if (Settings.Default.AvalonDockLayout != null) { if (Settings.Default.AvalonDockLayout != null) {
uxDockingManager.RestoreLayout(Settings.Default.AvalonDockLayout.ToStream()); uxDockingManager.RestoreLayout(Settings.Default.AvalonDockLayout.ToStream());
} }
};
} }
void SaveSettings() void SaveSettings()

16
samples/XamlDesigner/XamlDesigner.csproj

@ -45,22 +45,19 @@
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="AvalonDock, Version=1.1.1231.0, Culture=neutral, PublicKeyToken=85a1e0ada7ec13e4, processorArchitecture=MSIL"> <Reference Include="AvalonDock">
<SpecificVersion>False</SpecificVersion> <HintPath>..\..\bin\AvalonDock.dll</HintPath>
<HintPath>Libraries\AvalonDock.dll</HintPath> </Reference>
<Reference Include="ICSharpCode.AvalonEdit">
<HintPath>..\..\bin\ICSharpCode.AvalonEdit.dll</HintPath>
</Reference> </Reference>
<Reference Include="ICSharpCode.SharpDevelop.Widgets"> <Reference Include="ICSharpCode.SharpDevelop.Widgets">
<HintPath>..\..\bin\ICSharpCode.SharpDevelop.Widgets.dll</HintPath> <HintPath>..\..\bin\ICSharpCode.SharpDevelop.Widgets.dll</HintPath>
</Reference> </Reference>
<Reference Include="ICSharpCode.TextEditor, Version=3.0.0.3267, Culture=neutral, PublicKeyToken=4d61825e8dd49f1a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\bin\ICSharpCode.TextEditor.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>
</Reference> </Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml"> <Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework> <RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference> </Reference>
@ -84,9 +81,6 @@
<Reference Include="PresentationFramework"> <Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework> <RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="WindowsFormsIntegration">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ApplicationDefinition Include="App.xaml"> <ApplicationDefinition Include="App.xaml">

Loading…
Cancel
Save