OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Blogs > shelbym

Rating: 23 votes, 5.00 average.

Custom .NET Dockers in CorelDRAW X6

Posted 01-04-2012 at 23:38 by shelbym


In the previous blog post we showed an example of a custom WPF control that was hosted in the UI of CorelDRAW. In this post we are going to take a Custom Web Docker that Hendrik had provided as an example and rewrite it as a Custom WPF .NET Docker. If you have never made a custom docker his article is a wonderful place to start. You may find it here: Custom add-ons and dockers in CorelDRAW

WPF User Control Library

Once again I will be using Visual Studio Professional. I will be posting all code samples this time in VB.NET as they were downloaded the most often in the last blog post. I will however include a C# version of the source code for those that prefer it.

To begin Open Visual Studio and Start a New Project | Visual Basic | Windows | WPF User Control Library. I named my project SM_Selection_VB, but feel free to name it whatever you like. Rename the UserControl1.xaml to Docker.xaml, double click on the Docker.xaml.vb and rename the public class UserControl1 to Docker. In the Solution Explorer right click your project name, in my case SM_Selection_VB and select add reference. If you have done the previous example the CorelDRAW interop assemblies will be listed in the Recent tab, if not the 64-bit location is:
C:\Program Files\Corel\CorelDRAW Graphics Suite X6\Programs64\Assemblies
You need to add a reference to both the Corel.Interop.CorelDRAW.dll and Corel.Interop.VGCore.dll. That should be it for setup we are all ready to get started coding.


Since we are creating a docker we will use the DesignHeight and DesignWidth, I have found that DesignWidth is best set to 225, and the height can be whatever fits your content best, in this case I went with a DesignHeight of 500.

Replace the Grid, with a StackPanel and then we can drag our needed labels, textboxes, and buttons from the Toolbox to our XAML, if you prefer you could of course type all the XAML by hand. I like to rename all the controls so they are easily identified. When you are done, you should have something that looks like the XAML below:
Name:  Docker_XAML.PNG
Views: 57397
Size:  48.2 KB
Visual Basic

Now that we are done with the XAML we need to code it up, this time we shall use Visual Basic. Again, keeping the code very basic, we have a Sub for each button that we created and our Sub for the SelectionChange event, you will only need WithEvents if you are listening for these types of events. All the selection of our shapes is done with a little CQL, which makes it very simple. When you are done, your code will look something like this:
Name:  Docker_VB.PNG
Views: 51499
Size:  36.3 KB
Note: I did not post the full code due to space, if you want to see all the code please download the source files.

Save your work, and Build the solution to generate the .dll, I move the .dll to my Addons folder, but it can be placed anywhere you wish. Just remember where you put it because you will need to reference it in your VBA code.

Add Custom Docker

Adding the docker is very similar to adding or WPF Custom Control; expect that we will need a unique GUID to identify the docker by. You can generate a GUID from the tool included with Visual Studio, Create GUID, or if you prefer use an online tool such as: http://www.guidgenerator.com/ the important thing to remember is that you need to generate a new GUID for each new Custom .NET Docker you create.

The following VBA code, creates the docker in the UI, and makes an entry for our Docker in the Windows | Dockers menu.
Sub addSelectionVB()
    Dim dockerAssembly As String
    dockerAssembly = "C:\Program Files\Corel\CorelDRAW Graphics Suite X6\Programs64\Addons\SM_Selection\SM_Selection_VB.dll"
    Call FrameWork.AddDocker("6139b731-672f-4131-88e4-3a30833b349d", "SM_Selection_VB.Docker", dockerAssembly)
    Call FrameWork.CommandBars("Dockers").Controls.AddToggleButton("6139b731-672f-4131-88e4-3a30833b349d", 0, False)
End Sub
The newly create docker should look similar to this:
Name:  Selection_Docker.PNG
Views: 49060
Size:  20.1 KB

Congratulations you have just created your very first Custom WPF .NET Docker for CorelDRAW X6. As always if you have question feel free to ask them in the forums.

Coming up Next…

Adding a Custom Docker or Control via XSLT instead of VBA

Full Visual Studio 2010 Source Code

If you would like to look at the full source code, I am providing both C# and VB.NET examples.

Posted in VBA
Views 126705 Comments 3
« Prev     Main     Next »
Total Comments 3


  1. Old Comment


    This is awesome, quite a bit easier to do than in X5 once you get the hang of it.

    Thanks, Shelby! I totally stole your example code and then modified it with very pleasant results
    Posted 15-05-2012 at 05:31 by Joe Joe is offline
  2. Old Comment
    great post!

    I was totally with you up until the point that you reference the vb code that adds the docker.

    What do I do with that code?
    Posted 15-05-2014 at 15:42 by Keefster Keefster is offline
  3. Old Comment
    shelbym's Avatar

    VBA Code

    Originally Posted by Keefster View Comment
    great post!

    I was totally with you up until the point that you reference the vb code that adds the docker.

    What do I do with that code?
    You need to run this code via VBA. (Alt-F11), I suggest making your own GMS file and add the code there, then run it. Keeps things nice and neat. :-)
    Posted 22-05-2014 at 11:48 by shelbym shelbym is offline
Total Trackbacks 0


All times are GMT -5. The time now is 21:26.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com