0

有没有办法在我执行检查数据库可用性等操作时禁用 UI 控件?现在是这样的:

<Control Id="Next" Type="PushButton">
    <Publish Event="DoAction" Value="CheckDBConnection" Order="3">
        <![CDATA[SQL_SERVER <> "" AND SQL_USER <> "" AND SQL_PASSWORD <> ""]]>
    </Publish>
    <Publish Event="DoAction" Value="Confirm_OverwriteDatabase" Order="2"/>
    <Publish Event="NewDialog" Value="VerifyReadyDlg" Order="1"/>
</Control>

执行时CheckDBConnection,所有控件都处于活动状态,但不执行任何操作。在执行后台操作时禁用它们会更准确。

4

2 回答 2

0

根据所需的属性,使用具有启用\禁用操作的条件:

<Control Id="{Id}" Type="{Type}">
     <Condition Action="enable" ><![CDATA[SOMEPROPERTY = SomeValue]]></Condition>
     <Condition Action="disable"><![CDATA[SOMEPROPERTY <> SomeValue]]></Condition>
</Control>
于 2013-09-03T09:38:49.713 回答
0

感谢@vitaliy-zadorozhnyy,我能够想出一个我自己都不理解的奇怪代码。但它有效。

...
...

<Property Id="DBCHECK_INPROGRESS" Value="0" />
<Property Id="DBCHECK_NOTINPROGRESS" Value="0" />

...
...

<Control Id="{Id}" Type="{Type}">
    <Condition Action="enable"><![CDATA[DBCHECK_INPROGRESS <> 1]]></Condition>
    <Condition Action="disable"><![CDATA[DBCHECK_INPROGRESS = 1]]></Condition>
</Control>

{insert those conditions for any control you want to disable during action}

...
...


<Control Id="Next" Type="PushButton">
    <Condition Action="enable"><![CDATA[DBCHECK_INPROGRESS <> 1]]></Condition>
    <Condition Action="disable"><![CDATA[DBCHECK_INPROGRESS = 1]]></Condition>

    <Publish Event="DoAction" Value="SetInProgress">1</Publish>
    <Publish Property="TEMP_INPROGRESS" Value="[DBCHECK_INPROGRESS]">1</Publish>
    <Publish Property="DBCHECK_INPROGRESS" Value="[TEMP_INPROGRESS]" />

    <Publish Event="DoAction" Value="CheckDBConnection"/>

    <Publish Event="DoAction" Value="SetNotInProgress">1</Publish>
    <Publish Property="TEMP_NOTINPROGRESS" Value="[DBCHECK_NOTINPROGRESS]">1</Publish>
    <Publish Property="DBCHECK_NOTINPROGRESS" Value="[TEMP_NOTINPROGRESS]" />

    {other events}

</Control>

和自定义操作(JScript)很简单:

function SetInProgress_CA() {
    Session.Property("DBCHECK_INPROGRESS") = "1";
}
function SetNotInProgress_CA() {
    Session.Property("DBCHECK_INPROGRESS") = "0";
}
于 2013-09-03T11:29:51.093 回答