Adding it as a button in the top bar is the far most easiest since its just a matter of creating a ActionProvider which adds extra buttons to IPageElements in the tree. You can see here an example of how its done
https://bitbucket.org/burningice/compositec1contrib/src/b645449e2dd89c7881c768b38192e191f50fb92a/Sorting/SortableActionProvider.cs?at=default#cl-91
Creating actions that just executes some code is pretty easy, there is some examples here
https://bitbucket.org/burningice/compositec1contrib.formbuilder/src/bbee75568b4575a8183090440271dbfd397ca217/FormBuilder.Dynamic/C1Console/Actions/DeleteFormActionToken.cs?at=default
https://bitbucket.org/burningice/compositec1contrib/src/b645449e2dd89c7881c768b38192e191f50fb92a/Sorting/SortableActionProvider.cs?at=default#cl-91
Creating actions that just executes some code is pretty easy, there is some examples here
https://bitbucket.org/burningice/compositec1contrib.formbuilder/src/bbee75568b4575a8183090440271dbfd397ca217/FormBuilder.Dynamic/C1Console/Actions/DeleteFormActionToken.cs?at=default