windowactiveevaluator.cs
来自「SharpDevelop2.0.0 c#开发免费工具」· CS 代码 · 共 64 行
CS
64 行
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version>$Revision: 915 $</version>
// </file>
using System;
using System.Xml;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.Core
{
/// <summary>
/// Tests if the current workbench window is a specified type or implements an interface.
/// </summary>
/// <attribute name="activewindow">
/// The fully qualified name of the type the active window should be or the
/// interface name it should implement.
/// "*" to test if any window is active.
/// </attribute>
/// <example title="Test if the current window is a text editor">
/// <Condition name="WindowActive" activewindow="ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor.ITextEditorControlProvider">
/// </example>
/// <example title="Test if any window is active">
/// <Condition name="WindowActive" activewindow="*">
/// </example>
public class WindowActiveConditionEvaluator : IConditionEvaluator
{
public bool IsValid(object caller, Condition condition)
{
if (WorkbenchSingleton.Workbench == null) {
return false;
}
string activewindow = condition.Properties["activewindow"];
if (activewindow == "*") {
return WorkbenchSingleton.Workbench.ActiveWorkbenchWindow != null;
}
if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow == null || WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent == null) {
return false;
}
Type currentType = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent.GetType();
if (currentType.FullName == activewindow)
return true;
foreach (Type interf in currentType.GetInterfaces()) {
if (interf.FullName == activewindow)
return true;
}
while ((currentType = currentType.BaseType) != null) {
if (currentType.FullName == activewindow)
return true;
}
return false;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?