Browse Source

Restore XamlDesigner to match old WPF Designer version

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4781 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
8429b4a3af
  1. 4
      samples/XamlDesigner/App.xaml
  2. 2
      samples/XamlDesigner/App.xaml.cs
  3. 26
      samples/XamlDesigner/Converters.cs
  4. 198
      samples/XamlDesigner/Document.cs
  5. 30
      samples/XamlDesigner/DocumentView.xaml
  6. 102
      samples/XamlDesigner/DocumentView.xaml.cs
  7. 10
      samples/XamlDesigner/ErrorListView.xaml
  8. 3
      samples/XamlDesigner/ErrorListView.xaml.cs
  9. BIN
      samples/XamlDesigner/Images/Control.png
  10. BIN
      samples/XamlDesigner/Images/Folder.png
  11. 184
      samples/XamlDesigner/MainWindow.xaml
  12. 26
      samples/XamlDesigner/MainWindow.xaml.cs
  13. 125
      samples/XamlDesigner/MainWindow_Commands.cs
  14. 3
      samples/XamlDesigner/Properties/AssemblyInfo.cs
  15. 110
      samples/XamlDesigner/Properties/Settings.Designer.cs
  16. 46
      samples/XamlDesigner/Properties/Settings.settings
  17. 29
      samples/XamlDesigner/Properties/app.manifest
  18. 85
      samples/XamlDesigner/Shell.cs
  19. 2
      samples/XamlDesigner/SimpleCommand.cs
  20. 10
      samples/XamlDesigner/TestFiles/grid.xaml
  21. 5
      samples/XamlDesigner/Toolbox.cs
  22. 26
      samples/XamlDesigner/ToolboxTreeView.cs
  23. 65
      samples/XamlDesigner/XamlDesigner.csproj
  24. 25
      samples/XamlDesigner/XamlDesigner.sln
  25. 51
      samples/XamlDesigner/app.config

4
samples/XamlDesigner/App.xaml

@ -5,9 +5,9 @@ @@ -5,9 +5,9 @@
StartupUri="MainWindow.xaml"
ShutdownMode="OnMainWindowClose">
<Application.Resources>
<Converters:CollapsedWhenFalse x:Key="CollapsedWhenFalse" />
<Converters:FalseWhenZero x:Key="FalseWhenZero" />
</Application.Resources>
</Application>

2
samples/XamlDesigner/App.xaml.cs

@ -4,7 +4,7 @@ using System.Configuration; @@ -4,7 +4,7 @@ using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using ICSharpCode.XamlDesigner.Properties;
using ICSharpCode.XamlDesigner.Configuration;
using System.Windows.Threading;
using System.Diagnostics;

26
samples/XamlDesigner/Converters.cs

