-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModelClasses.cs
218 lines (184 loc) · 5.31 KB
/
ModelClasses.cs
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#region Helper Classes
//TODO blog about PropertyChangedBase for color binding
using ArcGIS.Core.Geometry;
using ArcGIS.Desktop.Framework.Contracts;
using System;
using System.Xml.Linq;
namespace Esri.APL.MilesPerDollar {
public class Vehicle : PropertyChangedBase {
private string _year, _make, _model, _type;
private int _mpg;
public Vehicle(string year, string make, string model, string engine, int mpg) {
_year = year;
_make = make;
_model = model;
_type = engine;
_mpg = mpg;
}
public Vehicle(XElement vehicle) {
_year = vehicle.Attribute("year").Value;
_make = vehicle.Attribute("make").Value;
_model = vehicle.Attribute("model").Value;
_type = vehicle.Attribute("engine").Value;
_mpg = Int32.Parse(vehicle.Attribute("mpg").Value);
}
internal static readonly double METERS_PER_MILE = 1609.34;
public override string ToString() {
return LongDescription;
}
public string ShortDescription {
get {
return String.Format("{0} {1} {2}", Year, Make, Model);
}
}
public string LongDescription {
get {
return String.Format("{0} {1} {2} {3}", Year, Make, Model, Type);
}
}
public string Make {
get {
return _make;
}
set {
_make = value;
}
}
public string Model {
get {
return _model;
}
set {
_model = value;
}
}
public string Type {
get {
return _type;
}
set {
_type = value;
}
}
public string Year {
get {
return _year;
}
set {
_year = value;
}
}
public int Mpg {
get {
return _mpg;
}
set {
_mpg = value;
}
}
public double MetersPerGallon => Mpg * METERS_PER_MILE;
}
public class Result : PropertyChangedBase {
private Vehicle _vehicle;
private Polygon _driveServiceArea;
private Polygon _driveCircularBound;
private double _driveDistM;
private string _paddZone;
private double _dollarsPerGallon;
private string _color;
private DateTime _resultDateTimeUTC = DateTime.UtcNow;
private IDisposable _driveServiceAreaGraphic, _driveCircularBoundGraphic;
public Result(Vehicle vehicle) {
this.Vehicle = vehicle;
}
public Result(Vehicle vehicle, DateTime resultDT) {
this.Vehicle = vehicle;
this._resultDateTimeUTC = resultDT;
}
public Vehicle Vehicle {
get {
return _vehicle;
}
set {
SetProperty(ref _vehicle, value);
}
}
public Polygon DriveServiceArea {
get {
return _driveServiceArea;
}
set {
SetProperty(ref _driveServiceArea, value);
}
}
public Polygon DriveCircularBound {
get {
return _driveCircularBound;
}
set {
SetProperty(ref _driveCircularBound, value);
}
}
public IDisposable DriveServiceAreaGraphic {
get {
return _driveServiceAreaGraphic;
}
set {
_driveServiceAreaGraphic = value;
}
}
public IDisposable DriveCircularBoundGraphic {
get {
return _driveCircularBoundGraphic;
}
set {
_driveCircularBoundGraphic = value;
}
}
public double DriveDistM {
get {
return _driveDistM;
}
set {
SetProperty(ref _driveDistM, value);
}
}
/// <summary>
/// The original color displayed for this result
/// </summary>
public string Color {
get {
return _color;
}
set {
SetProperty(ref _color, value);
}
}
public double DriveDistMi => Math.Round(DriveDistM / Vehicle.METERS_PER_MILE, 1);
/// <summary>
/// Date and time this result was generated, expressed in the UTC time zone
/// </summary>
public DateTime ResultDateTimeUTC => _resultDateTimeUTC;
public string PaddZone {
get {
return _paddZone;
}
set {
_paddZone = value;
}
}
public double MilesPerDollar => Vehicle.Mpg / DollarsPerGallon;
public double DollarsPerGallon {
get {
return _dollarsPerGallon;
}
set {
_dollarsPerGallon = value;
}
}
//public override string ToString() {
// return Vehicle.ShortDescription;
//}
}
#endregion
}