Пример #1
0
        internal static List <Vector2> JsonToPoints(JsonReader reader, float scale)
        {
            List <Vector2> points = new List <Vector2>();

            reader.BeginArray();
            while (reader.Peek() == JsonToken.StartArray)
            {
                reader.BeginArray();
                points.Add(JsonToPoint(reader, scale));
                reader.EndArray();
            }
            reader.EndArray();
            return(points);
        }
Пример #2
0
        internal static List <Vector> JsonToPoints(JsonReader reader)
        {
            var points = new List <Vector>();

            reader.BeginArray();
            while (reader.Peek() == JsonToken.StartArray)
            {
                reader.BeginArray();
                points.Add(JsonToPoint(reader));
                reader.EndArray();
            }

            reader.EndArray();
            return(points);
        }
Пример #3
0
 private void ReadJsonHead(JsonReader jReader)
 {
     jReader.BeginObject();
     while (jReader.HasNext)
     {
         string name = jReader.NextName();
         if (name.Equals("Items"))
         {
             ReadItemsArray(jReader);
         }
         else if (name.Equals("PropertyList"))
         {
             jReader.BeginArray();
             while (jReader.HasNext)
             {
                 Property.Add(jReader.NextString());
             }
             jReader.EndArray();
         }
         else
         {
             jReader.SkipValue();
         }
     }
     jReader.EndObject();
     jReader.Close();
 }
Пример #4
0
        private void ReadPropertiesArray(JsonReader jReader)
        {
            jReader.BeginArray();
            List <string> col = new List <string>();

            while (jReader.HasNext)
            {
                jReader.BeginObject();
                while (jReader.HasNext)
                {
                    string name = jReader.NextName();
                    if (name.Equals("Property"))
                    {
                        col.Add(jReader.NextString());
                    }
                    else
                    {
                        jReader.SkipValue();
                    }
                }
                jReader.EndObject();
            }
            jReader.EndArray();
            Rows.Add(col);
        }
Пример #5
0
        public Color?Parse(JsonReader reader, float scale)
        {
            bool isArray = reader.Peek() == JsonToken.StartArray;

            if (isArray)
            {
                reader.BeginArray();
            }
            var r = reader.NextDouble();
            var g = reader.NextDouble();
            var b = reader.NextDouble();
            var a = reader.NextDouble();

            if (isArray)
            {
                reader.EndArray();
            }

            if (r <= 1 && g <= 1 && b <= 1 && a <= 1)
            {
                r *= 255;
                g *= 255;
                b *= 255;
                a *= 255;
            }
            return(new Color((byte)r, (byte)g, (byte)b, (byte)a));
        }
        internal static ShapeGroup Parse(JsonReader reader, LottieComposition composition)
        {
            string name  = null;
            var    items = new List <IContentModel>();

            while (reader.HasNext())
            {
                switch (reader.NextName())
                {
                case "nm":
                    name = reader.NextString();
                    break;

                case "it":
                    reader.BeginArray();
                    while (reader.HasNext())
                    {
                        var newItem = ContentModelParser.Parse(reader, composition);
                        if (newItem != null)
                        {
                            items.Add(newItem);
                        }
                    }

                    reader.EndArray();
                    break;

                default:
                    reader.SkipValue();
                    break;
                }
            }

            return(new ShapeGroup(name, items));
        }
Пример #7
0
        private static void ParseLayers(JsonReader reader, LottieComposition composition, List <Layer> layers,
                                        Dictionary <long, Layer> layerMap)
        {
            var imageCount = 0;

            reader.BeginArray();
            while (reader.HasNext())
            {
                var layer = LayerParser.Parse(reader, composition);
                if (layer.GetLayerType() == Layer.LayerType.Image)
                {
                    imageCount++;
                }
                layers.Add(layer);
                layerMap[layer.Id] = layer;

                if (imageCount > 4)
                {
                    LottieLog.Warn(
                        $"You have {imageCount} images. Lottie should primarily be used with shapes. If you are using Adobe Illustrator, convert the Illustrator layers to shape layers.");
                }
            }

            reader.EndArray();
        }
Пример #8
0
        private static void ParseFonts(JsonReader reader, Dictionary <string, Font> fonts)
        {
            reader.BeginObject();
            while (reader.HasNext())
            {
                switch (reader.NextName())
                {
                case "list":
                    reader.BeginArray();
                    while (reader.HasNext())
                    {
                        var font = FontParser.Parse(reader);
                        fonts.Add(font.Name, font);
                    }

                    reader.EndArray();
                    break;

                default:
                    reader.SkipValue();
                    break;
                }
            }

            reader.EndObject();
        }
        private void readStatesHierarchy(Dictionary <string, string> mapsItemsCodes, string currentCountryCode, JsonReader reader)
        {
            string currentStateCode = null;

            reader.BeginObject();
            while (reader.HasNext)
            {
                string key = reader.NextName();
                if (key != null)
                {
                    if (key.Equals(STATE_CODE_ID))
                    {
                        currentStateCode = reader.NextString();
                        if ((currentStateCode != null) && (currentCountryCode != null))
                        {
                            mapsItemsCodes.Add(currentStateCode, currentCountryCode);
                        }
                    }
                    else if (key.Equals(CITY_CODES_ID))
                    {
                        reader.BeginArray();
                        while (reader.HasNext)
                        {
                            readCitiesHierarchy(mapsItemsCodes, currentStateCode, reader);
                        }
                        reader.EndArray();
                    }
                }
            }
            reader.EndObject();
        }
        private void readContinentsHierarchy(Dictionary <string, string> mapsItemsCodes, JsonReader reader)
        {
            string currentContinentCode = null;

            reader.BeginObject();
            while (reader.HasNext)
            {
                string key = reader.NextName();
                if (key != null)
                {
                    if (key.Equals(CONTINENT_CODE_ID))
                    {
                        currentContinentCode = reader.NextString();
                        if (currentContinentCode != null)
                        {
                            mapsItemsCodes.Add(currentContinentCode, "");
                        }
                    }
                    else if (key.Equals(COUNTRIES_ID))
                    {
                        reader.BeginArray();
                        while (reader.HasNext)
                        {
                            readCountriesHierarchy(mapsItemsCodes, currentContinentCode, reader);
                        }
                        reader.EndArray();
                    }
                }
            }
            reader.EndObject();
        }
Пример #11
0
 private void ReadSOAPJsonHead(JsonReader jReader)
 {
     if (jReader.Peek() == JsonToken.Null)
     {
         return;
     }
     jReader.BeginObject();
     while (jReader.HasNext)
     {
         string name = jReader.NextName();
         if (name.Equals("IDOName"))
         {
             iResult.IDOName = jReader.NextString();
         }
         else if (name.Equals("Items"))
         {
             ReadSOAPItemsArray(jReader);
         }
         else if (name.Equals("PropertyList"))
         {
             jReader.BeginArray();
             while (jReader.HasNext)
             {
                 iResult.ObjectNames.Add(jReader.NextString());
             }
             jReader.EndArray();
         }
         else
         {
             jReader.SkipValue();
         }
     }
     jReader.EndObject();
     jReader.Close();
 }
Пример #12
0
 private void ReadSOAPItemsArray(JsonReader jReader)
 {
     jReader.BeginArray();
     while (jReader.HasNext)
     {
         ReadSOAPItem(jReader);
     }
     jReader.EndArray();
 }
 private void readWorldHierarchy(Dictionary <string, string> mapsItemsCodes, JsonReader reader)
 {
     reader.BeginArray();
     while (reader.HasNext)
     {
         readContinentsHierarchy(mapsItemsCodes, reader);
     }
     reader.EndArray();
 }
 private void readMapsDetails(List <MapDownloadResource> maps, JsonReader reader)
 {
     reader.BeginArray();
     while (reader.HasNext)
     {
         readCurrentMapDetails(maps, reader);
     }
     reader.EndArray();
 }
 private void ReadSampleGroups(JsonReader reader, List <SampleGroup> groups)
 {
     reader.BeginArray();
     while (reader.HasNext)
     {
         ReadSampleGroup(reader, groups);
     }
     reader.EndArray();
 }
 private void readRegionsDetails(Dictionary <string, string> regionItemsCodes, JsonReader reader)
 {
     reader.BeginArray();
     while (reader.HasNext)
     {
         readCurrentRegionDetails(regionItemsCodes, reader);
     }
     reader.EndArray();
 }
 private static void ParseChars(JsonReader reader, LottieComposition composition, Dictionary <int, FontCharacter> characters)
 {
     reader.BeginArray();
     while (reader.HasNext())
     {
         var character = FontCharacterParser.Parse(reader, composition);
         characters.Add(character.GetHashCode(), character);
     }
     reader.EndArray();
 }
