How to use a DropDownList in your Plugin
You have to create a new cs file in the same project (if your import from another it doesnt work)
In this cs file you create your public enum class like this and enumerate each option:
namespace OB2TestPlugin
{
public enum Calculator
{
Addition,
Soustraction,
Division,
Multiplication
}
}
Then in your Methods.cs your have to define a variable with the type you created before (the type will be Calculator here):
public static float Calcul(BotData data, float firstNumber, Calculator Operator, float secondNumber)
Then you can use “if” for each option for example.
public static float Calcul(BotData data, float firstNumber, Calculator Operator, float secondNumber)
{
float sum = 0;
var Op = Operator.ToString();
if (Op.Equals("Addition"))
{
sum = (firstNumber + secondNumber);
}
if (Op.Equals("Soustraction"))
{
sum = (firstNumber - secondNumber);
}
return sum;
}
You can also assign a number for each response so it can be more easy to handle, see more here: Types énumération-référence C# | Microsoft Docs
Simple Plugin Example Source code: OB2 Plugin DropDownList.zip (436.0 KB)
Hope the terms i used are correct