in the previous post i described what a dialog consists of and introduced the module PSGUI. Now i will show you some features which will work mostly at the loading time.
If you try to load a XAML into Powershell by your own (by using [Windows.Markup.XamlReader]::Load) you normally will fight some problems:
The first one will be, that you normally have to delete the class which will be placed by Visual Studio automatically. Also you would ran into some problems with the namespace. (x:name).
I managed to fix these at the loading process. The XAML data will be corrected after loading it from file.
The next problem which you will run into it is, that neither relative links nor absolute ones will work properly on every computer. But the links for images or other files should work if you want to create nice looking UIs.
Fixed this problem by using RegEx and adding the correct links at the loading process.
If you create your WPFApplication in VS just add a folder “Resources” (or any other name) and add some pictures/files to it. (This is how it is done!) Grab these pictures and place it into the WPF-code as you like to.
Pro: the design will be created and you can use your WYSIWYG designer as it is intended.
Here for example the icon of the window, which will be shown on the top right corner but also on the taskbar is set. By standard this would be the powershell icon.
There is only one condition with file links – do not use two files with the same name within one dialog. e.g.: “nicePicture.png” and “Folder\nicePicture.png”
Keep this in mind and you will never have any problems with file links.
I described that all the variables for all objects were created automatically at the loading process. Let´s take a deeper look into this:
The window is the name of the dialog, the folder and all the files. It is always the same.
The objects will be added to this name with an starting underscore.
The events will be added with the pattern “.add_” & EventName.
And how is this visualized in the GUI-Manager?. The GUI-Manager loads the dialog of its dialog folder. New dialogs can be placed there.
If you select one of the dialogs the dialog its XAML will be loaded internally and the variables-list in the middle will be filled. If you select now a specific object the events will be shown in the listview on the right:
With this functionality you do not have to know all the events nor the objectnames. You may also have noticed that the “Click”-event is written in bold. It has just been defined in the CodeBehind-file. With a doubleclick on the event the textbox on the bottom will jump to this event.
If the event does not exist till now it will be added into the CodeBehind-file at the end and you will be moved to it. No more misstyping. No more searching. You manage your events easily with this.
After you have added an event to the file just save it by pressing “CTRL+S”. You want to see what the new code causes? Press the menu item “Dialogs” and press “Render Dialog”. Now the dialog is created and visualized within a second and shown on top of the GUI-Manager.
One problem with this whole construction is, that the dialogname is integrated in every object, event etc. If you want to rename a dialog you have to rename the folder, the files and also lots of names in the file.
You could do this – but – i added a function in the PSGUI module herefore which has an absolutely complex name: Rename-XAMLDialog
This is also integrated in the GUI-Manager by just selecting the dialog you want to rename, press “Dialogs” and “Rename Dialog” and just enter your new name.
And now you should test the functions by your own. Play with the GUI-Manager and tell me if you have some inovative ideas or find some bugs.
And this should be it – the first introduction of the GUI-Manager. This is just work in progress and will be modified in the upcoming weeks. So i will stop at this point for now.