2009-06-24 77 views
1

我有一个相当复杂的安装程序,我在Wix中编写了很多基于您正在安装的组件的自定义对话框选项。一般来说,默认情况很好,因此无人值守的安装会成功,但具有这种自定义功能会有所帮助。Wix UI条件最佳实践

我想知道的是,Wix中做UI条件的最佳实践是什么?我注意到,维克斯评估所有<Publish>标签,无论是否不是最后一个被评估为真,这是导致很多这样的代码:

<Publish Dialog="Questions" Control="Next" Event="NewDialog" Value="Component1Questions" Order="1">INSTALLCOMPONENT1</Publish> 
<Publish Dialog="Questions" Control="Next" Event="NewDialog" Value="Component2Questions" Order="2">NOT INSTALLCOMPONENT1 AND INSTALLCOMPONENT2</Publish> 
<Publish Dialog="Questions" Control="Next" Event="NewDialog" Value="Component3Questions" Order="3">NOT INSTALLCOMPONENT1 AND NOT INSTALLCOMPONENT2 AND INSTALLCOMPONENT3</Publish> 
<Publish Dialog="Questions" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="4">NOT INSTALLCOMPONENT1 AND NOT INSTALLCOMPONENT2 AND NOT INSTALLCOMPONENT3</Publish> 

而且同样也在“后退”节每个对话框都有这个最佳实践吗?有没有一种方法可以对Publish元素进行短路评估,并将第一个元素返回true?

回答

2

您已经在使用Publish/@ Order元素来简化代码,但我会建议尽可能明确。

无论如何你可以简化逻辑,而不用担心订单价值...

<Publish ... Value="Component1Questions">CMP1 And Not (CMP2 Or CMP3)</Publish> 
<Publish ... Value="Component2Questions">CMP2 And Not (CMP1 Or CMP3)</Publish> 
<Publish ... Value="Component3Questions">CMP3 And Not (CMP1 Or CMP2)</Publish> 
<Publish ... Value="VerifyReadyDlg">Not (CMP1 Or CMP2 Or CMP3)</Publish> 
+0

逻辑更简单但稍微不正确。如果我想安装所有3个组件,在这种情况下,下一个按钮将不起作用。 – Jeff 2009-06-25 20:14:45

0

我仍然不知道这是否是一个很好的做法或没有,但我得到的东西相同的结果是这样的:

<Publish Dialog="Questions" Control="Next" Event="NewDialog" Value="Component1Questions" Order="4">INSTALLCOMPONENT1</Publish> 
<Publish Dialog="Questions" Control="Next" Event="NewDialog" Value="Component2Questions" Order="3">INSTALLCOMPONENT2</Publish> 
<Publish Dialog="Questions" Control="Next" Event="NewDialog" Value="Component3Questions" Order="2">INSTALLCOMPONENT3</Publish> 
<Publish Dialog="Questions" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="1">1</Publish> 

我的意思是,扭转订单号码,忘记了合成条件。最后,你拥有的条件数量是相同的,但它更易于维护和阅读。 当然,这意味着不止一个“NewDialog”事件引发,但只显示最后一个。有没有人知道不这样做的好理由?