コード例 #1
0
        private async void OnLoad()
        {
            UserInstructions();

            var a        = DependencyService.Get <IFile>().Exist("Info");
            var jsonUser = DependencyService.Get <IFile>().LoadText("Info");

            Info = JsonConvert.DeserializeObject <UserModel>(jsonUser);
            var    assembly = typeof(LoadResourceText).GetTypeInfo().Assembly;
            Stream stream   = assembly.GetManifestResourceStream("KidsApp.Exercises.json");

            using (var reader = new System.IO.StreamReader(stream))
            {
                Level = "Principiante";
                var json       = reader.ReadToEnd();
                var rootobject = JsonConvert.DeserializeObject <Rootobject>(json);
                ExerciseLoad = rootobject.Exercises.ToArray();
            }
            ExerciseImage       = ExerciseLoad[0].Image;
            ExerciseLevel       = ExerciseLoad[0].Type;
            ExerciseName        = ExerciseLoad[0].Exercise;
            ExerciseDescription = ExerciseLoad[0].Description;
            Total = ExerciseLoad.Count();
            Index = 1;
        }
コード例 #2
0
        private async void OnLoad()
        {
            UserInstructions();

            var a        = DependencyService.Get <IFile>().Exist("Info");
            var jsonUser = DependencyService.Get <IFile>().LoadText("Info");

            Info = JsonConvert.DeserializeObject <UserModel>(jsonUser);
            var    assembly = typeof(LoadResourceText).GetTypeInfo().Assembly;
            Stream stream   = assembly.GetManifestResourceStream("KidsApp.Exercises.json");

            using (var reader = new System.IO.StreamReader(stream))
            {
                if (Info.Points <= 20)
                {
                    Level = "Principiante";
                }
                if (Info.Points > 20 && Info.Points <= 40)
                {
                    Level = "Intermedio";
                }
                if (Info.Points > 40)
                {
                    Level = "Avanzado";
                }

                var json       = reader.ReadToEnd();
                var rootobject = JsonConvert.DeserializeObject <Rootobject>(json);
                ExerciseLoad = rootobject.Exercises.Where(x => x.Type == Level).ToArray();
            }
            ExerciseImage       = ExerciseLoad[0].Image;
            ExerciseLevel       = ExerciseLoad[0].Type;
            ExerciseName        = ExerciseLoad[0].Exercise;
            ExerciseDescription = ExerciseLoad[0].Description;
            Total = ExerciseLoad.Count();
            Index = 1;



            if (Level == "Principiante") //Muestra el porcentaje
            {
                Info.Percentage = ((Info.Points * 100) / 20);
            }
            if (Level == "Intermedio")
            {
                Info.Percentage = ((Info.Points * 100) / 40);
            }
            if (Level == "Avanzado")
            {
                Info.Percentage = ((Info.Points * 100) / 60);
            }
        }