- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
private void AddDesigner()
{
Lazy<HostSurfaceFactory, IDesignerMetadataView> exportSurfaceFactory = fileNewDialog.GetHostFactory();
HostControl hc = new HostControl();
if (designerCounts.ContainsKey(exportSurfaceFactory.Metadata.ItemType))
designerCounts[exportSurfaceFactory.Metadata.ItemType]++;
else
designerCounts.Add(exportSurfaceFactory.Metadata.ItemType, 1);
string siteName = exportSurfaceFactory.Metadata.ItemType + designerCounts[exportSurfaceFactory.Metadata.ItemType].ToString();
HostSurface hostSurface = exportSurfaceFactory.Value.CreateNew(siteName);
hc.InitializeHost(hostSurface);
string fileName = siteName + "." + exportSurfaceFactory.Metadata.FileExtension;
TabPage tabpage = new TabPage(fileName + " - Design");
tabpage.Tag = exportSurfaceFactory.Metadata.Language;
hc.Parent = tabpage;
hc.Dock = DockStyle.Fill;
this.tabControl1.TabPages.Add(tabpage);
this.tabControl1.SelectedIndex = this.tabControl1.TabPages.Count - 1;
this.outputWindow.Writeline("Opened new host.");
this.toolbox.DesignerHost = hostSurface.DesignerHost;
this.solutionExplorer.AddFileNode(fileName);
SetupMenus(hostSurface);
}
Пример из MEF. Написан неким Dinesh Chandnani.