diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
index 3abca2a889..ac7cbc8a10 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
@@ -68,7 +68,11 @@
+
+
+
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/App.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/App.xaml.cs
new file mode 100644
index 0000000000..12ea48806c
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/App.xaml.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Windows;
+using ICSharpCode.XamlDesigner.Configuration;
+using System.Windows.Threading;
+using System.Diagnostics;
+
+namespace ICSharpCode.XamlDesigner
+{
+ public partial class App
+ {
+ public static string[] Args;
+
+ protected override void OnStartup(StartupEventArgs e)
+ {
+ DispatcherUnhandledException += App_DispatcherUnhandledException;
+ Args = e.Args;
+ System.Windows.Forms.Application.EnableVisualStyles();
+ base.OnStartup(e);
+ }
+
+ void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
+ {
+ Shell.ReportException(e.Exception);
+ e.Handled = true;
+ }
+
+ protected override void OnExit(ExitEventArgs e)
+ {
+ Settings.Default.Save();
+ base.OnExit(e);
+ }
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/BitmapButton.xaml b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/BitmapButton.xaml
new file mode 100644
index 0000000000..7c1a28bd96
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/BitmapButton.xaml
@@ -0,0 +1,32 @@
+
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/BitmapButton.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/BitmapButton.xaml.cs
new file mode 100644
index 0000000000..4200c1bc9d
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/BitmapButton.xaml.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace ICSharpCode.XamlDesigner
+{
+ public partial class BitmapButton
+ {
+ public BitmapButton()
+ {
+ InitializeComponent();
+ DataContext = this;
+ }
+
+ public string ImageHover {
+ get { return "Images/" + GetType().Name + ".Hover.png"; }
+ }
+
+ public string ImageNormal {
+ get { return "Images/" + GetType().Name + ".Normal.png"; }
+ }
+
+ public string ImagePressed {
+ get { return "Images/" + GetType().Name + ".Pressed.png"; }
+ }
+
+ public string ImageDisabled {
+ get { return "Images/" + GetType().Name + ".Disabled.png"; }
+ }
+ }
+
+ class CloseButton : BitmapButton
+ {
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/AssemblyInfo.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/AssemblyInfo.cs
new file mode 100644
index 0000000000..651ee86e68
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/AssemblyInfo.cs
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("XamlDesigner")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+//In order to begin building localizable applications, set
+//CultureYouAreCodingWith in your .csproj file
+//inside a . For example, if you are using US english
+//in your source files, set the to en-US. Then uncomment
+//the NeutralResourceLanguage attribute below. Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/Settings.Designer.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/Settings.Designer.cs
new file mode 100644
index 0000000000..9a835b8cf5
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/Settings.Designer.cs
@@ -0,0 +1,110 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.3031
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace ICSharpCode.XamlDesigner.Configuration {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0,0,0,0")]
+ public global::System.Windows.Rect MainWindowRect {
+ get {
+ return ((global::System.Windows.Rect)(this["MainWindowRect"]));
+ }
+ set {
+ this["MainWindowRect"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute(@"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+")]
+ public string AvalonDockLayout {
+ get {
+ return ((string)(this["AvalonDockLayout"]));
+ }
+ set {
+ this["AvalonDockLayout"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ public global::System.Collections.Specialized.StringCollection RecentFiles {
+ get {
+ return ((global::System.Collections.Specialized.StringCollection)(this["RecentFiles"]));
+ }
+ set {
+ this["RecentFiles"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute(@"
+
+ %ProgramFiles%\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll
+")]
+ public global::System.Collections.Specialized.StringCollection AssemblyList {
+ get {
+ return ((global::System.Collections.Specialized.StringCollection)(this["AssemblyList"]));
+ }
+ set {
+ this["AssemblyList"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("Maximized")]
+ public global::System.Windows.WindowState MainWindowState {
+ get {
+ return ((global::System.Windows.WindowState)(this["MainWindowState"]));
+ }
+ set {
+ this["MainWindowState"] = value;
+ }
+ }
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/Settings.settings b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/Settings.settings
new file mode 100644
index 0000000000..65e359e302
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/Settings.settings
@@ -0,0 +1,46 @@
+
+
+
+
+
+ 0,0,0,0
+
+
+ <DockingManager>
+ <ResizingPanel Orientation="Horizontal">
+ <ResizingPanel ResizeWidth="200" Orientation="Vertical">
+ <DockablePane ResizeHeight="441.36166666666668" Anchor="Left">
+ <DockableContent Name="content1" AutoHide="false" />
+ </DockablePane>
+ <DockablePane ResizeWidth="200" Anchor="Left">
+ <DockableContent Name="content2" AutoHide="false" />
+ </DockablePane>
+ </ResizingPanel>
+ <ResizingPanel Orientation="Vertical">
+ <DocumentPanePlaceHolder />
+ <DockablePane ResizeHeight="138" Anchor="Bottom">
+ <DockableContent Name="content3" AutoHide="false" />
+ </DockablePane>
+ </ResizingPanel>
+ <DockablePane ResizeWidth="271" Anchor="Right">
+ <DockableContent Name="content4" AutoHide="false" />
+ </DockablePane>
+ </ResizingPanel>
+ <Hidden />
+ <Windows />
+</DockingManager>
+
+
+
+
+
+ <?xml version="1.0" encoding="utf-16"?>
+<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <string>%ProgramFiles%\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll</string>
+</ArrayOfString>
+
+
+ Maximized
+
+
+
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/app.config b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/app.config
new file mode 100644
index 0000000000..c49779f8d1
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/app.config
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+ 0,0,0,0
+
+
+ <DockingManager>
+ <ResizingPanel Orientation="Horizontal">
+ <ResizingPanel ResizeWidth="200" Orientation="Vertical">
+ <DockablePane ResizeHeight="441.36166666666668" Anchor="Left">
+ <DockableContent Name="content1" AutoHide="false" />
+ </DockablePane>
+ <DockablePane ResizeWidth="200" Anchor="Left">
+ <DockableContent Name="content2" AutoHide="false" />
+ </DockablePane>
+ </ResizingPanel>
+ <ResizingPanel Orientation="Vertical">
+ <DocumentPanePlaceHolder />
+ <DockablePane ResizeHeight="138" Anchor="Bottom">
+ <DockableContent Name="content3" AutoHide="false" />
+ </DockablePane>
+ </ResizingPanel>
+ <DockablePane ResizeWidth="271" Anchor="Right">
+ <DockableContent Name="content4" AutoHide="false" />
+ </DockablePane>
+ </ResizingPanel>
+ <Hidden />
+ <Windows />
+</DockingManager>
+
+
+
+
+ %ProgramFiles%\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll
+
+
+
+
+ Maximized
+
+
+
+
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/app.manifest b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/app.manifest
new file mode 100644
index 0000000000..e82a10f183
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Configuration/app.manifest
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Converters.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Converters.cs
new file mode 100644
index 0000000000..3590603bf4
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Converters.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows.Data;
+using System.Globalization;
+using System.Windows;
+using System.Collections;
+
+namespace ICSharpCode.XamlDesigner.Converters
+{
+ public class EnumToIntConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return (int)value;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return value;
+ }
+ }
+
+ public class CollapsedWhenFalse : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return (bool)value ? Visibility.Visible : Visibility.Collapsed;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public class FalseWhenZero : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value == null || (int)value == 0) {
+ return false;
+ }
+ return true;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Document.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Document.cs
new file mode 100644
index 0000000000..5c1da59c5b
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Document.cs
@@ -0,0 +1,212 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.ComponentModel;
+using System.IO;
+using ICSharpCode.WpfDesign.Designer;
+using ICSharpCode.WpfDesign.Designer.Xaml;
+using System.Xml;
+using ICSharpCode.WpfDesign;
+using ICSharpCode.WpfDesign.Designer.Services;
+using System.Diagnostics;
+
+namespace ICSharpCode.XamlDesigner
+{
+ public class Document : INotifyPropertyChanged
+ {
+ public Document(string tempName, string text)
+ {
+ this.tempName = tempName;
+ Text = text;
+ IsDirty = false;
+ }
+
+ public Document(string filePath)
+ {
+ this.filePath = filePath;
+ ReloadFile();
+ }
+
+ string tempName;
+ DesignSurface designSurface = new DesignSurface();
+
+ string text;
+
+ public string Text {
+ get {
+ return text;
+ }
+ set {
+ if (text != value) {
+ text = value;
+ IsDirty = true;
+ RaisePropertyChanged("Text");
+ }
+ }
+ }
+
+ DocumentMode mode;
+
+ void SetMode(DocumentMode newMode)
+ {
+ mode = newMode;
+ if (IsDesign) {
+ UpdateDesign();
+ }
+ else {
+ UpdateXaml();
+ }
+ RaisePropertyChanged("IsXaml");
+ RaisePropertyChanged("IsDesign");
+ RaisePropertyChanged("SelectionService");
+ }
+
+ public bool IsXaml {
+ get { return mode == DocumentMode.Xaml; }
+ set { if (value) SetMode(DocumentMode.Xaml); }
+ }
+
+ public bool IsDesign {
+ get { return mode == DocumentMode.Design; }
+ set { if (value) SetMode(DocumentMode.Design); }
+ }
+
+ string filePath;
+
+ public string FilePath {
+ get {
+ return filePath;
+ }
+ private set {
+ filePath = value;
+ RaisePropertyChanged("FilePath");
+ RaisePropertyChanged("FileName");
+ RaisePropertyChanged("Title");
+ RaisePropertyChanged("Name");
+ }
+ }
+
+ bool isDirty;
+
+ public bool IsDirty {
+ get {
+ return isDirty;
+ }
+ private set {
+ isDirty = value;
+ RaisePropertyChanged("IsDirty");
+ RaisePropertyChanged("Name");
+ RaisePropertyChanged("Title");
+ }
+ }
+
+ public string FileName {
+ get {
+ if (FilePath == null) return null;
+ return Path.GetFileName(FilePath);
+ }
+ }
+
+ public string Name {
+ get {
+ return FileName ?? tempName;
+ }
+ }
+
+ public string Title {
+ get {
+ return IsDirty ? Name + "*" : Name;
+ }
+ }
+
+ public DesignSurface DesignSurface {
+ get { return designSurface; }
+ }
+
+ public DesignContext DesignContext {
+ get { return designSurface.DesignContext; }
+ }
+
+ public UndoService UndoService {
+ get { return DesignContext.Services.GetService(); }
+ }
+
+ public ISelectionService SelectionService {
+ get {
+ if (IsDesign && DesignContext != null) {
+ return DesignContext.Services.Selection;
+ }
+ return null;
+ }
+ }
+
+ void ReloadFile()
+ {
+ Text = File.ReadAllText(FilePath);
+ UpdateDesign();
+ IsDirty = false;
+ }
+
+ public void Save()
+ {
+ if (IsDesign) {
+ UpdateXaml();
+ }
+ File.WriteAllText(FilePath, Text);
+ IsDirty = false;
+ }
+
+ public void SaveAs(string filePath)
+ {
+ FilePath = filePath;
+ Save();
+ }
+
+ void UpdateXaml()
+ {
+ var sb = new StringBuilder();
+ using (var xmlWriter = XmlWriter.Create(sb)) {
+ try {
+ DesignSurface.SaveDesigner(xmlWriter);
+ Text = XamlFormatter.Format(sb.ToString());
+ }
+ catch (Exception x) {
+ Shell.ReportException(x);
+ }
+ }
+ }
+
+ void UpdateDesign()
+ {
+ try {
+ XamlLoadSettings settings = new XamlLoadSettings();
+ using (var xmlReader = XmlReader.Create(new StringReader(Text))) {
+ DesignSurface.LoadDesigner(xmlReader, settings);
+ }
+ UndoService.UndoStackChanged += delegate { IsDirty = true; };
+ }
+ catch (Exception x) {
+ Shell.ReportException(x);
+ }
+ }
+
+ #region INotifyPropertyChanged Members
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ void RaisePropertyChanged(string name)
+ {
+ if (PropertyChanged != null) {
+ PropertyChanged(this, new PropertyChangedEventArgs(name));
+ }
+ }
+
+ #endregion
+
+ enum DocumentMode
+ {
+ Xaml, Design
+ }
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/DocumentView.xaml b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/DocumentView.xaml
new file mode 100644
index 0000000000..c2fc424bea
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/DocumentView.xaml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/DocumentView.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/DocumentView.xaml.cs
new file mode 100644
index 0000000000..f567d7347d
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/DocumentView.xaml.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace ICSharpCode.XamlDesigner
+{
+ public partial class DocumentView
+ {
+ public DocumentView(Document doc)
+ {
+ InitializeComponent();
+ uxTextEditor.SetHighlighting("XML");
+ uxTextEditor.DataBindings.Add("Text", doc, "Text", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
+ }
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/DragListener.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/DragListener.cs
new file mode 100644
index 0000000000..e2d3cec7c9
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/DragListener.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Input;
+
+namespace ICSharpCode.XamlDesigner
+{
+ class DragListener
+ {
+ public DragListener(IInputElement target)
+ {
+ this.target = target;
+ target.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(target_PreviewMouseLeftButtonDown);
+ target.PreviewMouseMove += new MouseEventHandler(target_PreviewMouseMove);
+ }
+
+ public event MouseEventHandler DragStarted;
+
+ IInputElement target;
+ Window window;
+ Point startPoint;
+ bool readyToRaise;
+
+ Point GetMousePosition()
+ {
+ if (window == null) {
+ window = Window.GetWindow(target as DependencyObject);
+ }
+ return Mouse.GetPosition(window);
+ }
+
+ bool IsMovementBigEnough()
+ {
+ Point currentPoint = GetMousePosition();
+ return (Math.Abs(currentPoint.X - startPoint.X) >= SystemParameters.MinimumHorizontalDragDistance ||
+ Math.Abs(currentPoint.Y - startPoint.Y) >= SystemParameters.MinimumVerticalDragDistance);
+ }
+
+ void target_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ readyToRaise = true;
+ startPoint = GetMousePosition();
+ }
+
+ void target_PreviewMouseMove(object sender, MouseEventArgs e)
+ {
+ if (readyToRaise && IsMovementBigEnough()) {
+ readyToRaise = false;
+ if (DragStarted != null) {
+ DragStarted(target, e);
+ }
+ }
+ }
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/ExtensionMethods.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/ExtensionMethods.cs
new file mode 100644
index 0000000000..4c9a1dd358
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/ExtensionMethods.cs
@@ -0,0 +1,93 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Documents;
+using System.Windows.Media;
+using System.IO;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
+using System.Collections;
+
+namespace ICSharpCode.XamlDesigner
+{
+ static class ExtensionMethods
+ {
+ public static IEnumerable Paths(this IDataObject data)
+ {
+ string[] paths = (string[])data.GetData(DataFormats.FileDrop);
+ if (paths != null) {
+ foreach (var path in paths) {
+ yield return path;
+ }
+ }
+ }
+
+ public static T GetObject(this IDataObject data)
+ {
+ return (T)data.GetData(typeof(T).FullName);
+ }
+
+ public static T FindAncestor(this DependencyObject d) where T : class
+ {
+ while (true) {
+ if (d == null) return null;
+ if (d is T) return d as T;
+ d = VisualTreeHelper.GetParent(d);
+ }
+ }
+
+ public static Stream ToStream(this string s)
+ {
+ return new MemoryStream(Encoding.UTF8.GetBytes(s));
+ }
+
+ public static void AddRange(this ObservableCollection col, IEnumerable items)
+ {
+ foreach (var item in items) {
+ col.Add(item);
+ }
+ }
+
+ public static void KeepSyncronizedWith(this IList target, ObservableCollection source, Func convert)
+ {
+ target.Clear();
+ foreach (var item in source) {
+ target.Add(convert(item));
+ }
+
+ source.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs e) {
+ switch (e.Action) {
+ case NotifyCollectionChangedAction.Add:
+ target.Add(convert((S)e.NewItems[0]));
+ break;
+
+ case NotifyCollectionChangedAction.Remove:
+ target.RemoveAt(e.OldStartingIndex);
+ break;
+
+ case NotifyCollectionChangedAction.Move:
+ target.RemoveAt(e.OldStartingIndex);
+ target.Insert(e.NewStartingIndex, e.NewItems[0]);
+ break;
+
+ case NotifyCollectionChangedAction.Replace:
+ target[e.NewStartingIndex] = convert((S)e.NewItems[0]);
+ break;
+
+ case NotifyCollectionChangedAction.Reset:
+ target.Clear();
+ break;
+ }
+ };
+ }
+
+ public static object GetDataContext(this RoutedEventArgs e)
+ {
+ var f = e.OriginalSource as FrameworkElement;
+ if (f != null) return f.DataContext;
+ return null;
+ }
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Images/Reference.png b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Images/Reference.png
new file mode 100644
index 0000000000..da47049481
Binary files /dev/null and b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Images/Reference.png differ
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Images/Tag.png b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Images/Tag.png
new file mode 100644
index 0000000000..b7686f106b
Binary files /dev/null and b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Images/Tag.png differ
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Libraries/AvalonDock.dll b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Libraries/AvalonDock.dll
new file mode 100644
index 0000000000..15ca4dce3b
Binary files /dev/null and b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Libraries/AvalonDock.dll differ
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Libraries/ICSharpCode.TextEditor.dll b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Libraries/ICSharpCode.TextEditor.dll
new file mode 100644
index 0000000000..04f11701e9
Binary files /dev/null and b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Libraries/ICSharpCode.TextEditor.dll differ
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/MainWindow.xaml b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/MainWindow.xaml
new file mode 100644
index 0000000000..3fda7bd62e
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/MainWindow.xaml
@@ -0,0 +1,118 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/MainWindow.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/MainWindow.xaml.cs
new file mode 100644
index 0000000000..67c68bb513
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/MainWindow.xaml.cs
@@ -0,0 +1,181 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+using ICSharpCode.XamlDesigner.Configuration;
+using System.ComponentModel;
+using Microsoft.Win32;
+using AvalonDock;
+using System.IO;
+using System.Collections.Specialized;
+
+namespace ICSharpCode.XamlDesigner
+{
+ public partial class MainWindow
+ {
+ public MainWindow()
+ {
+ RenameCommands();
+
+ Instance = this;
+ DataContext = Shell.Instance;
+ InitializeComponent();
+
+ Shell.Instance.PropertyGrid = uxPropertyGridView.PropertyGrid;
+ AvalonDockWorkaround();
+ LoadSettings();
+ ProcessPaths(App.Args);
+ }
+
+ public static MainWindow Instance;
+
+ OpenFileDialog openFileDialog;
+ SaveFileDialog saveFileDialog;
+
+ protected override void OnDragEnter(DragEventArgs e)
+ {
+ ProcessDrag(e);
+ }
+
+ protected override void OnDragOver(DragEventArgs e)
+ {
+ ProcessDrag(e);
+ }
+
+ protected override void OnDrop(DragEventArgs e)
+ {
+ ProcessPaths(e.Data.Paths());
+ }
+
+ protected override void OnClosing(CancelEventArgs e)
+ {
+ if (Shell.Instance.PrepareExit()) {
+ SaveSettings();
+ }
+ else {
+ e.Cancel = true;
+ }
+ base.OnClosing(e);
+ }
+
+ void RecentFiles_Click(object sender, RoutedEventArgs e)
+ {
+ var path = (string)(e.OriginalSource as MenuItem).Header;
+ Shell.Instance.Open(path);
+ }
+
+ void ProcessDrag(DragEventArgs e)
+ {
+ e.Effects = DragDropEffects.None;
+ e.Handled = true;
+
+ foreach (var path in e.Data.Paths()) {
+ if (path.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase) ||
+ path.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase)) {
+ e.Effects = DragDropEffects.Copy;
+ break;
+ }
+ else if (path.EndsWith(".xaml", StringComparison.InvariantCultureIgnoreCase)) {
+ e.Effects = DragDropEffects.Copy;
+ break;
+ }
+ }
+ }
+
+ void ProcessPaths(IEnumerable paths)
+ {
+ foreach (var path in paths) {
+ if (path.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase) ||
+ path.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase)) {
+ Toolbox.Instance.AddAssembly(path);
+ }
+ else if (path.EndsWith(".xaml", StringComparison.InvariantCultureIgnoreCase)) {
+ Shell.Instance.Open(path);
+ }
+ }
+ }
+
+ public string AskOpenFileName()
+ {
+ if (openFileDialog == null) {
+ openFileDialog = new OpenFileDialog();
+ openFileDialog.Filter = "Xaml Documents (*.xaml)|*.xaml";
+ }
+ if ((bool)openFileDialog.ShowDialog()) {
+ return openFileDialog.FileName;
+ }
+ return null;
+ }
+
+ public string AskSaveFileName(string initName)
+ {
+ if (saveFileDialog == null) {
+ saveFileDialog = new SaveFileDialog();
+ saveFileDialog.Filter = "Xaml Documents (*.xaml)|*.xaml";
+ }
+ saveFileDialog.FileName = initName;
+ if ((bool)saveFileDialog.ShowDialog()) {
+ return saveFileDialog.FileName;
+ }
+ return null;
+ }
+
+ void LoadSettings()
+ {
+ WindowState = Settings.Default.MainWindowState;
+
+ Rect r = Settings.Default.MainWindowRect;
+ if (r != new Rect()) {
+ Left = r.Left;
+ Top = r.Top;
+ Width = r.Width;
+ Height = r.Height;
+ }
+
+ if (Settings.Default.AvalonDockLayout != null) {
+ uxDockingManager.RestoreLayout(Settings.Default.AvalonDockLayout.ToStream());
+ }
+ }
+
+ void SaveSettings()
+ {
+ Settings.Default.MainWindowState = WindowState;
+ if (WindowState == WindowState.Normal) {
+ Settings.Default.MainWindowRect = new Rect(Left, Top, Width, Height);
+ }
+
+ var writer = new StringWriter();
+ uxDockingManager.SaveLayout(writer);
+ Settings.Default.AvalonDockLayout = writer.ToString();
+
+ Shell.Instance.SaveSettings();
+ }
+
+ #region AvalonDockWorkaround
+
+ void AvalonDockWorkaround()
+ {
+ uxDocumentPane.Items.KeepSyncronizedWith(Shell.Instance.Documents, d => CreateContentFor(d));
+ }
+
+ DocumentContent CreateContentFor(Document doc)
+ {
+ var content = new DocumentContent() {
+ DataContext = doc,
+ Content = new DocumentView(doc)
+ };
+ content.SetBinding(DocumentContent.TitleProperty, "Title");
+ return content;
+ }
+
+ #endregion
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/MainWindow_Commands.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/MainWindow_Commands.cs
new file mode 100644
index 0000000000..26ebe8c10b
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/MainWindow_Commands.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows.Input;
+
+namespace ICSharpCode.XamlDesigner
+{
+ public partial class MainWindow
+ {
+ public static SimpleCommand CloseAllCommand = new SimpleCommand("Close All");
+ public static SimpleCommand SaveAllCommand = new SimpleCommand("Save All", ModifierKeys.Control | ModifierKeys.Shift, Key.S);
+ public static SimpleCommand ExitCommand = new SimpleCommand("Exit");
+
+ static void RenameCommands()
+ {
+ ApplicationCommands.Open.Text = "Open...";
+ ApplicationCommands.SaveAs.Text = "Save As...";
+ }
+
+ void NewCommand_Executed(object sender, ExecutedRoutedEventArgs e)
+ {
+ Shell.Instance.New();
+ }
+
+ void OpenCommand_Executed(object sender, ExecutedRoutedEventArgs e)
+ {
+ Shell.Instance.Open();
+ }
+
+ void CloseCommand_Executed(object sender, ExecutedRoutedEventArgs e)
+ {
+ Shell.Instance.CloseCurrentDocument();
+ }
+
+ void CloseCommand_PreviewExecuted(object sender, ExecutedRoutedEventArgs e)
+ {
+ Shell.Instance.CloseCurrentDocument();
+ }
+
+ void CloseAllCommand_Executed(object sender, ExecutedRoutedEventArgs e)
+ {
+ Shell.Instance.CloseAll();
+ }
+
+ void SaveCommand_Executed(object sender, ExecutedRoutedEventArgs e)
+ {
+ Shell.Instance.SaveCurrentDocument();
+ }
+
+ void SaveAsCommand_Executed(object sender, ExecutedRoutedEventArgs e)
+ {
+ Shell.Instance.SaveCurrentDocumentAs();
+ }
+
+ void SaveAllCommand_Executed(object sender, ExecutedRoutedEventArgs e)
+ {
+ Shell.Instance.SaveAll();
+ }
+
+ void ExitCommand_Executed(object sender, ExecutedRoutedEventArgs e)
+ {
+ Shell.Instance.Exit();
+ }
+
+ void CurrentDocument_CanExecute(object sender, CanExecuteRoutedEventArgs e)
+ {
+ e.CanExecute = Shell.Instance.CurrentDocument != null;
+ }
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/NewFileTemplate.xaml b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/NewFileTemplate.xaml
new file mode 100644
index 0000000000..1734c1d49d
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/NewFileTemplate.xaml
@@ -0,0 +1,4 @@
+
+
+
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Outline.xaml b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Outline.xaml
new file mode 100644
index 0000000000..4f82d8f516
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Outline.xaml
@@ -0,0 +1,107 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Outline.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Outline.xaml.cs
new file mode 100644
index 0000000000..f7186ac275
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/Outline.xaml.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace ICSharpCode.XamlDesigner
+{
+ public partial class Outline
+ {
+ public Outline()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/OutlineTree.cs b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/OutlineTree.cs
new file mode 100644
index 0000000000..806cd34aa6
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/XamlDesigner/OutlineTree.cs
@@ -0,0 +1,267 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows.Controls;
+using System.Windows;
+using System.Collections.ObjectModel;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Controls.Primitives;
+
+namespace ICSharpCode.XamlDesigner
+{
+ public class OutlineTree : TreeView
+ {
+ public OutlineTree()
+ {
+ AllowDrop = true;
+ new DragListener(this).DragStarted += new MouseEventHandler(TreeList_DragStarted);
+ DragEnter += new DragEventHandler(TreeList_DragEnter);
+ DragOver += new DragEventHandler(TreeList_DragOver);
+ Drop += new DragEventHandler(TreeList_Drop);
+
+ //Selection = new ObservableCollection