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
|
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassLibrary1
{
public class Program : BindableBase
{
private string Title = "";
public string title
{
get { return this.Title; }
set { this.SetProperty(ref this.Title, value); }
}
private string Genre = "";
public string genre
{
get { return this.Genre; }
set { this.SetProperty(ref this.Genre, value); }
}
private double Duration;
public double duration
{
get { return this.Duration; }
set { this.SetProperty(ref this.Duration, value); }
}
private DateTime StartDate;
public DateTime startDate
{
get { return this.StartDate; }
set { this.SetProperty(ref this.StartDate, value); }
}
private DateTime EndDate;
public DateTime endDate
{
get { return this.EndDate; }
set { this.SetProperty(ref this.EndDate, value); }
}
private string StartTime = "";
public string startTime
{
get { return this.StartTime; }
set { this.SetProperty(ref this.StartTime, value); }
}
private string EndTime = "";
public string endTime
{
get { return this.EndTime; }
set { this.SetProperty(ref this.EndTime, value); }
}
private Channel Parent;
public Channel parent
{
get { return this.Parent; }
set { this.SetProperty(ref this.Parent, value); }
}
private double Width;
public double width
{
get { return this.Width; }
set { this.SetProperty(ref this.Width, value); }
}
private String DurationDisplay;
public String durationDisplay
{
get { return this.DurationDisplay; }
set { this.SetProperty(ref this.DurationDisplay, value); }
}
private bool IsNow=false;
public bool isNow
{
get { return this.IsNow; }
set { this.SetProperty(ref this.IsNow, value); }
}
public void parseJson(JToken token)
{
this.Title = token.SelectToken("titolo",false)!=null? token.SelectToken("titolo",false).Value<String>():"";
this.Genre = token.SelectToken("tipo", false) != null ? token.SelectToken("tipo", false).Value<String>() : "";
this.Duration = token.SelectToken("durata", false) != null ? token.SelectToken("durata", false).Value<double>() : 0;
this.DurationDisplay = duration + " min";
setWidth();
string timestamp = token.SelectToken("timestamp", false) != null ? token.SelectToken("timestamp", false).Value<string>() :"";
try
{
int year = int.Parse(timestamp.Substring(0, 4));
int month = int.Parse(timestamp.Substring(4, 2));
int day = int.Parse(timestamp.Substring(6, 2));
int hour = int.Parse(timestamp.Substring(8, 2));
int minute = int.Parse(timestamp.Substring(10, 2));
this.StartDate = new DateTime(year, month, day, hour, minute, 0);
this.EndDate = this.StartDate + new TimeSpan(0, (int)this.duration, 0);
this.StartTime = this.StartDate.TimeOfDay.ToString(@"hh\:mm");
this.EndTime = this.StartDate.TimeOfDay.Add(new TimeSpan(0, (int)this.Duration, 0)).ToString(@"hh\:mm");
}
catch {
this.startDate = DateTime.Now;
}
}
public void setWidth() {
this.Width = (this.Duration * 4) - 4;
}
}
}
|