Browse Source

Removed XamlDesigner sample.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3779 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 17 years ago
parent
commit
1f4a614b4c
  1. 13
      samples/XamlDesigner/App.xaml
  2. 37
      samples/XamlDesigner/App.xaml.cs
  3. 32
      samples/XamlDesigner/BitmapButton.xaml
  4. 45
      samples/XamlDesigner/BitmapButton.xaml.cs
  5. 33
      samples/XamlDesigner/Configuration/AssemblyInfo.cs
  6. 110
      samples/XamlDesigner/Configuration/Settings.Designer.cs
  7. 46
      samples/XamlDesigner/Configuration/Settings.settings
  8. 51
      samples/XamlDesigner/Configuration/app.config
  9. 29
      samples/XamlDesigner/Configuration/app.manifest
  10. 66
      samples/XamlDesigner/Converters.cs
  11. 243
      samples/XamlDesigner/Document.cs
  12. 23
      samples/XamlDesigner/DocumentView.xaml
  13. 134
      samples/XamlDesigner/DocumentView.xaml.cs
  14. 7
      samples/XamlDesigner/EnumBar.xaml
  15. 72
      samples/XamlDesigner/EnumBar.xaml.cs
  16. 26
      samples/XamlDesigner/EnumButton.cs
  17. 16
      samples/XamlDesigner/ErrorListView.xaml
  18. 34
      samples/XamlDesigner/ErrorListView.xaml.cs
  19. 84
      samples/XamlDesigner/ExtensionMethods.cs
  20. BIN
      samples/XamlDesigner/Images/Control.png
  21. BIN
      samples/XamlDesigner/Images/Error.png
  22. BIN
      samples/XamlDesigner/Images/Folder.png
  23. BIN
      samples/XamlDesigner/Images/Reference.png
  24. BIN
      samples/XamlDesigner/Images/Tag.png
  25. 90
      samples/XamlDesigner/MainWindow.xaml
  26. 191
      samples/XamlDesigner/MainWindow.xaml.cs
  27. 143
      samples/XamlDesigner/MainWindow_Commands.cs
  28. 4
      samples/XamlDesigner/NewFileTemplate.xaml
  29. 3
      samples/XamlDesigner/Properties/AssemblyInfo.cs
  30. 110
      samples/XamlDesigner/Properties/Settings.Designer.cs
  31. 46
      samples/XamlDesigner/Properties/Settings.settings
  32. 29
      samples/XamlDesigner/Properties/app.manifest
  33. 287
      samples/XamlDesigner/Shell.cs
  34. 27
      samples/XamlDesigner/SimpleCommand.cs
  35. 31
      samples/XamlDesigner/TestFiles/1.xaml
  36. 53
      samples/XamlDesigner/TestFiles/2.xaml
  37. 16
      samples/XamlDesigner/TestFiles/3.xaml
  38. 16
      samples/XamlDesigner/TestFiles/4.xaml
  39. 10
      samples/XamlDesigner/TestFiles/grid.xaml
  40. 6
      samples/XamlDesigner/Themes/Generic.xaml
  41. 105
      samples/XamlDesigner/Toolbox.cs
  42. 26
      samples/XamlDesigner/ToolboxTreeView.cs
  43. 26
      samples/XamlDesigner/ToolboxView.xaml
  44. 77
      samples/XamlDesigner/ToolboxView.xaml.cs
  45. 193
      samples/XamlDesigner/XamlDesigner.csproj
  46. 20
      samples/XamlDesigner/XamlDesigner.sln
  47. 203
      samples/XamlDesigner/XamlFormatter.cs
  48. 51
      samples/XamlDesigner/app.config

13
samples/XamlDesigner/App.xaml

@ -1,13 +0,0 @@ @@ -1,13 +0,0 @@
<Application x:Class="ICSharpCode.XamlDesigner.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Converters="clr-namespace:ICSharpCode.XamlDesigner.Converters"
StartupUri="MainWindow.xaml"
ShutdownMode="OnMainWindowClose">
<Application.Resources>
<Converters:CollapsedWhenFalse x:Key="CollapsedWhenFalse" />
<Converters:FalseWhenZero x:Key="FalseWhenZero" />
</Application.Resources>
</Application>

37
samples/XamlDesigner/App.xaml.cs

@ -1,37 +0,0 @@ @@ -1,37 +0,0 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using ICSharpCode.XamlDesigner.Properties;
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);
}
}
}

32
samples/XamlDesigner/BitmapButton.xaml

@ -1,32 +0,0 @@ @@ -1,32 +0,0 @@
<Button x:Class="ICSharpCode.XamlDesigner.BitmapButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Focusable="False">
<Button.Template>
<ControlTemplate TargetType="Button">
<Image x:Name="image1"
Stretch="None"
Source="{Binding ImageNormal}" />
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Source"
Value="{Binding ImageHover}"
TargetName="image1" />
</Trigger>
<Trigger Property="IsPressed"
Value="True">
<Setter Property="Source"
Value="{Binding ImagePressed}"
TargetName="image1" />
</Trigger>
<Trigger Property="IsEnabled"
Value="False">
<Setter Property="Source"
Value="{Binding ImageDisabled}"
TargetName="image1" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>

45
samples/XamlDesigner/BitmapButton.xaml.cs

@ -1,45 +0,0 @@ @@ -1,45 +0,0 @@
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
{
}
}

33
samples/XamlDesigner/Configuration/AssemblyInfo.cs

@ -1,33 +0,0 @@ @@ -1,33 +0,0 @@
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
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> 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)
)]

110
samples/XamlDesigner/Configuration/Settings.Designer.cs generated

@ -1,110 +0,0 @@ @@ -1,110 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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(@"<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>")]
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(@"<?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>")]
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;
}
}
}
}

46
samples/XamlDesigner/Configuration/Settings.settings

@ -1,46 +0,0 @@ @@ -1,46 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="ICSharpCode.XamlDesigner.Configuration" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="MainWindowRect" Type="System.Windows.Rect" Scope="User">
<Value Profile="(Default)">0,0,0,0</Value>
</Setting>
<Setting Name="AvalonDockLayout" Type="System.String" Scope="User">
<Value Profile="(Default)">&lt;DockingManager&gt;
&lt;ResizingPanel Orientation="Horizontal"&gt;
&lt;ResizingPanel ResizeWidth="200" Orientation="Vertical"&gt;
&lt;DockablePane ResizeHeight="441.36166666666668" Anchor="Left"&gt;
&lt;DockableContent Name="content1" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;DockablePane ResizeWidth="200" Anchor="Left"&gt;
&lt;DockableContent Name="content2" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;/ResizingPanel&gt;
&lt;ResizingPanel Orientation="Vertical"&gt;
&lt;DocumentPanePlaceHolder /&gt;
&lt;DockablePane ResizeHeight="138" Anchor="Bottom"&gt;
&lt;DockableContent Name="content3" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;/ResizingPanel&gt;
&lt;DockablePane ResizeWidth="271" Anchor="Right"&gt;
&lt;DockableContent Name="content4" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;/ResizingPanel&gt;
&lt;Hidden /&gt;
&lt;Windows /&gt;
&lt;/DockingManager&gt;</Value>
</Setting>
<Setting Name="RecentFiles" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="AssemblyList" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
&lt;string&gt;%ProgramFiles%\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll&lt;/string&gt;
&lt;/ArrayOfString&gt;</Value>
</Setting>
<Setting Name="MainWindowState" Type="System.Windows.WindowState" Scope="User">
<Value Profile="(Default)">Maximized</Value>
</Setting>
</Settings>
</SettingsFile>

