Plugin Development
From UBot Studio
Revision as of 21:24, 16 October 2012 by Edward Waller (Talk | contribs)
Contents |
Getting Started
Plugin Interfaces
IUBotCommand
You should implement this interface when creating a new command for your plugin.
public interface IUBotCommand { string CommandName { get; } string Category { get; } IEnumerable<UBotParameterDefinition> ParameterDefinitions { get; } void Execute(IUBotStudio ubotStudio, Dictionary<string, string> parameters); bool IsContainer { get; } }
IUBotFunction
public interface IUBotFunction { string FunctionName { get; } object ReturnValue { get; } UBotType ReturnValueType { get; } string Category { get; } IEnumerable<UBotParameterDefinition> ParameterDefinitions { get; } void Execute(IUBotStudio ubotStudio, Dictionary<string, string> parameters); }
IUBotStudio
public interface IUBotStudio { void RunScript(string script); void ChangeUserInterface(string name); IUBotCommand ContainerParent { get; set; } void RunContainerCommands(); void SetVariable(string variableName, string value); void SetList(string listName, List<string> value); void SetTable(string tableName, string[,] value); string GetVariable(string variableName); List<string> GetList(string listName); string[,] GetTable(string tableName); }
IEventEnabled
public interface IEventEnabled { void StartEventListener(); void StopEventListener(); }
IWizardEnabled
public interface IWizardEnabled { IWizard GenerateWizard(); }
IWizard
public interface IWizard { Window WizardWindow { get; } Dictionary<string, string> WizardValues { get; } }
UBotParameterDefinition
public class UBotParameterDefinition { public string Name { get; private set; } public UBotType Type { get; private set; } public IEnumerable<string> Options { get; set; } public object DefaultValue { get; set; } public UBotParameterDefinition(string name, UBotType type) { Name = name; Type = type; } }
UBotType
public enum UBotType { String, UBotVariable, UBotList, UBotTable }
Plugin Examples
Simple Commands and Functions
Error Alert Command (Command with One Parameter)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using UBotPlugin; using System.Windows; namespace SimpleCommands { /// <summary> /// This command is an example of a command with one parameter. It will show a MessageBox with an error icon. /// Parameters: The MessageBox text to use for your error. /// </summary> public class ErrorAlertCommand : IUBotCommand { // List to hold the parameters we define for our command. private List<UBotParameterDefinition> _parameters = new List<UBotParameterDefinition>(); public ErrorAlertCommand() { // Add our parameter (Alert Text) with a String type since it is text. _parameters.Add(new UBotParameterDefinition("Alert Text", UBotType.String)); } public string Category { // This is what category our command is categorized as. // If you choose something not already in the toolbox list, a new category will be created. get { return "Flow Commands"; } } public string CommandName { // The name of our node in UBot Studio. get { return "error alert"; } } public void Execute(IUBotStudio ubotStudio, Dictionary<string, string> parameters) { // Grab the value of the Alert Text parameter we defined. string value = parameters["Alert Text"]; // Display the MessageBox with an error icon and the text given. MessageBox.Show(value, "Error Alert", MessageBoxButton.OK, MessageBoxImage.Error); } public bool IsContainer { // This command does not have any nested commands inside of it, so it is not a container command. get { return false; } } public IEnumerable<UBotParameterDefinition> ParameterDefinitions { // We reference our parameter list we defined above here. get { return _parameters; } } } }