利用MagicLibrary控件实现VsNet平台界面:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
//加入using语句
using Crownwood.Magic.Common;
using Crownwood.Magic.Docking;
namespace WindowsApplication3
{
public partial class MainForm : Form
{
//主窗口MainForm类里定义DockingManager对象
private DockingManager dockManager;
/**//*DockingManager的数据成员OuterControl,InnerControl用来决定DockingManager所在的窗口上哪些区域不受到DockingManager停靠窗口的影响
* Docking Manager不会影响在OuterControl对象以后加入主窗口的对象的窗口区域
* Docking Manager也不会影响在InnerControl对象以前加入主窗口的对象的窗口区域
*/
//构造函数里添加初始化代码
public MainForm()
{
InitializeComponent();
//生成IDE风格的管理窗口
dockManager = new DockingManager(this, VisualStyle.IDE);
dockManager.OuterControl = statusStrip1;
dockManager.InnerControl = centerPanel;
centerPanel.IDEPixelBorder = true;
//生成Content对象,该对象是DockingManager管理的浮动窗口
Content solutionExplorerContent = new Content(dockManager);
//用Content对象包装要管理的窗口
solutionExplorerContent.Control = new solutionExplorer();
//设置停靠窗口属性
//获取"解决方案资源管理器"窗口的初始窗口尺寸
Size solutionExplorerSize = solutionExplorerContent.Control.Size;
//设置当停靠窗口收缩成标签时标签上的标题
solutionExplorerContent.Title = "解决方案资源管理器";
//设置停靠窗口展开时的标题
solutionExplorerContent.FullTitle = "解决方案资源管理器-Example";
//设置Content停靠窗口从标签状态滑动出来成为窗口状态时窗口大小
solutionExplorerContent.AutoHideSize = solutionExplorerSize;
//设置停靠窗口被“钉”在DockManager管理窗口上时的尺寸
solutionExplorerContent.DisplaySize = solutionExplorerSize;
//设定停靠窗口收缩时标签上显示的小图标,viewImgs是用户事先定义好的ImageList类型变量
solutionExplorerContent.ImageList = viewImgs;
solutionExplorerContent.ImageIndex = 0;
Content classViewContent = new Content(dockManager);
classViewContent.Control = new ClassView();
Size classViewSize = classViewContent.Control.Size;
classViewContent.Title = "类视图";
classViewContent.FullTitle = "类视图-Exam";
classViewContent.AutoHideSize = classViewSize;
classViewContent.DisplaySize = classViewSize;
classViewContent.ImageList = viewImgs;
classViewContent.ImageIndex = 1;
//设置浮动窗口的属性,title是窗口收缩以后的标题
//FullTitle是窗口显示时的标题
//将浮动窗口和具体在浮动窗口中被包含的面板联系起来
dockManager.Contents.Add(solutionExplorerContent);
//用AddContentWithState()显示Content停靠窗口,
//State.DockRight表明了是将窗口停靠在整个DockManager管理区域的右边
//可选的还有State.DockLeft,State.DockTop,State.DockBottom,State.Floating;
//返回值是WindowContent类型的变量,是用来容纳多个Content对象
WindowContent wc = dockManager.AddContentWithState(solutionExplorerContent, State.DockRight);
//下面将classViewContent加入停靠
dockManager.Contents.Add(classViewContent);
//将classViewContent加入到“资源管理器”窗口所在的WindowContent中
dockManager.AddContentToWindowContent(classViewContent, wc);
}
//菜单新建
private void 新建NToolStripMenuItem_Click(object sender, EventArgs e)
{
Crownwood.Magic.Controls.TabPage page = new Crownwood.Magic.Controls.TabPage();
page.Title = "Example.cs";
page.Control = new CodeEditer();
centerPanel.TabPages.Add(page);
}
private void 退出XToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}