51
samples/XamlDesigner/Configuration/app.config

@ -1,51 +0,0 @@ @@ -1,51 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ICSharpCode.XamlDesigner.Configuration.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<ICSharpCode.XamlDesigner.Configuration.Settings>
<setting name="MainWindowRect" serializeAs="String">
<value>0,0,0,0</value>
</setting>
<setting name="AvalonDockLayout" serializeAs="String">
<value>&lt;DockingManager&gt;
&lt;ResizingPanel Orientation="Horizontal"&gt;
&lt;ResizingPanel ResizeWidth="200" Orientation="Vertical"&gt;
&lt;DockablePane ResizeHeight="441.36166666666668" Anchor="Left"&gt;
&lt;DockableContent Name="content1" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;DockablePane ResizeWidth="200" Anchor="Left"&gt;
&lt;DockableContent Name="content2" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;/ResizingPanel&gt;
&lt;ResizingPanel Orientation="Vertical"&gt;
&lt;DocumentPanePlaceHolder /&gt;
&lt;DockablePane ResizeHeight="138" Anchor="Bottom"&gt;
&lt;DockableContent Name="content3" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;/ResizingPanel&gt;
&lt;DockablePane ResizeWidth="271" Anchor="Right"&gt;
&lt;DockableContent Name="content4" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;/ResizingPanel&gt;
&lt;Hidden /&gt;
&lt;Windows /&gt;
&lt;/DockingManager&gt;</value>
</setting>
<setting name="AssemblyList" serializeAs="Xml">
<value>
<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>
</value>
</setting>
<setting name="MainWindowState" serializeAs="String">
<value>Maximized</value>
</setting>
</ICSharpCode.XamlDesigner.Configuration.Settings>
</userSettings>
</configuration>

29
samples/XamlDesigner/Configuration/app.manifest

@ -1,29 +0,0 @@ @@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
</dependentAssembly>
</dependency>
</asmv1:assembly>

66
samples/XamlDesigner/Converters.cs

@ -1,66 +0,0 @@ @@ -1,66 +0,0 @@
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();
}
}
public class LevelConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return new Thickness(5 + 19 * (int)value, 0, 5, 0);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

243
samples/XamlDesigner/Document.cs

@ -1,243 +0,0 @@ @@ -1,243 +0,0 @@
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.XamlBackend;
using ICSharpCode.WpfDesign.Designer.OutlineView;
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()
{
this.tempName = tempName;
Text = text;
Context.Parse(Text);
IsDirty = false;
}
public Document(string filePath)
: this()
{
this.filePath = filePath;
ReloadFile();
}
Document()
{
var doc = Shell.Instance.Project.CreateDocument();
context = new XamlDesignContext(doc);
context.UndoService.UndoStackChanged += new EventHandler(UndoService_UndoStackChanged);
}
string tempName;
XamlDesignContext context;
string text;
public string Text
{
get
{
return text;
}
set
{
if (text != value) {
text = value;
IsDirty = true;
RaisePropertyChanged("Text");
}
}
}
DocumentMode mode;
public DocumentMode Mode
{
get
{
return mode;
}
set
{
mode = value;
//if (InDesignMode) {
// UpdateDesign();
//}
//else {
// UpdateXaml();
//}
RaisePropertyChanged("Mode");
RaisePropertyChanged("InXamlMode");
RaisePropertyChanged("InDesignMode");
}
}
public bool InXamlMode
{
get { return Mode == DocumentMode.Xaml; }
}
public bool InDesignMode
{
get { return Mode == 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 DesignContext Context
{
get { return context; }
}
//TODO
//public XamlErrorService XamlErrorService {
// get {
// if (DesignContext != null) {
// return DesignContext.GetService<XamlErrorService>();
// }
// return null;
// }
//}
void ReloadFile()
{
Text = File.ReadAllText(FilePath);
//UpdateDesign();
Context.Parse(Text);
IsDirty = false;
}
public void Save()
{
//if (InDesignMode) {
// UpdateXaml();
//}
File.WriteAllText(FilePath, Text);
IsDirty = false;
}
public void SaveAs(string filePath)
{
FilePath = filePath;
Save();
}
public void Refresh()
{
//UpdateXaml();
//UpdateDesign();
}
//void UpdateXaml()
//{
// if (Context.CanSave) {
// Text = Context.Save();
// }
//}
//void UpdateDesign()
//{
// Context.Parse(Text);
//}
void UndoService_UndoStackChanged(object sender, EventArgs e)
{
IsDirty = Context.UndoService.CanUndo;
if (Context.ParseSuggested) {
Context.Parse(Text);
}
//if (Context.Is
//IsDirty = true;
//if (InXamlMode) {
// UpdateXaml();
//}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
void RaisePropertyChanged(string name)
{
if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
#endregion
}
public enum DocumentMode
{
Xaml, Design
}
}

23
samples/XamlDesigner/DocumentView.xaml

@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
<UserControl 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:Default="clr-namespace:ICSharpCode.XamlDesigner"
xmlns:Designer="clr-namespace:ICSharpCode.WpfDesign.Designer;assembly=ICSharpCode.WpfDesign.Designer"
xmlns:DesignerControls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls;assembly=ICSharpCode.WpfDesign.Designer">
<DockPanel>
<DesignerControls:EnumBar Value="{Binding Mode}"
DockPanel.Dock="Bottom" />
<Grid>
<Integration:WindowsFormsHost Visibility="{Binding InXamlMode, Converter={StaticResource CollapsedWhenFalse}}">
<Default:TextEditorWithoutUndo x:Name="uxTextEditor" />
</Integration:WindowsFormsHost>
<Designer:DesignSurface x:Name="uxDesignSurface"
Context="{Binding Context}"
Visibility="{Binding InDesignMode, Converter={StaticResource CollapsedWhenFalse}}" />
</Grid>
</DockPanel>
</UserControl>

134
samples/XamlDesigner/DocumentView.xaml.cs

@ -1,134 +0,0 @@ @@ -1,134 +0,0 @@
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;
using ICSharpCode.WpfDesign.Designer.Services;
using System.Windows.Threading;
using ICSharpCode.Xaml;
using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.TextEditor;
using System.Windows.Forms;
using ICSharpCode.TextEditor.Document;
using ICSharpCode.WpfDesign;
using ICSharpCode.TextEditor.Undo;
namespace ICSharpCode.XamlDesigner
{
public partial class DocumentView
{
public DocumentView(Document doc)
{
InitializeComponent();
ShellDocument = doc;
Shell.Instance.Views[doc] = this;
uxTextEditor.SetHighlighting("XML");
uxTextEditor.DataBindings.Add("Text", doc, "Text", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
ShellDocument.Context.AddService(typeof(ITextContainer), uxTextEditor);
uxTextEditor.Document.UndoStack.OperationPushed += UndoStack_OperationPushed;
uxTextEditor.Document.DocumentChanged += Document_DocumentChanged;
uxTextEditor.Document.DocumentAboutToBeChanged += Document_DocumentAboutToBeChanged;
}
public Document ShellDocument { get; private set; }
IUndoableOperation lastOperation;
bool textValid;
void Document_DocumentAboutToBeChanged(object sender, DocumentEventArgs e)
{
textValid = false;
}
void Document_DocumentChanged(object sender, DocumentEventArgs e)
{
textValid = true;
TryUpdateDesignUndoStack();
}
void UndoStack_OperationPushed(object sender, OperationEventArgs e)
{
lastOperation = e.Operation;
TryUpdateDesignUndoStack();
}
void TryUpdateDesignUndoStack()
{
if (textValid && lastOperation != null) {
ShellDocument.Context.UndoService.Done(new TextAction(lastOperation));
lastOperation = null;
}
}
public DesignSurface DesignSurface
{
get
{
return uxDesignSurface;
}
}
public void JumpToError(XamlDocumentError error)
{
ShellDocument.Mode = DocumentMode.Xaml;
Dispatcher.BeginInvoke(new Action(delegate {
uxTextEditor.ActiveTextAreaControl.JumpTo(error.LineNumber - 1, error.LinePosition - 1);
}), DispatcherPriority.Background);
}
}
class TextEditorWithoutUndo : TextEditorControl, ITextContainer
{
public TextEditorWithoutUndo()
{
editactions.Remove(Keys.Control | Keys.Z);
editactions.Remove(Keys.Control | Keys.Y);
}
public override void EndUpdate()
{
base.EndUpdate();
}
}
class TextAction : ITextAction
{
public TextAction(IUndoableOperation op)
{
this.op = op;
}
IUndoableOperation op;
public IEnumerable<DesignItem> AffectedItems
{
get { yield break; }
}
public string Title
{
get { return "Text Editing"; }
}
public void Do()
{
op.Redo();
}
public void Undo()
{
op.Undo();
}
}
}

7
samples/XamlDesigner/EnumBar.xaml

@ -1,7 +0,0 @@ @@ -1,7 +0,0 @@
<UserControl
x:Class="ICSharpCode.XamlDesigner.EnumBar"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel x:Name="uxPanel"
Orientation="Horizontal" />
</UserControl>

72
samples/XamlDesigner/EnumBar.xaml.cs

@ -1,72 +0,0 @@ @@ -1,72 +0,0 @@
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;
using System.Windows.Controls.Primitives;
namespace ICSharpCode.XamlDesigner
{
public partial class EnumBar
{
public EnumBar()
{
InitializeComponent();
}
Type currentEnumType;
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(object), typeof(EnumBar),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
public object Value {
get { return (object)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.Property == ValueProperty) {
var type = e.NewValue.GetType();
if (currentEnumType != type) {
currentEnumType = type;
uxPanel.Children.Clear();
foreach (var v in Enum.GetValues(type)) {
var b = new EnumButton();
b.Value = v;
b.Content = Enum.GetName(type, v);
b.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(button_PreviewMouseLeftButtonDown);
uxPanel.Children.Add(b);
}
}
foreach (EnumButton c in uxPanel.Children) {
if (c.Value.Equals(Value)) {
c.IsChecked = true;
}
else {
c.IsChecked = false;
}
}
}
}
void button_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Value = (sender as EnumButton).Value;
e.Handled = true;
}
}
}

26
samples/XamlDesigner/EnumButton.cs

@ -1,26 +0,0 @@ @@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls.Primitives;
using System.Windows;
namespace ICSharpCode.XamlDesigner
{
public class EnumButton : ToggleButton
{
static EnumButton()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(EnumButton),
new FrameworkPropertyMetadata(typeof(EnumButton)));
}
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(object), typeof(EnumButton));
public object Value {
get { return (object)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}
}
}

