AddIns with DotNetBar

Tags: 

It's possible, with a bit of effort, to make add-ins look like they are standard controls within CX instead of ugly WinForms shoe-horned into an otherwise fairly attractive application. Doing so can greatly improve the reception that your add-in receives from the business side of a project. CX is written using a control library called DotNetBar and add-ins using this library can use much of the same functionality and theming that CX uses. There are however a few catches (as usual):

  • DotNetBar isn't free: ~$300 for a personal license and ~$3000 for a site license
  • CX hasn't upgraded the version of DotNetBar they use in at least 5 years, while this isn't a big deal it does require us to do some funky stuff when trying to use controls that only exist in newer builds (more on this later)
  • DotNetBar isn't bug free: like all pieces of software it has issues from time to time however with a license you get both the source and access to support, so between the two you should be able to fix anything that comes up
  • At some point, I expect CX to be re-written using WPF (this is a theory, I don't know anything for certain) or even Java (though I doubt this, the upgrade would be terrible) but in either case the add-in you went through so much work to make look like the rest of the product... now doesn't

Steps to write a DotNetBar Add-in

  1. Buy DotNetBar or use the free trial to sell the idea to the business
  2. Once installed you should get an additional set of tools in your VisualStudio Toolbox
  3. Create your UI as usual but instead of using the WinForms controls use the DotNetBar controls instead. For this example I'm going to create a WorkspaceComponent with a single ButtonX added to the UserControl
  4. Here's a tricky bit: in the references for the project find the DotNetBar2 reference and delete it. Instead add a reference to the copy of the DLL that is in the root directory of your site install (somewhere around C:\Users\[yourUserName]\AppData\Roaming\RightNow_Technologies\[site]\[version]\). We do this so that the add-in uses the copy of DotNetBar that comes with CX and keeps us from having to bundle the DLL in with our add-in. It also ensures that all of our controls are part of the early implementation of DotNetBar.
  5. Once upload you should have an add-in that responds to theme changes in CX (RN Button (aka: the Eye of Sauron if you're on a new version) --> RightNow CX Options --> View Options)
    1. Blue
    2. Gray
    3. Tint works as well (though there are some really ugly ones out there - I usually make production sites some terrible color so that I don't make changes accidently)
  6. As long as every control you want is part of the DLL that ships with CX you can stop reading, however if you want to use a control that exists in the new library then you need to do a bit more work. Start by adding the reference back for DotNetBar2. Select the reference and set it's alias to 'dnb2' instead of global. This is done because both DLLs use the same namespace and we need a way to differentiate between them (if there is a more elegant way send me an email)
  7. Now in the designer for your control
    1. Add an external alias to the top of the file: 'extern alias dnb2;'
    2. Change the type of your DotNetBar2 control to start with dnb2
  8. Finally, and most unfortunately, you need to handle the theme changes. In DotNetBar1 there was a different system for controlling them than there is in DotNetBar2
  9. This code can handle all theme changes, however I haven't figured out how to deal with tint's yet. Obviously the data is there somewhere, I just haven't figured out the correct way to pull it yet

Comments

Hey Jack,

with the newer versions do they have an updated version of DotNetBar? As all controls are updated.

Bastiaan

sorry for the delay, see http://cxdeveloper.com/discussion/current-status-rightnow-dotnetbar-wpf#... for my thoughts on the current status of CX and DNB

Zircon - This is a contributing Drupal Theme
Design by WeebPal.