private void CreateScriptFunctionForGUIItem(string eventHandler, object objectToCheck, PropertyInfo property)
{
string itemName;
int maxLength;
if (objectToCheck is GUI)
{
itemName = ((GUI)objectToCheck).Name;
maxLength = NormalGUI.MAX_EVENT_HANDLER_LENGTH;
}
else
{
itemName = ((GUIControl)objectToCheck).Name;
maxLength = GUIControl.MAX_EVENT_HANDLER_LENGTH;
}
if (string.IsNullOrEmpty(itemName))
{
Factory.GUIController.ShowMessage("You need to give this a name before you can create a script for it. Set the Name property in the properties grid to the right.", MessageBoxIcon.Warning);
return;
}
object[] paramsAttribute = property.GetCustomAttributes(typeof(ScriptFunctionParametersAttribute), true);
if (paramsAttribute.Length > 0)
{
property.SetValue(objectToCheck, ScriptFunctionUIEditor.CreateOrOpenScriptFunction(eventHandler, itemName, property.Name, (ScriptFunctionParametersAttribute)paramsAttribute[0], true, maxLength), null);
}
}