[]
        
(Showing Draft Content)

GrapeCity.Forguncy.CellTypes.IQueryConditionWindow

接口 IQueryConditionWindow

活字格内置的设置查询条件的对话窗口。

注意:由内置查询条件对话窗口生成的对象可能包含单元格引用信息,需要实现IReferenceFormulaIDependenceCells这两个接口。

命名空间: GrapeCity.Forguncy.CellTypes
程序集: GrapeCity.Forguncy.CellTypes.Design.dll
语法
public interface IQueryConditionWindow : IWindow
示例
[Designer("Forguncy.TreeCellTypeDesigner, Forguncy")]
public class TreeCellType : CellType, IDependenceCells, IReferenceFormula
{
    public BindingTreeLevelInfo BindingTreeLevelInfo { get; set; }

    public IEnumerable<LocatedObject<object>> GetFormulaReferObjects(LocationIndicator location)
    {
        if (this.BindingTreeLevelInfo != null)
        {
            return this.BindingTreeLevelInfo.GetFormulaReferObjects(location);
        }
        return Enumerable.Empty<LocatedObject<object>>();
    }

    public IEnumerable<object> EnumDependenceCells(IBuilderContext context)
    {
        return EnumDependenceCells(this.BindingTreeLevelInfo, context);
    }

    private IEnumerable<object> EnumDependenceCells(BindingTreeLevelInfo info, IBuilderContext context)
    {
        var result = Enumerable.Empty<object>();
        if (info != null)
        {
            if (info.QueryCondition != null)
            {
                result = result.Union(context.EnumDependenceCells(info.QueryCondition) ?? Enumerable.Empty<object>());
            }
            if (info.SubBindingTreeLevelInfo != null)
            {
                result = result.Union(EnumDependenceCells(info.SubBindingTreeLevelInfo, context) ?? Enumerable.Empty<object>());
            }
        }
        return result;
    }
}

public class TreeCellTypeDesigner : CellTypeDesigner<CurrentUserCellType>
{
    public BindingTreeLevelInfo BindingTreeLevelInfo { get; set; }

    public override EditorSetting GetEditorSetting(PropertyDescriptor property, IBuilderContext builderContext)
    {
        if (property.Name == "BindingTreeLevelInfo")
        {
            return new HyperlinkEditorSetting(new BindingTreeLevelInfoEditorSettingsCommand(builderContext));
        }
        return base.GetEditorSetting(property, builderContext);
    }

}

public class BindingTreeLevelInfoEditorSettingsCommand : ICommand
{
    IBuilderContext _builderContext;
    public BindingTreeLevelInfoEditorSettingsCommand(IBuilderContext builderContext)
    {
        _builderContext = builderContext;
    }

    public void Execute(object parameter)
    {
        var dataContext = parameter as IEditorSettingsDataContext;
        BindingTreeLevelInfo bindingTreeLevelInfo = dataContext?.Value as BindingTreeLevelInfo;

        Window window = new Window();
        UserControl dialog = new BindingTreeItemsEditor(_builderContext);
        /*这里需要将设计器上下文信息传递到编辑树节点的对话窗口,从而可以在需要的时候弹出查询对话窗口。*/

        //...
    }
}

public partial class BindingTreeItemsEditor : UserControl
{
    IBuilderContext _builderContext;
    public BindingTreeItemsEditor(IBuilderContext builderContext)
    {
        InitializeComponent();
        _builderContext = builderContext;
    }

    private void EditQueryConditionHyperlink_Click(object sender, RoutedEventArgs e)
    {
        /*使用数据层的查询条件和表名初始化查询对话窗口。*/
        var window = _builderContext?.GetQueryConditionWindow(queryCondition, tableName);
        window.Closed += (s, e2) =>
        {
            if (window.DialogResult == true)
            {
                /*当窗口被关闭后需要将新生成的查询条件提交到数据层。*/
                /*ViewModel.QueryCondition = window.QueryCondition;*/

                /*重新打开父窗口。*/
                _builderContext.ShowParentDialog(this);
            }
        }
        /*由于查询条件中可能引用单元格,所以这里需要暂时隐藏父窗口。*/
        _builderContext.HideParentDialog(this);
        window.ShowDialog();
    }
}

public class BindingTreeLevelInfo
{
    public string TableName { get; set; }
    public string ValueColumn { get; set; }
    public string NameColumn { get; set; }
    public string MasterTableRelatedColumn { get; set; }
    public BindingTreeLevelInfo SubBindingTreeLevelInfo { get; set; }

    public object QueryCondition { get; set; }

    public IEnumerable<LocatedObject<object>> GetFormulaReferObjects(LocationIndicator location)
    {
        var newLocation = location.AppendProperty("TreeCellType").AppendProperty("BindingTreeLevelInfo");
        if(this.QueryCondition is IReferenceFormula)
        {
            var items = (this.QueryCondition as IReferenceFormula).GetFormulaReferObjects(newLocation);
            foreach (var item in items)
            {
                yield return item;
            }
        }
        if (this.SubBindingTreeLevelInfo != null)
        {
            var items = this.SubBindingTreeLevelInfo.GetFormulaReferObjects(location);
            foreach (var item in items)
            {
                yield return item;
            }
        }
    }
}

属性

NullFormulaValueQueryPolicy

公式计算后空值查询策略。

声明
NullFormulaValueQueryPolicy NullFormulaValueQueryPolicy { get; }
属性值
类型 描述
NullFormulaValueQueryPolicy

QueryCondition

查询条件。

声明
object QueryCondition { get; }
属性值
类型 描述
object