Ejemplo n.º 1
0
        public void Interprete(string[] filetext)
        {
            UsedCulture = new CultureInfo("da-DK");
            string firstline = filetext[0].Trim();

            string[] metadata = firstline.Split('\t');
            YUnit = metadata[2];
            Count = filetext.Length - 1;
            X     = new DateTime[Count];
            Y     = new double[Count];

            string[] currentline;
            for (int i = 1; i < filetext.Length; i++)
            {
                currentline = filetext[i].Split('\t');
                string datetime = currentline[0].Trim().Replace('.', '/') + " " +
                                  currentline[1].Trim().Replace('.', ':');
                X[i - 1] = DateTime.Parse(datetime);
                Y[i - 1] = float.Parse(currentline[2].Trim());
                Note     = currentline[4];
            }

            Total = 0.0;
            foreach (double d in Y)
            {
                Total += d;
            }

            MinX = X[0];
            MaxX = X[Count - 1];

            MinY = Y[0];
            MaxY = Y[0];
            foreach (double f in Y)
            {
                if (f < MinY)
                {
                    MinY = f;
                }
                if (MaxY < f)
                {
                    MaxY = f;
                }
            }

            string newPathFormat;

            (XFormat, newPathFormat) = NumberFormatter.DefineDateTimeFormat(X);
            YFormat     = NumberFormatter.DefineFloatFormat(Y);
            XUnit       = "Dato/tid";
            Note        = metadata[4] + ": " + Note;
            NewFileName = NumberFormatter.DefineFilename(MinX, MaxX);
            NewFilepath = MinX.ToString(newPathFormat);
        }