@ -9,21 +9,21 @@ using System.Collections; @@ -9,21 +9,21 @@ 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 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 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;
@ -36,7 +36,7 @@ namespace ICSharpCode.XamlDesigner.Converters @@ -36,7 +36,7 @@ namespace ICSharpCode.XamlDesigner.Converters
}
public class FalseWhenZero : IValueConverter
{
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null || (int)value == 0) {

198
samples/XamlDesigner/Document.cs

@ -5,7 +5,7 @@ using System.Text; @@ -5,7 +5,7 @@ using System.Text;
using System.ComponentModel;
using System.IO;
using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.WpfDesign.Designer.XamlBackend;
using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.Designer.OutlineView;
using System.Xml;
using ICSharpCode.WpfDesign;
@ -17,41 +17,28 @@ namespace ICSharpCode.XamlDesigner @@ -17,41 +17,28 @@ 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;
DesignSurface designSurface = new DesignSurface();
string text;
public string Text
{
get
{
public string Text {
get {
return text;
}
set
{
set {
if (text != value) {
text = value;
IsDirty = true;
@ -62,47 +49,39 @@ namespace ICSharpCode.XamlDesigner @@ -62,47 +49,39 @@ namespace ICSharpCode.XamlDesigner
DocumentMode mode;
public DocumentMode Mode
{
get
{
public DocumentMode Mode {
get {
return mode;
}
set
{
set {
mode = value;
//if (InDesignMode) {
// UpdateDesign();
//}
//else {
// UpdateXaml();
//}
if (InDesignMode) {
UpdateDesign();
}
else {
UpdateXaml();
}
RaisePropertyChanged("Mode");
RaisePropertyChanged("InXamlMode");
RaisePropertyChanged("InDesignMode");
}
}
public bool InXamlMode
{
public bool InXamlMode {
get { return Mode == DocumentMode.Xaml; }
}
public bool InDesignMode
{
public bool InDesignMode {
get { return Mode == DocumentMode.Design; }
}
string filePath;
public string FilePath
{
get
{
public string FilePath {
get {
return filePath;
}
private set
{
private set {
filePath = value;
RaisePropertyChanged("FilePath");
RaisePropertyChanged("FileName");
@ -113,14 +92,11 @@ namespace ICSharpCode.XamlDesigner @@ -113,14 +92,11 @@ namespace ICSharpCode.XamlDesigner
bool isDirty;
public bool IsDirty
{
get
{
public bool IsDirty {
get {
return isDirty;
}
private set
{
private set {
isDirty = value;
RaisePropertyChanged("IsDirty");
RaisePropertyChanged("Name");
@ -128,59 +104,79 @@ namespace ICSharpCode.XamlDesigner @@ -128,59 +104,79 @@ namespace ICSharpCode.XamlDesigner
}
}
public string FileName
{
get
{
public string FileName {
get {
if (FilePath == null) return null;
return Path.GetFileName(FilePath);
}
}
public string Name
{
get
{
public string Name {
get {
return FileName ?? tempName;
}
}
public string Title
{
get
{
public string Title {
get {
return IsDirty ? Name + "*" : Name;
}
}
public DesignContext Context
{
get { return context; }
public DesignSurface DesignSurface {
get { return designSurface; }
}
//TODO
//public XamlErrorService XamlErrorService {
// get {
// if (DesignContext != null) {
// return DesignContext.GetService<XamlErrorService>();
// }
// return null;
// }
//}
public DesignContext DesignContext {
get { return designSurface.DesignContext; }
}
public UndoService UndoService {
get { return DesignContext.Services.GetService<UndoService>(); }
}
public ISelectionService SelectionService {
get {
if (InDesignMode) {
return DesignContext.Services.Selection;
}
return null;
}
}
public XamlErrorService XamlErrorService {
get {
if (DesignContext != null) {
return DesignContext.Services.GetService<XamlErrorService>();
}
return null;
}
}
OutlineNode outlineRoot;
public OutlineNode OutlineRoot {
get {
return outlineRoot;
}
private set {
outlineRoot = value;
RaisePropertyChanged("OutlineRoot");
}
}
void ReloadFile()
{
Text = File.ReadAllText(FilePath);
//UpdateDesign();
Context.Parse(Text);
UpdateDesign();
IsDirty = false;
}
public void Save()
{
//if (InDesignMode) {
// UpdateXaml();
//}
if (InDesignMode) {
UpdateXaml();
}
File.WriteAllText(FilePath, Text);
IsDirty = false;
}
@ -193,33 +189,41 @@ namespace ICSharpCode.XamlDesigner @@ -193,33 +189,41 @@ namespace ICSharpCode.XamlDesigner
public void Refresh()
{
//UpdateXaml();
//UpdateDesign();
UpdateXaml();
UpdateDesign();
}
//void UpdateXaml()
//{
// if (Context.CanSave) {
// Text = Context.Save();
// }
//}
void UpdateXaml()
{
if (DesignContext.CanSave && UndoService.CanUndo) {
var sb = new StringBuilder();
using (var xmlWriter = XmlWriter.Create(sb)) {
DesignSurface.SaveDesigner(xmlWriter);
Text = XamlFormatter.Format(sb.ToString());
}
}
}
//void UpdateDesign()
//{
// Context.Parse(Text);
//}
void UpdateDesign()
{
OutlineRoot = null;
using (var xmlReader = XmlReader.Create(new StringReader(Text))) {
DesignSurface.LoadDesigner(xmlReader, null);
}
if (DesignContext.RootItem != null) {
OutlineRoot = OutlineNode.Create(DesignContext.RootItem);
UndoService.UndoStackChanged += new EventHandler(UndoService_UndoStackChanged);
}
RaisePropertyChanged("SelectionService");
RaisePropertyChanged("XamlErrorService");
}
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();
//}
IsDirty = true;
if (InXamlMode) {
UpdateXaml();
}
}
#region INotifyPropertyChanged Members

30
samples/XamlDesigner/DocumentView.xaml

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

102
samples/XamlDesigner/DocumentView.xaml.cs

@ -13,13 +13,6 @@ using System.Windows.Navigation; @@ -13,13 +13,6 @@ 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
{
@ -29,106 +22,21 @@ namespace ICSharpCode.XamlDesigner @@ -29,106 +22,21 @@ namespace ICSharpCode.XamlDesigner
{
InitializeComponent();
ShellDocument = doc;
Document = 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 Document Document { get; private set; }
public void JumpToError(XamlDocumentError error)
public void JumpToError(XamlError error)
{
ShellDocument.Mode = DocumentMode.Xaml;
Document.Mode = DocumentMode.Xaml;
Dispatcher.BeginInvoke(new Action(delegate {
uxTextEditor.ActiveTextAreaControl.JumpTo(error.LineNumber - 1, error.LinePosition - 1);
uxTextEditor.ActiveTextAreaControl.JumpTo(error.Line - 1, error.Column - 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();
}
}
}

10
samples/XamlDesigner/ErrorListView.xaml

@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
<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">
xmlns:Services="clr-namespace:ICSharpCode.WpfDesign.Designer.Services;assembly=ICSharpCode.WpfDesign.Designer">
<Control.Resources>
<DataTemplate DataType="{x:Type Xaml:XamlDocumentError}">
<DataTemplate DataType="{x:Type Services:XamlError}">
<StackPanel Orientation="Horizontal">
<Image Source="Images/Error.png"
Stretch="None"
Margin="2" />
<TextBlock Text="{Binding Message}"
VerticalAlignment="Center" />
Margin="2"/>
<TextBlock Text="{Binding Message}"
VerticalAlignment="Center"/>
</StackPanel>
</DataTemplate>
</Control.Resources>

3
samples/XamlDesigner/ErrorListView.xaml.cs

@ -12,7 +12,6 @@ using System.Windows.Media.Imaging; @@ -12,7 +12,6 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.Designer.Services;
using ICSharpCode.Xaml;
namespace ICSharpCode.XamlDesigner
{
@ -25,7 +24,7 @@ namespace ICSharpCode.XamlDesigner @@ -25,7 +24,7 @@ namespace ICSharpCode.XamlDesigner
protected override void OnMouseDoubleClick(MouseButtonEventArgs e)
{
var error = e.GetDataContext() as XamlDocumentError;
var error = e.GetDataContext() as XamlError;
if (error != null) {
Shell.Instance.JumpToError(error);
}

BIN
samples/XamlDesigner/Images/Control.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 470 B

BIN
samples/XamlDesigner/Images/Folder.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 537 B

184
samples/XamlDesigner/MainWindow.xaml

@ -5,86 +5,114 @@ @@ -5,86 +5,114 @@
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.CommandBindings>
<CommandBinding Command="New"
Executed="NewCommand_Executed" />
<CommandBinding Command="Open"
Executed="OpenCommand_Executed" />
<CommandBinding Command="Close"
Executed="CloseCommand_Executed"
CanExecute="CurrentDocument_CanExecute"
PreviewExecuted="CloseCommand_PreviewExecuted"/>
<CommandBinding Command="Default:MainWindow.CloseAllCommand"
Executed="CloseAllCommand_Executed"
CanExecute="CurrentDocument_CanExecute" />
<CommandBinding Command="Save"
Executed="SaveCommand_Executed"
CanExecute="CurrentDocument_CanExecute" />
<CommandBinding Command="SaveAs"
Executed="SaveAsCommand_Executed"
CanExecute="CurrentDocument_CanExecute" />
<CommandBinding Command="Default:MainWindow.SaveAllCommand"
Executed="SaveAllCommand_Executed"
CanExecute="CurrentDocument_CanExecute" />
<CommandBinding Command="Default:MainWindow.ExitCommand"
Executed="ExitCommand_Executed" />
</Window.CommandBindings>
<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">
<Default:ToolboxView />
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content2" Title="Outline">
<Outline:Outline Root="{Binding CurrentDocument.OutlineRoot}"/>
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content3" Title="Errors">
<Default:ErrorListView ItemsSource="{Binding CurrentDocument.XamlErrorService.Errors}"/>
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content4" Title="Properties">
<sd:PropertyGridView x:Name="uxPropertyGridView"
SelectedItems="{Binding DataContext.CurrentDocument.SelectionService.SelectedItems, ElementName=root, FallbackValue={x:Null}}"/>
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
</AvalonDock:ResizingPanel>
</AvalonDock:DockingManager>
</DockPanel>
</Window>

26
samples/XamlDesigner/MainWindow.xaml.cs

@ -10,14 +10,13 @@ using System.Windows.Input; @@ -10,14 +10,13 @@ using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ICSharpCode.XamlDesigner.Properties;
using ICSharpCode.XamlDesigner.Configuration;
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
{
@ -28,12 +27,15 @@ namespace ICSharpCode.XamlDesigner @@ -28,12 +27,15 @@ namespace ICSharpCode.XamlDesigner
Instance = this;
DataContext = Shell.Instance;
RenameCommands();
BasicMetadata.Register();
InitializeComponent();
Shell.Instance.PropertyGrid = uxPropertyGridView.PropertyGrid;
AvalonDockWorkaround();
RegisterCommandHandlers();
RouteDesignSurfaceCommands();
this.AddCommandHandler(RefreshCommand, Shell.Instance.Refresh, Shell.Instance.CanRefresh);
LoadSettings();
ProcessPaths(App.Args);
@ -87,7 +89,7 @@ namespace ICSharpCode.XamlDesigner @@ -87,7 +89,7 @@ namespace ICSharpCode.XamlDesigner
e.Effects = DragDropEffects.Copy;
break;
}
else if (XamlConstants.HasXamlExtension(path)) {
else if (path.EndsWith(".xaml", StringComparison.InvariantCultureIgnoreCase)) {
e.Effects = DragDropEffects.Copy;
break;
}
@ -97,12 +99,11 @@ namespace ICSharpCode.XamlDesigner @@ -97,12 +99,11 @@ namespace ICSharpCode.XamlDesigner
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)) {
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);
}
}
@ -148,11 +149,6 @@ namespace ICSharpCode.XamlDesigner @@ -148,11 +149,6 @@ namespace ICSharpCode.XamlDesigner
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()

125
samples/XamlDesigner/MainWindow_Commands.cs

@ -4,8 +4,6 @@ using System.Linq; @@ -4,8 +4,6 @@ using System.Linq;
using System.Text;
using System.Windows.Input;
using System.Windows;
using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.WpfDesign;
namespace ICSharpCode.XamlDesigner
{
@ -22,122 +20,81 @@ namespace ICSharpCode.XamlDesigner @@ -22,122 +20,81 @@ namespace ICSharpCode.XamlDesigner
ApplicationCommands.SaveAs.Text = "Save As...";
}
void RegisterCommandHandlers()
void NewCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
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();
Shell.Instance.New();
}
void Copy()
void OpenCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
CurrentCommandService.Copy();
Shell.Instance.Open();
}
void Paste()
void CloseCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
CurrentCommandService.Paste();
Shell.Instance.CloseCurrentDocument();
}
void Cut()
void CloseCommand_PreviewExecuted(object sender, ExecutedRoutedEventArgs e)
{
CurrentCommandService.Cut();
Shell.Instance.CloseCurrentDocument();
}
void SelectAll()
void CloseAllCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
CurrentCommandService.SelectAll();
}
void Delete()
{
CurrentCommandService.Delete();
Shell.Instance.CloseAll();
}
bool CanUndo()
void SaveCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
return CurrentCommandService != null && CurrentCommandService.CanUndo();
Shell.Instance.SaveCurrentDocument();
}
bool CanRedo()
void SaveAsCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
return CurrentCommandService != null && CurrentCommandService.CanRedo();
Shell.Instance.SaveCurrentDocumentAs();
}
bool CanCopy()
void SaveAllCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
return CurrentCommandService != null && CurrentCommandService.CanCopy();
Shell.Instance.SaveAll();
}
bool CanPaste()
void ExitCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
return CurrentCommandService != null && CurrentCommandService.CanPaste();
Shell.Instance.Exit();
}
bool CanCut()
void CurrentDocument_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
return CurrentCommandService != null && CurrentCommandService.CanCut();
e.CanExecute = Shell.Instance.CurrentDocument != null;
}
bool CanSelectAll()
void RouteDesignSurfaceCommands()
{
return CurrentCommandService != null && CurrentCommandService.CanSelectAll();
RouteDesignSurfaceCommand(ApplicationCommands.Undo);
RouteDesignSurfaceCommand(ApplicationCommands.Redo);
RouteDesignSurfaceCommand(ApplicationCommands.Copy);
RouteDesignSurfaceCommand(ApplicationCommands.Cut);
RouteDesignSurfaceCommand(ApplicationCommands.Paste);
RouteDesignSurfaceCommand(ApplicationCommands.SelectAll);
RouteDesignSurfaceCommand(ApplicationCommands.Delete);
}
bool CanDelete()
void RouteDesignSurfaceCommand(RoutedCommand command)
{
return CurrentCommandService != null && CurrentCommandService.CanDelete();
var cb = new CommandBinding(command);
cb.CanExecute += delegate(object sender, CanExecuteRoutedEventArgs e) {
if (Shell.Instance.CurrentDocument != null) {
Shell.Instance.CurrentDocument.DesignSurface.RaiseEvent(e);
}else {
e.CanExecute = false;
}
};
cb.Executed += delegate(object sender, ExecutedRoutedEventArgs e) {
Shell.Instance.CurrentDocument.DesignSurface.RaiseEvent(e);
};
CommandBindings.Add(cb);
}
}
}

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>

85
samples/XamlDesigner/Shell.cs

@ -5,14 +5,12 @@ using System.Text; @@ -5,14 +5,12 @@ using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;
using ICSharpCode.WpfDesign.Designer.PropertyGrid;
using ICSharpCode.XamlDesigner.Properties;
using ICSharpCode.XamlDesigner.Configuration;
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
{
@ -31,52 +29,29 @@ namespace ICSharpCode.XamlDesigner @@ -31,52 +29,29 @@ namespace ICSharpCode.XamlDesigner
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 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 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
{
public Document CurrentDocument {
get {
return currentDocument;
}
set
{
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
{
public string Title {
get {
if (CurrentDocument != null) {
return CurrentDocument.Title + " - " + ApplicationTitle;
}
@ -109,7 +84,7 @@ namespace ICSharpCode.XamlDesigner @@ -109,7 +84,7 @@ namespace ICSharpCode.XamlDesigner
MessageBox.Show(x.ToString());
}
public void JumpToError(XamlDocumentError error)
public void JumpToError(XamlError error)
{
if (CurrentDocument != null) {
(Views[CurrentDocument] as DocumentView).JumpToError(error);
@ -128,10 +103,8 @@ namespace ICSharpCode.XamlDesigner @@ -128,10 +103,8 @@ namespace ICSharpCode.XamlDesigner
#region Files
bool IsSomethingDirty
{
get
{
bool IsSomethingDirty {
get {
foreach (var doc in Shell.Instance.Documents) {
if (doc.IsDirty) return true;
}
@ -142,22 +115,22 @@ namespace ICSharpCode.XamlDesigner @@ -142,22 +115,22 @@ namespace ICSharpCode.XamlDesigner
static int nonameIndex = 1;
public void New()
{
Document doc = new Document("New" + nonameIndex++, File.ReadAllText("NewFileTemplate.xaml"));
Documents.Add(doc);
CurrentDocument = doc;
}
{
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)
{
public void Open(string path)
{
path = Path.GetFullPath(path);
if (RecentFiles.Contains(path)) {
@ -172,10 +145,10 @@ namespace ICSharpCode.XamlDesigner @@ -172,10 +145,10 @@ namespace ICSharpCode.XamlDesigner
}
}
var newDoc = new Document(path);
Documents.Add(newDoc);
CurrentDocument = newDoc;
}
var newDoc = new Document(path);
Documents.Add(newDoc);
CurrentDocument = newDoc;
}
public bool Save(Document doc)
{
@ -192,7 +165,7 @@ namespace ICSharpCode.XamlDesigner @@ -192,7 +165,7 @@ namespace ICSharpCode.XamlDesigner
{
var initName = doc.FileName ?? doc.Name + ".xaml";
var path = MainWindow.Instance.AskSaveFileName(initName);
if (path != null) {
if (path != null) {
doc.SaveAs(path);
return true;
}
@ -210,7 +183,7 @@ namespace ICSharpCode.XamlDesigner @@ -210,7 +183,7 @@ namespace ICSharpCode.XamlDesigner
public bool Close(Document doc)
{
if (doc.IsDirty) {
var result = MessageBox.Show("Save \"" + doc.Name + "\" ?", Shell.ApplicationTitle,
var result = MessageBox.Show("Save \"" + doc.Name + "\" ?", Shell.ApplicationTitle,
MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes) {
@ -238,7 +211,7 @@ namespace ICSharpCode.XamlDesigner @@ -238,7 +211,7 @@ namespace ICSharpCode.XamlDesigner
if (IsSomethingDirty) {
var result = MessageBox.Show("Save All?", Shell.ApplicationTitle,
MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes) {
if (!SaveAll()) return false;
}

2
samples/XamlDesigner/SimpleCommand.cs

@ -19,7 +19,7 @@ namespace ICSharpCode.XamlDesigner @@ -19,7 +19,7 @@ namespace ICSharpCode.XamlDesigner
Text = text;
}
public SimpleCommand(string text, Key key)
public SimpleCommand(string text, Key key)
: this(text, ModifierKeys.None, key)
{
}

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>

5
samples/XamlDesigner/Toolbox.cs

@ -4,7 +4,7 @@ using System.Linq; @@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Reflection;
using System.Collections.ObjectModel;
using ICSharpCode.XamlDesigner.Properties;
using ICSharpCode.XamlDesigner.Configuration;
using System.Windows;
using System.Collections.Specialized;
using ICSharpCode.WpfDesign;
@ -52,15 +52,12 @@ namespace ICSharpCode.XamlDesigner @@ -52,15 +52,12 @@ namespace ICSharpCode.XamlDesigner
}
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()

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);
}
}
}

65
samples/XamlDesigner/XamlDesigner.csproj

@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
<ApplicationManifest>Configuration\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -79,47 +79,60 @@ @@ -79,47 +79,60 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<ProjectReference Include="..\..\src\AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\Project\WpfDesign.Designer.csproj">
<Project>{78CC29AC-CC79-4355-B1F2-97936DF198AC}</Project>
<Name>WpfDesign.Designer</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\AddIns\DisplayBindings\WpfDesign\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj">
<Project>{88DA149F-21B2-48AB-82C4-28FB6BDFD783}</Project>
<Name>WpfDesign.XamlDom</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\AddIns\DisplayBindings\WpfDesign\WpfDesign\Project\WpfDesign.csproj">
<Project>{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}</Project>
<Name>WpfDesign</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\src\Main\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
<Link>Configuration\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="BitmapButton.xaml.cs">
<DependentUpon>BitmapButton.xaml</DependentUpon>
</Compile>
<Compile Include="Configuration\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Configuration\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</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" />
<Compile Include="Toolbox.cs" />
<Compile Include="ToolboxView.xaml.cs">
<DependentUpon>ToolboxView.xaml</DependentUpon>
</Compile>
<Compile Include="XamlFormatter.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>
@ -152,11 +165,15 @@ @@ -152,11 +165,15 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ToolboxView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<None Include="Configuration\app.config" />
<None Include="Configuration\app.manifest" />
<None Include="Configuration\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
@ -168,20 +185,6 @@ @@ -168,20 +185,6 @@
<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.

25
samples/XamlDesigner/XamlDesigner.sln

@ -1,8 +1,17 @@ @@ -1,8 +1,17 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
# SharpDevelop 3.1.0.4545
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlDesigner", "XamlDesigner.csproj", "{27DA2B5C-2AAA-4478-AB00-3E184273C241}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign", "..\..\src\AddIns\DisplayBindings\WpfDesign\WpfDesign\Project\WpfDesign.csproj", "{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Designer", "..\..\src\AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\Project\WpfDesign.Designer.csproj", "{78CC29AC-CC79-4355-B1F2-97936DF198AC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Tests", "..\..\src\AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\Tests\WpfDesign.Tests.csproj", "{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom", "..\..\src\AddIns\DisplayBindings\WpfDesign\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj", "{88DA149F-21B2-48AB-82C4-28FB6BDFD783}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -13,6 +22,22 @@ Global @@ -13,6 +22,22 @@ Global
{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
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.Build.0 = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|Any CPU.Build.0 = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Release|Any CPU.Build.0 = Release|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|Any CPU.Build.0 = Release|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

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