[NUI] Rebase develnui (DevelNUI only patches --> master) (#3910)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / TextMapHelper.cs
1 /*
2  * Copyright(c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 using System;
19 using System.ComponentModel;
20 using Tizen.NUI.Text;
21
22 namespace Tizen.NUI.BaseComponents
23 {
24     /// <summary>
25     /// TextMapHelper converts PropertyMap to struct and struct to PropertyMap.
26     /// </summary>
27     [EditorBrowsable(EditorBrowsableState.Never)]
28     public static class TextMapHelper
29     {
30         /// <summary>
31         /// It returns a string value according to FontWidthType.
32         /// The returned value can be used for FontStyle PropertyMap.
33         /// <param name="fontWidthType">The FontWidthType enum value.</param>
34         /// <returns> A string value for FontStyle.Width property. </returns>
35         /// </summary>
36         [EditorBrowsable(EditorBrowsableState.Never)]
37         public static string GetFontWidthString(FontWidthType fontWidthType)
38         {
39             string value = GetCamelCase(fontWidthType.ToString());
40             return string.IsNullOrEmpty(value) ? "none" : value;
41         }
42
43         /// <summary>
44         /// It returns a string value according to FontWeightType.
45         /// The returned value can be used for FontStyle PropertyMap.
46         /// <param name="fontWeightType">The FontWeightType enum value.</param>
47         /// <returns> A string value for FontStyle.Weight property. </returns>
48         /// </summary>
49         [EditorBrowsable(EditorBrowsableState.Never)]
50         public static string GetFontWeightString(FontWeightType fontWeightType)
51         {
52             string value = GetCamelCase(fontWeightType.ToString());
53             return string.IsNullOrEmpty(value) ? "none" : value;
54         }
55
56         /// <summary>
57         /// It returns a string value according to FontSlantType.
58         /// The returned value can be used for FontStyle PropertyMap.
59         /// <param name="fontSlantType">The FontSlantType enum value.</param>
60         /// <returns> A string value for FontStyle.Slant property. </returns>
61         /// </summary>
62         [EditorBrowsable(EditorBrowsableState.Never)]
63         public static string GetFontSlantString(FontSlantType fontSlantType)
64         {
65             string value = GetCamelCase(fontSlantType.ToString());
66             return string.IsNullOrEmpty(value) ? "none" : value;
67         }
68
69         /// <summary>
70         /// It returns a string value according to FontSizeType.
71         /// The returned value can be used for TextFit PropertyMap.
72         /// <param name="fontSizeType">The FontSizeType enum value.</param>
73         /// <returns> A string value for TextFit.FontSizeType property. </returns>
74         /// </summary>
75         [EditorBrowsable(EditorBrowsableState.Never)]
76         public static string GetFontSizeString(FontSizeType fontSizeType)
77         {
78             string value = GetCamelCase(fontSizeType.ToString());
79             return string.IsNullOrEmpty(value) ? "pointSize" : value;
80         }
81
82         /// <summary>
83         /// It returns a FontWidthType value according to fontWidthString.
84         /// The returned value can be used for FontStyle PropertyMap.
85         /// <param name="fontWidthString">The FontWidth string value.</param>
86         /// <returns> A FontWidthType value for FontStyle.Width property. </returns>
87         /// </summary>
88         [EditorBrowsable(EditorBrowsableState.Never)]
89         public static FontWidthType GetFontWidthType(string fontWidthString)
90         {
91             FontWidthType value;
92             if (!(Enum.TryParse(fontWidthString, true, out value) && Enum.IsDefined(typeof(FontWidthType), value)))
93             {
94                 value = FontWidthType.None; // If parsing fails, set a default value.
95             }
96
97             return value;
98         }
99
100         /// <summary>
101         /// It returns a FontWeightType value according to fontWeightString.
102         /// The returned value can be used for FontStyle PropertyMap.
103         /// <param name="fontWeightString">The FontWeight string value.</param>
104         /// <returns> A FontWeightType value for FontStyle.Weight property. </returns>
105         /// </summary>
106         [EditorBrowsable(EditorBrowsableState.Never)]
107         public static FontWeightType GetFontWeightType(string fontWeightString)
108         {
109             FontWeightType value;
110             if (!(Enum.TryParse(fontWeightString, true, out value) && Enum.IsDefined(typeof(FontWeightType), value)))
111             {
112                 value = FontWeightType.None; // If parsing fails, set a default value.
113             }
114
115             return value;
116         }
117
118         /// <summary>
119         /// It returns a FontSlantType value according to fontSlantString.
120         /// The returned value can be used for FontStyle PropertyMap.
121         /// <param name="fontSlantString">The FontSlant string value.</param>
122         /// <returns> A FontSlantType value for FontStyle.Slant property. </returns>
123         /// </summary>
124         [EditorBrowsable(EditorBrowsableState.Never)]
125         public static FontSlantType GetFontSlantType(string fontSlantString)
126         {
127             FontSlantType value;
128             if (!(Enum.TryParse(fontSlantString, true, out value) && Enum.IsDefined(typeof(FontSlantType), value)))
129             {
130                 value = FontSlantType.None; // If parsing fails, set a default value.
131             }
132
133             return value;
134         }
135
136         /// <summary>
137         /// It returns a FontSizeType value according to fontSizeString.
138         /// The returned value can be used for FontStyle PropertyMap.
139         /// <param name="fontSizeString">The FontSizeType string value.</param>
140         /// <returns> A FontSizeType value for TextFit.FontSizeType property. </returns>
141         /// </summary>
142         [EditorBrowsable(EditorBrowsableState.Never)]
143         public static FontSizeType GetFontSizeType(string fontSizeString)
144         {
145             FontSizeType value;
146             if (!(Enum.TryParse(fontSizeString, true, out value) && Enum.IsDefined(typeof(FontSizeType), value)))
147             {
148                 value = FontSizeType.PointSize; // If parsing fails, set a default value.
149             }
150
151             return value;
152         }
153
154         /// <summary>
155         /// This method converts a FontStyle struct to a PropertyMap and returns it.
156         /// The returned map can be used for set FontStyle PropertyMap in the SetFontStyle method.
157         /// <param name="fontStyle">The FontStyle struct value.</param>
158         /// <returns> A PropertyMap for FontStyle property. </returns>
159         /// </summary>
160         [EditorBrowsable(EditorBrowsableState.Never)]
161         public static PropertyMap GetFontStyleMap(FontStyle fontStyle)
162         {
163             var map = new PropertyMap();
164             map.Add("width", GetFontWidthString(fontStyle.Width));
165             map.Add("weight", GetFontWeightString(fontStyle.Weight));
166             map.Add("slant", GetFontSlantString(fontStyle.Slant));
167
168             return map;
169         }
170
171         /// <summary>
172         /// This method converts a FontStyle map to a struct and returns it.
173         /// The returned struct can be returned to the user as a FontStyle in the GetFontStyle method.
174         /// <param name="map">The FontStyle PropertyMap.</param>
175         /// <returns> A FontStyle struct. </returns>
176         /// </summary>
177         [EditorBrowsable(EditorBrowsableState.Never)]
178         public static FontStyle GetFontStyleStruct(PropertyMap map)
179         {
180             var fontStyle = new FontStyle();
181             if (null != map)
182             {
183                 var defaultValue = "none";
184                 fontStyle.Width = GetFontWidthType(GetStringFromMap(map, "width", defaultValue));
185                 fontStyle.Weight = GetFontWeightType(GetStringFromMap(map, "weight", defaultValue));
186                 fontStyle.Slant = GetFontSlantType(GetStringFromMap(map, "slant", defaultValue));
187             }
188
189             return fontStyle;
190         }
191
192         /// <summary>
193         /// This method converts a InputFilter struct to a PropertyMap and returns it. <br />
194         /// The returned map can be used for set InputFilter PropertyMap in the SetInputFilter method. <br />
195         /// <param name="inputFilter">The InputFilter struct value.</param>
196         /// <returns> A PropertyMap for InputFilter property. </returns>
197         /// </summary>
198         [EditorBrowsable(EditorBrowsableState.Never)]
199         public static PropertyMap GetInputFilterMap(InputFilter inputFilter)
200         {
201             var defaultValue = "";
202
203             var map = new PropertyMap();
204             var accepted = inputFilter.Accepted == null ? defaultValue : inputFilter.Accepted;
205             var rejected = inputFilter.Rejected == null ? defaultValue : inputFilter.Rejected;
206             map.Add(0, accepted);
207             map.Add(1, rejected);
208
209             return map;
210         }
211
212         /// <summary>
213         /// This method converts a InputFilter map to a struct and returns it. <br />
214         /// The returned struct can be returned to the user as a InputFilter in the GetInputFilter method. <br />
215         /// <param name="map">The InputFilter PropertyMap.</param>
216         /// <returns> A InputFilter struct. </returns>
217         /// </summary>
218         [EditorBrowsable(EditorBrowsableState.Never)]
219         public static InputFilter GetInputFilterStruct(PropertyMap map)
220         {
221             var inputFilter = new InputFilter();
222             if (null != map)
223             {
224                 var defaultValue = "";
225                 inputFilter.Accepted = GetStringFromMap(map, 0, defaultValue);
226                 inputFilter.Rejected = GetStringFromMap(map, 1, defaultValue);
227             }
228
229             return inputFilter;
230         }
231
232         /// <summary>
233         /// This method converts a Strikethrough struct to a PropertyMap and returns it.
234         /// The returned map can be used for set Strikethrough PropertyMap in the SetStrikethrough method.
235         /// <param name="strikethrough">The Strikethrough struct value.</param>
236         /// <returns> A PropertyMap for Strikethrough property. </returns>
237         /// </summary>
238         [EditorBrowsable(EditorBrowsableState.Never)]
239         public static PropertyMap GetStrikethroughMap(Strikethrough strikethrough)
240         {
241             var map = new PropertyMap();
242
243             map.Add("enable", strikethrough.Enable);
244
245             if (strikethrough.Color != null)
246                 map.Add("color", strikethrough.Color);
247
248             if (strikethrough.Height != null)
249                 map.Add("height", (float)strikethrough.Height);
250
251             return map;
252         }
253
254         /// <summary>
255         /// This method converts a Strikethrough map to a struct and returns it.
256         /// The returned struct can be returned to the user as a Strikethrough in the GetUnderline method.
257         /// <param name="map">The Strikethrough PropertyMap.</param>
258         /// <returns> A Strikethrough struct. </returns>
259         /// </summary>
260         [EditorBrowsable(EditorBrowsableState.Never)]
261         public static Strikethrough GetStrikethroughStruct(PropertyMap map)
262         {
263             var strikethrough = new Strikethrough();
264             if (null != map)
265             {
266                 strikethrough.Enable = GetBoolFromMap(map, "enable", false);
267                 strikethrough.Color = GetColorFromMap(map, "color");
268                 strikethrough.Height = GetFloatFromMap(map, "height", 0.0f);
269             }
270
271             return strikethrough;
272         }
273
274
275         /// <summary>
276         /// This method converts a Underline struct to a PropertyMap and returns it.
277         /// The returned map can be used for set Underline PropertyMap in the SetUnderline method.
278         /// <param name="underline">The Underline struct value.</param>
279         /// <returns> A PropertyMap for Underline property. </returns>
280         /// </summary>
281         [EditorBrowsable(EditorBrowsableState.Never)]
282         public static PropertyMap GetUnderlineMap(Underline underline)
283         {
284             var map = new PropertyMap();
285
286             map.Add("enable", underline.Enable);
287             map.Add("type", (int)underline.Type);
288
289             if (underline.Color != null)
290                 map.Add("color", underline.Color);
291
292             if (underline.Height != null)
293                 map.Add("height", (float)underline.Height);
294             
295             if (underline.DashWidth != null)
296                 map.Add("dashWidth", (float)underline.DashWidth);
297
298             if (underline.DashGap != null)
299                 map.Add("dashGap", (float)underline.DashGap);
300
301             return map;
302         }
303
304         /// <summary>
305         /// This method converts a Underline map to a struct and returns it.
306         /// The returned struct can be returned to the user as a Underline in the GetUnderline method.
307         /// <param name="map">The Underline PropertyMap.</param>
308         /// <returns> A Underline struct. </returns>
309         /// </summary>
310         [EditorBrowsable(EditorBrowsableState.Never)]
311         public static Underline GetUnderlineStruct(PropertyMap map)
312         {
313             var underline = new Underline();
314             if (null != map)
315             {
316                 underline.Enable = GetBoolFromMap(map, "enable", false);
317                 underline.Type = (UnderlineType)GetIntFromMap(map, "type", 0);
318                 underline.Color = GetColorFromMap(map, "color");
319                 underline.Height = GetFloatFromMap(map, "height", 0.0f);
320                 underline.DashWidth = GetNullableFloatFromMap(map, "dashWidth");
321                 underline.DashGap = GetNullableFloatFromMap(map, "dashGap");
322             }
323
324             return underline;
325         }
326
327         /// <summary>
328         /// This method converts a Shadow struct to a PropertyMap and returns it.
329         /// The returned map can be used for set Shadow PropertyMap in the SetShadow method.
330         /// <param name="shadow">The Shadow struct value.</param>
331         /// <returns> A PropertyMap for Shadow property. </returns>
332         /// </summary>
333         [EditorBrowsable(EditorBrowsableState.Never)]
334         public static PropertyMap GetShadowMap(Tizen.NUI.Text.Shadow shadow)
335         {
336             var map = new PropertyMap();
337
338             if (shadow.Offset != null)
339                 map.Add("offset", shadow.Offset);
340
341             if (shadow.Color != null)
342                 map.Add("color", shadow.Color);
343
344             if (shadow.BlurRadius != null)
345                 map.Add("blurRadius", (float)shadow.BlurRadius);
346
347             return map;
348         }
349
350         /// <summary>
351         /// This method converts a Shadow map to a struct and returns it.
352         /// The returned struct can be returned to the user as a Shadow in the GetShadow method.
353         /// <param name="map">The Shadow PropertyMap.</param>
354         /// <returns> A Shadow struct. </returns>
355         /// </summary>
356         [EditorBrowsable(EditorBrowsableState.Never)]
357         public static Tizen.NUI.Text.Shadow GetShadowStruct(PropertyMap map)
358         {
359             var shadow = new Tizen.NUI.Text.Shadow();
360             if (null != map)
361             {
362                 shadow.Offset = GetVector2FromMap(map, "offset");
363                 shadow.Color = GetColorFromMap(map, "color");
364                 shadow.BlurRadius = GetFloatFromMap(map, "blurRadius", 0.0f);
365             }
366
367             return shadow;
368         }
369
370         /// <summary>
371         /// This method converts a Outline struct to a PropertyMap and returns it.
372         /// The returned map can be used for set Outline PropertyMap in the SetOutline method.
373         /// <param name="outline">The Outline struct value.</param>
374         /// <returns> A PropertyMap for Outline property. </returns>
375         /// </summary>
376         [EditorBrowsable(EditorBrowsableState.Never)]
377         public static PropertyMap GetOutlineMap(Outline outline)
378         {
379             var map = new PropertyMap();
380
381             if (outline.Color != null)
382                 map.Add("color", outline.Color);
383
384             if (outline.Width != null)
385                 map.Add("width", (float)outline.Width);
386
387             return map;
388         }
389
390         /// <summary>
391         /// This method converts a Outline map to a struct and returns it.
392         /// The returned struct can be returned to the user as a Outline in the GetOutline method.
393         /// <param name="map">The Outline PropertyMap.</param>
394         /// <returns> A Outline struct. </returns>
395         /// </summary>
396         [EditorBrowsable(EditorBrowsableState.Never)]
397         public static Outline GetOutlineStruct(PropertyMap map)
398         {
399             var outline = new Outline();
400             if (null != map)
401             {
402                 outline.Color = GetColorFromMap(map, "color");
403                 outline.Width = GetFloatFromMap(map, "width", 0.0f);
404             }
405
406             return outline;
407         }
408
409         /// <summary>
410         /// This method converts a TextFit struct to a PropertyMap and returns it.
411         /// The returned map can be used for set TextFit PropertyMap in the SetTextFit method.
412         /// <param name="textFit">The TextFit struct value.</param>
413         /// <returns> A PropertyMap for TextFit property. </returns>
414         /// </summary>
415         [EditorBrowsable(EditorBrowsableState.Never)]
416         public static PropertyMap GetTextFitMap(TextFit textFit)
417         {
418             var map = new PropertyMap();
419             map.Add("enable", textFit.Enable);
420             map.Add("fontSizeType", GetFontSizeString(textFit.FontSizeType));
421
422             if (textFit.MinSize != null)
423                 map.Add("minSize", (float)textFit.MinSize);
424
425             if (textFit.MaxSize != null)
426                 map.Add("maxSize", (float)textFit.MaxSize);
427
428             if (textFit.StepSize != null)
429                 map.Add("stepSize", (float)textFit.StepSize);
430
431             return map;
432         }
433
434         /// <summary>
435         /// This method converts a TextFit map to a struct and returns it.
436         /// The returned struct can be returned to the user as a TextFit in the GetTextFit method.
437         /// <param name="map">The TextFit PropertyMap.</param>
438         /// <returns> A TextFit struct. </returns>
439         /// </summary>
440         [EditorBrowsable(EditorBrowsableState.Never)]
441         public static TextFit GetTextFitStruct(PropertyMap map)
442         {
443             var textFit = new TextFit();
444             if (null != map)
445             {
446                 var defaultValue = "PointSize";
447                 textFit.Enable = GetBoolFromMap(map, "enable", false);
448                 textFit.MinSize = GetFloatFromMap(map, "minSize", 0.0f);
449                 textFit.MaxSize = GetFloatFromMap(map, "maxSize", 0.0f);
450                 textFit.StepSize = GetFloatFromMap(map, "stepSize", 0.0f);
451                 textFit.FontSize = GetFloatFromMap(map, "fontSize", 0.0f);
452                 textFit.FontSizeType = GetFontSizeType(GetStringFromMap(map, "fontSizeType", defaultValue));
453             }
454
455             return textFit;
456         }
457
458         /// <summary>
459         /// This method converts a Placeholder struct to a PropertyMap and returns it.
460         /// The returned map can be used for set Placeholder PropertyMap in the SetPlaceholder method.
461         /// <param name="placeholder">The Placeholder struct value.</param>
462         /// <returns> A PropertyMap for Placeholder property. </returns>
463         /// </summary>
464         [EditorBrowsable(EditorBrowsableState.Never)]
465         public static PropertyMap GetPlaceholderMap(Placeholder placeholder)
466         {
467             var map = new PropertyMap();
468
469             if (placeholder.Text != null)
470                 map.Add("text", placeholder.Text);
471
472             if (placeholder.TextFocused != null)
473                 map.Add("textFocused", placeholder.TextFocused);
474
475             if (placeholder.Color != null)
476                 map.Add("color", placeholder.Color);
477
478             if (placeholder.FontFamily != null)
479                 map.Add("fontFamily", placeholder.FontFamily);
480
481             if (placeholder.FontStyle != null)
482             {
483                 using (var fontStyleMap = GetFontStyleMap((FontStyle)placeholder.FontStyle))
484                 using (var fontStyleValue = new PropertyValue(fontStyleMap))
485                 {
486                     map.Add("fontStyle", fontStyleValue);
487                 }
488             }
489
490             if (placeholder.PointSize != null && placeholder.PixelSize != null)
491                 map.Add("pointSize", (float)placeholder.PointSize);
492
493             else if (placeholder.PointSize != null)
494                 map.Add("pointSize", (float)placeholder.PointSize);
495
496             else if (placeholder.PixelSize != null)
497                 map.Add("pixelSize", (float)placeholder.PixelSize);
498
499             map.Add("ellipsis", placeholder.Ellipsis);
500
501             return map;
502         }
503
504         /// <summary>
505         /// This method converts a Placeholder map to a struct and returns it.
506         /// The returned struct can be returned to the user as a Placeholder in the GetPlaceholder method.
507         /// <param name="map">The Placeholder PropertyMap.</param>
508         /// <returns> A Placeholder struct. </returns>
509         /// </summary>
510         [EditorBrowsable(EditorBrowsableState.Never)]
511         public static Placeholder GetPlaceholderStruct(PropertyMap map)
512         {
513             var placeholder = new Placeholder();
514             if (null != map)
515             {
516                 var defaultText = "";
517                 placeholder.Text = GetStringFromMap(map, 0, defaultText);
518                 placeholder.TextFocused = GetStringFromMap(map, 1, defaultText);
519                 placeholder.Color = GetColorFromMap(map, 2);
520                 placeholder.FontFamily = GetStringFromMap(map, 3, defaultText);
521                 using (var fontStyleMap = GetMapFromMap(map, 4))
522                 {
523                     placeholder.FontStyle = GetFontStyleStruct(fontStyleMap);
524                 }
525                 placeholder.PointSize = GetNullableFloatFromMap(map, 5);
526                 placeholder.PixelSize = GetNullableFloatFromMap(map, 6);
527                 placeholder.Ellipsis = GetBoolFromMap(map, 7, false);
528             }
529
530             return placeholder;
531         }
532
533         /// <summary>
534         /// This method converts a HiddenInput struct to a PropertyMap and returns it.
535         /// The returned map can be used for set HiddenInputSettings PropertyMap in the SetHiddenInput method.
536         /// <param name="hiddenInput">The HiddenInput struct value.</param>
537         /// <returns> A PropertyMap for HiddenInput property. </returns>
538         /// </summary>
539         [EditorBrowsable(EditorBrowsableState.Never)]
540         public static PropertyMap GetHiddenInputMap(HiddenInput hiddenInput)
541         {
542             var map = new PropertyMap();
543
544             map.Add(0, (int)hiddenInput.Mode);
545
546             if (hiddenInput.SubstituteCharacter != null)
547                 map.Add(1, Convert.ToInt32(hiddenInput.SubstituteCharacter));
548
549             if (hiddenInput.SubstituteCount != null)
550                 map.Add(2, (int)hiddenInput.SubstituteCount);
551
552             if (hiddenInput.ShowLastCharacterDuration != null)
553                 map.Add(3, (int)hiddenInput.ShowLastCharacterDuration);
554
555             return map;
556         }
557
558         /// <summary>
559         /// This method converts a HiddenInputSettings map to a struct and returns it.
560         /// The returned struct can be returned to the user as a HiddenInput in the GetHiddenInput method.
561         /// <param name="map">The HiddenInput PropertyMap.</param>
562         /// <returns> A HiddenInput struct. </returns>
563         /// </summary>
564         [EditorBrowsable(EditorBrowsableState.Never)]
565         public static HiddenInput GetHiddenInputStruct(PropertyMap map)
566         {
567             var hiddenInput = new HiddenInput();
568             if (null != map)
569             {
570                 int defaultVlaue = 0;
571                 hiddenInput.Mode = (HiddenInputModeType)GetIntFromMap(map, 0, defaultVlaue);
572
573                 int? substituteCharacter = GetNullableIntFromMap(map, 1);
574                 if (substituteCharacter != null)
575                     hiddenInput.SubstituteCharacter = Convert.ToChar(substituteCharacter);
576
577                 hiddenInput.SubstituteCount = GetNullableIntFromMap(map, 2);
578                 hiddenInput.ShowLastCharacterDuration = GetNullableIntFromMap(map, 3);
579             }
580
581             return hiddenInput;
582         }
583
584         /// <summary>
585         /// This method converts a fileName string to a PropertyMap and returns it.
586         /// The returned map can be used for set SelectionHandleImageLeft, SelectionHandleImageRight PropertyMap in the SetSelectionHandleImage method.
587         /// <param name="fileName">The file path string value for SelectionHandleImage.</param>
588         /// <returns> A PropertyMap for SelectionHandleImageLeft, SelectionHandleImageRight properties. </returns>
589         /// </summary>
590         [EditorBrowsable(EditorBrowsableState.Never)]
591         public static PropertyMap GetFileNameMap(string fileName)
592         {
593             return new PropertyMap().Add("filename", fileName);
594         }
595
596         /// <summary>
597         /// This method converts a SelectionHandleImageLeft, SelectionHandleImageRight map to a struct and returns it.
598         /// The returned struct can be returned to the user as a SelectionHandleImage in the GetSelectionHandleImage method.
599         /// <param name="leftImageMap">The SelectionHandleImageLeft PropertyMap.</param>
600         /// <param name="rightImageMap">The SelectionHandleImageRight PropertyMap.</param>
601         /// <returns> A SelectionHandleImage struct. </returns>
602         /// </summary>
603         [EditorBrowsable(EditorBrowsableState.Never)]
604         public static SelectionHandleImage GetSelectionHandleImageStruct(PropertyMap leftImageMap, PropertyMap rightImageMap)
605         {
606             var defaultValue = "";
607
608             var selectionHandleImage = new SelectionHandleImage();
609             if (null != leftImageMap)
610                 selectionHandleImage.LeftImageUrl = GetStringFromMap(leftImageMap, "filename", defaultValue);
611
612             if (null != rightImageMap)
613                 selectionHandleImage.RightImageUrl = GetStringFromMap(rightImageMap, "filename", defaultValue);
614
615             return selectionHandleImage;
616         }
617
618         internal static string GetCamelCase(string pascalCase)
619         {
620             if (!string.IsNullOrEmpty(pascalCase))
621             {
622                 char[] charArray = pascalCase.ToCharArray();
623                 charArray[0] = Char.ToLower(charArray[0]);
624                 pascalCase = new string(charArray);
625             }
626
627             return pascalCase;
628         }
629
630         internal static string GetStringFromMap(PropertyMap map, string key, string defaultValue)
631         {
632             string value = defaultValue;
633             using (var propertyValue = map.Find(0, key))
634             {
635                 if (null != propertyValue) propertyValue.Get(out value);
636             }
637             return value;
638         }
639
640         internal static string GetStringFromMap(PropertyMap map, int key, string defaultValue)
641         {
642             string value = defaultValue;
643             using (var propertyValue = map.Find(key))
644             {
645                 if (null != propertyValue) propertyValue.Get(out value);
646             }
647             return value;
648         }
649
650         internal static bool GetBoolFromMap(PropertyMap map, string key, bool defaultValue)
651         {
652             bool value = defaultValue;
653             using (var propertyValue = map.Find(0, key))
654             {
655                 if (null != propertyValue) propertyValue.Get(out value);
656             }
657             return value;
658         }
659
660         internal static bool GetBoolFromMap(PropertyMap map, int key, bool defaultValue)
661         {
662             bool value = defaultValue;
663             using (var propertyValue = map.Find(key))
664             {
665                 if (null != propertyValue) propertyValue.Get(out value);
666             }
667             return value;
668         }
669
670         internal static int GetIntFromMap(PropertyMap map, int key, int defaultValue)
671         {
672             int value = defaultValue;
673             using (var propertyValue = map.Find(key))
674             {
675                 if (null != propertyValue) propertyValue.Get(out value);
676             }
677             return value;
678         }
679
680         internal static int GetIntFromMap(PropertyMap map, string key, int defaultValue)
681         {
682             int value = defaultValue;
683             using (var propertyValue = map.Find(0, key))
684             {
685                 if (null != propertyValue) propertyValue.Get(out value);
686             }
687             return value;
688         }
689
690         internal static float GetFloatFromMap(PropertyMap map, string key, float defaultValue)
691         {
692             float value = defaultValue;
693             using (var propertyValue = map.Find(0, key))
694             {
695                 if (null != propertyValue) propertyValue.Get(out value);
696             }
697             return value;
698         }
699
700         internal static Color GetColorFromMap(PropertyMap map, string key)
701         {
702             Color value = new Color();
703             using (var propertyValue = map.Find(0, key))
704             {
705                 if (null != propertyValue) propertyValue.Get(value);
706             }
707             return value;
708         }
709
710         internal static Color GetColorFromMap(PropertyMap map, int key)
711         {
712             Color value = new Color();
713             using (var propertyValue = map.Find(key))
714             {
715                 if (null != propertyValue) propertyValue.Get(value);
716             }
717             return value;
718         }
719
720         internal static Vector2 GetVector2FromMap(PropertyMap map, string key)
721         {
722             Vector2 value = new Vector2();
723             using (var propertyValue = map.Find(0, key))
724             {
725                 if (null != propertyValue) propertyValue.Get(value);
726             }
727             return value;
728         }
729
730         internal static PropertyMap GetMapFromMap(PropertyMap map, int key)
731         {
732             PropertyMap value = new PropertyMap();
733             using (var propertyValue = map.Find(key))
734             {
735                 if (null != propertyValue) propertyValue.Get(value);
736             }
737             return value;
738         }
739
740         internal static int? GetNullableIntFromMap(PropertyMap map, int key)
741         {
742             using (var propertyValue = map.Find(key))
743             {
744                 if (propertyValue == null)
745                     return null;
746
747                 propertyValue.Get(out int value);
748                 return value;
749             }
750         }
751
752         internal static float? GetNullableFloatFromMap(PropertyMap map, int key)
753         {
754             using (var propertyValue = map.Find(key))
755             {
756                 if (propertyValue == null)
757                     return null;
758
759                 propertyValue.Get(out float value);
760                 return value;
761             }
762         }
763
764         internal static float? GetNullableFloatFromMap(PropertyMap map, string key)
765         {
766             using (var propertyValue = map.Find(0, key))
767             {
768                 if (propertyValue == null)
769                     return null;
770
771                 propertyValue.Get(out float value);
772                 return value;
773             }
774         }
775
776         internal static bool IsValue(PropertyMap map, int key)
777         {
778             using (var propertyValue = map.Find(key))
779             {
780                 if (propertyValue == null)
781                     return false;
782
783                 return true;
784             }
785         }
786     }
787 }