定义触发控件事件时所要执行类所具有的功能的接口。

命名空间:  SuperMap.Desktop
程序集:  SuperMap.Desktop.Core (in SuperMap.Desktop.Core)
版本: dll

语法

C#
public interface ICtrlAction : IHelp

备注

触发控件事件所执行的内容是通过某个类对象来指定的,该类必须实现 ICtrlAction 接口,当控件事件被触发时,会调用对象的 Run() 方法,该方法也是重写了 ICtrlAction 接口的Run() 方法。

示例

CopyC#
// SuperMap.Desktop.ICtrlAction 示例
void CtrlActionExample()
{
    // 触发对象示例 
    if (this.Caller is IButton) // 修改按钮文本
    {
        System.Windows.Forms.CheckState checkState = (this.Caller as IButton).CheckState;
        (this.Caller as IButton).Text = "修改按钮文本";
    }
    else if (this.Caller is ICheckBox) // 修改复选框的选中状态
    {
        System.Windows.Forms.CheckState checkState = (this.Caller as ICheckBox).CheckState;
        if (checkState == CheckState.Checked)
        {
            (this.Caller as ICheckBox).CheckState = CheckState.Unchecked;
        }
        else
        {
            (this.Caller as ICheckBox).CheckState = CheckState.Checked;
        }
    }
    else // 其他对象类型
    {
    }

    // 绑定窗体示例
    if (this.FormClass is IFormMap) // 绑定窗体是地图窗口
    {
        SuperMap.Mapping.Map map = (this.FormClass as IFormMap).MapControl.Map;
    }
    else if (this.FormClass is IFormScene) // 绑定窗体是场景窗口
    {
        SuperMap.Realspace.Scene scene = (this.FormClass as IFormScene).SceneControl.Scene;
    }
    else if (this.FormClass is IFormLayout) // 绑定窗体是布局窗口
    {
        SuperMap.Layout.MapLayout layout = (this.FormClass as IFormLayout).MapLayoutControl.MapLayout;
    }
    else if (this.FormClass is IFormTabular) // 绑定窗体是属性表窗口
    {
        SuperMap.Desktop.ITabularControl tabularControl = (this.FormClass as IFormTabular).TabularControl;
    }
    else // 绑定窗体是其他类型的窗口
    {
    }
}

请参见