SharpSetup WPF GUI

Any SharpSetup related discussions are welcome here including but not limited to questions about functionality, suggestions for improvements and technical questions.
DaniDansen
Posts: 15
Joined: Wed May 11, 2011 9:19 am

SharpSetup WPF GUI

Postby DaniDansen » Wed May 11, 2011 9:24 am

Hi there,

I'm trying to create an installer with an WPF-Project GUI.
My current Problem is, that I can't update my Progressbar.
Is there a way how to do this by using MsiConnection.Instance? Or is there another way how to do this?

Are there any examples ?


greetings Daniel

tomasz_grobelny
Posts: 463
Joined: Sat May 22, 2010 1:26 pm

Re: SharpSetup WPF GUI

Postby tomasz_grobelny » Wed May 11, 2011 10:20 pm

This should be possible using MsiConnection.Instance.Progress event. The way Windows Installer sends progress messages is somewhat complicated. The following code (coming from InstallationProgress control) should give you some hints as to how you own progress bar should be implemented (not sure if all used methods are public, but you get the idea). Please let me know if you have further questions.

Code: Select all

                switch (e.Type)
                {
                    case ProgressType.DoStep:
                        pbInstallation.PerformStep();
                        break;
                    case ProgressType.Range:
                        pbInstallation.Minimum = 0;
                        pbInstallation.Maximum = e.Amount;
                        break;
                    case ProgressType.SetPos:
                        if (e.Amount > pbInstallation.Maximum)
                            pbInstallation.Maximum = e.Amount;
                        pbInstallation.Value = Math.Min(pbInstallation.Maximum, Math.Max(0, e.Amount > 0 ? e.Amount : pbInstallation.Maximum + e.Amount));
                        break;
                    case ProgressType.SetStep:
                        pbInstallation.Step = e.Amount;
                        break;
                    case ProgressType.Description:
                        if (string.IsNullOrEmpty(e.Description))
                            lblProgress.Text = defaultText;
                        else
                            lblProgress.Text = e.Description;
                        lblDetail.Text = string.Empty;
                        break;
                    case ProgressType.DescriptionDetail:
                        lblDetail.Text = e.Description;
                        break;
                    case ProgressType.InstallEnd:
                        break;
                    case ProgressType.FilesInUse:
                        var dialog = new ModernFilesInUseDialog(e.Description, e.Applications);
                        e.Result = (int)dialog.ShowDialog(this);
                        break;
                    case ProgressType.OutOfDiskSpace:
                        e.Result = (int)MessageBoxHelper.Show(this, e.Description, e.Caption, MsiConnection.MapInt32ToMessageBoxButtons(e.Flags), MsiConnection.MapInt32ToMessageBoxIcon(e.Flags), MessageBoxDefaultButton.Button1);
                        break;
                }

DaniDansen
Posts: 15
Joined: Wed May 11, 2011 9:19 am

Re: SharpSetup WPF GUI

Postby DaniDansen » Thu May 12, 2011 8:28 am

Thank you tomasz_grobelny!!

It perfectly works now! That was a greate hint.

Greetings Daniel


Return to “General”

Who is online

Users browsing this forum: No registered users and 1 guest