The Ribbon SDK can also be used directly in Net. Callings can directly call their own .Net routines. A MapBasic wrapper is no longer necessary.
Example
This example shows:
the use of a user-defined .Net-AddIn
the calling of a .Net-method with MapBasic
the calling of a .Net-method directly in the AddIn
using System; using System.Windows; using GeoAS.RibbonSDK;
namespace DotNetHelloWorld { public class HelloWorldAddIn : Addin { public void HelloWorld() { MessageBox.Show(String.Format("Hello World."), "Hello World", MessageBoxButton.OK, MessageBoxImage.Information); } /// Captures the call function to call directly functionality of the AddIn public override bool HandleCommand(string functionName) { try { switch (functionName) { case "ShowHelloWorld": HelloWorld(); break; default: CallMapBasicSubroutine(functionName); break; } return true; } catch (NotImplementedException ex) { //Handle Exception here } return false; } } }
|
Include "MapBasic.def" Declare Sub Main Declare Sub ShowHelloWorldMbx Declare Sub EndHandler Declare Method New_HelloWorldSDK Class "DotNetHelloWorld.HelloWorldAddIn" Lib "DotNetHelloWorld.dll" Alias Ctor_CreateInstance() as This Declare Method Initialize Class "DotNetHelloWorld.HelloWorldAddIn" Lib "DotNetHelloWorld.dll" Alias Initialize(ByVal p1 as This, ByVal p2 as refptr, ByVal p3 as String) Declare Method Unload Class "DotNetHelloWorld.HelloWorldAddIn" Lib "DotNetHelloWorld.dll" Alias Unload(ByVal p1 as This) Declare Method HelloWorld Class "DotNetHelloWorld.HelloWorldAddIn" Lib "DotNetHelloWorld.dll" Alias HelloWorld(ByVal p1 as This) Declare Function AddIn_Name() As String Global myAddIn as This '************************************************************************************ Sub Main myAddIn = New_HelloWorldSDK () call Initialize(myAddIn, SYSTEMINFO(SYS_INFO_IMAPINFOAPPLICATION), ApplicationName$() ) End Sub '************************************************************************************ Sub EndHandler call Unload(myAddIn) End Sub '************************************************************************************ Function AddIn_Name() As String AddIn_Name = "DotNetHelloWorld" End Function '************************************************************************************ Sub ShowHelloWorldMbx note ("HelloWorld now called") call HelloWorld(myAddIn) End Sub |
Find the full sample code in your RibbonDesigner folder