예제 #1
0
        //Functie ce actualizeaza proprietatile selectate ale punctului dintr-un segment text
        public bool ValuesFromString(string text, Format tip, DelimitedBy separator)
        {
            try
            {
                //Setarea separatorului folosit
                char sep;
                if (separator == DelimitedBy.Space)
                {
                    sep = ' ';
                }
                else
                {
                    sep = ',';
                }

                string[] segmente = text.Split(sep);

                //Actualizarea datelor
                switch (tip)
                {
                case Format.ENZ:
                    xPunct = double.Parse(segmente[0]);
                    yPunct = double.Parse(segmente[1]);
                    if (segmente.Length > 2)
                    {
                        zPunct = double.Parse(segmente[2]);
                    }
                    break;

                case Format.KmOZ:
                    kmPunct  = double.Parse(segmente[0].Replace("+", ""));
                    offPunct = double.Parse(segmente[1]);
                    if (segmente.Length > 2)
                    {
                        zPunct = double.Parse(segmente[2]);
                    }
                    break;

                case Format.KmOENZ:
                    kmPunct  = double.Parse(segmente[0].Replace("+", ""));
                    offPunct = double.Parse(segmente[1]);
                    xPunct   = double.Parse(segmente[2]);
                    yPunct   = double.Parse(segmente[3]);
                    if (segmente.Length > 4)
                    {
                        zPunct = double.Parse(segmente[4]);
                    }
                    break;
                }

                return(true);
            }

            catch
            {
                return(false);
            }
        }
예제 #2
0
 //Functie statica ce returneaza un Punct3D cu valori citite dintr-un segment text
 public static Punct3D StringToPoint(string text, Format tip, DelimitedBy separator)
 {
     try
     {
         Punct3D punct = new Punct3D();
         punct.ValuesFromString(text, tip, separator);
         return(punct);
     }
     catch
     {
         return(null);
     }
 }
예제 #3
0
        //Functie ce completeaza proprietatile selectate ale punctului intr-un segment text
        public string toString(Format tip, DelimitedBy separator, int Precision)
        {
            //Setarea separatorului folosit
            string sep;

            if (separator == DelimitedBy.Space)
            {
                sep = " ";
            }
            else
            {
                sep = ",";
            }

            //Convertirea valorilor in format text, cu precizia aleasa
            NumberFormatInfo nfi = new NumberFormatInfo();

            nfi.NumberDecimalDigits = Precision;
            string stringX      = xPunct.ToString("F", nfi);
            string stringY      = yPunct.ToString("F", nfi);
            string stringZ      = zPunct.ToString("F", nfi);
            string stringKM     = kmPunct.ToString("0+000.000", nfi);
            string stringOffset = offPunct.ToString("F", nfi);

            //string stringX = xPunct.ToString("F" + Precision);
            //string stringY = yPunct.ToString("F" + Precision);
            //string stringZ = zPunct.ToString("F" + Precision);
            //string stringKM = kmPunct.ToString("0+000.000");
            //string stringOffset = offPunct.ToString("F" + Precision);

            switch (tip)
            {
            case Format.ENZ:
                return(stringX + sep + stringY + sep + stringZ);

            //    break;
            case Format.KmOZ:
                return(stringKM + sep + stringOffset + sep + stringZ);

            //    break;
            case Format.KmOENZ:
                return(stringKM + sep + stringOffset + sep + stringX + sep + stringY + sep + stringZ);

            default:
                return(stringX + sep + stringY + sep + stringZ);
                //    break;
            }
        }
예제 #4
0
        //Functie ce completeaza proprietatile selectate ale punctului intr-un segment text
        public string toString(Format tip, DelimitedBy separator, int nrZecimale, bool formatKM)
        {
            //Setarea separatorului folosit
            string sep;

            if (separator == DelimitedBy.Space)
            {
                sep = " ";
            }
            else
            {
                sep = ",";
            }

            //Convertirea valorilor in format text, cu precizia aleasa
            NumberFormatInfo nfi = new NumberFormatInfo();

            nfi.NumberDecimalDigits = nrZecimale;
            string stringNr = nrPunct.ToString("F", nfi);
            string stringX  = xPunct.ToString("F", nfi);
            string stringY  = yPunct.ToString("F", nfi);
            string stringZ  = zPunct.ToString("F", nfi);
            string stringKM;

            if (formatKM)
            {
                stringKM = kmPunct.ToString("0+000." + "".PadRight(nrZecimale, '0'), nfi);
            }
            else
            {
                stringKM = kmPunct.ToString("F", nfi);
            }
            string stringOffset = offPunct.ToString("F", nfi);

            //string stringX = xPunct.ToString("F" + Precision);
            //string stringY = yPunct.ToString("F" + Precision);
            //string stringZ = zPunct.ToString("F" + Precision);
            //string stringKM = kmPunct.ToString("0+000.000");
            //string stringOffset = offPunct.ToString("F" + Precision);

            string stringProp = string.Empty;

            if (tip.ToString().Contains("Nr"))
            {
                stringProp += sep + stringNr;
            }
            if (tip.ToString().Contains("Km"))
            {
                stringProp += sep + stringKM;
            }
            if (tip.ToString().Contains("O"))
            {
                stringProp += sep + stringOffset;
            }
            if (tip.ToString().Contains("E"))
            {
                stringProp += sep + stringX;
            }
            if (tip.ToString().Contains("N"))
            {
                stringProp += sep + stringY;
            }
            if (tip.ToString().Contains("Z"))
            {
                stringProp += sep + stringZ;
            }
            if (tip.ToString().Contains("D"))
            {
                stringProp += sep + desPunct;
            }
            stringProp = stringProp.Substring(1);
            return(stringProp);

            //switch (tip)
            //{
            //    case Format.ENZ:
            //        return stringX + sep + stringY + sep + stringZ;
            //    //    break;
            //    case Format.KmOZ:
            //        return stringKM + sep + stringOffset + sep + stringZ;
            //    //    break;
            //    case Format.KmOENZ:
            //        return stringKM + sep + stringOffset + sep + stringX + sep + stringY + sep + stringZ;
            //    default:
            //        return stringX + sep + stringY + sep + stringZ;
            //    //    break;
            //}
        }