Click or drag to resize

Plugins & API Documentation

You can code your own plugins for GoManga MathStudio. Plugins can be easly installed by putting them in the "Plugin" subdirectory of the main directory of MathStudio (C:\GoManga\MathStudio). Console plugins can be called by using their commands in code or in the Console Command. Editor plugins can be called by the menu under the "Plugins" menu in the Editor.

Plugin project setup

To start coding your plugin for GoManga MathStudio, you first need a .Net IDE, such as Visual Studio or Mono . Create a new project in any dotNet language and import the "MathStudio.Core.dll", "MathStudio.Core.Math.dll" and "MathStudio.Core.Plotter.dll" as references (the libraries are located in the MathStudio main directory). The other libraries are optional.

Getting Started

You need to add the default class which represents the starting point of your plugin. So you need to implement the "MathStudio.Core.Plugin" interface. The interface requires the following fields:

  • Name (Field - System.String - ReadOnly): The name of your plugin;

  • Description (Field - System.String - ReadOnly): The description of your plugin;

  • Version (Field - System.String - ReadOnly): The current version of your plugin;

  • Author (Field - System.String - ReadOnly): Your name or organization;

  • Version (Field - System.String - ReadOnly): The current version of your plugin;

  • ExecutableInEditor (Field - System.Boolean - ReadOnly): Set true if your plugin has a graphic interface and it's executable in the editor;

  • ExecutableInConsole (Field - System.Boolean - ReadOnly): Set true if your plugin is executable by console command (and you want to use your command in the console);

  • CommandList (Field - System.String[] - ReadOnly): The list of the available command of your plugin (only if executable by console command);

  • Help (string cmd) (Function - System.String): The function that parses the help command (only if executable by console command);

  • Execute (string cmd) (Function - System.String): The function that parses the commands (only if executable by console command). Must return a result as string;

  • ExecuteInEditor (object sender, EventArgs e) (Event - Void): The function that is called when the user press the button in the MathStudio IDE.

Plugins Examples

This are two implementations of the "MathStudio.Core.Plugin" interface in VisualBasic.Net and C#.Net.

C# - Sumf function. The plugin adds the sumf function as console command. You can use in your code with the sumf {a} {b}. The return is equal to calc {a}+{b}

Sum.cs
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MathStudio.Core.Math;
using MathStudio.Core;

namespace MathStudio.Plugins
{
    public partial class Summation : Plugin
    {
        public string Name { get { return "Simple Addition"; } }
        public string Description { get { return "Calculates the sum of input numbers"; } }
        public string Version { get { return "1.0.0.0"; } }
        public string Author { get { return "Francesco Pio Squillante"; } }

        public string[] CommandsList { get { return new string[] { "sumf" }; } }

        public bool ExecutableInEditor { get { return false; } }
        public bool ExecutableInConsole { get { return true; } }

        public string Help(string cmd)
        {
            if (cmd.StartsWith("sumf"))
            {
                string help = "";
                help = "\nsumf\t- Calculates the sum of input numbers";
                help += "\n";
                help += "\nUsage: sumf a b";
                help += "\nIn this way the calculation will return the sum between a and b";
                return help;
            }
            return "Command \"" + cmd + "\" not recognized. Type \"help\" to list all available commands in the plugin";
        }
        public string Execute(string cmd)
        {
            if (cmd.StartsWith("sumf"))
            {
                cmd = cmd.Replace("sumf", "");
                cmd = cmd.Trim();
                cmd = cmd.Replace(" ", "+");
                return Console.Calculate(cmd);
            }
            return "Command \"" + cmd + "\" not recognized. Type \"help\" to list all available commands in the plugin";
        }

        public void ExecuteInEditor(object sender, System.EventArgs e)
        {
            throw new System.NotImplementedException();
        }
    }
}

VB - Calc in GUI. The plugin adds an editor window that allows you to solve mathematical expressions (like using the calc function)

ExpressionCalc.vb
Imports MathStudio.Core

Public Class ExpressionCalc : Implements Plugin

    Public ReadOnly Property Name As String Implements Plugin.Name
        Get
            Return "Simple Expression Calculator"
        End Get
    End Property

    Public ReadOnly Property Description As String Implements Plugin.Description
        Get
            Return "Implements MathStudio.Core.Math in UI"
        End Get
    End Property

    Public ReadOnly Property Version As String Implements Plugin.Version
        Get
            Return "1.0.0.0"
        End Get
    End Property

    Public ReadOnly Property Author As String Implements Plugin.Author
        Get
            Return "Francesco Pio Squillante"
        End Get
    End Property

    Public ReadOnly Property ExecutableInEditor As Boolean Implements Plugin.ExecutableInEditor
        Get
            Return True
        End Get
    End Property

    Public ReadOnly Property ExecutableInConsole As Boolean Implements Plugin.ExecutableInConsole
        Get
            Return False
        End Get
    End Property

    Public ReadOnly Property CommandsList As String() Implements Plugin.CommandsList
        Get
            Return New String() {""}
        End Get
    End Property

    Public Sub ExecuteInEditor(sender As Object, e As EventArgs) Implements Plugin.ExecuteInEditor
        Dim form1 As Form1 = New Form1()
        form1.Show()
    End Sub

    Public Function Help(cmd As String) As String Implements Plugin.Help
        Return ""
    End Function

    Public Function Execute(cmd As String) As String Implements Plugin.Execute
        Throw New NotImplementedException()
    End Function
End Class
Form1.Designer.vb
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form

    <System.Diagnostics.DebuggerNonUserCode()>
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    Private components As System.ComponentModel.IContainer

    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.TextBox1 = New System.Windows.Forms.TextBox()
        Me.TextBox2 = New System.Windows.Forms.TextBox()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(301, 75)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(75, 23)
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "Calculate"
        Me.Button1.UseVisualStyleBackColor = True
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(54, 12)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(322, 20)
        Me.TextBox1.TabIndex = 1
        '
        'TextBox2
        '
        Me.TextBox2.Enabled = False
        Me.TextBox2.Location = New System.Drawing.Point(54, 38)
        Me.TextBox2.Name = "TextBox2"
        Me.TextBox2.Size = New System.Drawing.Size(322, 20)
        Me.TextBox2.TabIndex = 2
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(9, 15)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(34, 13)
        Me.Label1.TabIndex = 3
        Me.Label1.Text = "Input:"
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Location = New System.Drawing.Point(8, 41)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(40, 13)
        Me.Label2.TabIndex = 4
        Me.Label2.Text = "Result:"
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(388, 110)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.TextBox2)
        Me.Controls.Add(Me.TextBox1)
        Me.Controls.Add(Me.Button1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "Form1"
        Me.ShowIcon = False
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Simple Expression Calculator"
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

    Friend WithEvents Button1 As Button
    Friend WithEvents TextBox1 As TextBox
    Friend WithEvents TextBox2 As TextBox
    Friend WithEvents Label1 As Label
    Friend WithEvents Label2 As Label
End Class
Form1.vb
Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        MathStudio.Core.Console.verbose = False

        TextBox2.Text = MathStudio.Core.Console.Calculate(TextBox1.Text)
    End Sub
End Class