-
Notifications
You must be signed in to change notification settings - Fork 3
/
GPXReader.cs
1647 lines (1518 loc) · 89.9 KB
/
GPXReader.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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Xml;
using System.Windows.Forms;
using System.Xml.Serialization;
namespace KMZRebuilder
{
public class Tachograph
{
/// <summary>
/// Track Point
/// </summary>
public class trkpt
{
/// <summary>
/// Latitude
/// </summary>
public double lat = 0;
/// <summary>
/// Longitude
/// </summary>
public double lon = 0;
/// <summary>
/// Elevation
/// </summary>
public double ele = 0;
/// <summary>
/// Date & Time
/// </summary>
public DateTime time = new DateTime(1900, 1, 1);
/// <summary>
/// Horizontal Speed (km/h)
/// </summary>
public double hspeed = 0;
/// <summary>
/// Vertical Speed (m/s)
/// </summary>
public double vspeed = 0;
/// <summary>
/// Horizontal segment length (km)
/// </summary>
public double seg_h_length = 0;
/// <summary>
/// Vertical segment length (m)
/// </summary>
public double seg_v_length = 0;
/// <summary>
/// Segment time
/// </summary>
public TimeSpan seg_time = new TimeSpan();
/// <summary>
/// Time lapse from start
/// </summary>
public TimeSpan timeLapse = new TimeSpan();
/// <summary>
/// Distance from start (km)
/// </summary>
public double distance = 0;
/// <summary>
/// Track Point
/// </summary>
/// <param name="lat">Latitude</param>
/// <param name="lon">Longitude</param>
/// <param name="ele">Elevation</param>
/// <param name="time">Date & Time</param>
public trkpt(double lat, double lon, double ele, DateTime time)
{
this.lat = lat;
this.lon = lon;
this.ele = ele;
this.time = time;
}
public override string ToString()
{
return timeLapse.Hours + ":" + timeLapse.Minutes + ":" + timeLapse.Seconds + " " + distance + "km " + hspeed + "km/h " + lat + " " + lon;
}
}
/// <summary>
/// Track Segment
/// </summary>
public class trkseg
{
/// <summary>
/// Track Points
/// </summary>
public trkpt[] points = new trkpt[0];
/// <summary>
/// Minimum Latitude
/// </summary>
public double MinLat = double.MaxValue;
/// <summary>
/// Maximum Latitude
/// </summary>
public double MaxLat = double.MinValue;
/// <summary>
/// Minimum Longitude
/// </summary>
public double MinLon = double.MaxValue;
/// <summary>
/// Maximum Longitude
/// </summary>
public double MaxLon = double.MinValue;
/// <summary>
/// Minimum Elevation
/// </summary>
public double MinEle = double.MaxValue;
/// <summary>
/// Maximum Elevation
/// </summary>
public double MaxEle = double.MinValue;
/// <summary>
/// Minimum Horizontal Speed (km/h)
/// </summary>
public double MinSpeed = double.MaxValue;
/// <summary>
/// Maximum Horizontal Speed (km/h)
/// </summary>
public double MaxSpeed = double.MinValue;
/// <summary>
/// Average Horizontal Speed (km/h)
/// </summary>
public double AvgSpeed = 0;
/// <summary>
/// Total Length (km)
/// </summary>
public double TotalLength = 0;
/// <summary>
/// Total Time
/// </summary>
public TimeSpan TotalTime = new TimeSpan();
/// <summary>
/// Start Time
/// </summary>
public DateTime MinTime = new DateTime(1900, 1, 1);
/// <summary>
/// Finish Time
/// </summary>
public DateTime MaxTime = new DateTime(8000, 1, 1);
public trkseg() { }
}
/// <summary>
/// Track Segments
/// </summary>
private List<trkseg> track = new List<trkseg>();
/// <summary>
/// Track Start Time
/// </summary>
private DateTime trackStartTime = new DateTime(1900, 1, 1);
/// <summary>
/// Track End Time
/// </summary>
private DateTime trackEndTime = new DateTime(8000, 1, 1);
/// <summary>
/// Graph Image
/// </summary>
private Bitmap bmp;
/// <summary>
/// Graph Image
/// </summary>
private Graphics g;
/// <summary>
/// Graph Width
/// </summary>
private int width = 600;
/// <summary>
/// Graph Height
/// </summary>
private int height = 600;
/// <summary>
/// Center of the Graph
/// </summary>
private Point center;
/// <summary>
/// Brush for km/h labels
/// </summary>
private Brush kmFontBrush = new SolidBrush(Color.FromArgb(80, 80, 80));
/// <summary>
/// Brush for hours labels
/// </summary>
private Brush HoursFontBrush = Brushes.Black;
/// <summary>
/// Pen for hour lines
/// </summary>
private Pen HoursDelimPen = new Pen(new SolidBrush(Color.FromArgb(230, 230, 230)), 2);
/// <summary>
/// Pen for main km/h lines
/// </summary>
private Pen kmMainLinesPen = new Pen(new SolidBrush(Color.FromArgb(20, 20, 20)), 1);
/// <summary>
/// Pen for misc km lines (110,90)
/// </summarykm/h
private Pen kmMiscLinesPen = new Pen(new SolidBrush(Color.FromArgb(100, 200, 120, 120)), 1);
/// <summary>
/// Fill pen for misc km/h lines (110,90)
/// </summary>
private Pen kmMiscLinesFill = new Pen(new SolidBrush(Color.FromArgb(100, 180, 180, 180)), 2);
/// <summary>
/// Bold pen for avtivity zone
/// </summary>
private Pen activityPenBold = new Pen(Brushes.Navy, 2);
/// <summary>
/// Pen for avtivity zone
/// </summary>
private Pen activityPen = new Pen(Brushes.Black, 1);
/// <summary>
/// Background color
/// </summary>
private Brush bFillBackground = Brushes.White;
/// <summary>
/// Night zone color
/// </summary>
private Brush bFillNight = new SolidBrush(Color.FromArgb(220, 220, 255));
/// <summary>
/// Hours font
/// </summary>
private Font hoursFont = new Font("Arial", 12, FontStyle.Bold);
/// <summary>
/// Hours small font
/// </summary>
private Font hoursSmallFont = new Font("Arial", 10, FontStyle.Bold);
/// <summary>
/// km/h font
/// </summary>
private Font kmphFont = new Font("MS Sans Serif", 9);
/// <summary>
/// Text zone font
/// </summary>
private Font textFont = new Font("Arial", 11, FontStyle.Bold);
/// <summary>
/// Text zone main color
/// </summary>
private Brush textBrush1 = Brushes.Black;
/// <summary>
/// Text zone 2 color
/// </summary>
private Brush textBrush2 = Brushes.Maroon;
/// <summary>
/// Text zone 3 color
/// </summary>
private Brush textBrush3 = Brushes.Navy;
/// <summary>
/// Ìíîæèòåëü ðàäèóñà äëÿ 125 êì/÷
/// </summary>
const double sc125kmph = 1.02;
/// <summary>
/// Ìíîæèòåëü ðàäèóñà äëÿ 120 êì/÷
/// </summary>
const double sc120kmph = 1;
/// <summary>
/// Ìíîæèòåëü ðàäèóñà äëÿ 110 êì/÷
/// </summary>
const double sc110kmph = 0.96;
/// <summary>
/// Ìíîæèòåëü ðàäèóñà äëÿ 100 êì/÷
/// </summary>
const double sc100kmph = 0.92;
/// <summary>
/// Ìíîæèòåëü ðàäèóñà äëÿ 90 êì/÷
/// </summary>
const double sc90kmph = 0.88;
/// <summary>
/// Ìíîæèòåëü ðàäèóñà äëÿ 80 êì/÷
/// </summary>
const double sc80kmph = 0.84;
/// <summary>
/// Ìíîæèòåëü ðàäèóñà äëÿ 60 êì/÷
/// </summary>
const double sc60kmph = 0.76;
/// <summary>
/// Ìíîæèòåëü ðàäèóñà äëÿ 40 êì/÷
/// </summary>
const double sc40kmph = 0.68;
/// <summary>
/// Ìíîæèòåëü ðàäèóñà äëÿ 20 êì/÷
/// </summary>
const double sc20kmph = 0.60;
/// <summary>
/// Ìíîæèòåëü ðàäèóñà äëÿ 0 êì/÷
/// </summary>
const double sc0kmph = 0.52;
/// <summary>
/// Ìíîæèòåëü ñäâèãà çîíû àêòèâíîñòè îò ñìåæíûõ çîí
/// </summary>
const double scActivityOffset = 0.02;
/// <summary>
/// Ìíîæèòåëü ðàññòîÿíèÿ ìåæäó çîíàìè àêòèâíîñòè
/// </summary>
const double scActivityScale = 0.04;
/// <summary>
/// Ìíîæèòåëü âíóòðåííåãî ðàäèóñà çîíû àêòèâíîñòè
/// </summary>
const double scActivityInside = 0.32;
/// <summary>
/// Îòñòóï îò âíåøíåãî ðàäèóñà äèñêà
/// </summary>
const double otstup = 15;
/// <summary>
/// Ìàêñèìàëüíûé ðàäèóñ ñêîðîñòíîé çîíû è çîíû àêòèâíîñòè
/// </summary>
double maxRadiusLineScale = 300 - otstup;
/// <summary>
/// Ìàñøòàáíîñòü äëÿ ñêîðîñòü â 100 êì/÷
/// </summary>
const double sc0_100kmph = (sc100kmph - sc0kmph) / 100;
/// <summary>
/// driver text
/// </summary>
private string _driverText = "";
/// <summary>
/// Start Point
/// </summary>
private string _startFrom = "";
/// <summary>
/// End Point
/// </summary>
private string _endTo = "";
/// <summary>
/// Start Date
/// </summary>
private string _startDT = "";
/// <summary>
/// End Date
/// </summary>
private string _endDT = "";
/// <summary>
/// Vehicle number
/// </summary>
private string _vehicle = "";
/// <summary>
/// Start odometer
/// </summary>
private string _startKM = "";
/// <summary>
/// End odometer
/// </summary>
private string _endKM = "";
/// <summary>
/// Text in text zone align by center
/// </summary>
private bool _altCenter = false;
/// <summary>
/// Sunrise time
/// </summary>
private DateTime _sunrise = DateTime.Now.Date.AddHours(5).AddMinutes(37);
/// <summary>
/// Sunset time
/// </summary>
private DateTime _sunset = DateTime.Now.Date.AddHours(21).AddMinutes(23);
/// <summary>
/// Sunset visible
/// </summary>
private bool _vSS = false;
/// <summary>
/// Sunrise visible
/// </summary>
private bool _vSR = false;
/// <summary>
/// custom start odometer text
/// </summary>
private bool customStartOdometerText = false;
/// <summary>
/// custom end odometer text
/// </summary>
private bool customFinishOdometerText = false;
/// <summary>
/// custom start/finish date text
/// </summary>
private bool customStartFinishDateText = false;
/// <summary>
/// custom start/finish point text
/// </summary>
private bool customStartFinishPointText = false;
/// <summary>
/// Driver Name Text
/// </summary>
public string DriverText { get { return _driverText; } set { _driverText = value; } }
/// <summary>
/// Vehicle Number Text
/// </summary>
public string VehicleText { get { return _vehicle; } set { _vehicle = value; } }
/// <summary>
/// Start From Point Text
/// </summary>
public string StartPointText { get { return _startFrom; } set { customStartFinishPointText = true; _startFrom = value; } }
/// <summary>
/// Finish To Point Text
/// </summary>
public string FinishPointText { get { return _endTo; } set { customStartFinishPointText = true; _endTo = value; } }
/// <summary>
/// Start From Date Text
/// </summary>
public string StartDateText { get { return _startDT; } set { customStartFinishDateText = true; _startDT = value; } }
/// <summary>
/// Finish To Date Text
/// </summary>
public string FinishDateText { get { return _endDT; } set { customStartFinishDateText = true; _endDT = value; } }
/// <summary>
/// Start From Odometer Value
/// </summary>
public string StartKMText { get { return _startKM; } set { customStartOdometerText = true; _startKM = value; RecalculateTrackOutputOptions(false); } }
/// <summary>
/// Finish To Odometer Value
/// </summary>
public string FinishKMText { get { return _endKM; } set { customFinishOdometerText = true; _endKM = value; RecalculateTrackOutputOptions(false); } }
/// <summary>
/// Text in text zone align by center
/// </summary>
public bool AlignTextToCenter { get { return _altCenter; } set { _altCenter = value; } }
/// <summary>
/// Text font in text zone
/// </summary>
public Font TextFont { get { return textFont; } set { textFont = value; } }
/// <summary>
/// Sunset Time
/// </summary>
public DateTime SunsetTime { get { return _sunset; } set { _sunset = value; } }
/// <summary>
/// Sunrise time
/// </summary>
public DateTime SunriseTime { get { return _sunrise; } set { _sunrise = value; } }
/// <summary>
/// Sunset Visible
/// </summary>
public bool SunsetVisible { get { return _vSS; } set { _vSS = value; } }
/// <summary>
/// Sunrise Visible
/// </summary>
public bool SunriseVisible { get { return _vSR; } set { _vSR = value; } }
/// <summary>
/// Graph begins at TrackStartTime
/// </summary>
public DateTime TrackStartTime { get { return trackStartTime; } set { trackStartTime = value; RecalculateTrackOutputOptions(false); } }
/// <summary>
/// Graph ends at TrackFinishTime
/// </summary>
public DateTime TrackFinishTime { get { return trackEndTime; } set { trackEndTime = value; RecalculateTrackOutputOptions(false); } }
/// <summary>
/// Custom Start Odometer Text
/// </summary>
public bool CustomStartOdometerText { get { return customStartOdometerText; } set { customStartOdometerText = value; RecalculateTrackOutputOptions(false); } }
/// <summary>
/// Custom Finish Odometer Text
/// </summary>
public bool CustomFinishOdometerText { get { return customFinishOdometerText; } set { customFinishOdometerText = value; RecalculateTrackOutputOptions(false); } }
/// <summary>
/// Custom Start/Finish Date Text
/// </summary>
public bool CustomStartFinishDateText { get { return customStartFinishDateText; } set { customStartFinishDateText = value; } }
/// <summary>
/// Custom Start/Finish Point Text
/// </summary>
public bool CustomStartFinishPointText { get { return customStartFinishPointText; } set { customStartFinishPointText = value; } }
System.Globalization.NumberFormatInfo nfi;
/// <summary>
/// Create Tachogramm
/// </summary>
public Tachograph()
{
nfi = (System.Globalization.NumberFormatInfo)
System.Globalization.CultureInfo.InvariantCulture.NumberFormat.Clone();
nfi.NumberGroupSeparator = ".";
Init();
}
/// <summary>
/// Create Tachogramm
/// </summary>
/// <param name="width">graph width</param>
/// <param name="height">graph height</param>
public Tachograph(int width, int height)
{
nfi = (System.Globalization.NumberFormatInfo)
System.Globalization.CultureInfo.InvariantCulture.NumberFormat.Clone();
nfi.NumberGroupSeparator = ".";
this.width = width;
this.height = height;
Init();
}
/// <summary>
/// Resize graph
/// </summary>
/// <param name="width">graph width</param>
/// <param name="height">graph height</param>
public void Resize(int width, int height)
{
this.width = width;
this.height = height;
Init();
}
private void RecalculateTrackOutputOptions()
{
RecalculateTrackOutputOptions(true);
}
private void RecalculateTrackOutputOptions(bool nullDates)
{
if (nullDates)
{
trackStartTime = new DateTime(8000, 1, 1);
trackEndTime = new DateTime(1900, 1, 1);
foreach (trkseg ts in track)
{
if (trackStartTime > ts.MinTime) trackStartTime = ts.MinTime;
if (trackEndTime < ts.MaxTime) trackEndTime = ts.MaxTime;
};
};
double skipped_dist = 0;
double dist = 0;
string sfTxt = ""; DateTime minT = new DateTime(8000, 1, 1);
string etTxt = ""; DateTime maxT = new DateTime(1900, 1, 1);
foreach (trkseg ts in this.track)
{
for (int i = 0; i < ts.points.Length; i++)
{
trkpt curr = ts.points[i];
if (curr.time < TrackStartTime) { skipped_dist += curr.seg_h_length; continue; };
if (curr.time > TrackFinishTime) continue;
dist += curr.seg_h_length;
if (minT > curr.time)
{
minT = curr.time;
sfTxt = curr.lat.ToString("0.000000", nfi) + "° " + curr.lon.ToString("0.000000", nfi) + "°";
};
if (maxT < curr.time)
{
maxT = curr.time;
etTxt = curr.lat.ToString("0.000000", nfi) + "° " + curr.lon.ToString("0.000000", nfi) + "°";
};
}
};
if (!customStartOdometerText)
{
_startKM = skipped_dist.ToString("0.00", nfi);
if (!customFinishOdometerText)
_endKM = (skipped_dist + dist).ToString("0.00", nfi);
};
if (!customFinishOdometerText)
{
if (!customStartOdometerText)
_endKM = (skipped_dist + dist).ToString("0.00", nfi);
else
{
double d = 0;
double.TryParse(_startKM, out d);
_endKM = (d + dist).ToString("0.00", nfi);
};
};
if (!customStartFinishPointText)
{
_startFrom = sfTxt; // track[0].points[0].lat.ToString("0.000000", nfi) + "° " + track[0].points[0].lon.ToString("0.000000", nfi) + "°";
_endTo = etTxt; // track[track.Count - 1].points[track[track.Count - 1].points.Length - 1].lat.ToString("0.000000", nfi) + "° " + track[track.Count - 1].points[track[track.Count - 1].points.Length - 1].lon.ToString("0.000000", nfi) + "°";
};
if (!customStartFinishDateText)
{
_startDT = trackStartTime.ToString("ddd dd.MM.yyyy HH:mm:ss");
_endDT = trackEndTime.ToString("ddd dd.MM.yyyy HH:mm:ss");
};
}
/// <summary>
/// Set or reset to new track for graph
/// </summary>
/// <param name="track">track segments</param>
public void SetTrack(trkseg[] track)
{
this.track.Clear();
this.track.AddRange(track);
RecalculateTrackOutputOptions();
}
/// <summary>
/// Add segement to track for graph
/// </summary>
/// <param name="segment">track segment</param>
public void AddSegment(trkseg segment)
{
this.track.Add(segment);
RecalculateTrackOutputOptions();
}
/// <summary>
/// Remove track (clear graph)
/// </summary>
public void RemoveTrack()
{
this.track.Clear();
}
/// <summary>
/// Init graph
/// </summary>
private void Init()
{
if (width > height) width = height;
if (height > width) height = width;
center = new Point(width / 2, height / 2);
bmp = new Bitmap(width, height);
g = Graphics.FromImage(bmp);
maxRadiusLineScale = this.width / 2 - otstup;
}
/// <summary>
/// Draw empty tachogramm disk
/// </summary>
private void DrawTemplate()
{
double sunriseAngle = 15 * _sunrise.Hour + 0.25 * _sunrise.Minute;
double sunsetAngle = 15 * _sunset.Hour + 0.25 * _sunset.Minute;
// CIRCLE
Rectangle fRect = new Rectangle(0, 0, width - 1, height - 1);
g.FillEllipse(bFillBackground, fRect);
g.DrawPie(new Pen(Color.Brown, 3), fRect, 0, 180);
g.DrawLine(new Pen(Color.White, 5), new Point(0, center.Y), new Point(width, center.Y));
g.DrawEllipse(new Pen(Color.Brown, 2), fRect);
// NIGHT
if (_vSR && _vSS)
g.FillPie(bFillNight, fRect, (float)sunsetAngle + 180, (float)(sunriseAngle + 360 - sunsetAngle));
// km/h LINES & Activity Lines
g.DrawEllipse(kmMainLinesPen, (int)(center.X - maxRadiusLineScale * sc120kmph), (int)(center.Y - maxRadiusLineScale * sc120kmph), (int)(maxRadiusLineScale * sc120kmph) * 2, (int)(maxRadiusLineScale * sc120kmph) * 2);
g.DrawEllipse(kmMainLinesPen, (int)(center.X - maxRadiusLineScale * sc100kmph), (int)(center.Y - maxRadiusLineScale * sc100kmph), (int)(maxRadiusLineScale * sc100kmph) * 2, (int)(maxRadiusLineScale * sc100kmph) * 2);
g.DrawEllipse(kmMainLinesPen, (int)(center.X - maxRadiusLineScale * sc80kmph), (int)(center.Y - maxRadiusLineScale * sc80kmph), (int)(maxRadiusLineScale * sc80kmph) * 2, (int)(maxRadiusLineScale * sc80kmph) * 2);
g.DrawEllipse(kmMiscLinesFill, (int)(center.X - maxRadiusLineScale * sc60kmph), (int)(center.Y - maxRadiusLineScale * sc60kmph), (int)(maxRadiusLineScale * sc60kmph) * 2, (int)(maxRadiusLineScale * sc60kmph) * 2);
g.DrawEllipse(kmMainLinesPen, (int)(center.X - maxRadiusLineScale * sc60kmph), (int)(center.Y - maxRadiusLineScale * sc60kmph), (int)(maxRadiusLineScale * sc60kmph) * 2, (int)(maxRadiusLineScale * sc60kmph) * 2);
g.DrawEllipse(kmMainLinesPen, (int)(center.X - maxRadiusLineScale * sc40kmph), (int)(center.Y - maxRadiusLineScale * sc40kmph), (int)(maxRadiusLineScale * sc40kmph) * 2, (int)(maxRadiusLineScale * sc40kmph) * 2);
g.DrawEllipse(kmMainLinesPen, (int)(center.X - maxRadiusLineScale * sc20kmph), (int)(center.Y - maxRadiusLineScale * sc20kmph), (int)(maxRadiusLineScale * sc20kmph) * 2, (int)(maxRadiusLineScale * sc20kmph) * 2);
for (double angle = 0; angle < 360; angle += 15 / 4)
{
bool fillNight = _vSR && _vSS && (!(angle > (sunriseAngle) && (angle < (sunsetAngle))));
Pen p = new Pen(fillNight ? bFillNight : bFillBackground, 5);
double x2 = center.X + (width / 2 - ((angle - 90) % 3.75 > 0 ? 3 : 6 + ((angle - 90) % 5 > 0 ? 0 : 4))) * Math.Sin((angle - 90) * Math.PI / 180);
double y2 = center.Y - (height / 2 - ((angle - 90) % 3.75 > 0 ? 3 : 6 + ((angle - 90) % 5 > 0 ? 0 : 4))) * Math.Cos((angle - 90) * Math.PI / 180);
g.DrawLine(p, new Point((int)x2, (int)y2), new Point(center.X, center.Y));
};
g.DrawEllipse(kmMiscLinesFill, (int)(center.X - maxRadiusLineScale * sc110kmph), (int)(center.Y - maxRadiusLineScale * sc110kmph), (int)(maxRadiusLineScale * sc110kmph) * 2, (int)(maxRadiusLineScale * sc110kmph) * 2);
g.DrawEllipse(kmMiscLinesPen, (int)(center.X - maxRadiusLineScale * sc110kmph), (int)(center.Y - maxRadiusLineScale * sc110kmph), (int)(maxRadiusLineScale * sc110kmph) * 2, (int)(maxRadiusLineScale * sc110kmph) * 2);
g.DrawEllipse(kmMiscLinesFill, (int)(center.X - maxRadiusLineScale * sc90kmph), (int)(center.Y - maxRadiusLineScale * sc90kmph), (int)(maxRadiusLineScale * sc90kmph) * 2, (int)(maxRadiusLineScale * sc90kmph) * 2);
g.DrawEllipse(kmMiscLinesPen, (int)(center.X - maxRadiusLineScale * sc90kmph), (int)(center.Y - maxRadiusLineScale * sc90kmph), (int)(maxRadiusLineScale * sc90kmph) * 2, (int)(maxRadiusLineScale * sc90kmph) * 2);
for (double angle = 0; angle < 360; angle += 15)
{
bool fillNight = _vSR && _vSS && (!(angle > (sunriseAngle) && (angle < (sunsetAngle))));
Pen p = new Pen(fillNight ? bFillNight : bFillBackground, 7);
double x2 = center.X + (maxRadiusLineScale * sc125kmph - 1) * Math.Sin((angle - 90) * Math.PI / 180);
double y2 = center.Y - (maxRadiusLineScale * sc125kmph - 1) * Math.Cos((angle - 90) * Math.PI / 180);
g.DrawLine(p, new Point((int)x2, (int)y2), new Point(center.X, center.Y));
double x1 = center.X + (maxRadiusLineScale * sc0kmph - 1) * Math.Sin((angle - 90) * Math.PI / 180);
double y1 = center.Y - (maxRadiusLineScale * sc0kmph - 1) * Math.Cos((angle - 90) * Math.PI / 180);
g.DrawLine(HoursDelimPen, new Point((int)x2, (int)y2), new Point((int)x1, (int)y1));
};
g.DrawEllipse(new Pen(Color.Brown, 3), (int)(center.X - maxRadiusLineScale * sc0kmph), (int)(center.Y - maxRadiusLineScale * sc0kmph), (int)(maxRadiusLineScale * sc0kmph) * 2, (int)(maxRadiusLineScale * sc0kmph) * 2);
for (int i = 0; i < 4; i++)
{
drawRotatedBgText(g, (int)(center.X + (maxRadiusLineScale - 1) * sc20kmph * Math.Sin((i * 90 - 67.5) * Math.PI / 180)), (int)(center.Y - (maxRadiusLineScale - 1) * sc20kmph * Math.Cos((i * 90 - 67.5) * Math.PI / 180)), (float)(i * 90 - 67.5), "20êì/÷", kmphFont, kmFontBrush, _vSR && _vSS && (!((i * 90 + 90 - 67.5) > (sunriseAngle) && ((i * 90 + 90 - 67.5) < (sunsetAngle)))) ? bFillNight : bFillBackground);
drawRotatedBgText(g, (int)(center.X + (maxRadiusLineScale - 1) * sc40kmph * Math.Sin((i * 90 - 52.5) * Math.PI / 180)), (int)(center.Y - (maxRadiusLineScale - 1) * sc40kmph * Math.Cos((i * 90 - 52.5) * Math.PI / 180)), (float)(i * 90 - 52.5), "40êì/÷", kmphFont, kmFontBrush, _vSR && _vSS && (!((i * 90 + 90 - 52.5) > (sunriseAngle) && ((i * 90 + 90 - 52.5) < (sunsetAngle)))) ? bFillNight : bFillBackground);
drawRotatedBgText(g, (int)(center.X + (maxRadiusLineScale - 1) * sc60kmph * Math.Sin((i * 90 - 37.5) * Math.PI / 180)), (int)(center.Y - (maxRadiusLineScale - 1) * sc60kmph * Math.Cos((i * 90 - 37.5) * Math.PI / 180)), (float)(i * 90 - 37.5), "60êì/÷", kmphFont, kmFontBrush, _vSR && _vSS && (!((i * 90 + 90 - 37.5) > (sunriseAngle) && ((i * 90 + 90 - 37.5) < (sunsetAngle)))) ? bFillNight : bFillBackground);
drawRotatedBgText(g, (int)(center.X + (maxRadiusLineScale - 1) * sc80kmph * Math.Sin((i * 90 - 22.5) * Math.PI / 180)), (int)(center.Y - (maxRadiusLineScale - 1) * sc80kmph * Math.Cos((i * 90 - 22.5) * Math.PI / 180)), (float)(i * 90 - 22.5), "80êì/÷", kmphFont, kmFontBrush, _vSR && _vSS && (!((i * 90 + 90 - 22.5) > (sunriseAngle) && ((i * 90 + 90 - 22.5) < (sunsetAngle)))) ? bFillNight : bFillBackground);
drawRotatedBgText(g, (int)(center.X + (maxRadiusLineScale - 1) * sc100kmph * Math.Sin((i * 90 - 7.5) * Math.PI / 180)), (int)(center.Y - (maxRadiusLineScale - 1) * sc100kmph * Math.Cos((i * 90 - 7.5) * Math.PI / 180)), (float)(i * 90 - 7.5), "100êì/÷", kmphFont, kmFontBrush, _vSR && _vSS && (!((i * 90 + 90 - 7.5) > (sunriseAngle) && ((i * 90 + 90 - 7.5) < (sunsetAngle)))) ? bFillNight : bFillBackground);
drawRotatedBgText(g, (int)(center.X + (maxRadiusLineScale - 1) * sc120kmph * Math.Sin((i * 90 + 7.5) * Math.PI / 180)), (int)(center.Y - (maxRadiusLineScale - 1) * sc120kmph * Math.Cos((i * 90 + 7.5) * Math.PI / 180)), (float)(i * 90 + 7.5), "120êì/÷", kmphFont, kmFontBrush, _vSR && _vSS && (!((i * 90 + 90 + 7.5) > (sunriseAngle) && ((i * 90 + 90 + 7.5) < (sunsetAngle)))) ? bFillNight : bFillBackground);
};
// MINUTES
for (double angle = 0; angle < 360; angle += 1.25)
{
Pen p = new Pen(Brushes.Brown, 1);
double x1 = center.X + (width / 2) * Math.Sin(angle * Math.PI / 180);
double y1 = center.Y - (height / 2) * Math.Cos(angle * Math.PI / 180);
double x2 = center.X + (width / 2 - (angle % 3.75 > 0 ? 3 : 6 + (angle % 5 > 0 ? 0 : 4))) * Math.Sin(angle * Math.PI / 180);
double y2 = center.Y - (height / 2 - (angle % 3.75 > 0 ? 3 : 6 + (angle % 5 > 0 ? 0 : 4))) * Math.Cos(angle * Math.PI / 180);
g.DrawLine(p, new Point((int)x1, (int)y1), new Point((int)x2, (int)y2));
x1 = center.X + (maxRadiusLineScale * sc0kmph + (angle % 3.75 > 0 ? 3 : 6 + (angle % 5 > 0 ? 0 : 4))) * Math.Sin((angle - 180) * Math.PI / 180);
y1 = center.Y - (maxRadiusLineScale * sc0kmph + (angle % 3.75 > 0 ? 3 : 6 + (angle % 5 > 0 ? 0 : 4))) * Math.Cos((angle - 180) * Math.PI / 180);
x2 = center.X + (maxRadiusLineScale * sc0kmph) * Math.Sin((angle - 180) * Math.PI / 180);
y2 = center.Y - (maxRadiusLineScale * sc0kmph) * Math.Cos((angle - 180) * Math.PI / 180);
g.DrawLine(p, new Point((int)x1, (int)y1), new Point((int)x2, (int)y2));
};
// HOURS
for (int hour = 1; hour < 25; hour += 1)
{
int angle = 90 + 15 * hour;
string txt = hour.ToString();
SizeF tSize = g.MeasureString(txt, hoursFont);
double dx = (width / 2 - tSize.Width / 2 - 4) * Math.Sin((angle - 180) * Math.PI / 180);
double dy = (height / 2 - tSize.Height / 2 - 4) * Math.Cos((angle - 180) * Math.PI / 180);
int x = (int)(center.X + dx);
int y = (int)(center.Y - dy);
drawRotatedText(g, x, y, 180 + angle, txt, hoursFont, HoursFontBrush);
tSize = g.MeasureString(txt, hoursSmallFont);
double x1 = center.X + (maxRadiusLineScale * sc0kmph + 4) * Math.Sin((angle - 180) * Math.PI / 180);
double y1 = center.Y - (maxRadiusLineScale * sc0kmph + 4) * Math.Cos((angle - 180) * Math.PI / 180);
drawRotatedText(g, (int)x1, (int)y1, 180 + angle, txt, hoursSmallFont, HoursFontBrush);
};
g.FillEllipse(bFillBackground, new Rectangle((int)(center.X - maxRadiusLineScale * sc0kmph) + 3, (int)(center.Y - maxRadiusLineScale * sc0kmph) + 3, (int)(maxRadiusLineScale * sc0kmph) * 2 - 6, (int)(maxRadiusLineScale * sc0kmph) * 2 - 6));
// Activity
g.DrawEllipse(activityPen, (int)(center.X - maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 0))), (int)(center.Y - maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 0))), (int)(maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 0))) * 2, (int)(maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 0))) * 2);
g.DrawEllipse(activityPen, (int)(center.X - maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 1))), (int)(center.Y - maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 1))), (int)(maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 1))) * 2, (int)(maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 1))) * 2);
g.DrawEllipse(activityPen, (int)(center.X - maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 2))), (int)(center.Y - maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 2))), (int)(maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 2))) * 2, (int)(maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 2))) * 2);
g.DrawEllipse(activityPen, (int)(center.X - maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 3))), (int)(center.Y - maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 3))), (int)(maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 3))) * 2, (int)(maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 3))) * 2);
g.DrawEllipse(activityPen, (int)(center.X - maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 4))), (int)(center.Y - maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 4))), (int)(maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 4))) * 2, (int)(maxRadiusLineScale * (sc0kmph - scActivityOffset - (scActivityScale * 4))) * 2);
for (double angle = 0; angle < 360; angle += 15 / 4)
{
Pen p = new Pen(bFillBackground, 4);
double x1 = center.X + maxRadiusLineScale * (sc0kmph - scActivityOffset) * Math.Sin(angle * Math.PI / 180);
double y1 = center.Y - maxRadiusLineScale * (sc0kmph - scActivityOffset) * Math.Cos(angle * Math.PI / 180);
double x2 = center.X + maxRadiusLineScale * (scActivityInside) * Math.Sin(angle * Math.PI / 180);
double y2 = center.Y - maxRadiusLineScale * (scActivityInside) * Math.Cos(angle * Math.PI / 180);
g.DrawLine(p, new Point((int)x1, (int)y1), new Point((int)x2, (int)y2));
if (angle % 15 == 0)
g.DrawLine(HoursDelimPen, new Point((int)x2, (int)y2), new Point((int)x1, (int)y1));
};
g.DrawEllipse(activityPenBold, (int)(center.X - maxRadiusLineScale * scActivityInside), (int)(center.Y - maxRadiusLineScale * scActivityInside), (int)(maxRadiusLineScale * scActivityInside) * 2, (int)(maxRadiusLineScale * scActivityInside) * 2);
g.DrawEllipse(activityPenBold, (int)(center.X - maxRadiusLineScale * (scActivityInside - scActivityOffset)), (int)(center.Y - maxRadiusLineScale * (scActivityInside - scActivityOffset)), (int)(maxRadiusLineScale * (scActivityInside - scActivityOffset)) * 2, (int)(maxRadiusLineScale * (scActivityInside - scActivityOffset)) * 2);
for (int i = 0; i < 4; i++)
{
drawRotatedImage(g, (int)(center.X + (maxRadiusLineScale * (scActivityInside + scActivityOffset + scActivityScale * 3.4)) * Math.Sin((i * 90 + 22.5) * Math.PI / 180)), (int)(center.Y - (maxRadiusLineScale * (scActivityInside + scActivityOffset + scActivityScale * 3.4)) * Math.Cos((i * 90 + 22.5) * Math.PI / 180)), (float)(i * 90 + 22.5), global::KMZRebuilder.Properties.Resources._01DRIVE);
drawRotatedImage(g, (int)(center.X + (maxRadiusLineScale * (scActivityInside + scActivityOffset + scActivityScale * 2.4)) * Math.Sin((i * 90 + 7.5) * Math.PI / 180)), (int)(center.Y - (maxRadiusLineScale * (scActivityInside + scActivityOffset + scActivityScale * 2.4)) * Math.Cos((i * 90 + 7.5) * Math.PI / 180)), (float)(i * 90 + 7.5), global::KMZRebuilder.Properties.Resources._02WORK);
drawRotatedImage(g, (int)(center.X + (maxRadiusLineScale * (scActivityInside + scActivityOffset + scActivityScale * 1.4)) * Math.Sin((i * 90 - 7.5) * Math.PI / 180)), (int)(center.Y - (maxRadiusLineScale * (scActivityInside + scActivityOffset + scActivityScale * 1.4)) * Math.Cos((i * 90 - 7.5) * Math.PI / 180)), (float)(i * 90 - 15), global::KMZRebuilder.Properties.Resources._04PERIODS);
drawRotatedImage(g, (int)(center.X + (maxRadiusLineScale * (scActivityInside + scActivityOffset + scActivityScale * 0.4)) * Math.Sin((i * 90 - 22.5) * Math.PI / 180)), (int)(center.Y - (maxRadiusLineScale * (scActivityInside + scActivityOffset + scActivityScale * 0.4)) * Math.Cos((i * 90 - 22.5) * Math.PI / 180)), (float)(i * 90 - 22.5), global::KMZRebuilder.Properties.Resources._03REST);
};
// 24:00
{
Pen p = new Pen(bFillBackground, 4);
double x1 = center.X + maxRadiusLineScale * (sc0kmph) * Math.Sin(-90 * Math.PI / 180);
double y1 = center.Y - maxRadiusLineScale * (sc0kmph) * Math.Cos(-90 * Math.PI / 180);
double x2 = center.X + maxRadiusLineScale * (scActivityInside) * Math.Sin(-90 * Math.PI / 180);
double y2 = center.Y - maxRadiusLineScale * (scActivityInside) * Math.Cos(-90 * Math.PI / 180);
g.DrawLine(Pens.Navy, new Point(0, center.Y), new Point((int)x1, (int)y1));
g.DrawLine(Pens.Maroon, new Point((int)x1, (int)y1), new Point((int)x2, (int)y2));
}
// SUN PERIODS
if (_vSR || _vSS)
{
if (_vSR)
{
double x1 = center.X + this.width / 2 * Math.Sin((sunriseAngle - 90) * Math.PI / 180);
double y1 = center.Y - this.width / 2 * Math.Cos((sunriseAngle - 90) * Math.PI / 180);
double x2 = center.X + maxRadiusLineScale * (sc0kmph) * Math.Sin((sunriseAngle - 90) * Math.PI / 180);
double y2 = center.Y - maxRadiusLineScale * (sc0kmph) * Math.Cos((sunriseAngle - 90) * Math.PI / 180);
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(120, Color.DarkGoldenrod)), 3), new Point((int)x1, (int)y1), new Point((int)x2, (int)y2));
};
if (_vSS)
{
double x1 = center.X + this.width / 2 * Math.Sin((sunsetAngle - 90) * Math.PI / 180);
double y1 = center.Y - this.width / 2 * Math.Cos((sunsetAngle - 90) * Math.PI / 180);
double x2 = center.X + maxRadiusLineScale * (sc0kmph) * Math.Sin((sunsetAngle - 90) * Math.PI / 180);
double y2 = center.Y - maxRadiusLineScale * (sc0kmph) * Math.Cos((sunsetAngle - 90) * Math.PI / 180);
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(120, Color.DarkRed)), 3), new Point((int)x1, (int)y1), new Point((int)x2, (int)y2));
};
};
// LOGO
{
string tLogo = "GPX Tacho";
Font logoF = new Font("Arial", 10, FontStyle.Bold);
SizeF mLogo = g.MeasureString(tLogo, logoF);
g.DrawString(tLogo, logoF, new SolidBrush(Color.FromArgb(200, 200, 200)), new PointF(center.X - mLogo.Width / 2, (float)(center.Y - maxRadiusLineScale * (scActivityInside - scActivityOffset) + mLogo.Height / 2)));
};
// LINES AND SYMBOLS
{
//DRIVER
double x1 = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-55 * Math.PI / 180);
double y1 = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-55 * Math.PI / 180);
double x2 = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(55 * Math.PI / 180);
double y2 = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(55 * Math.PI / 180);
g.DrawLine(kmMiscLinesFill, (float)x1, (float)y2, (float)x2, (float)y2);
double xi = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-55 * Math.PI / 180);
double yi = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-55 * Math.PI / 180);
g.DrawImage(global::KMZRebuilder.Properties.Resources._05DRIVER, (float)xi, (float)yi - 17);
//START POINT
x1 = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-67 * Math.PI / 180);
y1 = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-67 * Math.PI / 180);
x2 = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(67 * Math.PI / 180);
y2 = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(67 * Math.PI / 180);
g.DrawLine(kmMiscLinesFill, (float)x1, (float)y2, (float)x2, (float)y2);
xi = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-67 * Math.PI / 180);
yi = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-67 * Math.PI / 180);
g.DrawImage(global::KMZRebuilder.Properties.Resources._06START, (float)xi, (float)yi - 17);
//END POINT
x1 = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-79 * Math.PI / 180);
y1 = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-79 * Math.PI / 180);
x2 = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(79 * Math.PI / 180);
y2 = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(79 * Math.PI / 180);
g.DrawLine(kmMiscLinesFill, (float)x1, (float)y2, (float)x2, (float)y2);
g.DrawLine(kmMiscLinesFill, (float)x1, (float)y2, (float)x2, (float)y2);
xi = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-79 * Math.PI / 180);
yi = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-79 * Math.PI / 180);
g.DrawImage(global::KMZRebuilder.Properties.Resources._07FINISH, (float)xi, (float)yi - 17);
//TACHO INSERTED
x1 = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-91 * Math.PI / 180);
y1 = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-91 * Math.PI / 180);
x2 = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(91 * Math.PI / 180);
y2 = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(91 * Math.PI / 180);
g.DrawLine(kmMiscLinesFill, (float)x1, (float)y2, (float)x2, (float)y2);
xi = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-91 * Math.PI / 180);
yi = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-91 * Math.PI / 180);
g.DrawImage(global::KMZRebuilder.Properties.Resources._10STARTD, (float)xi, (float)yi - 17);
//TACHO REMOVED
x1 = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-103 * Math.PI / 180);
y1 = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-103 * Math.PI / 180);
x2 = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(103 * Math.PI / 180);
y2 = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(103 * Math.PI / 180);
g.DrawLine(kmMiscLinesFill, (float)x1, (float)y2, (float)x2, (float)y2);
xi = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-103 * Math.PI / 180);
yi = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-103 * Math.PI / 180);
g.DrawImage(global::KMZRebuilder.Properties.Resources._11FINISHD, (float)xi, (float)yi - 17);
//VEHICLE
x1 = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-115 * Math.PI / 180);
y1 = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-115 * Math.PI / 180);
x2 = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(115 * Math.PI / 180);
y2 = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(115 * Math.PI / 180);
g.DrawLine(kmMiscLinesFill, (float)x1, (float)y2, (float)x2, (float)y2);
xi = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-115 * Math.PI / 180);
yi = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-115 * Math.PI / 180);
g.DrawImage(global::KMZRebuilder.Properties.Resources._12VEHICLE, (float)xi, (float)yi - 17);
//ODO START
x1 = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-127 * Math.PI / 180);
y1 = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-127 * Math.PI / 180);
x2 = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(127 * Math.PI / 180);
y2 = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(127 * Math.PI / 180);
g.DrawLine(kmMiscLinesFill, (float)x1, (float)y2, (float)x2, (float)y2);
xi = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-127 * Math.PI / 180);
yi = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-127 * Math.PI / 180);
g.DrawImage(global::KMZRebuilder.Properties.Resources._08KMSTART, (float)xi, (float)yi - 17);
//ODO END
x1 = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-139 * Math.PI / 180);
y1 = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-139 * Math.PI / 180);
x2 = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(139 * Math.PI / 180);
y2 = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(139 * Math.PI / 180);
xi = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-139 * Math.PI / 180);
yi = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-139 * Math.PI / 180);
g.DrawImage(global::KMZRebuilder.Properties.Resources._09KMFINISH, (float)xi, (float)yi - 17);
g.DrawLine(kmMiscLinesFill, (float)x1, (float)y2, (float)x2, (float)y2);
//
x1 = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-155 * Math.PI / 180);
y1 = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-155 * Math.PI / 180);
x2 = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(155 * Math.PI / 180);
y2 = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(155 * Math.PI / 180);
g.DrawLine(kmMiscLinesFill, (float)x1, (float)y2, (float)x2, (float)y2);
};
g.FillEllipse(bFillBackground, new Rectangle((int)(center.X - maxRadiusLineScale * 0.09), (int)(center.Y - maxRadiusLineScale * 0.09), (int)(maxRadiusLineScale * 0.09) * 2, (int)(maxRadiusLineScale * 0.09) * 2));
g.DrawEllipse(Pens.Silver, new Rectangle((int)(center.X - maxRadiusLineScale * 0.09), (int)(center.Y - maxRadiusLineScale * 0.09), (int)(maxRadiusLineScale * 0.09) * 2, (int)(maxRadiusLineScale * 0.09) * 2));
}
/// <summary>
/// Draw Rotated Text
/// </summary>
/// <param name="g">graph</param>
/// <param name="x">x position</param>
/// <param name="y">y position</param>
/// <param name="angle">rotate anle</param>
/// <param name="text">text</param>
/// <param name="font">font</param>
/// <param name="brush">color</param>
private void drawRotatedText(Graphics g, int x, int y, float angle, string text, Font font, Brush brush)
{
g.TranslateTransform(x, y); // Set rotation point
g.RotateTransform(angle); // Rotate text
g.TranslateTransform(-x, -y); // Reset translate transform
SizeF size = g.MeasureString(text, font); // Get size of rotated text (bounding box)
g.DrawString(text, font, brush, new PointF(x - size.Width / 2.0f, y - size.Height / 2.0f)); // Draw string centered in x, y
g.ResetTransform(); // Only needed if you reuse the Graphics object for multiple calls to DrawString
}
/// <summary>
/// Draw Rotated Text with background
/// </summary>
/// <param name="g">graph</param>
/// <param name="x">x position</param>
/// <param name="y">y position</param>
/// <param name="angle">rotate anle</param>
/// <param name="text">text</param>
/// <param name="font">font</param>
/// <param name="brush">color</param>
/// <param name="Fill">background</param>
private void drawRotatedBgText(Graphics g, int x, int y, float angle, string text, Font font, Brush brush, Brush Fill)
{
g.TranslateTransform(x, y); // Set rotation point
g.RotateTransform(angle); // Rotate text
g.TranslateTransform(-x, -y); // Reset translate transform
SizeF size = g.MeasureString(text, font); // Get size of rotated text (bounding box)
g.FillRectangle(Fill, new Rectangle((int)(x - size.Width / 2.0f - 3), (int)(y - size.Height / 2.0f - 3), (int)size.Width + 6, (int)size.Height + 6));
g.DrawString(text, font, brush, new PointF(x - size.Width / 2.0f, y - size.Height / 2.0f)); // Draw string centered in x, y
g.ResetTransform(); // Only needed if you reuse the Graphics object for multiple calls to DrawString
}
/// <summary>
/// Draw Rotated Image
/// </summary>
/// <param name="g">graph</param>
/// <param name="x">x position</param>
/// <param name="y">y position</param>
/// <param name="angle">rotate anle</param>
/// <param name="image">image</param>
private void drawRotatedImage(Graphics g, int x, int y, float angle, Bitmap image)
{
g.TranslateTransform(x, y); // Set rotation point
g.RotateTransform(angle); // Rotate text
g.TranslateTransform(-x, -y); // Reset translate transform
g.DrawImage(image, new Point((int)(x - image.Width / 2.0), (int)(y - image.Height / 2.0)));
g.ResetTransform(); // Only needed if you reuse the Graphics object for multiple calls to DrawString
}
/// <summary>
/// Draw text zone data
/// </summary>
private void DrawTexts()
{
//DRIVER
double xi = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-55 * Math.PI / 180);
double yi = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-55 * Math.PI / 180);
SizeF sz = g.MeasureString(_driverText, textFont);
g.DrawString(_driverText, textFont, textBrush2, AlignTextToCenter ? center.X - sz.Width / 2 : (float)xi + 16, (float)yi - 15); ;
//START POINT
xi = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-67 * Math.PI / 180);
yi = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-67 * Math.PI / 180);
sz = g.MeasureString(_startFrom, textFont);
g.DrawString(_startFrom, textFont, textBrush1, AlignTextToCenter ? center.X - sz.Width / 2 : (float)xi + 16, (float)yi - 15); ;
//END POINT
xi = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-79 * Math.PI / 180);
yi = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-79 * Math.PI / 180);
sz = g.MeasureString(_endTo, textFont);
g.DrawString(_endTo, textFont, textBrush1, AlignTextToCenter ? center.X - sz.Width / 2 : (float)xi + 16, (float)yi - 15); ;
//TACHO INSERTED
xi = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-91 * Math.PI / 180);
yi = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-91 * Math.PI / 180);
sz = g.MeasureString(_startDT, textFont);
g.DrawString(_startDT, textFont, textBrush2, AlignTextToCenter ? center.X - sz.Width / 2 : (float)xi + 16, (float)yi - 15); ;
//TACHO REMOVED
xi = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-103 * Math.PI / 180);
yi = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-103 * Math.PI / 180);
sz = g.MeasureString(_endDT, textFont);
g.DrawString(_endDT, textFont, textBrush2, AlignTextToCenter ? center.X - sz.Width / 2 : (float)xi + 16, (float)yi - 15); ;
//VEHICLE
xi = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-115 * Math.PI / 180);
yi = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-115 * Math.PI / 180);
sz = g.MeasureString(_vehicle, textFont);
g.DrawString(_vehicle, textFont, textBrush3, AlignTextToCenter ? center.X - sz.Width / 2 : (float)xi + 16, (float)yi - 15); ;
//ODO START
xi = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-127 * Math.PI / 180);
yi = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-127 * Math.PI / 180);
sz = g.MeasureString(_startKM, textFont);
g.DrawString(_startKM, textFont, textBrush3, AlignTextToCenter ? center.X - sz.Width / 2 : (float)xi + 16, (float)yi - 15); ;
//ODO END
xi = center.X + (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Sin(-139 * Math.PI / 180);
yi = center.Y - (maxRadiusLineScale * (scActivityInside - scActivityOffset * 2)) * Math.Cos(-139 * Math.PI / 180);
sz = g.MeasureString(_endKM, textFont);
g.DrawString(_endKM, textFont, textBrush3, AlignTextToCenter ? center.X - sz.Width / 2 : (float)xi + 16, (float)yi - 15);
//CIRCLES
g.DrawEllipse(activityPenBold, (int)(center.X - maxRadiusLineScale * scActivityInside), (int)(center.Y - maxRadiusLineScale * scActivityInside), (int)(maxRadiusLineScale * scActivityInside) * 2, (int)(maxRadiusLineScale * scActivityInside) * 2);
g.DrawEllipse(activityPenBold, (int)(center.X - maxRadiusLineScale * (scActivityInside - scActivityOffset)), (int)(center.Y - maxRadiusLineScale * (scActivityInside - scActivityOffset)), (int)(maxRadiusLineScale * (scActivityInside - scActivityOffset)) * 2, (int)(maxRadiusLineScale * (scActivityInside - scActivityOffset)) * 2);