private void ClickEventForNewButton(object sender, EventArgs e)
        {
            Button        senderButton = sender as Button;
            ControlObject parentObject = new ControlObject();

            // Get parent object.
            foreach (ControlObject c in mainFM.AllObjects)
            {
                if (c.rootObject.Name == senderButton.Name)
                {
                    parentObject = c;
                }
            }

            switch ((Int32)senderButton.Tag)
            {
            case (Int32)ButtonActionIndex.SendSerial:
            {
                string text = "";
                // Select where the serial message shall come from.
                switch (parentObject.local_buttonAction.messageSourceIndex)
                {
                case (Int32)SendOnClickMessageSourceIndex.HardSetMessage:
                {
                    text = parentObject.local_buttonAction.serialMessageToSend;
                    break;
                }

                case (Int32)SendOnClickMessageSourceIndex.FromComboBox:
                case (Int32)SendOnClickMessageSourceIndex.FromTextBox:
                {
                    text = parentObject.local_buttonAction.sourceObject.rootObject.Text;

                    break;
                }
                }

                Serial_functions.SendCommand(text);
                break;
            }

            case (Int32)ButtonActionIndex.OpenClosePort:
            {
                Serial_functions.OpenClosePort();
                break;
            }

            case (Int32)ButtonActionIndex.ShowHideObject:
            {
                bool current = parentObject.local_buttonAction.targetObject.rootObject.Visible;

                parentObject.local_buttonAction.targetObject.rootObject.Visible = !current;

                break;
            }
            }
        }
        public void ExecuteSendOperation(string serialAnswer)
        {
            switch (serial.sendIdx)
            {
            case SendOperationIndex.Always:
            {
                Serial_functions.SendCommand(serial.answer);
                break;
            }

            case SendOperationIndex.YesNo:
            {
                if (KeywordCheck(serialAnswer) == FunctionResultIndex.ResultYes)
                {
                    Serial_functions.SendCommand(serial.answerPos);
                }
                else
                {
                    Serial_functions.SendCommand(serial.answerNeg);
                }
                break;
            }
            }
        }