#develop (short for SharpDevelop) is a free IDE for .NET programming languages.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

89 lines
2.1 KiB

// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Markup;
using System.Xml;
using ICSharpCode.WpfDesign.Designer.Services;
using ICSharpCode.WpfDesign.Designer.Controls;
namespace ICSharpCode.WpfDesign.Designer
{
/// <summary>
/// Surface hosting the WPF designer.
/// </summary>
public sealed class DesignSurface : SingleVisualChildElement
{
readonly ScrollViewer _scrollViewer;
readonly DesignPanel _designPanel;
DesignContext _designContext;
/// <summary>
/// Create a new DesignSurface instance.
/// </summary>
public DesignSurface()
{
_scrollViewer = new ScrollViewer();
_designPanel = new DesignPanel();
_scrollViewer.Content = _designPanel;
this.VisualChild = _scrollViewer;
}
/// <summary>
/// Gets the active design context.
/// </summary>
public DesignContext DesignContext {
get { return _designContext; }
}
/// <summary>
/// Gets the designed element.
/// </summary>
public UIElement DesignedElement {
get {
return _designPanel.DesignedElement;
}
}
/// <summary>
/// Initializes the designer content from the specified XmlReader.
/// </summary>
public void LoadDesigner(XmlReader xamlReader)
{
UnloadDesigner();
InitializeDesigner(new Xaml.XamlDesignContext(xamlReader));
}
/// <summary>
/// Saves the designer content into the specified XmlWriter.
/// </summary>
public void SaveDesigner(XmlWriter writer)
{
_designContext.Save(writer);
}
void InitializeDesigner(DesignContext context)
{
_designContext = context;
_designPanel.Context = context;
_designPanel.DesignedElement = context.RootItem.View;
}
/// <summary>
/// Unloads the designer content.
/// </summary>
public void UnloadDesigner()
{
_designContext = null;
_designPanel.Context = null;
_designPanel.DesignedElement = null;
}
}
}