16
samples/XamlDesigner/ErrorListView.xaml

@ -1,16 +0,0 @@ @@ -1,16 +0,0 @@
<ListBox x:Class="ICSharpCode.XamlDesigner.ErrorListView"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Xaml="clr-namespace:ICSharpCode.Xaml;assembly=ICSharpCode.Xaml">
<Control.Resources>
<DataTemplate DataType="{x:Type Xaml:XamlDocumentError}">
<StackPanel Orientation="Horizontal">
<Image Source="Images/Error.png"
Stretch="None"
Margin="2" />
<TextBlock Text="{Binding Message}"
VerticalAlignment="Center" />
</StackPanel>
</DataTemplate>
</Control.Resources>
</ListBox>

34
samples/XamlDesigner/ErrorListView.xaml.cs

@ -1,34 +0,0 @@ @@ -1,34 +0,0 @@
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;
using ICSharpCode.WpfDesign.Designer.Services;
using ICSharpCode.Xaml;
namespace ICSharpCode.XamlDesigner
{
public partial class ErrorListView
{
public ErrorListView()
{
InitializeComponent();
}
protected override void OnMouseDoubleClick(MouseButtonEventArgs e)
{
var error = e.GetDataContext() as XamlDocumentError;
if (error != null) {
Shell.Instance.JumpToError(error);
}
}
}
}

84
samples/XamlDesigner/ExtensionMethods.cs

@ -1,84 +0,0 @@ @@ -1,84 +0,0 @@
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<string> 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<T>(this IDataObject data)
{
return (T)data.GetData(typeof(T).FullName);
}
public static Stream ToStream(this string s)
{
return new MemoryStream(Encoding.UTF8.GetBytes(s));
}
public static void AddRange<T>(this ObservableCollection<T> col, IEnumerable<T> items)
{
foreach (var item in items) {
col.Add(item);
}
}
public static void KeepSyncronizedWith<S>(this IList target, ObservableCollection<S> source, Func<S, object> 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;
}
}
}

BIN
samples/XamlDesigner/Images/Control.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 470 B

BIN
samples/XamlDesigner/Images/Error.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 701 B

BIN
samples/XamlDesigner/Images/Folder.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 537 B

BIN
samples/XamlDesigner/Images/Reference.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

BIN
samples/XamlDesigner/Images/Tag.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 389 B

90
samples/XamlDesigner/MainWindow.xaml

@ -1,90 +0,0 @@ @@ -1,90 +0,0 @@
<Window x:Class="ICSharpCode.XamlDesigner.MainWindow"
x:Name="root"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sd="http://sharpdevelop.net"
xmlns:AvalonDock="clr-namespace:AvalonDock;assembly=AvalonDock"
xmlns:Outline="clr-namespace:ICSharpCode.WpfDesign.Designer.OutlineView;assembly=ICSharpCode.WpfDesign.Designer"
xmlns:Designer="clr-namespace:ICSharpCode.WpfDesign.Designer;assembly=ICSharpCode.WpfDesign.Designer"
xmlns:Default="clr-namespace:ICSharpCode.XamlDesigner"
SnapsToDevicePixels="True"
AllowDrop="True"
Title="{Binding Title}">
<DockPanel>
<Menu DockPanel.Dock="Top">
<MenuItem Header="File">
<MenuItem Command="New" />
<MenuItem Command="Open" />
<Separator />
<MenuItem Command="Close" />
<MenuItem Command="Default:MainWindow.CloseAllCommand" />
<Separator />
<MenuItem Command="Save" />
<MenuItem Command="SaveAs" />
<MenuItem Command="Default:MainWindow.SaveAllCommand" />
<Separator />
<MenuItem Header="Recent Files"
ItemsSource="{Binding RecentFiles}"
IsEnabled="{Binding RecentFiles.Count, Converter={StaticResource FalseWhenZero}}"
Click="RecentFiles_Click" />
<Separator />
<MenuItem Command="Default:MainWindow.ExitCommand" />
</MenuItem>
<MenuItem Header="Edit">
<MenuItem Command="Undo" />
<MenuItem Command="Redo" />
<Separator />
<MenuItem Command="Cut" />
<MenuItem Command="Copy" />
<MenuItem Command="Paste" />
<MenuItem Command="Delete" />
<MenuItem Command="SelectAll" />
<Separator />
<MenuItem Command="Default:MainWindow.RefreshCommand" />
<MenuItem Command="Find" />
</MenuItem>
</Menu>
<AvalonDock:DockingManager x:Name="uxDockingManager">
<AvalonDock:ResizingPanel>
<AvalonDock:DocumentPane x:Name="uxDocumentPane"
SelectedValue="{Binding CurrentDocument}"
SelectedValuePath="DataContext" />
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content1"
Title="Toolbox">
<Designer:Toolbox x:Name="uxToolbox"
Context="{Binding CurrentDocument.Context}" />
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content2"
Title="Outline">
<Outline:Outline Context="{Binding CurrentDocument.Context}" />
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content3"
Title="Errors">
<Default:ErrorListView ItemsSource="{Binding CurrentDocument.Context.Document.Errors}" />
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content4"
Title="Properties">
<sd:PropertyGridView x:Name="uxPropertyGridView"
Context="{Binding CurrentDocument.Context}" />
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
</AvalonDock:ResizingPanel>
</AvalonDock:DockingManager>
</DockPanel>
</Window>

191
samples/XamlDesigner/MainWindow.xaml.cs

@ -1,191 +0,0 @@ @@ -1,191 +0,0 @@
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.Properties;
using System.ComponentModel;
using Microsoft.Win32;
using AvalonDock;
using System.IO;
using System.Collections.Specialized;
using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.Xaml;
namespace ICSharpCode.XamlDesigner
{
public partial class MainWindow
{
public MainWindow()
{
Instance = this;
DataContext = Shell.Instance;
RenameCommands();
InitializeComponent();
Shell.Instance.PropertyGrid = uxPropertyGridView.PropertyGrid;
AvalonDockWorkaround();
RegisterCommandHandlers();
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 (XamlConstants.HasXamlExtension(path)) {
e.Effects = DragDropEffects.Copy;
break;
}
}
}
void ProcessPaths(IEnumerable<string> paths)
{
foreach (var path in paths) {
//if (path.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase) ||
// path.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase)) {
// Toolbox.Instance.AddAssembly(path);
//}
//else
if (XamlConstants.HasXamlExtension(path)) {
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());
}
var toolboxContentPath = "WpfToolbox.xaml";
if (File.Exists(toolboxContentPath)) {
uxToolbox.Load(File.ReadAllText(toolboxContentPath));
}
}
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
}
}

143
samples/XamlDesigner/MainWindow_Commands.cs

@ -1,143 +0,0 @@ @@ -1,143 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using System.Windows;
using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.WpfDesign;
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");
public static SimpleCommand RefreshCommand = new SimpleCommand("Refresh", Key.F5);
static void RenameCommands()
{
ApplicationCommands.Open.Text = "Open...";
ApplicationCommands.SaveAs.Text = "Save As...";
}
void RegisterCommandHandlers()
{
this.AddCommandHandler(ApplicationCommands.New, Shell.Instance.New);
this.AddCommandHandler(ApplicationCommands.Open, Shell.Instance.Open);
this.AddCommandHandler(ApplicationCommands.Close, Shell.Instance.CloseCurrentDocument, HasCurrentDocument);
this.AddCommandHandler(ApplicationCommands.Save, Shell.Instance.SaveCurrentDocument, HasCurrentDocument);
this.AddCommandHandler(ApplicationCommands.SaveAs, Shell.Instance.SaveCurrentDocumentAs, HasCurrentDocument);
this.AddCommandHandler(SaveAllCommand, SaveAll, HasCurrentDocument);
this.AddCommandHandler(CloseAllCommand, CloseAll, HasCurrentDocument);
this.AddCommandHandler(ExitCommand, Shell.Instance.Exit, HasCurrentDocument);
this.AddCommandHandler(RefreshCommand, Shell.Instance.Refresh, Shell.Instance.CanRefresh);
this.AddCommandHandler(ApplicationCommands.Undo, Undo, CanUndo);
this.AddCommandHandler(ApplicationCommands.Redo, Redo, CanRedo);
this.AddCommandHandler(ApplicationCommands.Copy, Copy, CanCopy);
this.AddCommandHandler(ApplicationCommands.Cut, Cut, CanCut);
this.AddCommandHandler(ApplicationCommands.Delete, Delete, CanDelete);
this.AddCommandHandler(ApplicationCommands.Paste, Paste, CanPaste);
this.AddCommandHandler(ApplicationCommands.SelectAll, SelectAll, CanSelectAll);
}
bool HasCurrentDocument()
{
return Shell.Instance.CurrentDocument != null;
}
void SaveAll()
{
Shell.Instance.SaveAll();
}
void CloseAll()
{
Shell.Instance.CloseAll();
}
ICommandService CurrentCommandService
{
get
{
if (Shell.Instance.CurrentDocument != null) {
return Shell.Instance.CurrentDocument.Context.CommandService;
}
return null;
}
}
void Undo()
{
CurrentCommandService.Undo();
}
void Redo()
{
CurrentCommandService.Redo();
}
void Copy()
{
CurrentCommandService.Copy();
}
void Paste()
{
CurrentCommandService.Paste();
}
void Cut()
{
CurrentCommandService.Cut();
}
void SelectAll()
{
CurrentCommandService.SelectAll();
}
void Delete()
{
CurrentCommandService.Delete();
}
bool CanUndo()
{
return CurrentCommandService != null && CurrentCommandService.CanUndo();
}
bool CanRedo()
{
return CurrentCommandService != null && CurrentCommandService.CanRedo();
}
bool CanCopy()
{
return CurrentCommandService != null && CurrentCommandService.CanCopy();
}
bool CanPaste()
{
return CurrentCommandService != null && CurrentCommandService.CanPaste();
}
bool CanCut()
{
return CurrentCommandService != null && CurrentCommandService.CanCut();
}
bool CanSelectAll()
{
return CurrentCommandService != null && CurrentCommandService.CanSelectAll();
}
bool CanDelete()
{
return CurrentCommandService != null && CurrentCommandService.CanDelete();
}
}
}

