Include "MapBasic.def" Declare Sub Main Declare Sub HelloWorld 'Ribbon SDK ************* Declare Sub EndHandler Declare Method New_RibbonSDK Class "GeoAS.RibbonSDK.Addin" Lib "GeoAS.RibbonSDK.dll" Alias Ctor_CreateInstance() as This Declare Method Initialize Class "GeoAS.RibbonSDK.Addin" Lib "GeoAS.RibbonSDK.dll" Alias Initialize(ByVal p1 as This, ByVal p2 as refptr, ByVal p3 as String) Declare Method Unload Class "GeoAS.RibbonSDK.Addin" Lib "GeoAS.RibbonSDK.dll" Alias Unload(ByVal p1 as This) Declare Function AddIn_Name() As String Global myAddIn as This '************************************************************************************ Sub Main myAddIn = New_RibbonSDK() call Initialize(myAddIn, SYSTEMINFO(SYS_INFO_IMAPINFOAPPLICATION), ApplicationName$() ) End Sub '************************************************************************************ Sub EndHandler call Unload(myAddIn) End Sub '************************************************************************************ Function AddIn_Name() As String AddIn_Name = "HelloWorld" End Function '************************************************************************************ Sub HelloWorld note "Hello World" End Sub
Include "MapBasic.def" Declare Sub Main Declare Sub ShowHelloWorldMbx 'Ribbon SDK ************* 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.NET:
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 HideOpen Declare Sub DisplayOpen 'Ribbon SDK ************* Declare Sub EndHandler Declare Method New_RibbonSDK Class "GeoAS.RibbonSDK.Addin" Lib "GeoAS.RibbonSDK.dll" Alias Ctor_CreateInstance() as This Declare Method AlterControl Class "GeoAS.RibbonSDK.Addin" Lib "GeoAS.RibbonSDK.dll" Alias AlterControl(byval xml as string) Declare Method Initialize Class "GeoAS.RibbonSDK.Addin" Lib "GeoAS.RibbonSDK.dll" Alias Initialize(ByVal p1 as This, ByVal p2 as refptr, ByVal p3 as String) Declare Method Unload Class "GeoAS.RibbonSDK.Addin" Lib "GeoAS.RibbonSDK.dll" Alias Unload(ByVal p1 as This) Declare Function AddIn_Name() As String Declare Function AddIn_Description() As String Declare Function AddIn_Version() As String Declare Function AddIn_ImageUri() As String Declare Sub AddIn_About Declare Sub AddIn_Help Global myAddIn as This '************************************************************************************ Sub Main myAddIn = New_RibbonSDK() call Initialize(myAddIn, SYSTEMINFO(SYS_INFO_IMAPINFOAPPLICATION), ApplicationName$() ) End Sub '------------------------------------------------------------------------------------ Sub EndHandler call Unload(myAddIn) End Sub '************************************************************************************ Function AddIn_Name() As String AddIn_Name = "DisplayHide" End Function '------------------------------------------------------------------------------------ Function AddIn_Description() As String AddIn_Description = "Example: Displays and hides the Open-Button in the Home-Tab" End Function '------------------------------------------------------------------------------------ 'Tooltip des Info-Buttons 'displayed only if AddIn_About also defined Function AddIn_Version() As String AddIn_Version = "Version 1.0" End Function '------------------------------------------------------------------------------------ Function AddIn_ImageUri() As String Dim app_dir As String app_dir = ApplicationDirectory$( ) AddIn_ImageUri = app_dir & "\Icon_AddIn.png" End Function '------------------------------------------------------------------------------------ 'Aktion des Info-Buttons Sub AddIn_About Note "Sample DisplayHide - Version 1.0" End Sub '------------------------------------------------------------------------------------ Sub AddIn_Help Note "Ribbon Sample Help" End Sub '************************************************************************************ Sub HideOpen call AlterControl("Name=""HideButton"" Enabled=""False""") call AlterControl("Name=""DisplayButton"" Enabled=""True""") call AlterControl("Name=""HomeFileOpenGallerySplitButton"" Visible=""False""") note "Open-Button hidden" End Sub '------------------------------------------------------------------------------------ Sub DisplayOpen call AlterControl("Name=""HideButton"" Enabled=""True""") call AlterControl("Name=""DisplayButton"" Enabled=""False""") call AlterControl("Name=""HomeFileOpenGallerySplitButton"" Visible=""True""") note "Open-Button displayed" End Sub
Include "MapBasic.def" Declare Sub Main Declare Sub OpenTable Declare Sub ShowHelp(ByVal helpId as String) 'Ribbon SDK ************* Declare Sub EndHandler Declare Method New_RibbonSDK Class "GeoAS.RibbonSDK.Addin" Lib "GeoAS.RibbonSDK.dll" Alias Ctor_CreateInstance() as This Declare Method AlterControl Class "GeoAS.RibbonSDK.Addin" Lib "GeoAS.RibbonSDK.dll" Alias AlterControl(byval xml as string) Declare Method Initialize Class "GeoAS.RibbonSDK.Addin" Lib "GeoAS.RibbonSDK.dll" Alias Initialize(ByVal p1 as This, ByVal p2 as refptr, ByVal p3 as String) Declare Method Unload Class "GeoAS.RibbonSDK.Addin" Lib "GeoAS.RibbonSDK.dll" Alias Unload(ByVal p1 as This) Declare Function AddIn_Name() As String Declare Function AddIn_Description() As String Declare Function AddIn_Version() As String Declare Function AddIn_ImageUri() As String Declare Sub AddIn_About Declare Sub AddIn_Help Global myAddIn as This '************************************************************************************ Sub Main myAddIn = New_RibbonSDK() call Initialize(myAddIn, SYSTEMINFO(SYS_INFO_IMAPINFOAPPLICATION), ApplicationName$() ) End Sub '------------------------------------------------------------------------------------ Sub EndHandler call Unload(myAddIn) End Sub '************************************************************************************ Function AddIn_Name() As String AddIn_Name = "OpenTableBySelection" End Function '------------------------------------------------------------------------------------ Function AddIn_Description() As String AddIn_Description = "Example to open the table containing the selected object in a browserwindow" End Function '------------------------------------------------------------------------------------ 'Tooltip des Info-Buttons 'Wird nur angezeigt, wenn auch AddIn_About definiert Function AddIn_Version() As String AddIn_Version = "Version 2.0" End Function '------------------------------------------------------------------------------------ Function AddIn_ImageUri() As String AddIn_ImageUri = "pack://application:,,,/MapInfo.StyleResources;component/images/application/opendatatable_16x16.png" End Function '------------------------------------------------------------------------------------ 'Aktion des Info-Buttons Sub AddIn_About Dim app_dir As String app_dir = ApplicationDirectory$( ) Dim helpcmd as String helpcmd = "notepad.exe " & app_dir & "\help.txt" Run Program helpcmd End Sub '------------------------------------------------------------------------------------ Sub AddIn_Help Note "Ribbon Sample Help" End Sub '************************************************************************************ Sub OpenTable dim tab as String tab = SelectionInfo( SEL_INFO_TABLENAME ) browse * from tab End Sub '------------------------------------------------------------------------------------ Sub ShowHelp(ByVal helpId as String) note helpId End Sub
Include "MapBasic.def" Declare Sub Main Declare Sub SendParameter(byval ID as integer, byval Comment as string) Declare Sub RunParameter(byval Commando as string) 'Ribbon SDK ************* Declare Sub EndHandler Declare Method New_RibbonSDK Class "GeoAS.RibbonSDK.Addin" Lib "GeoAS.RibbonSDK.dll" Alias Ctor_CreateInstance() as This Declare Method Initialize Class "GeoAS.RibbonSDK.Addin" Lib "GeoAS.RibbonSDK.dll" Alias Initialize(ByVal p1 as This, ByVal p2 as refptr, ByVal p3 as String) Declare Method Unload Class "GeoAS.RibbonSDK.Addin" Lib "GeoAS.RibbonSDK.dll" Alias Unload(ByVal p1 as This) Declare Function AddIn_Name() As String Global myAddIn as This '************************************************************************************ Sub Main myAddIn = New_RibbonSDK() call Initialize(myAddIn, SYSTEMINFO(SYS_INFO_IMAPINFOAPPLICATION), ApplicationName$() ) End Sub '************************************************************************************ Sub EndHandler call Unload(myAddIn) End Sub '************************************************************************************ Function AddIn_Name() As String AddIn_Name = "SendParameter" End Function '************************************************************************************ Sub SendParameter(byval ID as integer, byval Comment as string) note Comment + ID End Sub '************************************************************************************ Sub RunParameter(byval Commando as string) run command Commando End Sub