Powershell & WPF: Build a prerequisites GUI - Part 1


In this post, I will show you a short sample to create easily your prerequisites part in a GUI.
Sometimes it could be useful to have a prerequisites part to check some parameters before clicking on a button and starting a process.

For instance, in a Upgrade In place scenario, you may need to check some prerequisites like disk size, RAM, supported model ...

I will share with you a little sample I did in one of my project that can be helpful for doing that.

It isn't a template, I just a sample and encourage you to play with XAML and your imagination.
So now let's start.

First see below the prerequisites I'll check:
- Model supported depending of a list
- Disk size: At least 20Gb
- RAM: At least 4Gb
- Computer plugged-in
- Secure boot enabled

My supported models list is located in a xml file, as below:

How it looks like ?
See below the final result of this sample, in case ok or not.


Where to find it ?




Building the XAML
It's pretty simple to do. If you need to add a prerequisite. 
Each prerequisite part is composed of a button with icon and a text part, as below:
Then between each part I added a canva, as below:
Now if you need to add a new prerequisite just add a new block as below:

Coding our check script
To change color of label, button and the line between each part I used the below code:
In the below code we will the code used to check the minimum RAM size and change RAM part color, label, button:
In the below code we will the code used to check the minimum disk free space and change RAM part color, label, button:
In the below code we will the how to change the line between the RAM and Disk size part.
If one of the prerequisite is KO, the line should be in red, if not it should be in green.

Share this

Related Posts

Previous
Next Post »