using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Diagnostics;
namespace Host
{
///
/// Hosts the HostSurface which inherits from DesignSurface.
///
public class HostControl : System.Windows.Forms.UserControl
{
///
/// Required designer variable.
///
private System.ComponentModel.IContainer components = null;
private HostSurface _hostSurface;
public HostControl(HostSurface hostSurface)
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
InitializeHost(hostSurface);
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
#region Component Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
//
// HostControl
//
this.Name = "HostControl";
this.Size = new System.Drawing.Size(268, 224);
}
#endregion
internal void InitializeHost(HostSurface hostSurface)
{
try
{
if (hostSurface == null)
return;
_hostSurface = hostSurface;
Control control = _hostSurface.View as Control;
control.Parent = this;
control.Dock = DockStyle.Fill;
control.Visible = true;
}
catch(Exception ex)
{
Trace.WriteLine(ex.ToString());
}
}
public HostSurface HostSurface
{
get
{
return _hostSurface;
}
}
public IDesignerHost DesignerHost
{
get
{
return (IDesignerHost)_hostSurface.GetService(typeof(IDesignerHost));
}
}
} // class
}// namespace