4
samples/XamlDesigner/NewFileTemplate.xaml

@ -1,4 +0,0 @@ @@ -1,4 +0,0 @@
<Window xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Canvas />
</Window>

3
samples/XamlDesigner/Properties/AssemblyInfo.cs

@ -1,3 +0,0 @@ @@ -1,3 +0,0 @@
using System.Windows;
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]

110
samples/XamlDesigner/Properties/Settings.Designer.cs generated

@ -1,110 +0,0 @@ @@ -1,110 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.3053
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ICSharpCode.XamlDesigner.Properties {
[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(@"<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>")]
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(@"<?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>")]
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;
}
}
}
}

46
samples/XamlDesigner/Properties/Settings.settings

@ -1,46 +0,0 @@ @@ -1,46 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="ICSharpCode.XamlDesigner.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="MainWindowRect" Type="System.Windows.Rect" Scope="User">
<Value Profile="(Default)">0,0,0,0</Value>
</Setting>
<Setting Name="AvalonDockLayout" Type="System.String" Scope="User">
<Value Profile="(Default)">&lt;DockingManager&gt;
&lt;ResizingPanel Orientation="Horizontal"&gt;
&lt;ResizingPanel ResizeWidth="200" Orientation="Vertical"&gt;
&lt;DockablePane ResizeHeight="441.36166666666668" Anchor="Left"&gt;
&lt;DockableContent Name="content1" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;DockablePane ResizeWidth="200" Anchor="Left"&gt;
&lt;DockableContent Name="content2" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;/ResizingPanel&gt;
&lt;ResizingPanel Orientation="Vertical"&gt;
&lt;DocumentPanePlaceHolder /&gt;
&lt;DockablePane ResizeHeight="138" Anchor="Bottom"&gt;
&lt;DockableContent Name="content3" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;/ResizingPanel&gt;
&lt;DockablePane ResizeWidth="271" Anchor="Right"&gt;
&lt;DockableContent Name="content4" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;/ResizingPanel&gt;
&lt;Hidden /&gt;
&lt;Windows /&gt;
&lt;/DockingManager&gt;</Value>
</Setting>
<Setting Name="RecentFiles" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="AssemblyList" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
&lt;string&gt;%ProgramFiles%\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll&lt;/string&gt;
&lt;/ArrayOfString&gt;</Value>
</Setting>
<Setting Name="MainWindowState" Type="System.Windows.WindowState" Scope="User">
<Value Profile="(Default)">Maximized</Value>
</Setting>
</Settings>
</SettingsFile>

29
samples/XamlDesigner/Properties/app.manifest

@ -1,29 +0,0 @@ @@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
</dependentAssembly>
</dependency>
</asmv1:assembly>

287
samples/XamlDesigner/Shell.cs

