Beispiel #1
0
        private void sendCommandToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Lese alle Textfelder nacheinander aus und bastle ein Paket zusammen
            Dictionary <string, string> Paket = new Dictionary <string, string>();
            //Ist überhaupt das command key word eingegeben???
            Boolean commandKeyWord = false;

            if (Server.udp_active() == true)
            {
                for (int i = 0; i < MessageTextboxName.Count; i++)
                {
                    TextBox NameBox  = MessageTextboxName[i];
                    TextBox ValueBox = MessageTextboxVariable[i];

                    if (NameBox.Text != "")
                    {
                        Paket.Add(NameBox.Text, ValueBox.Text);
                    }

                    if (NameBox.Text.ToLower() == "command")
                    {
                        commandKeyWord = true;
                    }
                }

                //Paket wird versendet
                if ((Paket.Count > 0) && (commandKeyWord == true))
                {
                    for (int i = 0; i < repeatUpDown.Value; i++)
                    {
                        statusBox1.print(i.ToString());
                        Server.SendCommand(Paket);
                        Thread.Yield();
                        Thread.Sleep(1);
                        Application.DoEvents();
                    }
                }
                else
                {
                    statusBox1.print("Command not send, because no data was entered or command key word is missing!");
                }
            }
        }