Browse Source

Fixed XamlDesigner sample

pull/1/head
Daniel Grunwald 15 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 @@ @@ -1,5 +1,5 @@
<?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>
<ProjectGuid>{6D17428C-A444-4C26-8FE3-976160F41D97}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>HtmlSyntaxColorizer</RootNamespace>
<AssemblyName>HtmlSyntaxColorizer</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>

6
samples/HtmlSyntaxColorizer/HtmlSyntaxColorizer.sln

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

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
# SharpDevelop 4.0.0.5490
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.0.0.6517
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlSyntaxColorizer", "HtmlSyntaxColorizer.csproj", "{6D17428C-A444-4C26-8FE3-976160F41D97}"
EndProject
Global

1
samples/XamlDesigner/App.xaml.cs

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

17
samples/XamlDesigner/DocumentView.xaml

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

29
samples/XamlDesigner/DocumentView.xaml.cs

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
@ -11,9 +12,10 @@ using System.Windows.Media; @@ -11,9 +12,10 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.Designer.Services;
using System.Windows.Threading;
using ICSharpCode.WpfDesign.Designer.Services;
namespace ICSharpCode.XamlDesigner
{
public partial class DocumentView
@ -25,9 +27,21 @@ namespace ICSharpCode.XamlDesigner @@ -25,9 +27,21 @@ namespace ICSharpCode.XamlDesigner
Document = doc;
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.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; }
@ -35,9 +49,12 @@ namespace ICSharpCode.XamlDesigner @@ -35,9 +49,12 @@ namespace ICSharpCode.XamlDesigner
public void JumpToError(XamlError error)
{
Document.Mode = DocumentMode.Xaml;
Dispatcher.BeginInvoke(new Action(delegate {
uxTextEditor.ActiveTextAreaControl.JumpTo(error.Line - 1, error.Column - 1);
}), DispatcherPriority.Background);
try {
uxTextEditor.ScrollTo(error.Line, error.Column);
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 @@ -148,9 +148,11 @@ namespace ICSharpCode.XamlDesigner
Height = r.Height;
}
uxDockingManager.Loaded += delegate {
if (Settings.Default.AvalonDockLayout != null) {
uxDockingManager.RestoreLayout(Settings.Default.AvalonDockLayout.ToStream());
}
};
}
void SaveSettings()

16
samples/XamlDesigner/XamlDesigner.csproj

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

Loading…
Cancel
Save