📄 menucheckbox.cs
字号:
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version>$Revision: 1047 $</version>
// </file>
using System;
using System.Drawing;
using System.Diagnostics;
using System.Drawing.Text;
using System.Drawing.Imaging;
using System.Windows.Forms;
namespace ICSharpCode.Core
{
public class MenuCheckBox : ToolStripMenuItem , IStatusUpdate
{
object caller;
Codon codon;
string description = String.Empty;
ICheckableMenuCommand menuCommand = null;
public ICheckableMenuCommand MenuCommand {
get {
if (menuCommand == null) {
try {
menuCommand = (ICheckableMenuCommand)codon.AddIn.CreateObject(codon.Properties["class"]);
} catch (Exception e) {
MessageService.ShowError(e, "Can't create menu command : " + codon.Id);
}
}
return menuCommand;
}
}
public string Description {
get {
return description;
}
set {
description = value;
}
}
public MenuCheckBox(string text)
{
this.RightToLeft = RightToLeft.Inherit;
Text = text;
}
public MenuCheckBox(Codon codon, object caller)
{
this.RightToLeft = RightToLeft.Inherit;
this.caller = caller;
this.codon = codon;
UpdateText();
}
protected override void OnClick(System.EventArgs e)
{
base.OnClick(e);
if (codon != null) {
MenuCommand.Run();
Checked = MenuCommand.IsChecked;
}
}
public override bool Enabled {
get {
if (codon == null) {
return base.Enabled;
}
ConditionFailedAction failedAction = codon.GetFailedAction(caller);
return failedAction != ConditionFailedAction.Disable;
}
}
public virtual void UpdateStatus()
{
if (codon != null) {
ConditionFailedAction failedAction = codon.GetFailedAction(caller);
this.Visible = failedAction != ConditionFailedAction.Exclude;
if (MenuCommand != null) {
Checked = MenuCommand.IsChecked;
}
}
}
public virtual void UpdateText()
{
if (codon != null) {
Text = StringParser.Parse(codon.Properties["label"]);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -