Product, version and build: PowerShell Studio 2018 v5.5.152
32 or 64 bit version of product: 64
Operating system: Windows 10 17134
32 or 64 bit OS: 64
I am not sure if this should go in the GUI forum, but since I am trying to do this in PSS I place it here.
I am trying to find a way of creating an editor for email body editing. Searching the web I found a webpage describing a tool based on some opensource C# code. On that page there is afor download link for the compiled dll provided and also information on how to use in a raw GUI PowerShell form. There is also a link to the original code.
Is there any way to incorporate this into a PowerShell Studio form? Any help would be appreciated if you could look at this.
If it is possible, it may be a useful add-in for PSS like you used my suggestion for what became your modern browser dialog.
http://hillside.no/rich-text-editor-in- ... -winforms/
Regards,
Pete
How to use HTML Editor in PowerShell Studio
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- PGomersall
- Posts: 131
- Last visit: Thu Feb 15, 2024 12:14 pm
Re: How to use HTML Editor in PowerShell Studio
PowerShell Studio's designer doesn't support third party controls, but that doesn't mean you can't use them in your GUI scripts. You will just need to dynamically add the custom control within the script.
To add a custom control, do the following:
1. Use the Add-Type cmdlet to add the assembly to your script or add it to the psf file via Ribbon->Home->Editor->Assemblies.
Note: You will need to distribute the assembly with your script.
2. Add a placeholder control, such as a picture box to the designer. This step isn't necessary but makes it easier design the GUI around the custom control.
3. In the form’s Load event, instantiate the custom control and replace the place holder control with the custom control. I highly recommend looking at the Element Host - WPF Control control set to see how this is done. The control set includes a function that will replace the placeholder control during runtime.
To add a custom control, do the following:
1. Use the Add-Type cmdlet to add the assembly to your script or add it to the psf file via Ribbon->Home->Editor->Assemblies.
Note: You will need to distribute the assembly with your script.
2. Add a placeholder control, such as a picture box to the designer. This step isn't necessary but makes it easier design the GUI around the custom control.
3. In the form’s Load event, instantiate the custom control and replace the place holder control with the custom control. I highly recommend looking at the Element Host - WPF Control control set to see how this is done. The control set includes a function that will replace the placeholder control during runtime.
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- PGomersall
- Posts: 131
- Last visit: Thu Feb 15, 2024 12:14 pm
Re: How to use HTML Editor in PowerShell Studio
David, Thanks for this help; I have it working the way you describe.
One question I have is related to adding the assembly to the form. If I add in this case a dll via the browse button, how is this referenced in the form\psf? Is there anyway to specify this reference to use the folder where the script\executables is run from; i.e. as long as the dll and script or exe are the same folder it will work? Similar to using the built in $PSScriptRoot variable.
Regards,
Pete
One question I have is related to adding the assembly to the form. If I add in this case a dll via the browse button, how is this referenced in the form\psf? Is there anyway to specify this reference to use the folder where the script\executables is run from; i.e. as long as the dll and script or exe are the same folder it will work? Similar to using the built in $PSScriptRoot variable.
Regards,
Pete
Re: How to use HTML Editor in PowerShell Studio
I recommend using Add-Type over the assembly form for custom assemblies. The assemblies dialog works best with assemblies in the Global Assembly Cache. If it isn't in the cache, it will specify the absolute path of the assembly.
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- PGomersall
- Posts: 131
- Last visit: Thu Feb 15, 2024 12:14 pm