Description
|
Just like PlayOn Plugins, PlayOn Scripts may have user configurable options. These options are loaded and stored by PlayOn and are editable by the user through PlayOn Settings using the controls the script creates.
The Lua code to create the options controls relies on the functionality of LuaInterface to access .NET Framework System.Windows.Forms.
--[[Options
|
Global Objects and Methods
Example
--this will prompt our user to enter their Zipcode.
--[[Options
--Options_Properties is a NameValueCollection of strings where you can store all your
--options by name - notable methods are Get and Set
--Options_ChangeHandler is the delegate you must Invoke when your options change so the
--apply button can get enabled and they can get properly saved when clicked.
function txtZip_TextChanged(sender, eventArgs)
Options_Properties:Set("zipcode", txtZip.Text);
Options_ChangeHandler:Invoke(control, EventArgs());
end;
--load the assemblies
luanet.load_assembly "System.Windows.Forms"
luanet.load_assembly "System.Drawing"
--assign the objects (#include controls can supplant this)
NameValueCollection = luanet.import_type "System.Collections.Specialized.NameValueCollection"
UserControl = luanet.import_type "System.Windows.Forms.UserControl"
TextBox = luanet.import_type "System.Windows.Forms.TextBox"
Label = luanet.import_type "System.Windows.Forms.Label"
Point = luanet.import_type "System.Drawing.Point"
EventArgs = luanet.import_type "System.EventArgs"
--create the objects
control = UserControl();
txtZip = TextBox();
lblZip = Label();
lblZip.Text = "Enter your Zipcode:";
lblZip.Location = Point(8,8);
lblZip.Width = 280;
s = Options_Properties:Get("zipcode");
if not s or s == "" then s = "90210" end
txtZip.Text = s;
txtZip.Location = Point(8,28);
txtZip.Width = 280;
txtZip.TextChanged:Add(txtZip_TextChanged);
control.Controls:Add(txtZip);
control.Controls:Add(lblZip);
return control;
EndOptions]]--
|