Ejemplo n.º 1
0
            private SDGPSData parseNO298ECmd(byte[] buffer, int start, out int cmdLen)
            {
                SDGPSData result = new SDGPSData();

                cmdLen = buffer[start + 4] + 5;
                try
                {
                    string   ip;
                    DateTime dt;
                    double   Lat, Lon;

                    start          += 5;
                    start          += ParseField.ParseFieldIP(buffer, start, out ip);
                    start          += ParseField.ParseFieldTime(buffer, start, out dt);
                    start          += ParseField.ParseFieldLat(buffer, start, out Lat);
                    start          += ParseField.ParseFieldLon(buffer, start, out Lon);
                    start          += ParseField.ParseFieldSpeed(buffer, start, out result.SOG);
                    start          += ParseField.ParseFieldAngle(buffer, start, out result.COG);
                    start          += ParseField.ParseFieldPosition(buffer, start, out result.Position);
                    result.Name     = getNameByIP(ip);
                    result.Id       = ip.Replace('.', '-');
                    result.Src      = "";
                    result.Time     = dt;
                    result.Shape    = new GeoPointShape(Lon, Lat);
                    result.Distance = 0;
                    return(result);
                }
                catch (Exception)
                {
                    return(null);
                }
            }
Ejemplo n.º 2
0
 public MenuField(Vector2i componentSize, Font font, ParseField parseField)
 {
     Initialize(componentSize);
     textField = new MenuText(new Vector2i(size.X, size.Y), font, "", Convert.ToUInt32(size.Y - 4), size.Y);
     textField.SetTextPosition("left", "center");
     textField.SetPivots("center", "center", "inside", 2);
     this.parseField = parseField;
     fieldState      = FieldState.Normal;
     collisionBox    = new BoundingBox(size);
     fieldBackGround = CreateMenuGraphicArrayWithBorder(new FloatRect(96, 0, 96, 96), 10);
     cursor          = new RectangleShape(new Vector2f(1, textField.charSize - 4));
     cursorCounter   = 0;
     cursorRefresh   = 30;
 }
Ejemplo n.º 3
0
        public static bool TryParse(string input, IFormatProvider provider, out IsoDuration result, out string errorMessage)
        {
            errorMessage = null;
            var  match   = IsoRegex.Match(input);
            bool success = match.Success;

            if (success)
            {
                var duration = new IsoDuration();

                bool negative = match.Groups[1].Success;
                duration.IsNegative = negative;

                var parser = new ParseField()
                {
                    IsNegative = negative
                };
                if (errorMessage == null)
                {
                    parser.TryParse(match.Groups[2].Value, provider, x => { duration.Years = x; }, out errorMessage);
                }
                if (errorMessage == null)
                {
                    parser.TryParse(match.Groups[3].Value, provider, x => { duration.Months = x; }, out errorMessage);
                }
                if (errorMessage == null)
                {
                    parser.TryParse(match.Groups[4].Value, provider, x => { duration.Weeks = x; }, out errorMessage);
                }
                if (errorMessage == null)
                {
                    parser.TryParse(match.Groups[5].Value, provider, x => { duration.Days = x; }, out errorMessage);
                }
                if (errorMessage == null)
                {
                    parser.TryParse(match.Groups[6].Value, provider, x => { duration.Hours = x; }, out errorMessage);
                }
                if (errorMessage == null)
                {
                    parser.TryParse(match.Groups[7].Value, provider, x => { duration.Minutes = x; }, out errorMessage);
                }
                if (errorMessage == null)
                {
                    parser.TryParse(match.Groups[8].Value, provider, x => { duration.Seconds = x; }, out errorMessage);
                }
                if (errorMessage == null)
                {
                    result  = duration;
                    success = true;
                }
                else
                {
                    result  = default(IsoDuration);
                    success = false;
                }
            }
            else
            {
                result = default(IsoDuration);
            }
            return(success);
        }