Пример #18
0
        internal static List <Keyframe <T> > Parse <T>(JsonReader reader, LottieComposition composition,
                                                       IValueParser <T> valueParser)
        {
            var keyframes = new List <Keyframe <T> >();

            if (reader.Peek() == JsonToken.String)
            {
                composition.AddWarning("Lottie doesn't support expressions.");
                return(keyframes);
            }

            reader.BeginObject();
            while (reader.HasNext())
            {
                switch (reader.NextName())
                {
                case "k":
                    if (reader.Peek() == JsonToken.StartArray)
                    {
                        reader.BeginArray();

                        if (reader.Peek() == JsonToken.Integer || reader.Peek() == JsonToken.Float)
                        {
                            // For properties in which the static value is an array of numbers.
                            keyframes.Add(KeyframeParser.Parse(reader, composition, valueParser, false));
                        }
                        else
                        {
                            while (reader.HasNext())
                            {
                                keyframes.Add(KeyframeParser.Parse(reader, composition, valueParser, true));
                            }
                        }
                        reader.EndArray();
                    }
                    else
                    {
                        keyframes.Add(KeyframeParser.Parse(reader, composition, valueParser, false));
                    }

                    break;

                default:
                    reader.SkipValue();
                    break;
                }
            }

            reader.EndObject();

            SetEndFrames <Keyframe <T>, T>(keyframes);
            return(keyframes);
        }
Пример #19
0
        /// <summary>
        /// [r,g,b]
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        internal static SKColor JsonToColor(JsonReader reader)
        {
            reader.BeginArray();
            var r = (byte)(reader.NextDouble() * 255);
            var g = (byte)(reader.NextDouble() * 255);
            var b = (byte)(reader.NextDouble() * 255);

            while (reader.HasNext())
            {
                reader.SkipValue();
            }
            reader.EndArray();
            return(new SKColor(r, g, b, 255));
        }
Пример #20
0
        /// <summary>
        /// [r,g,b]
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        internal static Color JsonToColor(JsonReader reader)
        {
            reader.BeginArray();
            var r = (byte)(reader.NextDouble() * 255);
            var g = (byte)(reader.NextDouble() * 255);
            var b = (byte)(reader.NextDouble() * 255);

            while (reader.HasNext())
            {
                reader.SkipValue();
            }
            reader.EndArray();
            return(Color.FromArgb(255, r, g, b));
        }
Пример #21
0
        private static Vector JsonArrayToPoint(JsonReader reader)
        {
            double x;
            double y;

            reader.BeginArray();
            x = reader.NextDouble();
            y = reader.NextDouble();
            while (reader.Peek() != JsonToken.EndArray)
            {
                reader.SkipValue();
            }
            reader.EndArray();
            return(new Vector(x, y));
        }
Пример #22
0
        private static Vector2 JsonArrayToPoint(JsonReader reader, float scale)
        {
            float x;
            float y;

            reader.BeginArray();
            x = reader.NextDouble();
            y = reader.NextDouble();
            while (reader.Peek() != JsonToken.EndArray)
            {
                reader.SkipValue();
            }
            reader.EndArray();
            return(new Vector2(x * scale, y * scale));
        }
Пример #23
0
 private void ReadRESTPropertiesArray(JsonReader jReader)
 {
     try
     {
         BaseIDOObject col = new BaseIDOObject();
         iResult.Objects.Add(col);
         jReader.BeginArray();
         while (jReader.HasNext)
         {
             ReadRESTProperties(jReader);
         }
         jReader.EndArray();
     }
     catch (Exception Ex)
     {
         throw Ex;
     }
 }
Пример #24
0
        public static AnimatablePathValue Parse(JsonReader reader, LottieComposition composition)
        {
            List <Keyframe <Vector2?> > keyframes = new List <Keyframe <Vector2?> >();

            if (reader.Peek() == JsonToken.StartArray)
            {
                reader.BeginArray();
                while (reader.HasNext())
                {
                    keyframes.Add(PathKeyframeParser.Parse(reader, composition));
                }
                reader.EndArray();
                KeyframesParser.SetEndFrames <Keyframe <Vector2?>, Vector2?>(keyframes);
            }
            else
            {
                keyframes.Add(new Keyframe <Vector2?>(JsonUtils.JsonToPoint(reader, Utils.Utils.DpScale())));
            }
            return(new AnimatablePathValue(keyframes));
        }
