Subversion Repository Public Repository

Nextrek

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace App1.DataModel
{
    class Schermata
    {
        public int id { get; set; }
        public String text { get; set; }
        public String topImage { get; set; }
        public int nBottoni { get; set; }
        public ObservableCollection<Bottone> bottoni { get; set; }
        //public String targetId { get; set; }
        //public String buttonText { get; set; }
        //public String buttonPrecondition { get; set; }
        //public String buttonPostcondition { get; set; }

        public Schermata() { }

        public Schermata(String testo, String immagine, int numBottoni, ObservableCollection<Bottone> listaBottoni)
        {
            this.text = testo;
            this.topImage = immagine;
            this.nBottoni = numBottoni;
            this.bottoni = listaBottoni;

        }


        public void parseJson(JToken token)
        {
            try
            {
                token = token.First;
                //var s = token.SelectToken("text");

                //Boolean test1 = (token.SelectToken("text") != null);
                //Boolean test2 = (token.SelectToken("text").HasValues());

                if (token.SelectToken("text") != null)  //&& token.SelectToken("text").HasValues
                {
                    this.text = token.SelectToken("text").Value<String>();
                }
                if (token.SelectToken("topImage") != null)
                {

                    this.topImage = token.SelectToken("topImage").Value<String>(); //.Replace("(", "").Replace(")", " ").Replace("Willpower", "Will power");
                    //if (powerUp != "" && powerUp.IndexOf("+") >= 0)
                    //{
                    //    powerUpValue = powerUp.Substring(powerUp.IndexOf("+"), 2);
                    //}
                    //else
                    //{
                    //    this.powerUpValue = "";
                    //}
                    //color = getColor(powerUp);

                }
                if (token.SelectToken("buttons") != null)
                {
                    this.nBottoni = token.SelectToken("buttons").Value<Int16>();
                }
                //if (token.SelectToken("startAt") != null)
                //{
                //    this.startAt = token.SelectToken("startAt").Value<String>();
                //}
                //if (token.SelectToken("endAt") != null)
                //{
                //    this.endAt = token.SelectToken("endAt").Value<String>();
                //}
                //if (token.SelectToken("map") != null)
                //{
                //    this.mapImage = token.SelectToken("map").Value<String>();
                //}
                this.bottoni = new ObservableCollection<Bottone>();
                int i;
                
                for (i = 0; i < nBottoni; i++)
                {
                    Bottone b = new Bottone();
                    String nomeBottone = String.Format("button{0}", i);

                    JToken jBottone = token.SelectToken(nomeBottone);
                    if (jBottone != null)
                    {
                        JToken jBottone2 = token.SelectToken(nomeBottone);
                        if (jBottone.SelectToken("targetId") != null) //&& jBottone.SelectToken("targetId").HasValues
                        {
                            b.targetID = jBottone2.SelectToken("targetId").Value<String>();
                            //this.targetId = jBottone2.SelectToken("targetId").Value<String>();
                            //b.targetID = this.targetId;
                        }

                        if (jBottone.SelectToken("buttonText") != null) //&& jBottone.SelectToken("buttonText").HasValues
                        {
                            b.testo = jBottone2.SelectToken("buttonText").Value<String>();
                            //this.buttonText = jBottone2.SelectToken("buttonText").Value<String>();
                            //b.testo = this.buttonText;
                        }

                        if (jBottone.SelectToken("buttonPreCond") != null) //&& jBottone.SelectToken("buttonPreCond").HasValues
                        {
                            b.preCond = jBottone2.SelectToken("buttonPreCond").Value<String>();
                            //this.buttonPrecondition = token.SelectToken("buttonPreCond").Value<String>();
                            //b.preCond = this.buttonPrecondition;
                        }

                        if (jBottone.SelectToken("buttonPostCond") != null) //&& jBottone.SelectToken("buttonPostCond").HasValues
                        {
                            b.postCond = jBottone2.SelectToken("buttonPostCond").Value<String>();
                            //this.buttonPostcondition = token.SelectToken("buttonPostCond").Value<String>();
                            //b.postCond = this.buttonPostcondition;
                        }

                        bottoni.Add(b);
                    }
                    //int i = 1;
                    //foreach (JToken video in vids.Children())
                    //{
                    //    vid = new Video();
                    //    vid.parseLink(video.Value<String>());
                    //    vid.title = "Watch Video " + i;
                    //    videos.Add(vid);
                    //    i++;
                    //}
                }
            }
            catch (Exception e)
            {
                String error = e.Message;

            }


        }

    }
}

Commits for Nextrek/Windows8/Minstrek/Walkinback/App1/DataModel/Schermata.cs

Diff revisions: vs.
Revision Author Commited Message
14 FMMortaroli picture FMMortaroli Mon 24 Jun, 2013 21:19:06 +0000