@ -1,287 +0,0 @@ @@ -1,287 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;
using ICSharpCode.WpfDesign.Designer.PropertyGrid;
using ICSharpCode.XamlDesigner.Properties;
using System.Collections.Specialized;
using System.IO;
using System.Windows;
using System.Diagnostics;
using ICSharpCode.WpfDesign.Designer.Services;
using ICSharpCode.Xaml;
using ICSharpCode.WpfDesign.Designer.XamlBackend;
namespace ICSharpCode.XamlDesigner
{
public class Shell : INotifyPropertyChanged
{
public Shell()
{
Documents = new ObservableCollection<Document>();
RecentFiles = new ObservableCollection<string>();
Views = new Dictionary<object, FrameworkElement>();
LoadSettings();
}
public static Shell Instance = new Shell();
public const string ApplicationTitle = "Xaml Designer";
//public Toolbox Toolbox { get; set; }
//public SceneTree SceneTree { get; set; }
public PropertyGrid PropertyGrid { get; internal set; }
//public ErrorList ErrorList { get; set; }
public ObservableCollection<Document> Documents { get; private set; }
public ObservableCollection<string> RecentFiles { get; private set; }
public Dictionary<object, FrameworkElement> Views { get; private set; }
XamlProject project = new DefaultWpfProject();
public XamlProject Project
{
get { return project; }
}
Document currentDocument;
public Document CurrentDocument
{
get
{
return currentDocument;
}
set
{
currentDocument = value;
RaisePropertyChanged("CurrentDocument");
RaisePropertyChanged("Title");
}
}
public DocumentView CurrentDocumentView
{
get
{
if (CurrentDocument != null) {
return Views[CurrentDocument] as DocumentView;
}
return null;
}
}
public string Title
{
get
{
if (CurrentDocument != null) {
return CurrentDocument.Title + " - " + ApplicationTitle;
}
return ApplicationTitle;
}
}
void LoadSettings()
{
if (Settings.Default.RecentFiles != null) {
RecentFiles.AddRange(Settings.Default.RecentFiles.Cast<string>());
}
}
public void SaveSettings()
{
if (Settings.Default.RecentFiles == null) {
Settings.Default.RecentFiles = new StringCollection();
}
else {
Settings.Default.RecentFiles.Clear();
}
foreach (var f in RecentFiles) {
Settings.Default.RecentFiles.Add(f);
}
}
public static void ReportException(Exception x)
{
MessageBox.Show(x.ToString());
}
public void JumpToError(XamlDocumentError error)
{
if (CurrentDocument != null) {
(Views[CurrentDocument] as DocumentView).JumpToError(error);
}
}
public bool CanRefresh()
{
return CurrentDocument != null;
}
public void Refresh()
{
CurrentDocument.Refresh();
}
#region Files
bool IsSomethingDirty
{
get
{
foreach (var doc in Shell.Instance.Documents) {
if (doc.IsDirty) return true;
}
return false;
}
}
static int nonameIndex = 1;
public void New()
{
Document doc = new Document("New" + nonameIndex++, File.ReadAllText("NewFileTemplate.xaml"));
Documents.Add(doc);
CurrentDocument = doc;
}
public void Open()
{
var path = MainWindow.Instance.AskOpenFileName();
if (path != null) {
Open(path);
}
}
public void Open(string path)
{
path = Path.GetFullPath(path);
if (RecentFiles.Contains(path)) {
RecentFiles.Remove(path);
}
RecentFiles.Insert(0, path);
foreach (var doc in Documents) {
if (doc.FilePath == path) {
CurrentDocument = doc;
return;
}
}
var newDoc = new Document(path);
Documents.Add(newDoc);
CurrentDocument = newDoc;
}
public bool Save(Document doc)
{
if (doc.IsDirty) {
if (doc.FilePath == null) {
return SaveAs(doc);
}
doc.Save();
}
return true;
}
public bool SaveAs(Document doc)
{
var initName = doc.FileName ?? doc.Name + ".xaml";
var path = MainWindow.Instance.AskSaveFileName(initName);
if (path != null) {
doc.SaveAs(path);
return true;
}
return false;
}
public bool SaveAll()
{
foreach (var doc in Documents) {
if (!Save(doc)) return false;
}
return true;
}
public bool Close(Document doc)
{
if (doc.IsDirty) {
var result = MessageBox.Show("Save \"" + doc.Name + "\" ?", Shell.ApplicationTitle,
MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes) {
if (!Save(doc)) return false;
}
else if (result == MessageBoxResult.Cancel) {
return false;
}
}
Documents.Remove(doc);
Views.Remove(doc);
return true;
}
public bool CloseAll()
{
foreach (var doc in Documents.ToArray()) {
if (!Close(doc)) return false;
}
return true;
}
public bool PrepareExit()
{
if (IsSomethingDirty) {
var result = MessageBox.Show("Save All?", Shell.ApplicationTitle,
MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes) {
if (!SaveAll()) return false;
}
else if (result == MessageBoxResult.Cancel) {
return false;
}
}
return true;
}
public void Exit()
{
MainWindow.Instance.Close();
}
public void SaveCurrentDocument()
{
Save(CurrentDocument);
}
public void SaveCurrentDocumentAs()
{
SaveAs(CurrentDocument);
}
public void CloseCurrentDocument()
{
Close(CurrentDocument);
}
#endregion
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
void RaisePropertyChanged(string name)
{
if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
#endregion
}
}

27
samples/XamlDesigner/SimpleCommand.cs

@ -1,27 +0,0 @@ @@ -1,27 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
namespace ICSharpCode.XamlDesigner
{
public class SimpleCommand : RoutedUICommand
{
public SimpleCommand(string text)
{
Text = text;
}
public SimpleCommand(string text, ModifierKeys modifiers, Key key)
{
InputGestures.Add(new KeyGesture(key, modifiers));
Text = text;
}
public SimpleCommand(string text, Key key)
: this(text, ModifierKeys.None, key)
{
}
}
}

31
samples/XamlDesigner/TestFiles/1.xaml

@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
<Window xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WindowTitle"
BorderThickness="10"
Width="400"
Height="300">
<StackPanel>
<Canvas Height="50">
<Button>CB</Button>
</Canvas>
<TabControl MinHeight="150">
<TabItem Header="StackPanel">
<StackPanel>
<Button>a</Button>
</StackPanel>
</TabItem>
<TabItem Header="Button">
<Button>button on page 2</Button>
</TabItem>
<TabItem Header="Canvas">
<Canvas />
</TabItem>
<TabItem Header="Grid">
<Grid />
</TabItem>
<TabItem Header="DockPanel">
<DockPanel />
</TabItem>
</TabControl>
</StackPanel>
</Window>

53
samples/XamlDesigner/TestFiles/2.xaml

@ -1,53 +0,0 @@ @@ -1,53 +0,0 @@
<Window xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="524"
Height="385">
<Canvas>
<Ellipse Width="146"
Height="63"
Fill="#FF5DAF05"
Stroke="#FF000000"
StrokeThickness="8"
Canvas.Left="8"
Canvas.Top="158.9" />
<Grid Width="279"
Height="336.99999999999989"
Background="#FFFFFFE1"
Canvas.Left="226.99999999999994"
Canvas.Top="8.0000000000000853">
<Panel.Children>
<TextBlock Width="59"
Height="39"
Margin="0,10,12,0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
FontSize="33"
Text="Grid"
Grid.Column="0"
Grid.Row="0" />
</Panel.Children>
</Grid>
<GroupBox Content="GroupBox"
Width="175.39666666666668"
Height="116"
Canvas.Left="8"
Canvas.Top="8" />
<TextBlock Width="66.710000000000008"
FontSize="14"
Text="StackPanel"
Canvas.Left="8"
Canvas.Top="133" />
<StackPanel Width="209.99999999999994"
Height="114.09999999999991"
Background="#FFEDEDED"
Canvas.Left="8"
Canvas.Top="230.90000000000012">
<Panel.Children />
</StackPanel>
<Button Content="bla-blakjh"
Width="54.999999999999886"
Height="88.900000000000091"
Canvas.Left="163.00000000000006"
Canvas.Top="133.00000000000003" />
</Canvas>
</Window>

16
samples/XamlDesigner/TestFiles/3.xaml

@ -1,16 +0,0 @@ @@ -1,16 +0,0 @@
<Window xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Name="root"
Title="Hydralisk">
<Window.Resources>
<sys:String x:Key="r1">Title</sys:String>
<sys:String x:Key="r2">Width</sys:String>
</Window.Resources>
<StackPanel>
<Button Name="b1"
Width="100"
Content="Button" />
<TextBlock Text="{Binding Path={StaticResource r1}, ElementName=root}" />
</StackPanel>
</Window>

16
samples/XamlDesigner/TestFiles/4.xaml

@ -1,16 +0,0 @@ @@ -1,16 +0,0 @@
<Window xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Name="root"
Title="Hydralisk">
<Window.Resources>
<sys:String x:Key="r1">Title</sys:String>
<sys:String x:Key="r2">Width</sys:String>
</Window.Resources>
<StackPanel>
<Button Name="b1"
Width="100"
Content="Button" />
<TextBlock Text="{Binding Path={StaticResource r1}, ElementName=root}" />
</StackPanel>
</Window>

10
samples/XamlDesigner/TestFiles/grid.xaml

@ -1,10 +0,0 @@ @@ -1,10 +0,0 @@
<Window xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="524"
Height="385">
<ContentControl.Content>
<Grid>
<Panel.Children />
</Grid>
</ContentControl.Content>
</Window>

6
samples/XamlDesigner/Themes/Generic.xaml

@ -1,6 +0,0 @@ @@ -1,6 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Default="clr-namespace:ICSharpCode.XamlDesigner"
xmlns:Converters="clr-namespace:ICSharpCode.XamlDesigner.Converters">
</ResourceDictionary>

105
samples/XamlDesigner/Toolbox.cs

@ -1,105 +0,0 @@ @@ -1,105 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Collections.ObjectModel;
using ICSharpCode.XamlDesigner.Properties;
using System.Windows;
using System.Collections.Specialized;
using ICSharpCode.WpfDesign;
namespace ICSharpCode.XamlDesigner
{
public class Toolbox
{
public Toolbox()
{
AssemblyNodes = new ObservableCollection<AssemblyNode>();
LoadSettings();
}
public static Toolbox Instance = new Toolbox();
public ObservableCollection<AssemblyNode> AssemblyNodes { get; private set; }
public void AddAssembly(string path)
{
AddAssembly(path, true);
}
void AddAssembly(string path, bool updateSettings)
{
var assembly = Assembly.LoadFile(path);
var node = new AssemblyNode();
node.Assembly = assembly;
node.Path = path;
foreach (var t in assembly.GetExportedTypes()) {
if (IsControl(t) && Metadata.IsPopularControl(t)) {
node.Controls.Add(new ControlNode() { Type = t });
}
}
node.Controls.Sort(delegate(ControlNode c1, ControlNode c2) {
return c1.Name.CompareTo(c2.Name);
});
AssemblyNodes.Add(node);
if (updateSettings) {
if (Settings.Default.AssemblyList == null) {
Settings.Default.AssemblyList = new StringCollection();
}
Settings.Default.AssemblyList.Add(path);
}
Shell.Instance.Project.AddReference(assembly);
}
public void Remove(AssemblyNode node)
{
AssemblyNodes.Remove(node);
Settings.Default.AssemblyList.Remove(node.Path);
Shell.Instance.Project.RemoveReference(node.Assembly);
}
public void LoadSettings()
{
if (Settings.Default.AssemblyList != null) {
foreach (var path in Settings.Default.AssemblyList) {
AddAssembly(Environment.ExpandEnvironmentVariables(path), false);
}
}
}
static bool IsControl(Type t)
{
return !t.IsAbstract && !t.IsGenericTypeDefinition && t.IsSubclassOf(typeof(FrameworkElement));
}
}
public class AssemblyNode
{
public AssemblyNode()
{
Controls = new List<ControlNode>();
}
public Assembly Assembly { get; set; }
public List<ControlNode> Controls { get; private set; }
public string Path { get; set; }
public string Name {
get { return Assembly.GetName().Name; }
}
}
public class ControlNode
{
public Type Type { get; set; }
public string Name {
get { return Type.Name; }
}
}
}

26
samples/XamlDesigner/ToolboxTreeView.cs

@ -1,26 +0,0 @@ @@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICSharpCode.WpfDesign.Designer.OutlineView;
namespace ICSharpCode.XamlDesigner
{
class ToolboxTreeView : DragTreeView
{
protected override bool CanInsert(DragTreeViewItem target, DragTreeViewItem[] items, DragTreeViewItem after, bool copy)
{
return base.CanInsert(target, items, after, copy);
}
protected override void Insert(DragTreeViewItem target, DragTreeViewItem[] items, DragTreeViewItem after, bool copy)
{
base.Insert(target, items, after, copy);
}
protected override void Remove(DragTreeViewItem target, DragTreeViewItem item)
{
base.Remove(target, item);
}
}
}

26
samples/XamlDesigner/ToolboxView.xaml

@ -1,26 +0,0 @@ @@ -1,26 +0,0 @@
<UserControl x:Class="ICSharpCode.XamlDesigner.ToolboxView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Outline="clr-namespace:ICSharpCode.WpfDesign.Designer.OutlineView;assembly=ICSharpCode.WpfDesign.Designer"
xmlns:Default="clr-namespace:ICSharpCode.XamlDesigner">
<UserControl.Resources>
<HierarchicalDataTemplate DataType="{x:Type Default:AssemblyNode}"
ItemsSource="{Binding Controls}">
<Outline:IconItem Icon="Images/Reference.png"
Text="{Binding Name}"
ToolTip="{Binding Path}" />
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type Default:ControlNode}">
<Outline:IconItem Icon="Images/Tag.png"
Text="{Binding Type.Name}" />
</DataTemplate>
</UserControl.Resources>
<TreeView x:Name="uxTreeView"
ItemsSource="{Binding AssemblyNodes}"
BorderThickness="0"/>
</UserControl>

