Difference between revisions of "A 'hello world' CS program"

From Ribbon Commander Documentation
Jump to: navigation, search
(Creating a tab)
Line 4: Line 4:
  
 
<syntaxhighlight lang="csharp" line>
 
<syntaxhighlight lang="csharp" line>
 +
// Namespaces of the two Dynamic RibbonX assemblies
 +
using LogismiX.Interop.DynamicRibbonX;
 +
using LogismiX.DynamicRibbonX.Core;
  
 +
namespace DynamicRibbonXAddin
 +
{
 +
 +
    class MyCustomUI
 +
    {
 +
        private rxCustomUI _customUI;
 +
 +
        public MyCustomUI()
 +
        {
 +
            // Instantiate a new rxCustomUI in a new context with id 'my_test_cs_ctx'
 +
            _customUI = rxCustomUI.create("my_test_cs_ctx", "Test C# Context");
 +
 +
            // Cache a reference to the custom UI's ribbon
 +
            rxRibbon myRibbon = _customUI.ribbon;
 +
 +
            // Create a new tab and label it 'My Tab'
 +
            rxTab myTab = new rxTab();
 +
            myTab.label = "My First Tab";
 +
 +
            // Add the tab to myRibbon's tabs
 +
            myRibbon.tabs.add(myTab);
 +
 +
            // Render the UI
 +
            _customUI.refresh();
 +
        }
 +
 +
    }
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 01:36, 15 March 2013

Creating a tab

  • Add a new class to your project and name it MyCustomUI.
  • Add the following code to your class
  1. // Namespaces of the two Dynamic RibbonX assemblies 
  2. using LogismiX.Interop.DynamicRibbonX;
  3. using LogismiX.DynamicRibbonX.Core;
  4.  
  5. namespace DynamicRibbonXAddin
  6. {
  7.  
  8.     class MyCustomUI
  9.     {
  10.         private rxCustomUI _customUI;
  11.  
  12.         public MyCustomUI()
  13.         {
  14.             // Instantiate a new rxCustomUI in a new context with id 'my_test_cs_ctx'
  15.             _customUI = rxCustomUI.create("my_test_cs_ctx", "Test C# Context");
  16.  
  17.             // Cache a reference to the custom UI's ribbon
  18.             rxRibbon myRibbon = _customUI.ribbon;
  19.  
  20.             // Create a new tab and label it 'My Tab'
  21.             rxTab myTab = new rxTab();
  22.             myTab.label = "My First Tab";
  23.  
  24.             // Add the tab to myRibbon's tabs
  25.             myRibbon.tabs.add(myTab);
  26.  
  27.             // Render the UI
  28.             _customUI.refresh();
  29.         }
  30.  
  31.     }
  32. }