-
Notifications
You must be signed in to change notification settings - Fork 2
/
MilitarySymbolToGraphicLayersMaker.cs
769 lines (604 loc) · 30.4 KB
/
MilitarySymbolToGraphicLayersMaker.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
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MilitarySymbols
{
/// <summary>
/// General processing is to convert a Symbol Id Code into a list of strings
/// These strings represent the paths to the set of images/layers that *should*
/// represent that Symbol Id
/// For convenience, it takes a MilitarySymbol object in it main entry method:
/// SetMilitarySymbolGraphicLayers and sets the GraphicLayers to these strings
/// We might also replace this complicated logic with a table lookup, but for now
/// it is a nice way to validate that the rules are actually consistent.
/// </summary>
public class MilitarySymbolToGraphicLayersMaker
{
// IMPORTANT: defaults to {exe folder}\MIL_STD_2525D_Symbols (mainly for deployment)
private static readonly string DEFAULT_PATH =
System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"MIL_STD_2525D_Symbols");
// IMPORTANT: - OR - you can set this at Runtime with
// Utilities.SetImageFilesHome -or- MilitarySymbolToGraphicLayersMaker.ImageFilesHome
// Allow this property to be set externally at runtime (if desired/needed)
public static string ImageFilesHome
{
get { return imageFilesHome; }
set
{
string checkForDirectorySeparator = value;
// but make sure it ends in a DirectorySeparatorChar
checkForDirectorySeparator =
checkForDirectorySeparator.TrimEnd(System.IO.Path.DirectorySeparatorChar) +
System.IO.Path.DirectorySeparatorChar;
imageFilesHome = checkForDirectorySeparator;
}
}
private static string imageFilesHome =
DEFAULT_PATH
+ System.IO.Path.DirectorySeparatorChar; // IMPORTANT/NOTE: Ends in DirectorySeparator
const string ImageSuffix = ".svg";
public static bool AddReferenceCenterPoint
{
get;
set;
}
public static bool UseCivilianFrames
{
get;
set;
}
// IMPORTANT: If you don't have the expected SVG Files, in the expected folder format
// then this class will not do anything.
// The assumed/expected Folder structure:
// {ImageFilesHome} <--- SEE DEFINITION BELOW
// |- Echelon
// |- Frames
// |- Headquarters
// |- Appendices
// |- Air
// |- Control Measures
// |- Cyberspace
// |- Land
// (etc.)
public static string GetIconFolderName(SymbolSetType symbolSet)
{
StringBuilder sb = new StringBuilder();
sb.Append("Appendices");
sb.Append(System.IO.Path.DirectorySeparatorChar);
string symbolSetSubFolderName = string.Empty;
if (TypeUtilities.SymbolSetToFolderName.ContainsKey(symbolSet))
symbolSetSubFolderName = TypeUtilities.SymbolSetToFolderName[symbolSet];
sb.Append(symbolSetSubFolderName);
sb.Append(System.IO.Path.DirectorySeparatorChar);
return sb.ToString();
}
public static string GetMainIconName(SymbolSetType symbolSet, string fullEntityCode)
{
if (fullEntityCode.Length != 6)
{
return "00000000";
}
StringBuilder sb = new StringBuilder();
string symbolSetString = TypeUtilities.EnumHelper.getEnumValAsString(symbolSet, 2);
sb.Append(symbolSetString);
sb.Append(fullEntityCode);
return sb.ToString();
}
public static string GetMainIconName(ref MilitarySymbol milSymbol)
{
string mainIcon;
if (milSymbol.Id.IsLandUnitSpecialEntity) // Special/Exceptional Case for this
{
string altEntityCode = milSymbol.Id.EntityField + milSymbol.Id.EntityTypeField + "00";
mainIcon = GetMainIconName(milSymbol.Id.SymbolSet, altEntityCode);
}
else
mainIcon = GetMainIconName(milSymbol.Id.SymbolSet, milSymbol.Id.EntityCode);
return mainIcon;
}
// MainIconNameWithFolder
// Appendices\{SymbolSetTypeName}\SymbolSetType + EntityCode
// e.g. Appendices\Air\01110000.svg ==> { 01 } + { 110000 }
public static string GetMainIconNameWithFolder(ref MilitarySymbol milSymbol)
{
StringBuilder sb = new StringBuilder();
string currentAppendixHome = GetIconFolderName(milSymbol.Id.SymbolSet);
sb.Append(currentAppendixHome);
string mainIconName = GetMainIconName(ref milSymbol);
sb.Append(mainIconName);
sb.Append(ImageSuffix);
return sb.ToString();
}
// same as ImageFilesHome + GetMainIconNameWithFolder
public static string GetMainIconNameWithFullPath(ref MilitarySymbol milSymbol)
{
StringBuilder sb = new StringBuilder();
sb.Append(ImageFilesHome);
string mainIconNameWithoutImageFilesHome = GetMainIconNameWithFolder(ref milSymbol);
sb.Append(mainIconNameWithoutImageFilesHome);
string mainIconNameFullPath = sb.ToString();
// WORKAROUND/TRICKY: some center icon symbols that need to touch fram have _0, _1, _2, _3 suffix instead of base version
// Method: Find the frame suffix from the affiliation & add _0, _1, _2, _3 accordingly
// Also test for 2 other exceptional cases while we are at it
if (!System.IO.File.Exists(mainIconNameFullPath))
{
StandardIdentityAffiliationType mappedAffiliation = milSymbol.Id.Affiliation;
if (milSymbol.Id.StandardIdentity == StandardIdentityRealExerciseSimType.Exercise)
{
// Exceptional case for these 2 (has a friend frame)
if ((mappedAffiliation == StandardIdentityAffiliationType.Suspect_Joker) ||
(mappedAffiliation == StandardIdentityAffiliationType.Hostile))
mappedAffiliation = StandardIdentityAffiliationType.Friend;
}
string newFrameSuffix =
TypeUtilities.AffiliationFrameToSuffixName[mappedAffiliation] + ImageSuffix;
// more exceptional cases:
if (milSymbol.Id.SymbolSet == SymbolSetType.Control_Measures)
{
// use ".a" instead - 6 symbols
newFrameSuffix = ".a" + ImageSuffix;
}
else if (milSymbol.Id.SymbolSet == SymbolSetType.Atmospheric)
{
// use ".0" instead - only 1 symbol 45140200.0
newFrameSuffix = ".0" + ImageSuffix;
}
string subMainIconName = mainIconNameFullPath;
subMainIconName = subMainIconName.Replace(ImageSuffix, newFrameSuffix);
if (System.IO.File.Exists(subMainIconName)) // if the other file/version exists, use that one
mainIconNameFullPath = subMainIconName;
}
return mainIconNameFullPath;
}
public static string GetModfierIconName(SymbolSetType symbolSet, int modifierNumber, int modifierCodeInt)
{
StringBuilder sb = new StringBuilder();
if (!((modifierNumber == 1) || (modifierNumber == 2)))
return string.Empty;
string sModifierNumber = modifierNumber.ToString();
string modifierCode = modifierCodeInt.ToString();
// this one has to be 2 chars:
if (modifierCode.Length < 2)
modifierCode = modifierCode.PadLeft(2, '0');
string symbolSetString = TypeUtilities.EnumHelper.getEnumValAsString(symbolSet, 2);
string modifierIcon = symbolSetString + modifierCode + sModifierNumber;
sb.Append(modifierIcon);
return sb.ToString();
}
public static string GetModfierIconName(ref MilitarySymbol milSymbol, int modifierNumber)
{
StringBuilder sb = new StringBuilder();
if (!((modifierNumber == 1) || (modifierNumber == 2)))
return string.Empty;
string sModifierNumber = "1";
string sModifier = milSymbol.Id.ModifierOne;
if (modifierNumber == 2)
{
sModifierNumber = "2";
sModifier = milSymbol.Id.ModifierTwo;
}
string symbolSetString = TypeUtilities.EnumHelper.getEnumValAsString(milSymbol.Id.SymbolSet, 2);
string modifierIcon = symbolSetString + sModifier + sModifierNumber;
sb.Append(modifierIcon);
return sb.ToString();
}
// Center/Main Icon Modifiers: { # = 1 | 2 }, format =
// Appendices\{SymbolSetTypeName}\Mod{#}\{SymbolSetType} + {ModifierCode} + {#}
public static string GetModfierIconNameWithFolder(SymbolSetType symbolSet, int modifierNumber, int modifierCodeInt)
{
StringBuilder sb = new StringBuilder();
if (!((modifierNumber == 1) || (modifierNumber == 2)))
return string.Empty;
string sSubFolderName = "mod" + modifierNumber.ToString();
string currentAppendixHome = GetIconFolderName(symbolSet);
sb.Append(currentAppendixHome);
sb.Append(sSubFolderName);
sb.Append(System.IO.Path.DirectorySeparatorChar);
string modifierIcon = GetModfierIconName(symbolSet, modifierNumber, modifierCodeInt);
sb.Append(modifierIcon);
sb.Append(ImageSuffix);
return sb.ToString();
}
// same as ImageFilesHome + GetModfierIconNameWithFolder
public static string GetModfierIconNameWithFullPath(SymbolSetType symbolSet, int modifierNumber, int modifierCodeInt)
{
StringBuilder sb = new StringBuilder();
sb.Append(ImageFilesHome);
string modifierIconNameWithoutImageFilesHome = GetModfierIconNameWithFolder(
symbolSet, modifierNumber, modifierCodeInt);
sb.Append(modifierIconNameWithoutImageFilesHome);
return sb.ToString();
}
public static string GetModfierIconNameWithFolder(ref MilitarySymbol milSymbol, int modifierNumber)
{
if (!((modifierNumber == 1) || (modifierNumber == 2)))
return string.Empty;
string sModifierCode = (modifierNumber == 1) ? milSymbol.Id.ModifierOne : milSymbol.Id.ModifierTwo;
int modifierCodeInt = Convert.ToInt32(sModifierCode);
string modifierIconNameWithFolder = GetModfierIconNameWithFolder(
milSymbol.Id.SymbolSet, modifierNumber, modifierCodeInt);
return modifierIconNameWithFolder;
}
// Echelon/Mobility/Towed Array Amplifier Icon
// = StandardIdentityAffiliationType + EchelonMobilityType
// "Amplifier (Echelon): Uses SIDC positions 4 and 9-10."
// ex. Friend, Team Crew = 311
// --> 3 (Friend) + 11 (Echelon = Team/Crew)
//
public static string GetEchelonIconNameWithFolder(
SymbolSetType symbolSet,
StandardIdentityAffiliationType affiliation,
EchelonMobilityType echelonMobility)
{
if (echelonMobility == EchelonMobilityType.NoEchelonMobility)
return string.Empty;
StringBuilder sb = new StringBuilder();
if (echelonMobility < EchelonMobilityType.Wheeled_Limited_Cross_Country)
{
sb.Append("Echelon");
}
else
{
sb.Append("Amplifier");
}
sb.Append(System.IO.Path.DirectorySeparatorChar);
StandardIdentityAffiliationType mappedAffiliation =
TypeUtilities.AffiliationToAffiliationFrameMapping[affiliation];
string affiliationString =
TypeUtilities.EnumHelper.getEnumValAsString(mappedAffiliation, 1);
sb.Append(affiliationString);
// IMPORTANT NOTE:
// Only Land Symbol Sets (Unit, Civilian, Equipment, Installation)
// have echelon symbols so they only match/line up with those frames
string echelonString = TypeUtilities.EnumHelper.getEnumValAsString(echelonMobility, 2);
sb.Append(echelonString);
sb.Append(ImageSuffix);
return sb.ToString();
}
// same as ImageFilesHome + GetEchelonIconNameWithFolder
public static string GetEchelonIconNameWithFullPath(
SymbolSetType symbolSet,
StandardIdentityAffiliationType affiliation,
EchelonMobilityType echelonMobility)
{
if (echelonMobility == EchelonMobilityType.NoEchelonMobility)
return string.Empty;
StringBuilder sb = new StringBuilder();
sb.Append(ImageFilesHome);
string echelonIconNameWithoutImageFilesHome =
GetEchelonIconNameWithFolder(symbolSet, affiliation, echelonMobility);
sb.Append(echelonIconNameWithoutImageFilesHome);
return sb.ToString();
}
// Headquarters(HQ)/Task Force(TF)/Feint/Dummy(FD) HQ/TF/FD Amplifier Icon
// = StandardIdentityAffiliationType + SymbolSetType + HeadquartersTaskForceDummyType
// Uses SIDC positions 4-6 and position 8
// ex. Friend(3), Land_Unit (10), Feint_Dummy (1) = 3101
// --> 3 (Friend) + Land_Unit (10) + 1 (Feint_Dummy)
//
public static string GetHqTfFdIconNameWithFolder(
SymbolSetType symbolSet,
StandardIdentityAffiliationType affiliation,
HeadquartersTaskForceDummyType hqTfFd)
{
if (hqTfFd == HeadquartersTaskForceDummyType.NoHQTFDummyModifier)
return string.Empty;
StringBuilder sb = new StringBuilder();
sb.Append("HQTFFD");
sb.Append(System.IO.Path.DirectorySeparatorChar);
StandardIdentityAffiliationType mappedAffiliation =
TypeUtilities.AffiliationToAffiliationFrameMapping[affiliation];
string affiliationValueString =
TypeUtilities.EnumHelper.getEnumValAsString(mappedAffiliation, 1);
sb.Append(affiliationValueString);
// map the actual symbolSet to the supported/availble frame
SymbolSetType mappedSymbolSet = TypeUtilities.SymbolSetToFrameMapping[symbolSet];
// Exceptional cases for this one
if ((symbolSet == SymbolSetType.Activities) || (symbolSet == SymbolSetType.NotSet) ||
(symbolSet == SymbolSetType.Unknown))
mappedSymbolSet = SymbolSetType.Land_Unit;
string mappedSymbolSetValueString = TypeUtilities.EnumHelper.getEnumValAsString(mappedSymbolSet, 2);
sb.Append(mappedSymbolSetValueString);
string hqTfFdValueString = TypeUtilities.EnumHelper.getEnumValAsString(hqTfFd, 1);
sb.Append(hqTfFdValueString);
sb.Append(ImageSuffix);
return sb.ToString();
}
// same as ImageFilesHome + GetHqTfFdIconNameWithFolder
public static string GetHqTfFdIconNameWithFullPath(
SymbolSetType symbolSet,
StandardIdentityAffiliationType affiliation,
HeadquartersTaskForceDummyType hqTfFd)
{
if (hqTfFd == HeadquartersTaskForceDummyType.NoHQTFDummyModifier)
return string.Empty;
StringBuilder sb = new StringBuilder();
sb.Append(ImageFilesHome);
string hqTfFdIconNameWithoutImageFilesHome =
GetHqTfFdIconNameWithFolder(symbolSet, affiliation, hqTfFd);
sb.Append(hqTfFdIconNameWithoutImageFilesHome);
return sb.ToString();
}
// OperationalCondition Amplifier Icon
// = StandardIdentityAffiliationType + SymbolSetType + StatusType
// Uses SIDC positions 3-7 + "2"
// ex. Friend(03), Land_Unit (10), Damaged (3) = 031012
// --> 03 (Friend) + Land_Unit (10) + 1 (Damaged) + "2" (2nd format)
//
public static string GetOperationalConditionNameWithFolder(
SymbolSetType symbolSet,
StandardIdentityAffiliationType affiliation,
StatusType status)
{
if ((status == StatusType.NotSet) ||
(status == StatusType.Present) ||
(status == StatusType.Planned_Anticipated_Suspect))
return string.Empty;
StringBuilder sb = new StringBuilder();
sb.Append("OCA");
sb.Append(System.IO.Path.DirectorySeparatorChar);
StandardIdentityAffiliationType mappedAffiliation =
TypeUtilities.AffiliationToAffiliationFrameMapping[affiliation];
// TRICKY: used 2 digits for some reason
string affiliationValueString =
TypeUtilities.EnumHelper.getEnumValAsString(mappedAffiliation, 2);
sb.Append(affiliationValueString);
// map the actual symbolSet to the supported/availble frame
SymbolSetType mappedSymbolSet = TypeUtilities.SymbolSetToFrameMapping[symbolSet];
string mappedSymbolSetValueString = TypeUtilities.EnumHelper.getEnumValAsString(mappedSymbolSet, 2);
sb.Append(mappedSymbolSetValueString);
string opConditionString = TypeUtilities.EnumHelper.getEnumValAsString(status, 1);
sb.Append(opConditionString);
sb.Append("2");
sb.Append(ImageSuffix);
return sb.ToString();
}
// same as ImageFilesHome + GetOperationalConditionIconNameWithFolder
public static string GetOperationalConditionNameWithFullPath(
SymbolSetType symbolSet,
StandardIdentityAffiliationType affiliation,
StatusType status)
{
if ((status == StatusType.NotSet) ||
(status == StatusType.Present) ||
(status == StatusType.Planned_Anticipated_Suspect))
return string.Empty;
StringBuilder sb = new StringBuilder();
sb.Append(ImageFilesHome);
string opConditionNameWithoutImageFilesHome =
GetOperationalConditionNameWithFolder(symbolSet, affiliation, status);
sb.Append(opConditionNameWithoutImageFilesHome);
return sb.ToString();
}
// Land Unit Special Entity Icon
public static string GetLandUnitSpecialEntityIconNameWithFullPath(SymbolIdCode id)
{
if (!id.IsLandUnitSpecialEntity)
return string.Empty;
StringBuilder sb = new StringBuilder();
sb.Append(ImageFilesHome);
sb.Append(@"Appendices\Land\10xxxx");
sb.Append(id.EntitySubTypeField);
sb.Append(TypeUtilities.AffiliationFrameToSuffixName[id.Affiliation]);
sb.Append(ImageSuffix);
return sb.ToString();
}
// Frame Icon
// StandardIdentityAffiliationType + SymbolSetType
// IMPORTANT: StandardIdentityAffiliationType must be in
// { Unknown, Space, Air,Land_Unit, Land_Installation,
// Sea_Surface, Subsurface, Activity }
// See: TypeUtilities.SymbolSetToFrameType for mapping
// ex. 0520
public static string GetFrameIconNameWithFolder(
StandardIdentityRealExerciseSimType realExerciseSim,
StandardIdentityAffiliationType affiliation,
SymbolSetType symbolSet,
StatusType status)
{
StringBuilder sb = new StringBuilder();
sb.Append("Frames");
sb.Append(System.IO.Path.DirectorySeparatorChar);
if (realExerciseSim == StandardIdentityRealExerciseSimType.Reality)
sb.Append("0_");
else if (realExerciseSim == StandardIdentityRealExerciseSimType.Exercise)
{
sb.Append("Exercise");
sb.Append(System.IO.Path.DirectorySeparatorChar);
sb.Append("1_");
}
else if (realExerciseSim == StandardIdentityRealExerciseSimType.Simulation)
{
sb.Append("Sim");
sb.Append(System.IO.Path.DirectorySeparatorChar);
sb.Append("2_");
}
string affiliationString = TypeUtilities.EnumHelper.getEnumValAsString(affiliation, 1);
sb.Append(affiliationString);
// map the actual symbolSet to the supported/available frame
SymbolSetType mappedSymbolSet = TypeUtilities.SymbolSetToFrameMapping[symbolSet];
string mappedSymbolSetString = TypeUtilities.EnumHelper.getEnumValAsString(mappedSymbolSet, 2);
sb.Append(mappedSymbolSetString);
string status_suffix = "_0"; // normal case
// Planned / Present Status (but only for standard/non-anticipated frames)
if (status == StatusType.Planned_Anticipated_Suspect)
if ((affiliation == StandardIdentityAffiliationType.Friend) ||
(affiliation == StandardIdentityAffiliationType.Hostile) ||
(affiliation == StandardIdentityAffiliationType.Neutral) ||
(affiliation == StandardIdentityAffiliationType.Unknown))
status_suffix = "_1";
sb.Append(status_suffix);
if (UseCivilianFrames)
{
if (affiliation <= StandardIdentityAffiliationType.Neutral)
sb.Append("c");
}
sb.Append(ImageSuffix);
return sb.ToString();
}
public static string GetFrameIconNameWithFullPath(
StandardIdentityRealExerciseSimType realExerciseSim,
StandardIdentityAffiliationType affiliation,
SymbolSetType symbolSet,
StatusType status)
{
if (affiliation >= StandardIdentityAffiliationType.Dont_Display_Frame)
return string.Empty;
StringBuilder sb = new StringBuilder();
sb.Append(ImageFilesHome);
string frameIconNameWithoutImageFilesHome =
GetFrameIconNameWithFolder(realExerciseSim, affiliation, symbolSet, status);
sb.Append(frameIconNameWithoutImageFilesHome);
return sb.ToString();
}
public static bool SetMilitarySymbolGraphicLayers(ref MilitarySymbol milSymbol)
{
if (!System.IO.Directory.Exists(ImageFilesHome))
{
System.Diagnostics.Trace.WriteLine("--> Images Home *DOES NOT EXIST* : " + ImageFilesHome);
return false;
}
if ((milSymbol == null) || (milSymbol.Id == null) ||
(milSymbol.GraphicLayers == null) || (!milSymbol.Id.IsValid))
return false;
milSymbol.GraphicLayers.Clear();
//////////////////////////////////////////////////////////////////////////
// Assembly the layers
// Start with the Frame (if framed)
if (TypeUtilities.HasFrame(milSymbol.Id.SymbolSet, milSymbol.Id.EntityCode))
{
string frameIconNameWithFullPath =
GetFrameIconNameWithFullPath(
milSymbol.Id.StandardIdentity,
milSymbol.Id.Affiliation,
milSymbol.Id.SymbolSet,
milSymbol.Id.Status);
if (!string.IsNullOrEmpty(frameIconNameWithFullPath))
milSymbol.GraphicLayers.Add(frameIconNameWithFullPath);
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// Main Icon Layer (all symbols should have this)
string mainIconNameFullPath = GetMainIconNameWithFullPath(ref milSymbol);
milSymbol.GraphicLayers.Add(mainIconNameFullPath);
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// Skip the remaining if no more layers needed
bool skipRemainingLayers = !TypeUtilities.HasFrame(milSymbol.Id.SymbolSet);
if (!skipRemainingLayers)
{
StringBuilder sb = new StringBuilder();
// Main Icon Modfier 1
if (!string.IsNullOrEmpty(milSymbol.Id.ModifierOne)
&& (milSymbol.Id.ModifierOne != "00")) // TODO: find better way of checking that this isn't set/valid
{
sb.Clear();
sb.Append(ImageFilesHome);
string modifierIconNameWithFolder =
GetModfierIconNameWithFolder(ref milSymbol, 1);
sb.Append(modifierIconNameWithFolder);
milSymbol.GraphicLayers.Add(sb.ToString());
}
// Main Icon Modfier 2
if (!string.IsNullOrEmpty(milSymbol.Id.ModifierTwo)
&& (milSymbol.Id.ModifierTwo != "00")) // TODO: find better way of checking that this isn't set/valid
{
sb.Clear();
sb.Append(ImageFilesHome);
string modifierIconNameWithFolder =
GetModfierIconNameWithFolder(ref milSymbol, 2);
sb.Append(modifierIconNameWithFolder);
milSymbol.GraphicLayers.Add(sb.ToString());
}
// Echelon/Mobility Modifier
if (milSymbol.Id.EchelonMobility != EchelonMobilityType.NoEchelonMobility)
{
string echelonIconNameWithFullPath =
GetEchelonIconNameWithFullPath(
milSymbol.Id.SymbolSet,
milSymbol.Id.Affiliation,
milSymbol.Id.EchelonMobility);
if (echelonIconNameWithFullPath.Length > 0)
milSymbol.GraphicLayers.Add(echelonIconNameWithFullPath);
}
// Headquarters/TF/FD Modifier
if (milSymbol.Id.HeadquartersTaskForceDummy !=
HeadquartersTaskForceDummyType.NoHQTFDummyModifier)
{
string hqTfFdIconNameWithFullPath =
GetHqTfFdIconNameWithFullPath(
milSymbol.Id.SymbolSet,
milSymbol.Id.Affiliation,
milSymbol.Id.HeadquartersTaskForceDummy);
if (hqTfFdIconNameWithFullPath.Length > 0)
milSymbol.GraphicLayers.Add(hqTfFdIconNameWithFullPath);
}
// Status/Operational Condition Icon
// (Note: if "planned" was set in the frame used above)
if ((milSymbol.Id.Status != StatusType.NotSet) &&
(milSymbol.Id.Status > StatusType.Planned_Anticipated_Suspect))
{
string opConditionIconNameWithFullPath =
GetOperationalConditionNameWithFullPath(
milSymbol.Id.SymbolSet,
milSymbol.Id.Affiliation,
milSymbol.Id.Status);
if (opConditionIconNameWithFullPath.Length > 0)
milSymbol.GraphicLayers.Add(opConditionIconNameWithFullPath);
}
if (milSymbol.Id.IsLandUnitSpecialEntity)
{
// TABLE D-V. "Land unit icons – special entity subtypes"
string landUnitSpecialEntityIconNameWithFullPath =
GetLandUnitSpecialEntityIconNameWithFullPath(milSymbol.Id);
if (landUnitSpecialEntityIconNameWithFullPath.Length > 0)
milSymbol.GraphicLayers.Add(landUnitSpecialEntityIconNameWithFullPath);
}
} // end skipRemainingLayers
// check this before we add debug/unknown icons at the end
int validLayerCount = 0;
// Look at the layers to see if any do not exist:
foreach (string graphicLayer in milSymbol.GraphicLayers)
{
if (!System.IO.File.Exists(graphicLayer))
System.Diagnostics.Trace.WriteLine("SetMilitarySymbolGraphicLayers: Could not find layer: " + graphicLayer);
else
validLayerCount++;
}
bool success = validLayerCount > 0;
if (AddReferenceCenterPoint)
{
// For testing if icons are centered properly:
// Outer Circle:
string centerIcon = ImageFilesHome +
@"Appendices\ControlMeasures\25200500.svg"; // (Large Yellow Circle)
milSymbol.GraphicLayers.Add(centerIcon);
// Center Dot/Crosshair:
string centerIcon2 = ImageFilesHome +
// @"Appendices\Land\10130300.svg"; // (Center Black Circle)
@"Appendices\Land\10161300_2.svg"; // (Center Black Crosshairs)
milSymbol.GraphicLayers.Add(centerIcon2);
}
if (!success)
{
// add a default symbol
string defaultUnknownIcon = ImageFilesHome + @"Appendices\98100000.svg";
milSymbol.GraphicLayers.Add(defaultUnknownIcon);
}
return success;
}
}
}