User Tools

Site Tools


xide_plugin_system

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

xide_plugin_system [2018/01/26 05:05] (current)
wolfgangriedmann created
Line 1: Line 1:
 +====== The XIDE plugin system ======
 +
 +XIDE comes with a possibility to easily enhance it. [[xide_plugin_sample|Here]] you can find a complete sample (binaries and source) to use and maybe to enhance.
 +
 +The core of a plugin is to define a class that inherits from Xide.PluginSystem.Plugin and implements the ''​method Initialize()''​ and ''​propery Name''​. Initialize() passes you a PluginService object, with which you can communicate with XIDE. Type self:​oService:​ in the sample to get a list of available methods of this class.
 +After you have built your plugin dll, simply copy it in the plugin subdirectory of the XIDE directory, and it will be loaded on the next start of XIDE.
 +
 +And this is a sample code by Chris Pyrgas, the author of XIDE:
 +
 +<​code>​using Xide.PluginSystem
 +using System.Windows.Forms
 +
 +class TestPlugin inherit Xide.PluginSystem.Plugin
 +protect oService as PluginService
 +
 +virtual method Initialize(_oService as PluginService) as void
 +
 +  self:​oService := _oService
 +
 +  local oMenuItem as MenuItem
 +
 +  oMenuItem := MenuItem{"​Add some custom text" , PluginMenuItem_Edit_clicked }
 +  self:​oService:​RegisterMenuItem(MainMenuItem.Edit , oMenuItem)
 +
 +  oMenuItem := MenuItem{"​My Plugin"​ , PluginMenuItem_Window_clicked }
 +  self:​oService:​RegisterMenuItem(MainMenuItem.Window , oMenuItem)
 +
 +return
 +
 +method PluginMenuItem_Edit_clicked(o as object,e as EventArgs) as void
 +  local oFilePad as FilePad
 +  local oEditor as Editor
 +
 +  oFilePad := self:​oService:​GetActiveFilePad()
 +  if oFilePad == null
 +    return
 +  end if
 +  oEditor := oFilePad:​Editor
 +  oEditor:​AddLine(""​)
 +  oEditor:​AddLine(""​)
 +  oEditor:​AddLine("//​ This is some test entered from the plugin!"​)
 +  oEditor:​AddLine(""​)
 +  ​
 +  return
 +
 +method PluginMenuItem_Window_clicked(o as object,e as EventArgs) as void
 +  local oProject as Project
 +
 +  oProject := self:​oService:​ActiveProject
 +  if oProject == null
 +    return
 +  end if
 +  MessageBox.Show("​Applications in project " + oProject:​Name + " : " +   ​oProject:​GetApplications():​Length:​ToString() , "​Message from plugin!"​)
 +  return
 +
 +virtual property Name as string get "A test plugin"​
 +
 +end class</​code>​
  
xide_plugin_system.txt ยท Last modified: 2018/01/26 05:05 by wolfgangriedmann