Using XSLT files instead of VBA
Posted 09-04-2012 at 16:30 by shelbym
Introduction
Previously we have used VBA to load our .NET custom docker into the CorelDRAW UI. This article will show how this may also be done using XSLT files, very similar to the example Hendrik provided in his Custom Docker article: Custom add-ons and dockers in CorelDRAW
The "Addons" Folder
You customizations will need to be in the Addons folder, for X6 64-bit that folder is found here: “C:\Program Files\Corel\CorelDRAW Graphics Suite X6\Programs64\Addons”. You will want to create a folder and give it a meaningful name; since I will be using the SM_Selection docker from a previous post I will name my folder SM_Selection. You also need to tell the addons folder which products you wish your docker to be available to. To do this you just create a blank text file and name it: Coreldrw.addon , make sure if you have file extensions hidden that you have not accidently name the file Coreldrw.addon.txt :-) If you want your docker accessible to PHOTO-PAINT, you would use CorelPP.addon and for CorelDESIGNER use Designer.addon.
*Note – You might be asking what is the SM_, they are just my initials. If you plan on sharing your work, you may wish to name your macros like this because someone else may also have a macro called Selection. It is also an easy way to tell the author of the macro so you know whom to yell at when something doesn’t work. ;-)
Customizing UI via XSLT Files
We need to generate three unique GUID’s, again you can use the tool included with Visual Studio or use an online generator: www.guidgenerator.com once you have your GUID’s plug them into the proper places on the Templates. If you want details about what each of these actual do, please refer back to Hendrik’s article he gives excellent detail.
Lets get the .GMS file set up first, rename the TemplatedotNetDocker.gms file to the name you have chosen, I am renaming to SM_Selection.gms. You may be asking why do we need the GMS file I thought we were not going to use VBA, the GMS file does not add the docker to the UI, instead it is the code behind the button that lets us easily open and close the docker we are adding with the XSLT files. This way it acts just like a normal docker. After the .gms file is renamed open the VBA Editor and rename the project also to your selected name. Replace the <<TemplatedotNetDocker>> with the name of your docker and the <<GUID C>> with one of the GUID's you generated.
To add our custom .NET docker we will need two XSLT files. First an APPUI.xslt file which defines items such as buttons, menu items, menu flyouts, and dockers. Second a UserDRAW.xslt file which adds these customizations to the current UI. I have provided a Template of each file below. Just as with the .gms file plug in the GUID and names as needed.
Here is a small piece of the XSLT file:
<itemData guid="cbdb5570-ccb0-4c52-b715-a93be68f08ad"
type="wpfhost"
hostedType="C:\Program Files\Corel\CorelDRAW Graphics Suite X6\Programs64\Addons\SM_Selection\SM_Selection_VB.dll,SM_Selection_VB.Docker"
enable="true"/>
It seems to work best putting the full path here, it doesn't have to be in the addons folder for the .dll, but since everything else is there it is nice to keep it all in one place.
Conclusion
An advantage of the XSLT approach to adding the docker is that you may name it whatever you like, if you use the VBA as in the previous article your docker would be named SM_Selection_VB.Docker, with the XSLT we just name is SM_Selection which is much nicer. I hope you all find success in this approach, it is my preferred method to adding dockers.
Coming up Next…
How to add an icon in your XSLT file...
Template XSLT Files and GMS
Template dotNet Docker
Previously we have used VBA to load our .NET custom docker into the CorelDRAW UI. This article will show how this may also be done using XSLT files, very similar to the example Hendrik provided in his Custom Docker article: Custom add-ons and dockers in CorelDRAW
The "Addons" Folder
You customizations will need to be in the Addons folder, for X6 64-bit that folder is found here: “C:\Program Files\Corel\CorelDRAW Graphics Suite X6\Programs64\Addons”. You will want to create a folder and give it a meaningful name; since I will be using the SM_Selection docker from a previous post I will name my folder SM_Selection. You also need to tell the addons folder which products you wish your docker to be available to. To do this you just create a blank text file and name it: Coreldrw.addon , make sure if you have file extensions hidden that you have not accidently name the file Coreldrw.addon.txt :-) If you want your docker accessible to PHOTO-PAINT, you would use CorelPP.addon and for CorelDESIGNER use Designer.addon.
*Note – You might be asking what is the SM_, they are just my initials. If you plan on sharing your work, you may wish to name your macros like this because someone else may also have a macro called Selection. It is also an easy way to tell the author of the macro so you know whom to yell at when something doesn’t work. ;-)
Customizing UI via XSLT Files
We need to generate three unique GUID’s, again you can use the tool included with Visual Studio or use an online generator: www.guidgenerator.com once you have your GUID’s plug them into the proper places on the Templates. If you want details about what each of these actual do, please refer back to Hendrik’s article he gives excellent detail.
Lets get the .GMS file set up first, rename the TemplatedotNetDocker.gms file to the name you have chosen, I am renaming to SM_Selection.gms. You may be asking why do we need the GMS file I thought we were not going to use VBA, the GMS file does not add the docker to the UI, instead it is the code behind the button that lets us easily open and close the docker we are adding with the XSLT files. This way it acts just like a normal docker. After the .gms file is renamed open the VBA Editor and rename the project also to your selected name. Replace the <<TemplatedotNetDocker>> with the name of your docker and the <<GUID C>> with one of the GUID's you generated.
To add our custom .NET docker we will need two XSLT files. First an APPUI.xslt file which defines items such as buttons, menu items, menu flyouts, and dockers. Second a UserDRAW.xslt file which adds these customizations to the current UI. I have provided a Template of each file below. Just as with the .gms file plug in the GUID and names as needed.
Here is a small piece of the XSLT file:
<itemData guid="cbdb5570-ccb0-4c52-b715-a93be68f08ad"
type="wpfhost"
hostedType="C:\Program Files\Corel\CorelDRAW Graphics Suite X6\Programs64\Addons\SM_Selection\SM_Selection_VB.dll,SM_Selection_VB.Docker"
enable="true"/>
It seems to work best putting the full path here, it doesn't have to be in the addons folder for the .dll, but since everything else is there it is nice to keep it all in one place.
Conclusion
An advantage of the XSLT approach to adding the docker is that you may name it whatever you like, if you use the VBA as in the previous article your docker would be named SM_Selection_VB.Docker, with the XSLT we just name is SM_Selection which is much nicer. I hope you all find success in this approach, it is my preferred method to adding dockers.
Coming up Next…
How to add an icon in your XSLT file...
Template XSLT Files and GMS
Template dotNet Docker
Total Comments 7
Comments
-
32-bit
Hello Sir,
This is a great post ,but I have some questions please as I try it but it didn't work with me,I am sure it it my problem so please give me a hand here
Q1. In this post after this title >>>The "Addons" Folder
we can read >>> You customizations will need to be in the Addons folder, for X6 64-bit that folder is found here: “C:\Program Files\Corel\CorelDRAW Graphics Suite X6\Programs64\Addons”.
is this means that this is not supported in corel 32-bit...?
in case your answer was ,No it is supported in corel 32-bit too, then is this path looking correct for you Sir >>> C:\Program Files (x86)\Corel\CorelDRAW Graphics Suite X6\Programs\Addons\EasyStone_EasyTools
Best Regards,Posted 03-10-2012 at 15:27 by amr
Updated 03-10-2012 at 15:35 by amr -
Questions...
Hello Sir,
This is a great post ,but I have some questions please as I try it but it didn't work with me ,I am sure it it my problem so please give me a hand here
Q1. In this post after this title >>>The "Addons" Folder
we can read >>> You customizations will need to be in the Addons folder, for X6 64-bit that folder is found here: “C:\Program Files\Corel\CorelDRAW Graphics Suite X6\Programs64\Addons”.
is this means that this is not supported in corel 32-bit...?
in case your answer was ,No it is supported in corel 32-bit too, then is this path looking correct for you Sir >>> C:\Program Files (x86)\Corel\CorelDRAW Graphics Suite X6\Programs\Addons\EasyStone_EasyTools
Best Regards,Posted 03-10-2012 at 15:55 by katruax -
Posted 06-10-2012 at 17:31 by shelbym -
Posted 22-10-2012 at 00:27 by shelbym -
anyone tried adding a menu btn in x7
I am trying to create a btn in x7 but so far no luck.
Any ideas on how to do it?Posted 29-04-2014 at 03:50 by mika -
Posted 29-04-2014 at 22:20 by shelbym
Total Trackbacks 0