[]
        
(Showing Draft Content)

GrapeCity.Forguncy.Commands.CommandDesigner

类 CommandDesigner

命令设计器。

继承
object
CommandDesigner
命名空间: GrapeCity.Forguncy.Commands
程序集: Forguncy.Commands.Design.dll
语法
public class CommandDesigner

构造函数

CommandDesigner()

命令设计器。

声明
public CommandDesigner()

属性

Command

编辑器对应的命令。

声明
public Command Command { get; set; }
属性值
类型 描述
Command

方法

GetCommandEditor()

返回命令插件对应的编辑器。

声明
public virtual ICommandEditor GetCommandEditor()
返回值
类型 描述
ICommandEditor

返回命令对应的编辑器。

示例

UserControl和自定义插件弹出消息框命令定义如下:

public partial class ShowMessageCommandEditor : UserControl, ICommandEditor
{
    public ShowMessageCommandEditor()
    {
        InitializeComponent();
    }
    public Command Command
    {
        get
        {
            return new ShowMessageBoxCommand() { Message = messageTextBox.Text };
            //messageTextBox is the name of TextBox in UserControl.
        }
        set
        {
            ShowMessageBoxCommand command = value as ShowMessageBoxCommand;
            if (command != null)
            {
                messageTextBox.Text = command.Message;
            }
        }
    }
public bool Validate()
{
    return true;
}

}
public class ShowMessageCommandDesigner : CommandDesigner<ShowMessageBoxCommand>, ICommandChecker
{
public override ICommandEditor GetCommandEditor()
{
return new ShowMessageCommandEditor();
}
}
[Designer("ShowMessageBoxCommand.ShowMessageCommandDesigner, ShowMessageBoxCommand")]
public class ShowMessageBoxCommand : Command
{
public string Message { get; set; }
}

GetCommandEditor(IBuilderCommandContext)

返回命令插件对应的编辑器。

声明
public virtual ICommandEditor GetCommandEditor(IBuilderCommandContext context)
参数
类型 名称 描述
IBuilderCommandContext context
返回值
类型 描述
ICommandEditor

返回命令对应的编辑器。

示例

UserControl和自定义插件弹出消息框命令定义如下:

public partial class ShowMessageCommandEditor : UserControl, ICommandEditor
{
    public ShowMessageCommandEditor()
    {
        InitializeComponent();
    }
    public Command Command
    {
        get
        {
            return new ShowMessageBoxCommand() { Message = messageTextBox.Text };
            //messageTextBox is the name of TextBox in UserControl.
        }
        set
        {
            ShowMessageBoxCommand command = value as ShowMessageBoxCommand;
            if (command != null)
            {
                messageTextBox.Text = command.Message;
            }
        }
    }
public bool Validate()
{
    return true;
}

}
public class ShowMessageCommandDesigner : CommandDesigner<ShowMessageBoxCommand>, ICommandChecker
{
public override ICommandEditor GetCommandEditor(IBuilderCommandContext context)
{
    return new ShowMessageCommandEditor();
}

}
[Designer("ShowMessageBoxCommand.ShowMessageCommandDesigner, ShowMessageBoxCommand")]
public class ShowMessageBoxCommand : Command
{
public string Message { get; set; }

}

GetEditorSetting(PropertyDescriptor, IBuilderCommandContext)

返回插件命令内部属性对应的编辑器。

声明
public virtual EditorSetting GetEditorSetting(PropertyDescriptor property, IBuilderCommandContext builderContext)
参数
类型 名称 描述
System.ComponentModel.PropertyDescriptor property

命令内部属性

IBuilderCommandContext builderContext

命令编辑上下文信息。

返回值
类型 描述
EditorSetting

返回插件命令内部属性对应的编辑器。

示例
public class WorkflowCommandDesigner : CommandDesigner<WorkflowCommand>;
{
    public string TableName { get; set; }

    public override EditorSetting GetEditorSetting(PropertyDescriptor property, IBuilderCommandContext builderContext)
    {
        if (property.Name == "TableName")
        {
            return new ComboEditorSetting(builderContext.EnumAllTableInfos().Where(t => t.WorkflowInfo != null && t.WorkflowInfo.IsEnabled).Select(t => t.TableName));
        }
    }
}

GetSearchTags()

搜索关键字

声明
public virtual IEnumerable<string> GetSearchTags()
返回值
类型 描述
System.Collections.Generic.IEnumerable<T><string>

OnPropertyEditorChanged(string, object, Dictionary<string, EditorSetting>)

属性值被编辑时会被调用的回调函数

声明
public virtual void OnPropertyEditorChanged(string propertyName, object propertyValue, Dictionary<string, EditorSetting> properties)
参数
类型 名称 描述
string propertyName

属性名

object propertyValue

属性值

System.Collections.Generic.Dictionary<TKey, TValue><string, EditorSetting> properties

全部属性

OnPropertyEditorChanged(string, object, Dictionary<string, IEditorSettingsDataContext>)

属性值被编辑时会被调用的回调函数

声明
public virtual void OnPropertyEditorChanged(string propertyName, object propertyValue, Dictionary<string, IEditorSettingsDataContext> properties)
参数
类型 名称 描述
string propertyName

属性名

object propertyValue

属性值

System.Collections.Generic.Dictionary<TKey, TValue><string, IEditorSettingsDataContext> properties

全部属性

Validate()

自定义校验逻辑

声明
public virtual string Validate()
返回值
类型 描述
string

返回空表示校验成功,否则表示校验失败,返回错误信息