77
samples/XamlDesigner/ToolboxView.xaml.cs

@ -1,77 +0,0 @@ @@ -1,77 +0,0 @@
using ICSharpCode.WpfDesign.Designer.OutlineView;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Reflection;
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;
using ICSharpCode.WpfDesign.Designer.Services;
namespace ICSharpCode.XamlDesigner
{
public partial class ToolboxView
{
public ToolboxView()
{
DataContext = Toolbox.Instance;
InitializeComponent();
new DragListener(this).DragStarted += Toolbox_DragStarted;
uxTreeView.SelectedItemChanged += uxTreeView_SelectedItemChanged;
uxTreeView.GotKeyboardFocus += uxTreeView_GotKeyboardFocus;
}
void uxTreeView_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
{
PrepareTool(uxTreeView.SelectedItem as ControlNode, false);
}
void uxTreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
PrepareTool(uxTreeView.SelectedItem as ControlNode, false);
}
void Toolbox_DragStarted(object sender, MouseButtonEventArgs e)
{
PrepareTool(e.GetDataContext() as ControlNode, true);
}
void PrepareTool(ControlNode node, bool drag)
{
if (node != null) {
var tool = new CreateComponentTool(node.Type);
if (Shell.Instance.CurrentDocument != null) {
Shell.Instance.CurrentDocument.DesignContext.Services.Tool.CurrentTool = tool;
if (drag) {
DragDrop.DoDragDrop(this, tool, DragDropEffects.Copy);
}
}
}
}
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Delete) {
Remove();
}
}
void Remove()
{
AssemblyNode node = uxTreeView.SelectedItem as AssemblyNode;
if (node != null) {
Toolbox.Instance.Remove(node);
}
}
}
}

193
samples/XamlDesigner/XamlDesigner.csproj

@ -1,193 +0,0 @@ @@ -1,193 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{27DA2B5C-2AAA-4478-AB00-3E184273C241}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>ICSharpCode.XamlDesigner</RootNamespace>
<AssemblyName>XamlDesigner</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</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>
<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.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationProvider">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsFormsIntegration">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\src\Main\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="BitmapButton.xaml.cs">
<DependentUpon>BitmapButton.xaml</DependentUpon>
</Compile>
<Compile Include="Converters.cs" />
<Compile Include="Document.cs" />
<Compile Include="DocumentView.xaml.cs">
<DependentUpon>DocumentView.xaml</DependentUpon>
<SubType>UserControl</SubType>
</Compile>
<Compile Include="ErrorListView.xaml.cs">
<DependentUpon>ErrorListView.xaml</DependentUpon>
</Compile>
<Compile Include="ExtensionMethods.cs" />
<Compile Include="MainWindow_Commands.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="Shell.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<Compile Include="SimpleCommand.cs" />
</ItemGroup>
<ItemGroup>
<None Include="NewFileTemplate.xaml">
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\..\data\options\WpfToolbox.xaml">
<Link>WpfToolbox.xaml</Link>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Page Include="BitmapButton.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="DocumentView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ErrorListView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<None Include="TestFiles\1.xaml">
<SubType>Designer</SubType>
</None>
<None Include="TestFiles\2.xaml">
<SubType>Designer</SubType>
</None>
<None Include="TestFiles\3.xaml">
<SubType>Designer</SubType>
</None>
<None Include="TestFiles\4.xaml">
<SubType>Designer</SubType>
</None>
<Page Include="Themes\Generic.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Reference.png" />
<Resource Include="Images\Tag.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Error.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\AddIns\BackendBindings\Xaml\Xaml\Xaml.csproj">
<Project>{B4E5C965-7BB9-4AE9-85FB-C47480B879AD}</Project>
<Name>Xaml</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\WpfDesign.Designer.csproj">
<Project>{78CC29AC-CC79-4355-B1F2-97936DF198AC}</Project>
<Name>WpfDesign.Designer</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\AddIns\DisplayBindings\WpfDesign\WpfDesign\WpfDesign.csproj">
<Project>{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}</Project>
<Name>WpfDesign</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

