基于复选框安装功能 [英] Install features based on checkboxes

查看:14
本文介绍了基于复选框安装功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使当用户通过复选框选择某些内容时,将安装相应的功能.

I am trying to make it so that when the user selects something via check box, a corresponding feature will be installed.

我知道 Wix 提供的预构建功能树,但我正在做的其他一些事情不允许我使用此功能.我很好奇如何将两者链接在一起,以便当用户选中安装功能 X"复选框时,当用户单击安装按钮时会安装功能 X.

I am aware of the prebuilt feature tree that Wix provides but there are some other things that I am doing that do not allow me to use this function. I am curious as to how to link the two together so that when the user selects the check box "Install Feature X", feature X is installed when the user clicks the install button.

推荐答案

我找到了解决我问题的方法.要按照我的预期做,我需要为每个功能创建一个复选框.

I found what it was that solves my issue. To do as I had intended, I needed to create a checkbox for each feature as so.

<Control Id="FeatureX" Type="CheckBox" X="191" Y="50" Width="140" Height="17"
     Property="FEATUREX_CHECKED" CheckBoxValue="myValue" Text="Install feature X" />
<Control Id="FeatureY" Type="CheckBox" X="191" Y="67" Width="140" Height="17"
     Property="FEATUREY_CHECKED" CheckBoxValue="myValue" Text="Install feature Y" />
<Control Id="FeatureZ" Type="CheckBox" X="191" Y="84" Width="140" Height="17"
     Property="FEATUREZ_CHECKED" CheckBoxValue="myValue" Text="Install feature Z" />

现在,一旦我这样做了,我就为每个发布添加了一个相应的发布,并设置了一个条件,以便只有选中该复选框才会安装该功能.像这样:

Now once I did that I then added a corresponding publish to each, and made a condition that made it so that only if the check box is selected will that feature be installed. Like so:

<Control Id="Next" Type="PushButton" Text="Next" X="254" Y="243" Height="17" Width="56">
   <Publish Event="Remove" Value="ALL" Order="1">1</Publish>
   <Publish Event="AddLocal" Value="FeatureX" Order="2">
      <![CDATA[FEATUREX_CHECKED]]>
   </Publish>
</Control>

注意:

Remove 用于取消选择安装中的所有内容(我注意到一旦调用 UI,更改功能级别为时已晚).

NOTE:

Remove is used to deselect everything from being installed (It was brought to my attention that once the UI is invoked, it is too late to change feature levels).

然后检查每个功能以查看相应的复选框"是否已被选中,如果是,则将其添加到AddLocal"属性中.AddLocal 看起来像这样:

Then each feature is checked to see if the "corresponding checkbox" has been selected and if so adds it to the "AddLocal" Property. AddLocal would look like this if one were to look at it:

ADDLOCAL=FeatureX, FeatureY, FeatureZ...

我需要做的最后一件事是检查我的 main.wxs 以确保复选框中使用的 FeatureID 与使用的 ComponentGroupRefID 匹配:

The final thing I needed to do to get this to work was too check in my main.wxs to make sure that the FeatureID used in the checkboxes matched up with the ComponentGroupRefID used:

 <ComponentGroupRef Id="FeatureX"/>

原来如此……我再次感谢大家对此的帮助.如果有人读到这篇文章有什么困惑,请随时给我写信,我会尽力进一步解释.

So there it is... I again, thank everyone for their help with this. If anyone reading this is confused by anything, please feel free to drop me a line, and I will do my best to explain things a little bit further.

这篇关于基于复选框安装功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