Beispiel #1
0
        private SortedDictionary <float, float[]> GetArgFileRegion(string argFileName)
        {
            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]),
                                 new float[] { MathCompare.FloatCompare(minmax[1], float.MaxValue) ? float.MaxValue : (minmax[1]), minmax[2] });
            }
            return(regionValues);
        }
Beispiel #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(new char[] { '~', ' ' });
            if (parts == null || parts.Length != 3)
            {
                return(false);
            }
            float min, max, level;

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