C# WinForm 技巧八:界面开发之“WeifenLuo.WinFormsUI.Docking+OutLookBar” 使用
概述
最近几天一直在关注WinFrom方面的文章主要还是园子里伍华聪的博客,在看看我们自己写的项目差不忍赌啊,有想着提炼一下项目的公共部分,公共部分有分为 界面,类库两方面,今天主要是把界面也先提炼提炼。
WeifenLuo.WinFormsUI.Docking + OutLookBar结合使用的效果图
WeifenLuo.WinFormsUI.Docking修改记录
从http://sourceforge.net/projects/dockpanelsuite上下载源码新建DockContentEx文件并继承WeifenLuo.WinFormsUI.Docking.DockContent在里面加入ContextMenuStrip菜单工具并加入 关闭 全部关闭 除此之外全部关闭 三个菜单。项目结构如下
组件结构图:
源代码如下:
/// <summary>
/// 很多窗体都在Tab中有个右键菜单,右击的里面有关闭,所以最好继承一下DockContent,
/// 让其它窗体只要继承这个就有了这个右键菜单
/// </summary>
public class DockContentEx : DockContent
{
//在标签上点击右键显示关闭菜单
public DockContentEx( )
{
System.Windows.Forms.ContextMenuStrip cms = new System.Windows.Forms.ContextMenuStrip();
//
// tsmiClose
//
System.Windows.Forms.ToolStripMenuItem tsmiClose = new System.Windows.Forms.ToolStripMenuItem();
tsmiClose.Name = "cms";
tsmiClose.Size = new System.Drawing.Size(98, 22);
tsmiClose.Text = "关闭";
tsmiClose.Click += new System.EventHandler(this.tsmiClose_Click);
//
// tsmiALLClose
//
System.Windows.Forms.ToolStripMenuItem tsmiALLClose = new System.Windows.Forms.ToolStripMenuItem();
tsmiALLClose.Name = "cms";
tsmiALLClose.Size = new System.Drawing.Size(98, 22);
tsmiALLClose.Text = "全部关闭";
tsmiALLClose.Click += new System.EventHandler(this.tsmiALLClose_Click);
//
// tsmiApartFromClose
//
System.Windows.Forms.ToolStripMenuItem tsmiApartFromClose = new System.Windows.Forms.ToolStripMenuItem();
tsmiApartFromClose.Name = "cms";
tsmiApartFromClose.Size = new System.Drawing.Size(98, 22);
tsmiApartFromClose.Text = "除此之外全部关闭";
tsmiApartFromClose.Click += new System.EventHandler(this.tsmiApartFromClose_Click);
//
// tsmiClose
//
cms.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
tsmiClose,tsmiApartFromClose,tsmiALLClose});
cms.Name = "tsmiClose";
cms.Size = new System.Drawing.Size(99, 26);
this.TabPageContextMenuStrip = cms;
}
private void tsmiClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void tsmiALLClose_Click(object sender, EventArgs e)
{
DockContentCollection contents = DockPanel.Contents;
int num = 0;
while (num < contents.Count)
{
if (contents[num].DockHandler.DockState == DockState.Document)
{
contents[num].DockHandler.Hide();
}
else
{
num++;
}
}
}
private void tsmiApartFromClose_Click(object sender, EventArgs e)
{
DockContentCollection contents = DockPanel.Contents;
int num = 0;
while (num < contents.Count)
{
if (contents[num].DockHandler.DockState == DockState.Document && DockPanel.ActiveContent != contents[num])
{
contents[num].DockHandler.Hide();
}
else
{
num++;
}
}
}
}双击关闭标签代码 主要是修改 DockPaneStripBase.cs 类里的protected override void WndProc(ref Message m)函数 代码如下
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
protected override void WndProc(ref Message m)
{
if (m.Msg == (int)Win32.Msgs.WM_LBUTTONDBLCLK)
{
base.WndProc(ref m); int index = HitTest();
if (DockPane.DockPanel.AllowEndUserDocking && index != -1)
{
IDockContent content = Tabs[index].Content;
//if (content.DockHandler.CheckDockState(!content.DockHandler.IsFloat) != DockState.Unknown)
// content.DockHandler.IsFloat = !content.DockHandler.IsFloat;
//else
// content.DockHandler.Close(); //实现双击文档选项卡自动关闭if
(content.DockHandler.HideOnClose)
content.DockHandler.Hide();//隐藏
else
content.DockHandler.Close(); //关闭
} return;
} base.WndProc(ref m);
return;
}
我是这样偷着写代码的。
插件的代码使用的是OEA框架里面代码,Logging使用的是SuperSocket代码。
1: 获取指定目录的所有DLL到内存。
2: 在ToolboxFrm界面中加入到OutLookBar控件并显示出来。
WinForm界面开发之布局控件"WeifenLuo.WinFormsUI.Docking"的使用
http://sourceforge.net/projects/dockpanelsuite
http://download.csdn.net/detail/luomingui/6290535
http://home.cnblogs.com/group/topic/54686.html
http://blog.csdn.net/dqvega/article/details/7594923
C# WinForm 技巧八:界面开发之“WeifenLuo.WinFormsUI.Docking+OutLookBar” 使用的更多相关文章
- C# WinForm 技巧八:界面开发之“WeifenLuo.WinFormsUI.Docking+OutLookBar” 使用
概述 转自 http://www.cnblogs.com/luomingui/archive/2013/09/19/3329763.html 最近几天一直在关注WinFrom方面的文章 有想着提炼一下 ...
- WinFrom界面框架之WeifenLuo.WinFormsUI.Docking + OutLookBar
本文转载:http://www.cnblogs.com/luomingui/p/3329763.html WeifenLuo.WinFormsUI.Docking + OutLookBar结合使用的效 ...
- WinForm界面开发之布局控件"WeifenLuo.WinFormsUI.Docking"的使用
WinForm界面开发之布局控件"WeifenLuo.WinFormsUI.Docking"的使用 转自:http://www.cnblogs.com/wuhuacong/arch ...
- WinForm界面布局控件WeifenLuo.WinFormsUI.Docking"的使用 (二)
WinForm界面布局控件WeifenLuo.WinFormsUI.Docking"的使用 (二) 编写人:CC阿爸 2015-1-29 今天我想与大家继续一起分享这一伟大的控件.有兴趣的同 ...
- WinForm界面布局控件WeifenLuo.WinFormsUI.Docking"的使用 (一)
WinForm界面布局控件WeifenLuo.WinFormsUI.Docking"的使用 (一) 编写人:CC阿爸 2015-1-28 在伍华聪的博客中,看到布局控件"Weife ...
- 学习winform第三方界面weiFenLuo.winFormsUI.Docking.dll
控件dockpanel中提供了几个可用的类, 重要的有两个, 一是DockPanel, 一是DockContent, DockPanel是从panel继承出来的, 用于提供可浮动的dock的子窗口进行 ...
- Winform中DockPanel(引用WeifenLuo.WinFormsUI.Docking.dll组件)的使用
WeiFenLuo.WinFormsUI.Docking.dll是开源项目DockPanel Suite的一个类库,可实现像Visual Studio的窗口停靠.拖拽等功能.WeifenLuo.Win ...
- Winform- 界面开发之布局控件"WeifenLuo.WinFormsUI.Docking"的使用
布局控件"WeifenLuo.WinFormsUI.Docking"是一个非常棒的开源控件,用过的人都深有体会,该控件之强大.美观.不亚于商业控件.而且控件使用也是比较简单的. 实 ...
- 开源布局控件 WeifenLuo.WinFormsUI.Docking.dll使用
WeifenLuo.WinFormsUI.Docking是一个很强大的界面布局控件,可以保存自定义的布局为XML文件,可以加载XML配置文件.! 先看一下效果 使用说明: 1.新建一个WinForm程 ...
随机推荐
- 用scala实现一个sql执行引擎-(下)
执行 上一篇讲述了如何通过scala提供的内置DSL支持,实现一个可以解析sql的解析器,这篇讲如何拿到了解析结果-AST以后,如何在数据上进行操作,得到我们想要的结果.之前说到,为什么选择scala ...
- haskell io模块
haskell中的io模块主要是用于读写文件屏幕的,通过import IO来导入 其中有如下常用定义 data IOMode = ReadMode | WriteMode | AppendMode | ...
- Oracle数据库字符集修改
Oracle字符集是一个字节数据的解释的符号集合,有大小之分,有相互的包容关系.ORACLE支持国家语言的体系结构允许你使用本地化语言来存储,处理,检索数据.一般来说,数据库字符集在安装数据库实例时就 ...
- 我们为什麽需要有经验的DBA
我们为什麽需要有经验的DBA 自从我进来园子之后,发觉虽然我们分享了很多质量很好的文章给大家,但是大家不一定能够消化得了这些文章 理解这些文章还是需要有一定环境,有环境你解决了,但是可能还有别的捷径减 ...
- ASP.NET MVC 下拉列表使用小结
ASP.NET MVC中下拉列表的用法很简单,也很方便,具体来说,主要是页面上支持两种Html帮助类的方法:DropDownList()和DropDownListFor().这篇博文主要作为个人的一个 ...
- [ACM_模拟] ACM - Draw Something Cheat [n个长12的大写字母串,找出交集,按字母序输出]
Description Have you played Draw Something? It's currently one of the hottest social drawing games o ...
- spring mvc 配置对静态资源的访问
在spring mvc的配置文件中做如下配置: 1. <?xml version="1.0" encoding="UTF-8"?> <bean ...
- javascript图片懒加载与预加载的分析
javascript图片懒加载与预加载的分析 懒加载与预加载的基本概念. 懒加载也叫延迟加载:前一篇文章有介绍:JS图片延迟加载 延迟加载图片或符合某些条件时才加载某些图片. 预加载:提前加载图片, ...
- Paip.最佳实践-- Buildin variale 内建变量 ,魔术变量,预定义变量,系统常量,系统变量 1
Paip.最佳实践-- Buildin variale 内建变量 ,魔术变量,预定义变量,系统常量,系统变量 1.1.1 C++内建变量(__LINE__).... 1.1.2 ...
- 深入理解HTML5:语义、标准与样式(勇猛精进早登大师殿堂创最优品质交互)
深入理解HTML5:语义.标准与样式(勇猛精进早登大师殿堂创最优品质交互) [美]布拉德福(Bradford,A.) [美]海涅(Haine,P.)著 高京译 ISBN 978-7-121-20552 ...