예제 #1
0
 public void RemoveButton(FunctionButton button)
 {
     if (functionButtonPanel.Controls.Contains(button))
     {
         functionButtonPanel.Controls.Remove(button);
     }
 }
예제 #2
0
        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);
            }
        }
예제 #3
0
        // public FunctionPanel(string groupName)
        // {
        //      InitializeComponent();
        //  groupNameLabel.Text = groupName;
        //  }

        public void AddButton(FunctionButton button)
        {
            functionButtonPanel.Controls.Add(button);
        }