|
|
@ -5,24 +5,24 @@ |
|
|
|
// <version>$Revision$</version>
|
|
|
|
// <version>$Revision$</version>
|
|
|
|
// </file>
|
|
|
|
// </file>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using ICSharpCode.WpfDesign.Designer.OutlineView; |
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.Diagnostics; |
|
|
|
|
|
|
|
using System.IO; |
|
|
|
using System.Text; |
|
|
|
using System.Text; |
|
|
|
using System.Windows.Forms; |
|
|
|
using System.Windows.Forms; |
|
|
|
using System.Windows.Forms.Integration; |
|
|
|
using System.Windows.Forms.Integration; |
|
|
|
using System.Windows.Markup; |
|
|
|
using System.Windows.Markup; |
|
|
|
using System.Xml; |
|
|
|
using System.Xml; |
|
|
|
|
|
|
|
|
|
|
|
using ICSharpCode.SharpDevelop; |
|
|
|
using ICSharpCode.SharpDevelop; |
|
|
|
|
|
|
|
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; |
|
|
|
using ICSharpCode.SharpDevelop.Gui; |
|
|
|
using ICSharpCode.SharpDevelop.Gui; |
|
|
|
using ICSharpCode.WpfDesign.Designer; |
|
|
|
using ICSharpCode.WpfDesign.Designer; |
|
|
|
|
|
|
|
using ICSharpCode.WpfDesign.Designer.PropertyGrid; |
|
|
|
using ICSharpCode.WpfDesign.Designer.Services; |
|
|
|
using ICSharpCode.WpfDesign.Designer.Services; |
|
|
|
using ICSharpCode.WpfDesign.Designer.Xaml; |
|
|
|
using ICSharpCode.WpfDesign.Designer.Xaml; |
|
|
|
using ICSharpCode.WpfDesign.PropertyGrid; |
|
|
|
using ICSharpCode.WpfDesign.PropertyGrid; |
|
|
|
using ICSharpCode.WpfDesign.Designer.PropertyGrid; |
|
|
|
|
|
|
|
using System.IO; |
|
|
|
|
|
|
|
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.WpfDesign.AddIn |
|
|
|
namespace ICSharpCode.WpfDesign.AddIn |
|
|
|
{ |
|
|
|
{ |
|
|
@ -30,23 +30,23 @@ namespace ICSharpCode.WpfDesign.AddIn |
|
|
|
/// IViewContent implementation that hosts the WPF designer.
|
|
|
|
/// IViewContent implementation that hosts the WPF designer.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public class WpfViewContent : AbstractViewContentHandlingLoadErrors, IHasPropertyContainer, IToolsHost |
|
|
|
public class WpfViewContent : AbstractViewContentHandlingLoadErrors, IHasPropertyContainer, IToolsHost |
|
|
|
{ |
|
|
|
{ |
|
|
|
public WpfViewContent(OpenedFile file) : base(file) |
|
|
|
public WpfViewContent(OpenedFile file) : base(file) |
|
|
|
{ |
|
|
|
{ |
|
|
|
BasicMetadata.Register(); |
|
|
|
BasicMetadata.Register(); |
|
|
|
|
|
|
|
|
|
|
|
this.TabPageText = "${res:FormsDesigner.DesignTabPages.DesignTabPage}"; |
|
|
|
this.TabPageText = "${res:FormsDesigner.DesignTabPages.DesignTabPage}"; |
|
|
|
this.IsActiveViewContentChanged += OnIsActiveViewContentChanged; |
|
|
|
this.IsActiveViewContentChanged += OnIsActiveViewContentChanged; |
|
|
|
this.editor = file.RegisteredViewContents[0] as TextEditorDisplayBindingWrapper; |
|
|
|
this.editor = file.RegisteredViewContents[0] as TextEditorDisplayBindingWrapper; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ElementHost wpfHost; |
|
|
|
ElementHost wpfHost; |
|
|
|
DesignSurface designer; |
|
|
|
DesignSurface designer; |
|
|
|
List<Task> tasks = new List<Task>(); |
|
|
|
List<Task> tasks = new List<Task>(); |
|
|
|
|
|
|
|
|
|
|
|
// save text from editor when designer cannot be saved (e.g. invalid xml)
|
|
|
|
// save text from editor when designer cannot be saved (e.g. invalid xml)
|
|
|
|
TextEditorDisplayBindingWrapper editor; |
|
|
|
TextEditorDisplayBindingWrapper editor; |
|
|
|
|
|
|
|
|
|
|
|
public DesignSurface DesignSurface { |
|
|
|
public DesignSurface DesignSurface { |
|
|
|
get { return designer; } |
|
|
|
get { return designer; } |
|
|
|
} |
|
|
|
} |
|
|
@ -58,15 +58,18 @@ namespace ICSharpCode.WpfDesign.AddIn |
|
|
|
protected override void LoadInternal(OpenedFile file, System.IO.Stream stream) |
|
|
|
protected override void LoadInternal(OpenedFile file, System.IO.Stream stream) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Debug.Assert(file == this.PrimaryFile); |
|
|
|
Debug.Assert(file == this.PrimaryFile); |
|
|
|
|
|
|
|
|
|
|
|
if (designer == null) { |
|
|
|
if (designer == null) { |
|
|
|
// initialize designer on first load
|
|
|
|
// initialize designer on first load
|
|
|
|
DragDropExceptionHandler.HandleException = ICSharpCode.Core.MessageService.ShowError; |
|
|
|
DragDropExceptionHandler.HandleException = ICSharpCode.Core.MessageService.ShowError; |
|
|
|
designer = new DesignSurface(); |
|
|
|
designer = new DesignSurface(); |
|
|
|
wpfHost = new SharpDevelopElementHost(this, designer); |
|
|
|
wpfHost = new SharpDevelopElementHost(this, designer); |
|
|
|
this.UserControl = wpfHost; |
|
|
|
this.UserControl = wpfHost; |
|
|
|
InitPropertyEditor(); |
|
|
|
InitPropertyEditor(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (outline != null) { |
|
|
|
|
|
|
|
outline.Root = null; |
|
|
|
|
|
|
|
} |
|
|
|
using (XmlTextReader r = new XmlTextReader(stream)) { |
|
|
|
using (XmlTextReader r = new XmlTextReader(stream)) { |
|
|
|
XamlLoadSettings settings = new XamlLoadSettings(); |
|
|
|
XamlLoadSettings settings = new XamlLoadSettings(); |
|
|
|
settings.DesignerAssemblies.Add(typeof(WpfViewContent).Assembly); |
|
|
|
settings.DesignerAssemblies.Add(typeof(WpfViewContent).Assembly); |
|
|
@ -81,9 +84,13 @@ namespace ICSharpCode.WpfDesign.AddIn |
|
|
|
settings.TypeFinder = MyTypeFinder.Create(this.PrimaryFile); |
|
|
|
settings.TypeFinder = MyTypeFinder.Create(this.PrimaryFile); |
|
|
|
|
|
|
|
|
|
|
|
designer.LoadDesigner(r, settings); |
|
|
|
designer.LoadDesigner(r, settings); |
|
|
|
|
|
|
|
|
|
|
|
UpdateTasks(); |
|
|
|
UpdateTasks(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (outline != null && designer.DesignContext != null && designer.DesignContext.RootItem != null) { |
|
|
|
|
|
|
|
outline.Root = OutlineNode.Create(designer.DesignContext.RootItem); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
propertyGridView.PropertyGrid.SelectedItems = null; |
|
|
|
propertyGridView.PropertyGrid.SelectedItems = null; |
|
|
|
designer.DesignContext.Services.Selection.SelectionChanged += OnSelectionChanged; |
|
|
|
designer.DesignContext.Services.Selection.SelectionChanged += OnSelectionChanged; |
|
|
|
designer.DesignContext.Services.GetService<UndoService>().UndoStackChanged += OnUndoStackChanged; |
|
|
|
designer.DesignContext.Services.GetService<UndoService>().UndoStackChanged += OnUndoStackChanged; |
|
|
@ -105,20 +112,20 @@ namespace ICSharpCode.WpfDesign.AddIn |
|
|
|
editor.Save(file, stream); |
|
|
|
editor.Save(file, stream); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override bool SupportsSwitchFromThisWithoutSaveLoad(OpenedFile file, IViewContent newView) |
|
|
|
public override bool SupportsSwitchFromThisWithoutSaveLoad(OpenedFile file, IViewContent newView) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return newView == editor && !designer.DesignContext.CanSave; |
|
|
|
return newView == editor && !designer.DesignContext.CanSave; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UpdateTasks() |
|
|
|
void UpdateTasks() |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (var task in tasks) { |
|
|
|
foreach (var task in tasks) { |
|
|
|
TaskService.Remove(task); |
|
|
|
TaskService.Remove(task); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tasks.Clear(); |
|
|
|
tasks.Clear(); |
|
|
|
|
|
|
|
|
|
|
|
var xamlErrorService = designer.DesignContext.Services.GetService<XamlErrorService>(); |
|
|
|
var xamlErrorService = designer.DesignContext.Services.GetService<XamlErrorService>(); |
|
|
|
foreach (var error in xamlErrorService.Errors) { |
|
|
|
foreach (var error in xamlErrorService.Errors) { |
|
|
|
var task = new Task(PrimaryFile.FileName, error.Message, error.Column - 1, error.Line - 1, TaskType.Error); |
|
|
|
var task = new Task(PrimaryFile.FileName, error.Message, error.Column - 1, error.Line - 1, TaskType.Error); |
|
|
@ -140,7 +147,7 @@ namespace ICSharpCode.WpfDesign.AddIn |
|
|
|
void InitPropertyEditor() |
|
|
|
void InitPropertyEditor() |
|
|
|
{ |
|
|
|
{ |
|
|
|
propertyGridView = new PropertyGridView(); |
|
|
|
propertyGridView = new PropertyGridView(); |
|
|
|
propertyEditorHost = new SharpDevelopElementHost(this, propertyGridView); |
|
|
|
propertyEditorHost = new SharpDevelopElementHost(this, propertyGridView); |
|
|
|
propertyContainer.PropertyGridReplacementControl = propertyEditorHost; |
|
|
|
propertyContainer.PropertyGridReplacementControl = propertyEditorHost; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -195,5 +202,19 @@ namespace ICSharpCode.WpfDesign.AddIn |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Outline outline; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Outline Outline { |
|
|
|
|
|
|
|
get { |
|
|
|
|
|
|
|
if (outline == null) { |
|
|
|
|
|
|
|
outline = new Outline(); |
|
|
|
|
|
|
|
if (DesignSurface != null && DesignSurface.DesignContext != null && DesignSurface.DesignContext.RootItem != null) { |
|
|
|
|
|
|
|
outline.Root = OutlineNode.Create(DesignSurface.DesignContext.RootItem); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return outline; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |