namespace UIWidgets
{
using System;
///
/// Button configuration.
///
/// Type of the sender.
public class ButtonConfiguration
{
///
/// Label.
///
public string Label;
Func actionSender;
///
/// Action with sender and button index.
///
public Func ActionSender
{
get
{
return actionSender;
}
set
{
actionSender = value;
}
}
Func action;
///
/// Action with button index.
///
public Func Action
{
get
{
return action;
}
set
{
action = value;
}
}
Func actionBool;
///
/// Action without button index.
/// Exists only to keep compatibility with previous versions.
///
[Obsolete("Replaced with Action.")]
public Func ActionBool
{
get
{
return actionBool;
}
set
{
actionBool = value;
}
}
///
/// Template index.
///
public int TemplateIndex;
///
/// Initializes a new instance of the class.
///
public ButtonConfiguration()
{
}
///
/// Initializes a new instance of the class.
///
/// Label.
/// Action on button click.
/// Button template index.
public ButtonConfiguration(string label, Func action, int templateIndex = 0)
{
Label = label;
ActionSender = action;
TemplateIndex = templateIndex;
}
///
/// Initializes a new instance of the class.
///
/// Label.
/// Action on button click.
/// Button template index.
[Obsolete("Type of \"action\" parameter changed to Func from Func")]
public ButtonConfiguration(string label, Func action, int templateIndex = 0)
{
Label = label;
Action = action;
TemplateIndex = templateIndex;
}
///
/// Initializes a new instance of the class.
/// Exists only to keep compatibility with previous versions.
///
/// Label.
/// Action on button click.
/// Button template index.
[Obsolete("Type of \"action\" parameter changed to Func from Func")]
public ButtonConfiguration(string label, Func action, int templateIndex = 0)
{
Label = label;
ActionBool = action;
TemplateIndex = templateIndex;
}
///
/// Process button click.
///
/// Sender.
/// Button index.
/// Action result; true if sender should be closed; otherwise false,
public bool Process(TSender sender, int index)
{
if (ActionSender != null)
{
return ActionSender(sender, index);
}
if (Action != null)
{
return Action(index);
}
#pragma warning disable 0618
return ActionBool();
#pragma warning restore 0618
}
}
}