public override object GetValue(object component)
        {
            PropertyInfo interactionsProperty = component.GetType().GetProperty("Interactions");
            Interactions interactions         = (Interactions)interactionsProperty.GetValue(component, null);

            return(interactions.ScriptFunctionNames[_eventIndex]);
        }
        public override void SetValue(object component, object value)
        {
            PropertyInfo interactionsProperty = component.GetType().GetProperty("Interactions");
            Interactions interactions         = (Interactions)interactionsProperty.GetValue(component, null);

            interactions.ScriptFunctionNames[_eventIndex] = value.ToString();
        }
Ejemplo n.º 3
0
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object component, Attribute[] attrs)
        {
            List <PropertyDescriptor> propList = new List <PropertyDescriptor>();

            PropertyInfo interactionsProperty = component.GetType().GetProperty("Interactions");

            if (interactionsProperty != null)
            {
                Interactions interactions = (Interactions)interactionsProperty.GetValue(component, null);
                for (int i = 0; i < interactions.FunctionSuffixes.Length; i++)
                {
                    string eventName = interactions.DisplayNames[i];
                    if (UpdateEventName != null)
                    {
                        eventName = UpdateEventName(eventName);
                    }
                    if (eventName.IndexOf("$$") < 0)
                    {
                        // Only add the event if the cursor mode exists
                        propList.Add(new InteractionPropertyDescriptor(component, i, interactions.FunctionSuffixes[i], eventName));
                    }
                }
            }

            return(new PropertyDescriptorCollection(propList.ToArray()));
        }
Ejemplo n.º 4
0
        private static bool CreateScriptsForInteraction(string itemName, Script script, Interactions interactions, CompileMessages errors)
        {
            bool convertedSome = false;

            for (int i = 0; i < interactions.ImportedScripts.Length; i++)
            {
                if ((interactions.ImportedScripts[i] != null) &&
                    (interactions.ImportedScripts[i].Length > 0))
                {
                    if (interactions.ImportedScripts[i].IndexOf(SINGLE_RUN_SCRIPT_TAG) >= 0)
                    {
                        // just a single Run Script -- don't wrap it in an outer
                        // function since there's no need to
                        interactions.ScriptFunctionNames[i] = interactions.ImportedScripts[i].Replace(SINGLE_RUN_SCRIPT_TAG, string.Empty).Replace("();", string.Empty).Trim();
                        convertedSome = true;
                    }
                    else
                    {
                        string funcName = itemName + "_" + interactions.FunctionSuffixes[i];
                        string funcScriptLine = "function " + funcName + "()";
                        interactions.ScriptFunctionNames[i] = funcName;
                        if (script.Text.IndexOf(funcScriptLine) >= 0)
                        {
                            errors.Add(new CompileWarning("Function " + funcName + " already exists in script and could not be created"));
                        }
                        else
                        {
                            script.Text += Environment.NewLine + funcScriptLine + Environment.NewLine;
                            script.Text += "{" + Environment.NewLine + interactions.ImportedScripts[i] + "}" + Environment.NewLine;
                            convertedSome = true;
                        }
                    }
                    interactions.ImportedScripts[i] = null;
                }
            }

            return convertedSome;
        }
Ejemplo n.º 5
0
 static void SerializeInteractionScripts(Interactions interactions, BinaryWriter writer)
 {
     writer.Write(interactions.ScriptFunctionNames.Length);
     foreach (string funcName in interactions.ScriptFunctionNames)
     {
         if (funcName == null)
         {
             writer.Write((byte)0);
         }
         else
         {
             WriteString(funcName, funcName.Length, writer);
             writer.Write((byte)0);
         }
     }
 }