Esempio n. 1
0
        private SortedDictionary <float, float> GetArgFileRegion(string argFileName)
        {
            float T2K = 273;

            if (string.IsNullOrEmpty(argFileName) || !File.Exists(argFileName))
            {
                return(null);
            }
            SortedDictionary <float, float> regionValues = new SortedDictionary <float, float>();

            string[] lines = File.ReadAllLines(argFileName, Encoding.Default);
            if (lines == null || lines.Length < 1)
            {
                return(null);
            }
            for (int i = 0; i < lines.Length; i++)
            {
                float[] minmax = ParseRegionToFloat(lines[i]);
                if (minmax == null || minmax.Length == 0)
                {
                    continue;
                }
                regionValues.Add(MathCompare.FloatCompare(minmax[0], float.MinValue) ? float.MinValue : (minmax[0] + T2K),
                                 MathCompare.FloatCompare(minmax[1], float.MaxValue) ? float.MaxValue : (minmax[1] + T2K));
            }
            return(regionValues);
        }
Esempio n. 2
0
        private bool CheckIsArg(string argLine, out string subItemStr)
        {
            subItemStr = argLine;
            if (string.IsNullOrEmpty(argLine))
            {
                return(false);
            }
            if (!argLine.Contains("~"))
            {
                return(false);
            }
            string[] parts = argLine.Split('~');
            if (parts == null || parts.Length != 2)
            {
                return(false);
            }
            float min, max;

            if (float.TryParse(parts[0], out min) && float.TryParse(parts[1], out max))
            {
                if (MathCompare.FloatCompare(min, float.MinValue))
                {
                    subItemStr = "最小" + '~' + parts[1];
                }
                else if (MathCompare.FloatCompare(max, float.MaxValue))
                {
                    subItemStr = parts[0] + '~' + "最大";
                }
                return(true);
            }
            return(false);
        }