将功能与WiX中的复选框关联

时间:2018-02-10 05:23:26

标签: checkbox dialog wix

我的Product.wxs中有一些功能(Complete,有2个子功能,即AppFeature和DBFeature),如下所示。

 <Feature InstallDefault="local" Description="!(loc.FullFeatureDesc)" Title="!(loc.FullFeatureTitle)" Level="1" Id="Complete" Absent="allow" AllowAdvertise="no" Display="expand">
      <Feature InstallDefault="local" Description="!(loc.AppFeatureDesc)" Title="!(loc.AppFeatureTitle)" Level="1" Id="AppFeature" Absent="allow" AllowAdvertise="no" Display="expand">
        <ComponentGroupRef Id="AppCG"/>
      </Feature>
      <Feature InstallDefault="local" Description="!(loc.DBFeatureDesc)" Title="!(loc.DBFeatureTitle)" Level="1" Id="DBFeature" Absent="allow" AllowAdvertise="no" Display="expand">
        <ComponentGroupRef Id="DbCG"/>
      </Feature>
    </Feature>

在另一个对话框中,我有一些All,App和DB选项的复选框,每个选项都用于一个功能(All表示App和DB)。我想将App复选框与App关联 数据库功能的功能和数据库复选框。我使用Event =&#34; AddLocal&#34;在该对话框的Next按钮中使用Publish元素尝试了它。和价值=&#34; AppFeature&#34;和一个DBFeature,适当选中复选框值。但是点击“下一步”按钮,没有任何反应。谁能帮帮我吗?我还提供了对话框中的元素供参考。

<Control Id="ControlAllFeature" Type="CheckBox" X="180" Y="33" Width="140" Height="17"
    Property="ALLFEATURES_CHECKED" CheckBoxValue="AllFeatureValue" Text="Install Everything">
          <Publish Property="APPFEATURE_CHECKED" Value="AppFeatureValue" Order="1">ALLFEATURES_CHECKED</Publish>
          <Publish Property="APPFEATURE_CHECKED" Value="{}" Order="2">NOT ALLFEATURES_CHECKED</Publish>
          <Publish Property="DBFEATURE_CHECKED" Value="DBFeatureValue" Order="3">ALLFEATURES_CHECKED</Publish>
          <Publish Property="DBFEATURE_CHECKED" Value="{}" Order="4">NOT ALLFEATURES_CHECKED</Publish>      
        </Control>
        <Control Id="ControlAppFeature" Type="CheckBox" X="191" Y="50" Width="140" Height="17"
     Property="APPFEATURE_CHECKED" CheckBoxValue="AppFeatureValue" Text="Install Application">
          <Publish Property="ALLFEATURES_CHECKED" Value="{}" Order="1">NOT APPFEATURE_CHECKED</Publish>
          <Publish Property="ALLFEATURES_CHECKED" Value="AllFeatureValue" Order="2">APPFEATURE_CHECKED AND DBFEATURE_CHECKED</Publish>
        </Control>
        <Control Id="ControlDBFeature" Type="CheckBox" X="191" Y="67" Width="140" Height="17"
           Property="DBFEATURE_CHECKED" CheckBoxValue="DBFeatureValue" Text="Install DB">
          <Publish Property="ALLFEATURES_CHECKED" Value="{}" Order="1">NOT DBFEATURE_CHECKED</Publish>
          <Publish Property="ALLFEATURES_CHECKED" Value="AllFeatureValue" Order="2">APPFEATURE_CHECKED AND DBFEATURE_CHECKED</Publish>
        </Control>

        <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&amp;Back">
          <Publish Event="NewDialog" Value="CustLicenseAgmtDlg">1</Publish>
        </Control>
        <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&amp;Next">
          <Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">CostingComplete = 1</Publish>
          <Publish Event="NewDialog" Value="BrowsePathDlg"></Publish>
           <Condition Action="disable">NOT APPFEATURE_CHECKED OR NOT DBFEATURE_CHECKED</Condition>
          <Condition Action="enable">APPFEATURE_CHECKED OR DBFEATURE_CHECKED</Condition>
         <Publish Event="Remove" Value="ALL" Order="1">1</Publish>
         <Publish Event="AddLocal" Value="AppFeature" Order="2">APPFEATURE_CHECKED</Publish>
         <Publish Event="AddLocal" Value="DBFeature" Order="3">DBFEATURE_CHECKED</Publish>
        </Control>
        <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
          <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
        </Control>

我之前提到了以下链接,但无法使其正常运行。任何帮助都将非常感激。

Wix 3.5, Install features based on checkboxes

2 个答案:

答案 0 :(得分:1)

我改变了方法。实际上有两种方式。一种是在要素元素中的Product.wxs中执行此操作以获得条件。另一个提供更好的控制。下面的标记解释了它。

<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&amp;Next">
          <Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">CostingComplete = 1</Publish>
          <Publish Event="NewDialog" Value="BrowsePathDlg">1</Publish>
             <Condition Action="disable">NOT APPFEATURE_CHECKED OR NOT DBFEATURE_CHECKED OR (((!AppFeature = 3) AND (!DBFeature = 2) AND NOT DBFEATURE_CHECKED) AND ((!DBFeature = 3) AND (!AppFeature = 2) AND NOT APPFEATURE_CHECKED)) OR ((!AppFeature = 3) AND (!DBFeature = 3))</Condition>
          <Condition Action="enable">(APPFEATURE_CHECKED OR DBFEATURE_CHECKED) AND (((!AppFeature = 2) AND APPFEATURE_CHECKED) OR ((!DBFeature = 2) AND DBFEATURE_CHECKED))</Condition>
           <Publish Event="AddLocal" Value="ALL">1</Publish> 
          <Publish Event="Remove" Value="AppFeature"><![CDATA[APPFEATURE_CHECKED <> "1"]]></Publish>
          <Publish Event="Remove" Value="DBFeature"><![CDATA[DBFEATURE_CHECKED <> "1"]]></Publish>
        </Control>

我之前缺少的是Publish NewDialog事件中的值1。一旦我添加它,它就开始工作并单击Next按钮,将我带到下一个对话框。

答案 1 :(得分:0)

试试这个:

你的chield功能中的

将它放在0级,然后他们在她的内部设置一个条件来验证是否选中了复选框

<Feature InstallDefault="local" Description="!(loc.FullFeatureDesc)" Title="!(loc.FullFeatureTitle)" Level="1" Id="Complete" Absent="allow" AllowAdvertise="no" Display="expand">
  <Feature InstallDefault="local" Description="!(loc.AppFeatureDesc)" Title="!(loc.AppFeatureTitle)" Level="0" Id="AppFeature" Absent="allow" AllowAdvertise="no" Display="expand">
    <ComponentGroupRef Id="AppCG"/><Condition Level="1">APPFEATURE_CHECKED</Condition>
  </Feature>
  <Feature InstallDefault="local" Description="!(loc.DBFeatureDesc)" Title="!(loc.DBFeatureTitle)" Level="1" Id="DBFeature" Absent="allow" AllowAdvertise="no" Display="expand">
    <ComponentGroupRef Id="DbCG"/>
  </Feature>
</Feature>