public static bool isDoubleCorrect(string str, out Color color, dMargin m = null)
 {
     Double dValue;
     color = cEmpty;
     if (string.IsNullOrEmpty(str)) return false;
     color = cErr;
     if (!Double.TryParse(str, out dValue)) return false;
     if (m != null) {
         color = cOutOfRange;
         if (!Double.IsNaN(m.Low) && (dValue < m.Low)) return false;
         if (!Double.IsNaN(m.High) && (dValue > m.High)) return false;
     }
     color = cNormal;
     return true;
 }
        private bool isInputCorrect()
        {
            LogClear();

            bool result = CheckItem(txbIronTemp, new dMargin(1100, 1500), out MixCalc.t_Iron, "IronTemp");
            dMargin streetTemp = new dMargin(-50, 50);

            result &= CheckItem(txbScrapTemp, streetTemp, out MixCalc.t_Scrap, "ScrapTemp");
            result &= CheckItem(txbSteelTemp, new dMargin(1600, 1800), out MixCalc.t_Steel, "SteelTemp");
            result &= CheckItem(txbIronTask, new dMargin(200, 400), out MixCalc.m_IronTask, "IronTask");
            MixCalc.s_CalcTask = MixCalc.CalcTask.CalcTaskIron;
            result &= CheckItem(txbBasiticy, new dMargin(1, 4), out MixCalc.basiticy, "Basiticy");
            if (txbLimeIn.Visible)
            {
                result &= CheckItem(txbLimeIn, new dMargin(0, 20000), out MixCalc.m_Lime, "LimeTask");
                MixCalc.m_Lime *= 0.001;
            }
            if (txbDolomIn.Visible)
            {
                result &= CheckItem(txbDolomIn, new dMargin(0, 20000), out MixCalc.m_DolomS, "DolmaxTask");
                MixCalc.m_DolomS *= 0.001;
            }
            if (txbFomIn.Visible)
            {
                result &= CheckItem(txbFomIn, new dMargin(0, 20000), out MixCalc.m_Fom, "FomTask");
                MixCalc.m_Fom *= 0.001;
            }
            if (txbLimeStoneIn.Visible)
            {
                result &= CheckItem(txbLimeStoneIn, new dMargin(0, 20000), out MixCalc.m_DolMax, "DolomSTask");
                MixCalc.m_DolMax *= 0.001;
            }
            MixCalc.calcPattern = 0;
            if (calcSelectedCount < 2)
            {
                foreach (var cle in calcList)
                {
                    cle.BackColor = (cle.CheckState == CheckState.Unchecked) ? Checker.cEmpty : SystemColors.Control;
                }
                result = false;
            }
            else
            {
                var cflag = 0x1000;
                for (int i = 0; i < calcList.Count; i++)
                {
                    var cle = calcList[i];
                    cle.BackColor = SystemColors.Control;
                    if (cle.CheckState == CheckState.Checked) MixCalc.calcPattern |= cflag;
                    cflag >>= 4;
                }
            }

            result &= CheckItem(txbCokeIn, new dMargin(0, 1000), out MixCalc.m_Coke, "CokeTask");
            MixCalc.m_Coke *= 0.001;
            result &= CheckItem(txbMgO, new dMargin(10, 40), out MixCalc.p_MgO, "PercentMgO");
            result &= CheckItem(txbFeO, new dMargin(10, 40), out MixCalc.p_FeO, "PercentFeO");
            if (!result)
            {
                LogStr(Checker.Message);
            }
            return result;
        }
 private bool CheckItem(TextBox txb, dMargin mrg, out double rv, String cfgKey)
 {
     var color = new Color();
     bool result = Checker.isDoubleCorrect(txb.Text, out color, mrg);
     rv = SetDoubleByKey(cfgKey, txb);
     txb.BackColor = color;
     return result;
 }