private void AddButton(string triggerName, string procName, SyncrFunctionType funcType) { if (flowLayoutPanel1.InvokeRequired) { SyncrUDPHost.FuncRegister d = new SyncrUDPHost.FuncRegister(AddButton); this.Invoke(d, new object[] { triggerName, procName, funcType }); } else { // Console.WriteLine("Adding button: " + triggerName); FunctionButton b = FunctionButtonFactory.CreateFunctionButton(funcType.type); if (b is FunctionButtonEnum) { b = new FunctionButtonEnum(funcType.enumChoices); } string func = triggerName; b.button.Text = func; b.button.Click += new EventHandler(delegate(Object o, EventArgs a) { if (runner.syncr.BoundFunctions.ContainsKey(func)) { runner.syncr.BoundFunctions[func](b.GetParameterValue()); } runner.BroadcastMessage(func + " " + b.GetParameterValue()); }); if (b.GetParameterControl() != null && funcType.type != SyncrParamType.STRING) { b.GetParameterControl().TextChanged += new EventHandler(delegate(Object o, EventArgs a) { if (runner.syncr.BoundFunctions.ContainsKey(func)) { runner.syncr.BoundFunctions[func](b.GetParameterValue()); } runner.BroadcastMessage(func + " " + b.GetParameterValue()); }); } if (!functionPanels.Keys.Contains(funcType.group)) { // Console.WriteLine("Adding button for " + procName); FunctionPanel newPanel = new FunctionPanel(funcType.group, procName, this); functionPanels.Add(funcType.group, newPanel); flowLayoutPanel1.Controls.Add(newPanel); } functionPanels[funcType.group].AddButton(b); //flowLayoutPanel1.Controls.Add(b); } }
private void RegisterFunction(ref string[] args) { string GroupName = args[1]; string procName = args[2]; string functionName = args[3]; SyncrFunctionType funcType = new SyncrFunctionType(SyncrParamType.VOID, g: GroupName); if (args.Length >= 5) { funcType.type = (SyncrParamType)Enum.Parse(typeof(SyncrParamType), args[4]); } if (funcType.type == SyncrParamType.INTERNAL) { return; } if (funcType.type == SyncrParamType.ENUM) { string[] tArr = new string[args.Length - 5]; for (int x = 5; x < args.Length; x++) { tArr[x - 5] = args[x]; } funcType.enumChoices = tArr; } if (!RegisteredFunctions.Contains(functionName)) { RegisteredFunctions.Add(functionName); OnRegisterFunction?.Invoke(functionName, procName, funcType); } }