oleg-shilo / wixsharp

Framework for building a complete MSI or WiX source code by using script files written with C# syntax.
MIT License
1.04k stars 168 forks source link

Mainteance dialog (Change enabled button) #1501

Closed grizoood closed 1 month ago

grizoood commented 1 month ago

I work with the template: "Wix Sharp Setup WPF UI", I try to get as close as possible to what was done in Wix.

I don't create a feature, so everything is in "Complete".

In my old Wix msi I had the Maintenance window which grayed out the "Change" button because there were no selectable features and also replace the text by MaintenanceTypeDlgChangeDisabledText.

Wix interface :

image

WixSharp interface :

image

oleg-shilo commented 1 month ago

TBH I am not sure the button should be disabled. It is rather a questionable UX.

I prefer the button to be enabled and if you click it it should go to the features dialog and show the current state of the features so user can decide if the change is really required. This is the current behaviour.

Though, if you want to make this decision on user behalf you can analyse the full state of every feature programmatically. It's not a problem.

I suggest you use "Custom WPF UI" template as it comes with the source code for the Features dialog where the "explore feature state" technique is used. You can just reuse the code. Most likely it will cover your needs.

image

grizoood commented 1 month ago

I used this :

    /// <summary>
    /// Updates the buttons of the dialog depending on ARPNOMODIFY, ARPNOREPAIR, ARPNOREMOVE.
    /// </summary>
    /// <param name="session">The session.</param>
    public void UpdateButtons(ISession session)
    {
        if (session["ARPNOMODIFY"] == "1")
        {
            ChangeLabel.Text = "[MaintenanceTypeDlgChangeDisabledText]";
            Change.IsEnabled = false;
        }
        else
        {
            ChangeLabel.Text = "[MaintenanceTypeDlgChangeText]";
            Change.IsEnabled = true;
        }

        if (session["ARPNOREPAIR"] == "1")
        {
            RepairLabel.Text = "[MaintenanceTypeDlgRepairDisabledText]";
            Repair.IsEnabled = false;
        }
        else
        {
            RepairLabel.Text = "[MaintenanceTypeDlgRepairText]";
            Repair.IsEnabled = true;
        }

        if (session["ARPNOREMOVE"] == "1")
        {
            RemoveLabel.Text = "[MaintenanceTypeDlgRemoveDisabledText]";
            Remove.IsEnabled = false;
        }
        else
        {
            RemoveLabel.Text = "[MaintenanceTypeDlgRemoveText]";
            Remove.IsEnabled = true;
        }

        // `Localize` resolves [...] text into the localized strings stored in MSI resources tables
        this.Localize();
    }