Пример #25
0
        public ScaleXy Parse(JsonReader reader, float scale)
        {
            var isArray = reader.Peek() == JsonToken.StartArray;

            if (isArray)
            {
                reader.BeginArray();
            }
            var sx = reader.NextDouble();
            var sy = reader.NextDouble();

            while (reader.HasNext())
            {
                reader.SkipValue();
            }
            if (isArray)
            {
                reader.EndArray();
            }
            return(new ScaleXy(sx / 100f * scale, sy / 100f * scale));
        }
Пример #26
0
 private void ReadRESTItemsArray(JsonReader jReader)
 {
     try
     {
         if (jReader.Peek() == JsonToken.Null)
         {
             jReader.SkipValue();
             return;
         }
         jReader.BeginArray();
         while (jReader.HasNext)
         {
             ReadRESTPropertiesArray(jReader);
         }
         jReader.EndArray();
     }
     catch (Exception Ex)
     {
         throw Ex;
     }
     //jReader.Close();
 }
 private void readSubRegionsForCurrentRegion(Dictionary <string, string> regionItemsCodes, string currentRegionCode, JsonReader reader)
 {
     reader.BeginArray();
     while (reader.HasNext)
     {
         reader.BeginObject();
         string key = reader.NextName();
         if (key != null)
         {
             if (key.Equals(SUB_REGION_CODE_ID))
             {
                 string subRegionCode = reader.NextString();
                 if (subRegionCode != null)
                 {
                     regionItemsCodes.Add(subRegionCode, currentRegionCode);
                 }
             }
         }
         reader.EndObject();
     }
     reader.EndArray();
 }
            private void ReadSampleGroup(JsonReader reader, List <SampleGroup> groups)
            {
                string        groupName = "";
                List <Sample> samples   = new List <Sample>();

                reader.BeginObject();
                while (reader.HasNext)
                {
                    string name = reader.NextName();
                    switch (name)
                    {
                    case "name":
                        groupName = reader.NextString();
                        break;

                    case "samples":
                        reader.BeginArray();
                        while (reader.HasNext)
                        {
                            samples.Add(ReadEntry(reader, false));
                        }
                        reader.EndArray();
                        break;

                    case "_comment":
                        reader.NextString();     // Ignore.
                        break;

                    default:
                        throw new ParserException("Unsupported name: " + name);
                    }
                }
                reader.EndObject();

                SampleGroup group = getGroup(groupName, groups);

                group.samples.AddRange(samples);
            }
Пример #29
0
        public string[] GetConfigurationNames()
        {
            //json/configurations
            string        path          = BasePath + "/json/configurations";
            List <String> configureList = new List <String>();

            try
            {
                JsonReader reader = new JsonReader(new Java.IO.StringReader(ExecuteHTTPRequest(path).ToString()));
                reader.BeginArray();
                while (reader.HasNext)
                {
                    configureList.Add(reader.NextString());
                }
                reader.EndArray();
                reader.Close();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
            return(configureList.ToArray());
        }
Пример #30
0
        private void ReadSOAPPropertiesArray(JsonReader jReader, ref BaseIDOObject col)
        {
            jReader.BeginArray();

            while (jReader.HasNext)
            {
                BaseIDOObjectItem propertyValues = new BaseIDOObjectItem();
                jReader.BeginObject();
                while (jReader.HasNext)
                {
                    string name = jReader.NextName();
                    if (name.Equals("Property"))
                    {
                        JsonToken peek = jReader.Peek();
                        if (peek == JsonToken.Null)
                        {
                            jReader.SkipValue();
                        }
                        else
                        {
                            propertyValues.ItemValue = jReader.NextString();
                        }
                    }
                    else if (name.Equals("Updated"))
                    {
                        propertyValues.Updated = jReader.NextBoolean();
                    }
                    else
                    {
                        jReader.SkipValue();
                    }
                }
                jReader.EndObject();
                col.ObjectItems.Add(propertyValues);
            }
            jReader.EndArray();
        }