20
samples/XamlDesigner/XamlDesigner.sln

@ -1,20 +0,0 @@ @@ -1,20 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlDesigner", "XamlDesigner.csproj", "{27DA2B5C-2AAA-4478-AB00-3E184273C241}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{27DA2B5C-2AAA-4478-AB00-3E184273C241}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{27DA2B5C-2AAA-4478-AB00-3E184273C241}.Debug|Any CPU.Build.0 = Debug|Any CPU
{27DA2B5C-2AAA-4478-AB00-3E184273C241}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27DA2B5C-2AAA-4478-AB00-3E184273C241}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

203
samples/XamlDesigner/XamlFormatter.cs

@ -1,203 +0,0 @@ @@ -1,203 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace ICSharpCode.XamlDesigner
{
public static class XamlFormatter
{
public static char IndentChar = ' ';
public static int Indenation = 2;
public static int LengthBeforeNewLine = 60;
static StringBuilder sb;
static int currentColumn;
static int nextColumn;
public static string Format(string xaml)
{
sb = new StringBuilder();
currentColumn = 0;
nextColumn = 0;
try {
var doc = XDocument.Parse(xaml);
WalkContainer(doc);
return sb.ToString();
}
catch {
return xaml;
}
}
static void WalkContainer(XContainer node)
{
foreach (var c in node.Nodes()) {
if (c is XElement) {
WalkElement(c as XElement);
} else {
NewLine();
Append(c.ToString().Trim());
}
}
}
static void WalkElement(XElement e)
{
NewLine();
string prefix1 = e.GetPrefixOfNamespace(e.Name.Namespace);
string name1 = prefix1 == null ? e.Name.LocalName : prefix1 + ":" + e.Name.LocalName;
Append("<" + name1);
List<AttributeString> list = new List<AttributeString>();
int length = name1.Length;
foreach (var a in e.Attributes()) {
string prefix2 = e.GetPrefixOfNamespace(a.Name.Namespace);
var g = new AttributeString() { Name = a.Name, Prefix = prefix2, Value = a.Value };
list.Add(g);
length += g.FinalString.Length;
}
list.Sort(AttributeComparrer.Instance);
if (length > LengthBeforeNewLine) {
nextColumn = currentColumn + 1;
for (int i = 0; i < list.Count; i++) {
if (i > 0) {
NewLine();
}
else {
Append(" ");
}
Append(list[i].FinalString);
}
nextColumn -= name1.Length + 2;
}
else {
foreach (var a in list) {
Append(" " + a.FinalString);
}
}
if (e.Nodes().Count() > 0) {
Append(">");
nextColumn += Indenation;
WalkContainer(e);
nextColumn -= Indenation;
NewLine();
Append("</" + name1 + ">");
}
else {
Append(" />");
}
}
static void NewLine()
{
if (sb.Length > 0) {
sb.AppendLine();
sb.Append(new string(' ', nextColumn));
currentColumn = nextColumn;
}
}
static void Append(string s)
{
sb.Append(s);
currentColumn += s.Length;
}
enum AttributeLayout
{
X,
XmlnsMicrosoft,
Xmlns,
XmlnsWithClr,
SpecialOrder,
ByName,
Attached,
WithPrefix
}
class AttributeString
{
public XName Name;
public string Prefix;
public string Value;
public string LocalName {
get { return Name.LocalName; }
}
public string FinalName {
get {
return Prefix == null ? Name.LocalName : Prefix + ":" + Name.LocalName;
}
}
public string FinalString {
get {
return FinalName + "=\"" + Value + "\"";
}
}
public AttributeLayout GetAttributeLayout()
{
if (Prefix == "xmlns" || LocalName == "xmlns") {
if (Value.StartsWith("http://schemas.microsoft.com")) return AttributeLayout.XmlnsMicrosoft;
if (Value.StartsWith("clr")) return AttributeLayout.XmlnsWithClr;
return AttributeLayout.Xmlns;
}
if (Prefix == "x") return AttributeLayout.X;
if (Prefix != null) return AttributeLayout.WithPrefix;
if (LocalName.Contains(".")) return AttributeLayout.Attached;
if (AttributeComparrer.SpecialOrder.Contains(LocalName)) return AttributeLayout.SpecialOrder;
return AttributeLayout.ByName;
}
}
class AttributeComparrer : IComparer<AttributeString>
{
public static AttributeComparrer Instance = new AttributeComparrer();
public int Compare(AttributeString a1, AttributeString a2)
{
var y1 = a1.GetAttributeLayout();
var y2 = a2.GetAttributeLayout();
if (y1 == y2) {
if (y1 == AttributeLayout.SpecialOrder) {
return
Array.IndexOf(SpecialOrder, a1.LocalName).CompareTo(
Array.IndexOf(SpecialOrder, a2.LocalName));
}
return a1.FinalName.CompareTo(a2.FinalName);
}
return y1.CompareTo(y2);
}
public static string[] SpecialOrder = new string[] {
"Name",
"Content",
"Command",
"Executed",
"CanExecute",
"Width",
"Height",
"Margin",
"HorizontalAlignment",
"VerticalAlignment",
"HorizontalContentAlignment",
"VerticalContentAlignment",
"StartPoint",
"EndPoint",
"Offset",
"Color"
};
}
}
}

51
samples/XamlDesigner/app.config

@ -1,51 +0,0 @@ @@ -1,51 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ICSharpCode.XamlDesigner.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<ICSharpCode.XamlDesigner.Properties.Settings>
<setting name="MainWindowRect" serializeAs="String">
<value>0,0,0,0</value>
</setting>
<setting name="AvalonDockLayout" serializeAs="String">
<value>&lt;DockingManager&gt;
&lt;ResizingPanel Orientation="Horizontal"&gt;
&lt;ResizingPanel ResizeWidth="200" Orientation="Vertical"&gt;
&lt;DockablePane ResizeHeight="441.36166666666668" Anchor="Left"&gt;
&lt;DockableContent Name="content1" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;DockablePane ResizeWidth="200" Anchor="Left"&gt;
&lt;DockableContent Name="content2" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;/ResizingPanel&gt;
&lt;ResizingPanel Orientation="Vertical"&gt;
&lt;DocumentPanePlaceHolder /&gt;
&lt;DockablePane ResizeHeight="138" Anchor="Bottom"&gt;
&lt;DockableContent Name="content3" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;/ResizingPanel&gt;
&lt;DockablePane ResizeWidth="271" Anchor="Right"&gt;
&lt;DockableContent Name="content4" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;/ResizingPanel&gt;
&lt;Hidden /&gt;
&lt;Windows /&gt;
&lt;/DockingManager&gt;</value>
</setting>
<setting name="AssemblyList" serializeAs="Xml">
<value>
<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>
</value>
</setting>
<setting name="MainWindowState" serializeAs="String">
<value>Maximized</value>
</setting>
</ICSharpCode.XamlDesigner.Properties.Settings>
</userSettings>
</configuration>
Loading…
Cancel
Save