private static void checkAllMultiAlarmTempFields(TextBox tbA1Temp, TextBox tbA3Temp, TextBox tbA4Temp, TextBox tbA5Temp, TextBox tbA6Temp, PictureBox pbA1, PictureBox pbA2, PictureBox pbA4, PictureBox pbA5, PictureBox pbA6
                                                         , ToolTip wrongTip, SuperDevice Tag, string configUnit, CheckBox cbA6, CheckBox cbA5, CheckBox cbA1)
        {
            string pattern = "^[-+]?[0-9]+[/.]?[0-9]?$";

            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(pattern);

            if (cbA1.Checked)
            {
                if (!regex.IsMatch(tbA1Temp.Text))
                {
                    pbA1.Visible = true;
                    Common.SetToolTip(wrongTip, pbA1, Messages.TemperatureValueInvalid);
                }
                else
                {
                    pbA1.Visible = false;
                }
            }

            if (!regex.IsMatch(tbA3Temp.Text))
            {
                pbA2.Visible = true;
                Common.SetToolTip(wrongTip, pbA2, Messages.TemperatureValueInvalid);
            }
            else
            {
                pbA2.Visible = false;
            }

            if (!regex.IsMatch(tbA4Temp.Text))
            {
                pbA4.Visible = true;
                Common.SetToolTip(wrongTip, pbA4, Messages.TemperatureValueInvalid);
            }
            else
            {
                pbA4.Visible = false;
            }


            if (cbA5.Checked)
            {
                if (!regex.IsMatch(tbA5Temp.Text))
                {
                    pbA5.Visible = true;
                    Common.SetToolTip(wrongTip, pbA5, Messages.TemperatureValueInvalid);
                }
                else
                {
                    pbA5.Visible = false;
                }
            }


            if (cbA6.Checked)
            {
                if (!regex.IsMatch(tbA6Temp.Text))
                {
                    pbA6.Visible = true;
                    Common.SetToolTip(wrongTip, pbA6, Messages.TemperatureValueInvalid);
                }
                else
                {
                    pbA6.Visible = false;
                }
            }

            if (cbA6.Checked)
            {
                if (!regex.IsMatch(tbA6Temp.Text))
                {
                    pbA6.Visible = true;
                    Common.SetToolTip(wrongTip, pbA6, Messages.TemperatureValueInvalid);
                }
                else
                {
                    pbA6.Visible = false;
                }
            }


            if (cbA1.Checked && !pbA1.Visible)
            {
                ResultForCheckTempWhetherExceedDefinedRange result = ConnectionController.IsOverTemp(Tag.DeviceID, tbA1Temp.Text, configUnit);
                if (result == ResultForCheckTempWhetherExceedDefinedRange.TooHigh)
                {
                    pbA1.Visible = true;
                    Common.SetToolTip(wrongTip, pbA1, Messages.AlarmHighLimitInvalid);
                }
                else if (result == ResultForCheckTempWhetherExceedDefinedRange.TooLow)
                {
                    pbA1.Visible = true;
                    Common.SetToolTip(wrongTip, pbA1, Messages.AlarmLowLimitInvalid);
                }
                else
                {
                    // nothing
                }
            }

            if (!pbA2.Visible)
            {
                ResultForCheckTempWhetherExceedDefinedRange result = ConnectionController.IsOverTemp(Tag.DeviceID, tbA3Temp.Text, configUnit);
                if (result == ResultForCheckTempWhetherExceedDefinedRange.TooHigh)
                {
                    pbA2.Visible = true;
                    Common.SetToolTip(wrongTip, pbA2, Messages.AlarmHighLimitInvalid);
                }
                else if (result == ResultForCheckTempWhetherExceedDefinedRange.TooLow)
                {
                    pbA2.Visible = true;
                    Common.SetToolTip(wrongTip, pbA2, Messages.AlarmLowLimitInvalid);
                }
                else
                {
                    // nothing
                }
            }


            if (!pbA4.Visible)
            {
                ResultForCheckTempWhetherExceedDefinedRange result = ConnectionController.IsOverTemp(Tag.DeviceID, tbA4Temp.Text, configUnit);
                if (result == ResultForCheckTempWhetherExceedDefinedRange.TooHigh)
                {
                    pbA4.Visible = true;
                    Common.SetToolTip(wrongTip, pbA4, Messages.AlarmHighLimitInvalid);
                }
                else if (result == ResultForCheckTempWhetherExceedDefinedRange.TooLow)
                {
                    pbA4.Visible = true;
                    Common.SetToolTip(wrongTip, pbA4, Messages.AlarmLowLimitInvalid);
                }
                else
                {
                    // nothing
                }
            }


            if (cbA5.Checked && !pbA5.Visible)
            {
                ResultForCheckTempWhetherExceedDefinedRange result = ConnectionController.IsOverTemp(Tag.DeviceID, tbA5Temp.Text, configUnit);
                if (result == ResultForCheckTempWhetherExceedDefinedRange.TooHigh)
                {
                    pbA5.Visible = true;
                    Common.SetToolTip(wrongTip, pbA5, Messages.AlarmHighLimitInvalid);
                }
                else if (result == ResultForCheckTempWhetherExceedDefinedRange.TooLow)
                {
                    pbA5.Visible = true;
                    Common.SetToolTip(wrongTip, pbA5, Messages.AlarmLowLimitInvalid);
                }
                else
                {
                    // nothing
                }
            }

            if (cbA6.Checked && !pbA6.Visible)
            {
                ResultForCheckTempWhetherExceedDefinedRange result = ConnectionController.IsOverTemp(Tag.DeviceID, tbA6Temp.Text, configUnit);
                if (result == ResultForCheckTempWhetherExceedDefinedRange.TooHigh)
                {
                    pbA6.Visible = true;
                    Common.SetToolTip(wrongTip, pbA6, Messages.AlarmHighLimitInvalid);
                }
                else if (result == ResultForCheckTempWhetherExceedDefinedRange.TooLow)
                {
                    pbA6.Visible = true;
                    Common.SetToolTip(wrongTip, pbA6, Messages.AlarmLowLimitInvalid);
                }
                else
                {
                    // nothing
                }
            }

            if (cbA1.Checked && !pbA1.Visible)
            {
                if (!pbA2.Visible && !string.IsNullOrEmpty(tbA1Temp.Text) && !string.IsNullOrEmpty(tbA3Temp.Text) &&
                    Convert.ToDouble(tbA1Temp.Text) >= Convert.ToDouble(tbA3Temp.Text))
                {
                    pbA1.Visible = true;
                    pbA2.Visible = true;
                    Common.SetToolTip(wrongTip, pbA1, string.Format("A{0} >= A{1}: {2}", "5", "4", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA2, string.Format("A{0} >= A{1}: {2}", "5", "4", Messages.HighLimitMoreThanLowLimit));
                }
                else if (!pbA4.Visible && !string.IsNullOrEmpty(tbA4Temp.Text) && Convert.ToDouble(tbA1Temp.Text) >= Convert.ToDouble(tbA4Temp.Text))
                {
                    pbA1.Visible = true;
                    pbA4.Visible = true;
                    Common.SetToolTip(wrongTip, pbA1, "Alarm limit over A3");
                    Common.SetToolTip(wrongTip, pbA1, string.Format("A{0} >= A{1}: {2}", "5", "3", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA4, string.Format("A{0} >= A{1}: {2}", "5", "3", Messages.HighLimitMoreThanLowLimit));
                }
                else if (!pbA5.Visible && cbA5.Checked && !string.IsNullOrEmpty(tbA5Temp.Text) && Convert.ToDouble(tbA1Temp.Text) >= Convert.ToDouble(tbA5Temp.Text))
                {
                    pbA1.Visible = true;
                    pbA5.Visible = true;
                    Common.SetToolTip(wrongTip, pbA1, "Alarm limit over A2");
                    Common.SetToolTip(wrongTip, pbA1, string.Format("A{0} >= A{1}: {2}", "5", "2", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA5, string.Format("A{0} >= A{1}: {2}", "5", "2", Messages.HighLimitMoreThanLowLimit));
                }
                else if (!pbA6.Visible && cbA6.Checked && !string.IsNullOrEmpty(tbA6Temp.Text) && Convert.ToDouble(tbA1Temp.Text) >= Convert.ToDouble(tbA6Temp.Text))
                {
                    pbA1.Visible = true;
                    pbA6.Visible = true;
                    Common.SetToolTip(wrongTip, pbA1, "Alarm limit over A1");
                    Common.SetToolTip(wrongTip, pbA1, string.Format("A{0} >= A{1}: {2}", "5", "1", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA6, string.Format("A{0} >= A{1}: {2}", "5", "1", Messages.HighLimitMoreThanLowLimit));
                }
            }

            if (!pbA2.Visible)
            {
                if (!pbA4.Visible && !string.IsNullOrEmpty(tbA5Temp.Text) && Convert.ToDouble(tbA3Temp.Text) >= Convert.ToDouble(tbA4Temp.Text))
                {
                    pbA2.Visible = true;
                    pbA4.Visible = true;
                    Common.SetToolTip(wrongTip, pbA2, "Alarm limit over A3");
                    Common.SetToolTip(wrongTip, pbA2, string.Format("A{0} >= A{1}: {2}", "4", "3", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA4, string.Format("A{0} >= A{1}: {2}", "4", "3", Messages.HighLimitMoreThanLowLimit));
                }
                else if (!pbA5.Visible && cbA5.Checked && !string.IsNullOrEmpty(tbA5Temp.Text) && Convert.ToDouble(tbA3Temp.Text) >= Convert.ToDouble(tbA5Temp.Text))
                {
                    pbA2.Visible = true;
                    pbA5.Visible = true;
                    Common.SetToolTip(wrongTip, pbA2, "Alarm limit over A2");
                    Common.SetToolTip(wrongTip, pbA2, string.Format("A{0} >= A{1}: {2}", "4", "2", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA5, string.Format("A{0} >= A{1}: {2}", "4", "2", Messages.HighLimitMoreThanLowLimit));
                }
                else if (!pbA6.Visible && cbA6.Checked && !string.IsNullOrEmpty(tbA6Temp.Text) && Convert.ToDouble(tbA3Temp.Text) >= Convert.ToDouble(tbA6Temp.Text))
                {
                    pbA2.Visible = true;
                    pbA6.Visible = true;
                    Common.SetToolTip(wrongTip, pbA2, "Alarm limit over A1");
                    Common.SetToolTip(wrongTip, pbA2, string.Format("A{0} >= A{1}: {2}", "4", "1", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA6, string.Format("A{0} >= A{1}: {2}", "4", "1", Messages.HighLimitMoreThanLowLimit));
                }
            }

            if (!pbA4.Visible)
            {
                if (!pbA5.Visible && cbA5.Checked && !string.IsNullOrEmpty(tbA5Temp.Text) && Convert.ToDouble(tbA4Temp.Text) >= Convert.ToDouble(tbA5Temp.Text))
                {
                    pbA4.Visible = true;
                    pbA5.Visible = true;
                    Common.SetToolTip(wrongTip, pbA4, "Alarm limit over A2");
                    Common.SetToolTip(wrongTip, pbA4, string.Format("A{0} >= A{1}: {2}", "3", "2", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA5, string.Format("A{0} >= A{1}: {2}", "3", "2", Messages.HighLimitMoreThanLowLimit));
                }
                else if (!pbA6.Visible && cbA6.Checked && !string.IsNullOrEmpty(tbA6Temp.Text) && Convert.ToDouble(tbA4Temp.Text) >= Convert.ToDouble(tbA6Temp.Text))
                {
                    pbA4.Visible = true;
                    pbA6.Visible = true;
                    Common.SetToolTip(wrongTip, pbA4, "Alarm limit over A1");
                    Common.SetToolTip(wrongTip, pbA4, string.Format("A{0} >= A{1}: {2}", "3", "1", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA6, string.Format("A{0} >= A{1}: {2}", "3", "1", Messages.HighLimitMoreThanLowLimit));
                }
            }

            if (cbA5.Checked && !pbA5.Visible)
            {
                if (!pbA6.Visible && cbA6.Checked && !string.IsNullOrEmpty(tbA6Temp.Text) && Convert.ToDouble(tbA5Temp.Text) >= Convert.ToDouble(tbA6Temp.Text))
                {
                    pbA5.Visible = true;
                    pbA6.Visible = true;
                    Common.SetToolTip(wrongTip, pbA5, "Alarm limit below A1");
                    Common.SetToolTip(wrongTip, pbA5, string.Format("A{0} >= A{1}: {2}", "2", "1", Messages.HighLimitMoreThanLowLimit));
                    Common.SetToolTip(wrongTip, pbA6, string.Format("A{0} >= A{1}: {2}", "2", "1", Messages.HighLimitMoreThanLowLimit));
                }
            }
        }
        private static void checkAllSingleAlarmTempFields(TextBox tbHigh, TextBox tbLow, PictureBox pbHigh, PictureBox pbLow, ToolTip wrongTip, SuperDevice Tag, string configUnit, CheckBox cbHigh, CheckBox cbLow)
        {
            string pattern = "^[-+]?[0-9]+[/.]?[0-9]?$";

            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(pattern);
            if (cbHigh.Checked)
            {
                if (!regex.IsMatch(tbHigh.Text))
                {
                    pbHigh.Visible = true;
                    Common.SetToolTip(wrongTip, pbHigh, Messages.TemperatureValueInvalid);
                }
                else
                {
                    pbHigh.Visible = false;
                }
            }

            if (cbLow.Checked)
            {
                if (!regex.IsMatch(tbLow.Text))
                {
                    pbLow.Visible = true;
                    Common.SetToolTip(wrongTip, pbLow, Messages.TemperatureValueInvalid);
                }
                else
                {
                    pbLow.Visible = false;
                }
            }

            if (cbHigh.Checked && !pbHigh.Visible)
            {
                ResultForCheckTempWhetherExceedDefinedRange result = ConnectionController.IsOverTemp(Tag.DeviceID, tbHigh.Text, configUnit);
                if (result == ResultForCheckTempWhetherExceedDefinedRange.TooHigh)
                {
                    pbHigh.Visible = true;
                    Common.SetToolTip(wrongTip, pbHigh, Messages.AlarmHighLimitInvalid);
                }
                else if (result == ResultForCheckTempWhetherExceedDefinedRange.TooLow)
                {
                    pbHigh.Visible = true;
                    Common.SetToolTip(wrongTip, pbHigh, Messages.AlarmLowLimitInvalid);
                }
                else
                {
                    // nothing
                }
            }

            if (cbLow.Checked && !pbLow.Visible)
            {
                ResultForCheckTempWhetherExceedDefinedRange result = ConnectionController.IsOverTemp(Tag.DeviceID, tbLow.Text, configUnit);
                if (result == ResultForCheckTempWhetherExceedDefinedRange.TooHigh)
                {
                    pbLow.Visible = true;
                    Common.SetToolTip(wrongTip, pbLow, Messages.AlarmHighLimitInvalid);
                }
                else if (result == ResultForCheckTempWhetherExceedDefinedRange.TooLow)
                {
                    pbLow.Visible = true;
                    Common.SetToolTip(wrongTip, pbLow, Messages.AlarmLowLimitInvalid);
                }
                else
                {
                    // nothing
                }
            }

            if (cbHigh.Checked && cbLow.Checked && !pbHigh.Visible && !pbLow.Visible)
            {
                if (!string.IsNullOrEmpty(tbHigh.Text) && Convert.ToDouble(tbLow.Text) >= Convert.ToDouble(tbHigh.Text))
                {
                    pbHigh.Visible = true;
                    pbLow.Visible  = true;
                    Common.SetToolTip(wrongTip, pbLow, Messages.HighLimitMoreThanLowLimit);
                    Common.SetToolTip(wrongTip, pbHigh, Messages.HighLimitMoreThanLowLimit);
                }
            }
        }