📄 autohidemenustripcontainer.cs
字号:
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision: 1273 $</version>
// </file>
using System;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Gui
{
/// <summary>
/// AutoHideMenuStripContainer can be used instead of MenuStrip to get a menu
/// which is automaticaly hiden and shown. It is especially useful in fullscreen.
/// </summary>
public class AutoHideMenuStripContainer: AutoHideContainer
{
protected bool dropDownOpened;
Padding? defaultPadding;
protected override void Reformat()
{
if (defaultPadding == null) {
defaultPadding = ((MenuStrip)control).Padding;
}
((MenuStrip)control).Padding = AutoHide ? Padding.Empty : (Padding)defaultPadding;
base.Reformat();
}
public AutoHideMenuStripContainer(MenuStrip menuStrip):base(menuStrip)
{
menuStrip.AutoSize = false;
menuStrip.ItemAdded += OnMenuItemAdded;
foreach(ToolStripMenuItem menuItem in menuStrip.Items) {
AddEventHandlersForItem(menuItem);
}
}
void OnMenuItemAdded(object sender, EventArgs e)
{
AddEventHandlersForItem((ToolStripMenuItem)sender);
}
void AddEventHandlersForItem(ToolStripMenuItem menuItem)
{
menuItem.DropDownOpened += delegate { dropDownOpened = true; };
menuItem.DropDownClosed += delegate { dropDownOpened = false; if (!mouseIn) ShowOverlay = false; };
}
protected override void OnControlMouseLeave(object sender, EventArgs e)
{
mouseIn = false;
if (!dropDownOpened) ShowOverlay = false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -