2 Star 4 Fork 2

DCOSA/WinDocking

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
DockViewContent.cs 2.18 KB
一键复制 编辑 原始数据 按行查看 历史
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WinDocking.Docking;
namespace WinDocking
{
/// <summary>
/// 停靠视图窗体
/// </summary>
public class DockViewContent : DockContent
{
public DockViewContent()
{
this.HideOnClose = true;
this.CreatePopupMenu();
}
/// <summary>
/// 弹出菜单
/// </summary>
System.Windows.Forms.ContextMenuStrip popupMenu;
/// <summary>
/// 停靠视图区别名称
/// </summary>
public string ViewName
{
get;
set;
}
/// <summary>
/// 创建停靠视图菜单
/// </summary>
/// <param name="flat">浮动项文本</param>
/// <param name="dock">停靠项文本</param>
/// <param name="hide">自动隐藏项文本</param>
/// <param name="doc">文档停靠项文本</param>
/// <param name="close">关闭项文本</param>
protected void CreatePopupMenu(string flat = "浮动", string dock = "停靠", string hide = "自动隐藏", string doc = "以文档方式停靠", string close = "关闭")
{
popupMenu = new System.Windows.Forms.ContextMenuStrip();
popupMenu.Items.Add(flat, null, (sender, e) =>
{
this.DockState = DockState.Float;
});
popupMenu.Items.Add(dock, null, (sender, e) =>
{
if (this.DockState == DockState.Float)
{
this.DockState = this.DefaultDockState;
}
else
{
this.DockState = this.GetNormal();
}
});
popupMenu.Items.Add(hide, null, (sender, e) =>
{
this.DockState = this.GetAutoHide();
});
popupMenu.Items.Add(new System.Windows.Forms.ToolStripSeparator());
popupMenu.Items.Add(doc, null, (sender, e) =>
{
this.DockState = DockState.Document;
});
popupMenu.Items.Add(close, null, (sender, e) =>
{
this.Hide();
});
this.TabPageContextMenuStrip = popupMenu;
}
/// <summary>
/// 添加弹出菜单项
/// </summary>
public void AddPopupMenuItem(System.Windows.Forms.ToolStripMenuItem item)
{
popupMenu.Items.Add(item);
}
/// <summary>
/// 移除弹出菜单项
/// </summary>
public void RemovPopupMenuItem(System.Windows.Forms.ToolStripMenuItem item)
{
popupMenu.Items.Remove(item);
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/dcosa/WinDocking.git
[email protected]:dcosa/WinDocking.git
dcosa
WinDocking
WinDocking
master

搜索帮助