This repository has been archived by the owner on Nov 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
city.cs
executable file
·370 lines (311 loc) · 12.2 KB
/
city.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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
/*---------------------------------------------------------------------
Copyright (C) Microsoft Corporation. All rights reserved.
This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation. See these other
materials for detailed information regarding Microsoft code samples.
THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
----------------------------------------------------------------------- *
* File: City.cs
*
* Purpose: Managed representation of the ICity object
*
*
* Notes:
*
*/
namespace PocketOutlook
{
using System;
using System.Runtime.InteropServices;
public class City : OutlookItem
{
// The constructor is internal to prevent objects other than the
// Application class from using "new" to create an object of this
// type.
internal City(Application application,
ref IntPtr pICity) : base (application, ref pICity)
{
}
public void Dispose()
{
PocketOutlook.ReleaseCOMPtr(this.RawItemPtr);
}
~City()
{
this.Dispose();
}
/*
* Longitude and Latitude
*
* Notes:
* These accessors return integers which are "100 times the
* decimal representation of degrees". For example,
* Atlanta, GA, with a longitude of 84.42 degrees west,
* would return the value -8442. See the MSDN entry for
* "ICity Property Methods" for more details.
*/
// Longitude
public int Longitude
{
get
{
int nLongitude = 0;
int hResult = do_get_Longitude(this.RawItemPtr, ref nLongitude);
PocketOutlook.CheckHRESULT(hResult);
return nLongitude;
}
set
{
PocketOutlook.CheckHRESULT(do_put_Longitude(this.RawItemPtr, value));
}
} // Longitude
public int Latitude
{
get
{
int nLatitude = 0;
int hResult = do_get_Latitude(this.RawItemPtr, ref nLatitude);
PocketOutlook.CheckHRESULT(hResult);
return nLatitude;
}
set
{
PocketOutlook.CheckHRESULT(do_put_Latitude(this.RawItemPtr, value));
}
} // Latitude
/*
* Returns the index for this city's timezone in the
* Applications table of timezones.
*/
public int TimezoneIndex
{
get
{
int iIndex = 0;
int hResult = do_get_TimezoneIndex(this.RawItemPtr, ref iIndex);
PocketOutlook.CheckHRESULT(hResult);
return iIndex;
}
set
{
PocketOutlook.CheckHRESULT(do_put_TimezoneIndex(this.RawItemPtr,
value));
}
}
public String AirportCode
{
get
{
IntPtr bz = new IntPtr(0);
int hResult = do_get_AirportCode(this.RawItemPtr, ref bz);
String zAirportCode = null;
try
{
PocketOutlook.CheckHRESULT(hResult);
zAirportCode = Marshal.PtrToStringUni(bz);
}
finally
{
PocketOutlook.SysFreeString(bz);
}
return zAirportCode;
}
set
{
PocketOutlook.CheckHRESULT(do_put_AirportCode(this.RawItemPtr, value));
}
} // AirportCode
public String CountryPhoneCode
{
get
{
IntPtr bz = new IntPtr(0);
int hResult = do_get_CountryPhoneCode(this.RawItemPtr, ref bz);
String zCountryPhoneCode = null;
try
{
PocketOutlook.CheckHRESULT(hResult);
zCountryPhoneCode = Marshal.PtrToStringUni(bz);
}
finally
{
PocketOutlook.SysFreeString(bz);
}
return zCountryPhoneCode;
}
set
{
PocketOutlook.CheckHRESULT(do_put_CountryPhoneCode(this.RawItemPtr, value));
}
} // CountryPhoneCode
public String AreaCode
{
get
{
IntPtr bz = new IntPtr(0);
int hResult = do_get_AreaCode(this.RawItemPtr, ref bz);
String zAreaCode = null;
try
{
PocketOutlook.CheckHRESULT(hResult);
zAreaCode = Marshal.PtrToStringUni(bz);
}
finally
{
PocketOutlook.SysFreeString(bz);
}
return zAreaCode;
}
set
{
PocketOutlook.CheckHRESULT(do_put_AreaCode(this.RawItemPtr, value));
}
} // AreaCode
public String Name
{
get
{
IntPtr bz = new IntPtr(0);
int hResult = do_get_Name(this.RawItemPtr, ref bz);
String zName = null;
try
{
PocketOutlook.CheckHRESULT(hResult);
zName = Marshal.PtrToStringUni(bz);
}
finally
{
PocketOutlook.SysFreeString(bz);
}
return zName;
}
set
{
PocketOutlook.CheckHRESULT(do_put_Name(this.RawItemPtr, value));
}
} // Name
public String Country
{
get
{
IntPtr bz = new IntPtr(0);
int hResult = do_get_Country(this.RawItemPtr, ref bz);
String zCountry = null;
try
{
PocketOutlook.CheckHRESULT(hResult);
zCountry = Marshal.PtrToStringUni(bz);
}
finally
{
PocketOutlook.SysFreeString(bz);
}
return zCountry;
}
set
{
PocketOutlook.CheckHRESULT(do_put_Country(this.RawItemPtr, value));
}
} // Country
public bool InROM
{
get
{
bool bInROM = false;
int hResult = do_get_InROM(this.RawItemPtr, ref bInROM);
PocketOutlook.CheckHRESULT(hResult);
return bInROM;
}
}
protected override void doSave()
{
PocketOutlook.CheckHRESULT(do_Save(this.RawItemPtr));
}
protected override void doDelete()
{
PocketOutlook.CheckHRESULT(do_Delete(this.RawItemPtr));
}
protected override OutlookItem doCopy()
{
IntPtr pICity = new IntPtr(0);
int hResult = do_Copy(this.RawItemPtr, ref pICity);
try
{
PocketOutlook.CheckHRESULT(hResult);
}
catch (Exception)
{
PocketOutlook.ReleaseCOMPtr(pICity);
}
return new City(this.Application, ref pICity);
}
internal IntPtr RawCityPtr
{
get
{
return this.RawItemPtr;
}
}
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_get_Longitude") ]
private static extern int do_get_Longitude(IntPtr self,
ref int pnLongitude);
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_get_Latitude") ]
private static extern int do_get_Latitude(IntPtr self,
ref int pnLongitude);
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_get_TimezoneIndex") ]
private static extern int do_get_TimezoneIndex(IntPtr self,
ref int pnIndex);
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_get_AirportCode") ]
private static extern int do_get_AirportCode(IntPtr self,
ref IntPtr rbzAirportCode);
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_get_CountryPhoneCode") ]
private static extern int do_get_CountryPhoneCode(IntPtr self,
ref IntPtr rbzCountryPhoneCode);
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_get_AreaCode") ]
private static extern int do_get_AreaCode(IntPtr self,
ref IntPtr rbzAreaCode);
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_get_Name") ]
private static extern int do_get_Name(IntPtr self,
ref IntPtr rbzName);
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_get_Country") ]
private static extern int do_get_Country(IntPtr self,
ref IntPtr rbzCountry);
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_get_InROM") ]
private static extern int do_get_InROM(IntPtr self,
ref bool rbInROM);
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_put_Longitude") ]
private static extern int do_put_Longitude(IntPtr self,
int nLongitude);
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_put_Latitude") ]
private static extern int do_put_Latitude(IntPtr self,
int nLatitude);
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_put_TimezoneIndex") ]
private static extern int do_put_TimezoneIndex(IntPtr self,
int nIndex);
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_put_AirportCode") ]
private static extern int do_put_AirportCode(IntPtr self,
String zAirportCode);
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_put_CountryPhoneCode") ]
private static extern int do_put_CountryPhoneCode(IntPtr self,
String zCountryPhoneCode);
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_put_AreaCode") ]
private static extern int do_put_AreaCode(IntPtr self,
string zAreaCode);
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_put_Name") ]
private static extern int do_put_Name(IntPtr self,
String zName);
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_put_Country") ]
private static extern int do_put_Country(IntPtr self,
string zCountry);
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_Save") ]
private static extern int do_Save(IntPtr self);
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_Delete") ]
private static extern int do_Delete(IntPtr self);
[ DllImport("PocketOutlook.dll", EntryPoint="ICity_Copy") ]
private static extern int do_Copy(IntPtr self,
ref IntPtr rpICity);
} // class City
}