2009-06-24 76 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」事件引發,但只顯示最後一個。有沒有人知道不這樣做的好理由?