1.[NUI 276] c# nui visual high level class refactorying.
[platform/core/csapi/nui.git] / Tizen.NUI / src / public / VisualMaps.cs
1 // Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15
16 namespace Tizen.NUI
17 {
18     using System;
19     using System.Runtime.InteropServices;
20     using Tizen.NUI.UIComponents;
21
22     /// <summary>
23     /// A class encapsulating the transform map of visual.
24     /// </summary>
25     public class VisualMap
26     {
27         private Vector2 _visualSize = null;
28         private Vector2 _visualOffset = null;
29         private Vector2 _visualOffsetPolicy = null;
30         private Vector2 _visualSizePolicy = null;
31         private Visual.AlignType? _visualOrigin = null;
32         private Visual.AlignType? _visualAnchorPoint = null;
33
34         private PropertyMap _visualTransformMap = null;
35
36         private float? _depthIndex = null;
37         protected PropertyMap _outputVisualMap = null;
38
39         internal string Name
40         {
41             set;
42             get;
43         }
44
45         internal int VisualIndex
46         {
47             set;
48             get;
49         }
50
51         internal VisualView Parent
52         {
53             set;
54             get;
55         }
56
57         public VisualMap()
58         {
59         }
60
61         /// <summary>
62         /// Get or set size of the visual.<br>
63         /// It can be either relative (percentage of the parent)
64         /// or absolute (in world units).<br>
65         /// Optional.
66         /// </summary>
67         public Vector2 Size
68         {
69             get
70             {
71                 return _visualSize ?? (new Vector2(1.0f, 1.0f));
72             }
73             set
74             {
75                 _visualSize = value;
76                 if (_visualSizePolicy == null)
77                 {
78                     _visualSizePolicy = new Vector2(0.0f, 0.0f);
79                 }
80                 UpdateVisual();
81             }
82         }
83
84         /// <summary>
85         /// Get or set offset of the visual.<br>
86         /// It can be either relative (percentage of the parent)
87         /// or absolute (in world units).<br>
88         /// Optional.
89         /// </summary>
90         public Vector2 Position
91         {
92             get
93             {
94                 return _visualOffset ?? (new Vector2(0.0f, 0.0f));
95             }
96             set
97             {
98                 _visualOffset = value;
99                 if (_visualOffsetPolicy == null)
100                 {
101                     _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
102                 }
103                 UpdateVisual();
104             }
105         }
106
107         /// <summary>
108         /// Get or set relative size of the visual<br>
109         /// (percentage [0.0f to 1.0f] of the control).<br>
110         /// Optional.
111         /// </summary>
112         public RelativeVector2 RelativeSize
113         {
114             get
115             {
116                 return _visualSize ?? (new RelativeVector2(1.0f, 1.0f));
117             }
118             set
119             {
120                 _visualSize = value;
121                 _visualSizePolicy = new Vector2(0.0f, 0.0f);
122                 UpdateVisual();
123             }
124         }
125
126         /// <summary>
127         /// Get or set relative offset of the visual<br>
128         /// (percentage [0.0f to 1.0f] of the control).<br>
129         /// Optional.
130         /// </summary>
131         public RelativeVector2 RelativePosition
132         {
133             get
134             {
135                 return _visualOffset ?? (new RelativeVector2(0.0f, 0.0f));
136             }
137             set
138             {
139                 _visualOffset = value;
140                 _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
141                 UpdateVisual();
142             }
143         }
144
145         /// <summary>
146         /// Get or set whether the x and y offset values are relative<br>
147         /// (percentage [0.0f to 1.0f] of the control) or absolute (in world units).<br>
148         /// Be default, both the x and the y offset is relative.<br>
149         /// Optional.
150         /// </summary>
151         public VisualTransformPolicyType PositionPolicy
152         {
153             get
154             {
155                 if (_visualOffsetPolicy != null && _visualOffsetPolicy.X == 1.0f
156                     && _visualOffsetPolicy.Y == 1.0f)
157                 {
158                     return VisualTransformPolicyType.Absolute;
159                 }
160                 return VisualTransformPolicyType.Relative;
161             }
162             set
163             {
164                 switch (value)
165                 {
166                     case VisualTransformPolicyType.Relative:
167                         _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
168                         break;
169                     case VisualTransformPolicyType.Absolute:
170                         _visualOffsetPolicy = new Vector2(1.0f, 1.0f);
171                         break;
172                     default:
173                         _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
174                         break;
175                 }
176                 UpdateVisual();
177             }
178         }
179
180         /// <summary>
181         /// Get or set whether the x offset values are relative<br>
182         /// (percentage [0.0f to 1.0f] of the control) or absolute (in world units).<br>
183         /// Be default, the x offset is relative.<br>
184         /// Optional.
185         /// </summary>
186         public VisualTransformPolicyType PositionPolicyX
187         {
188             get
189             {
190                 if (_visualOffsetPolicy != null && _visualOffsetPolicy.X == 1.0f)
191                 {
192                     return VisualTransformPolicyType.Absolute;
193                 }
194                 return VisualTransformPolicyType.Relative;
195             }
196             set
197             {
198                 if (_visualOffsetPolicy == null)
199                 {
200                     _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
201                 }
202
203                 switch (value)
204                 {
205                     case VisualTransformPolicyType.Relative:
206                         _visualOffsetPolicy.X = 0.0f;
207                         break;
208                     case VisualTransformPolicyType.Absolute:
209                         _visualOffsetPolicy.X = 1.0f;
210                         break;
211                     default:
212                         _visualOffsetPolicy.X = 0.0f;
213                         break;
214                 }
215
216                 UpdateVisual();
217             }
218         }
219
220         /// <summary>
221         /// Get or set whether the y offset values are relative<br>
222         /// (percentage [0.0f to 1.0f] of the control) or absolute (in world units).<br>
223         /// Be default, the y offset is relative.<br>
224         /// Optional.
225         /// </summary>
226         public VisualTransformPolicyType PositionPolicyY
227         {
228             get
229             {
230                 if (_visualOffsetPolicy != null && _visualOffsetPolicy.Y == 1.0f)
231                 {
232                     return VisualTransformPolicyType.Absolute;
233                 }
234                 return VisualTransformPolicyType.Relative;
235             }
236             set
237             {
238                 if (_visualOffsetPolicy == null)
239                 {
240                     _visualOffsetPolicy = new Vector2(0.0f, 0.0f);
241                 }
242
243                 switch (value)
244                 {
245                     case VisualTransformPolicyType.Relative:
246                         _visualOffsetPolicy.Y = 0.0f;
247                         break;
248                     case VisualTransformPolicyType.Absolute:
249                         _visualOffsetPolicy.Y = 1.0f;
250                         break;
251                     default:
252                         _visualOffsetPolicy.Y = 0.0f;
253                         break;
254                 }
255                 UpdateVisual();
256             }
257         }
258
259         /// <summary>
260         /// Get or set whether the width or height size values are relative<br>
261         /// (percentage [0.0f to 1.0f] of the control) or absolute (in world units).<br>
262         /// Be default, both the width and the height offset is relative to the control's size.<br>
263         /// Optional.
264         /// </summary>
265         public VisualTransformPolicyType SizePolicy
266         {
267             get
268             {
269                 if (_visualSizePolicy != null && _visualSizePolicy.X == 1.0f
270                     && _visualSizePolicy.Y == 1.0f)
271                 {
272                     return VisualTransformPolicyType.Absolute;
273                 }
274                 return VisualTransformPolicyType.Relative;
275             }
276             set
277             {
278                 switch (value)
279                 {
280                     case VisualTransformPolicyType.Relative:
281                         _visualSizePolicy = new Vector2(0.0f, 0.0f);
282                         break;
283                     case VisualTransformPolicyType.Absolute:
284                         _visualSizePolicy = new Vector2(1.0f, 1.0f);
285                         break;
286                     default:
287                         _visualSizePolicy = new Vector2(0.0f, 0.0f);
288                         break;
289                 }
290                 UpdateVisual();
291             }
292         }
293
294         /// <summary>
295         /// Get or set whether the width size values are relative<br>
296         /// (percentage [0.0f to 1.0f] of the control) or absolute (in world units).<br>
297         /// Be default, the width value is relative to the control's width.<br>
298         /// Optional.
299         /// </summary>
300         public VisualTransformPolicyType SizePolicyWidth
301         {
302             get
303             {
304                 if (_visualSizePolicy != null && _visualSizePolicy.Width == 1.0f)
305                 {
306                     return VisualTransformPolicyType.Absolute;
307                 }
308                 return VisualTransformPolicyType.Relative;
309             }
310             set
311             {
312                 if (_visualSizePolicy == null)
313                 {
314                     _visualSizePolicy = new Vector2(0.0f, 0.0f);
315                 }
316
317                 switch (value)
318                 {
319                     case VisualTransformPolicyType.Relative:
320                         _visualSizePolicy.Width = 0.0f;
321                         break;
322                     case VisualTransformPolicyType.Absolute:
323                         _visualSizePolicy.Width = 1.0f;
324                         break;
325                     default:
326                         _visualSizePolicy.Width = 0.0f;
327                         break;
328                 }
329                 UpdateVisual();
330             }
331         }
332
333         /// <summary>
334         /// Get or set whether the height size values are relative<br>
335         /// (percentage [0.0f to 1.0f] of the control) or absolute (in world units).<br>
336         /// Be default, both the height value is relative to the control's height.<br>
337         /// Optional.
338         /// </summary>
339         public VisualTransformPolicyType SizePolicyHeight
340         {
341             get
342             {
343                 if (_visualSizePolicy != null && _visualSizePolicy.Height == 1.0f)
344                 {
345                     return VisualTransformPolicyType.Absolute;
346                 }
347                 return VisualTransformPolicyType.Relative;
348             }
349             set
350             {
351                 if (_visualSizePolicy == null)
352                 {
353                     _visualSizePolicy = new Vector2(0.0f, 0.0f);
354                 }
355
356                 switch (value)
357                 {
358                     case VisualTransformPolicyType.Relative:
359                         _visualSizePolicy.Height = 0.0f;
360                         break;
361                     case VisualTransformPolicyType.Absolute:
362                         _visualSizePolicy.Height = 1.0f;
363                         break;
364                     default:
365                         _visualSizePolicy.Height = 0.0f;
366                         break;
367                 }
368                 UpdateVisual();
369             }
370         }
371
372         /// <summary>
373         /// Get or set the origin of the visual within its control area.<br>
374         /// By default, the origin is Center.<br>
375         /// Optional.
376         /// </summary>
377         public Visual.AlignType Origin
378         {
379             get
380             {
381                 return _visualOrigin ?? (Visual.AlignType.Center);
382             }
383             set
384             {
385                 _visualOrigin = value;
386                 UpdateVisual();
387             }
388         }
389
390         /// <summary>
391         /// Get or set the anchor-point of the visual.<br>
392         /// By default, the anchor point is Center.<br>
393         /// Optional.
394         /// </summary>
395         public Visual.AlignType AnchorPoint
396         {
397             get
398             {
399                 return _visualAnchorPoint ?? (Visual.AlignType.Center);
400             }
401             set
402             {
403                 _visualAnchorPoint = value;
404                 UpdateVisual();
405             }
406         }
407
408         /// <summary>
409         /// Get or set the depth index of the visual.<br>
410         /// By default, the depth index is 0.<br>
411         /// Optional.
412         /// </summary>
413         public float DepthIndex
414         {
415             get
416             {
417                 return _depthIndex ?? (0.0f);
418             }
419             set
420             {
421                 _depthIndex = value;
422             }
423         }
424
425         private void ComposingTransformMap()
426         {
427             _visualTransformMap = new PropertyMap();
428             if (_visualSize != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.Size, new PropertyValue(_visualSize)); }
429             if (_visualOffset != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.Offset, new PropertyValue(_visualOffset)); }
430             if (_visualOffsetPolicy != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.OffsetPolicy, new PropertyValue(_visualOffsetPolicy)); }
431             if (_visualSizePolicy != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.SizePolicy, new PropertyValue(_visualSizePolicy)); }
432             if (_visualOrigin != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.Origin, new PropertyValue((int)_visualOrigin)); }
433             if (_visualAnchorPoint != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.AnchorPoint, new PropertyValue((int)_visualAnchorPoint)); }
434         }
435
436         /// <summary>
437         /// Get the transform map used by the visual.
438         /// </summary>
439         public PropertyMap OutputTransformMap
440         {
441             get
442             {
443                 ComposingTransformMap();
444                 return _visualTransformMap;
445             }
446         }
447
448         protected virtual void ComposingPropertyMap()
449         {
450             _outputVisualMap = new PropertyMap();
451         }
452
453         /// <summary>
454         /// Get the property map to create the visual.
455         /// </summary>
456         public PropertyMap OutputVisualMap
457         {
458             get
459             {
460                 ComposingPropertyMap();
461                 return _outputVisualMap;
462             }
463         }
464
465         internal void UpdateVisual()
466         {
467             if (VisualIndex > 0)
468             {
469 #if DEBUG_ON
470                 Tizen.Log.Debug("NUI", "UpdateVisual()! VisualIndex=" + VisualIndex);
471 #endif
472                 Parent.UpdateVisual(VisualIndex, Name, this);
473             }
474             else
475             {
476 #if DEBUG_ON
477                 Tizen.Log.Debug("NUI", "VisualIndex was not set");
478 #endif
479             }
480         }
481
482         protected PropertyMap _shader = null;
483         //private PropertyMap _transform = null;
484         protected bool? _premultipliedAlpha = null;
485         protected Color _mixColor = null;
486         protected float? _opacity = null;
487         protected PropertyMap _commonlyUsedMap = null;
488
489         /// <summary>
490         /// The shader to use in the visual.
491         /// </summary>
492         public PropertyMap Shader
493         {
494             get
495             {
496                 return _shader;
497             }
498             set
499             {
500                 _shader = value;
501                 UpdateVisual();
502             }
503         }
504
505         /// <summary>
506         /// Enables/disables premultiplied alpha. <br>
507         /// The premultiplied alpha is false by default unless this behaviour is modified by the derived Visual type.
508         /// </summary>
509         public bool PremultipliedAlpha
510         {
511             get
512             {
513                 return _premultipliedAlpha ?? (false);
514             }
515             set
516             {
517                 _premultipliedAlpha = value;
518                 UpdateVisual();
519             }
520         }
521
522         /// <summary>
523         /// Mix color is a blend color for any visual.
524         /// </summary>
525         public Color MixColor
526         {
527             get
528             {
529                 return _mixColor;
530             }
531             set
532             {
533                 _mixColor = value;
534                 UpdateVisual();
535             }
536         }
537
538         /// <summary>
539         /// Opacity is the alpha component of the mixColor, above.
540         /// </summary>
541         public float Opacity
542         {
543             get
544             {
545                 return _opacity ?? (1.0f);
546             }
547             set
548             {
549                 _opacity = value;
550                 UpdateVisual();
551             }
552         }
553
554     }
555
556     /// <summary>
557     /// A class encapsulating the property map of a image visual.
558     /// </summary>
559     public class ImageVisual : VisualMap
560     {
561         public ImageVisual() : base()
562         {
563         }
564
565         private string _url = null;
566         private FittingModeType? _fittingMode = null;
567         private SamplingModeType? _samplingMode = null;
568         private int? _desiredWidth = null;
569         private int? _desiredHeight = null;
570         private bool? _synchronousLoading = false;
571         private bool? _borderOnly = null;
572         private Vector4 _pixelArea = null;
573         private WrapModeType? _wrapModeU = null;
574         private WrapModeType? _wrapModeV = null;
575
576         /// <summary>
577         /// Get or set the URL of the image.<br>
578         /// Mandatory.
579         /// </summary>
580         public string URL
581         {
582             get
583             {
584                 return _url;
585             }
586             set
587             {
588                 _url = value;
589                 UpdateVisual();
590             }
591         }
592
593         /// <summary>
594         /// Get or set fitting options, used when resizing images to fit desired dimensions.<br>
595         /// If not supplied, default is FittingModeType.ShrinkToFit.<br>
596         /// For Normal Quad images only.<br>
597         /// Optional.
598         /// </summary>
599         public FittingModeType FittingMode
600         {
601             get
602             {
603                 return _fittingMode ?? (FittingModeType.ShrinkToFit);
604             }
605             set
606             {
607                 _fittingMode = value;
608                 UpdateVisual();
609             }
610         }
611
612         /// <summary>
613         /// Get or set filtering options, used when resizing images to sample original pixels.<br>
614         /// If not supplied, default is SamplingModeType.Box.<br>
615         /// For Normal Quad images only.<br>
616         /// Optional.
617         /// </summary>
618         public SamplingModeType SamplingMode
619         {
620             get
621             {
622                 return _samplingMode ?? (SamplingModeType.Box);
623             }
624             set
625             {
626                 _samplingMode = value;
627                 UpdateVisual();
628             }
629         }
630
631         /// <summary>
632         /// Get or set the desired image width.<br>
633         /// If not specified, the actual image width is used.<br>
634         /// For Normal Quad images only.<br>
635         /// Optional.
636         /// </summary>
637         public int DesiredWidth
638         {
639             get
640             {
641                 return _desiredWidth ?? (-1);
642             }
643             set
644             {
645                 _desiredWidth = value;
646                 UpdateVisual();
647             }
648         }
649
650         /// <summary>
651         /// Get or set the desired image height.<br>
652         /// If not specified, the actual image height is used.<br>
653         /// For Normal Quad images only.<br>
654         /// Optional.
655         /// </summary>
656         public int DesiredHeight
657         {
658             get
659             {
660                 return _desiredHeight ?? (-1);
661             }
662             set
663             {
664                 _desiredHeight = value;
665                 UpdateVisual();
666             }
667         }
668
669         /// <summary>
670         /// Get or set whether to load the image synchronously.<br>
671         /// If not specified, the default is false, i.e. the image is loaded asynchronously.<br>
672         /// For Normal Quad images only.<br>
673         /// Optional.
674         /// </summary>
675         public bool SynchronousLoading
676         {
677             get
678             {
679                 return _synchronousLoading ?? (false);
680             }
681             set
682             {
683                 _synchronousLoading = value;
684                 UpdateVisual();
685             }
686         }
687
688         /// <summary>
689         /// Get or set whether to draws the borders only(If true).<br>
690         /// If not specified, the default is false.<br>
691         /// For N-Patch images only.<br>
692         /// Optional.
693         /// </summary>
694         public bool BorderOnly
695         {
696             get
697             {
698                 return _borderOnly ?? (false);
699             }
700             set
701             {
702                 _borderOnly = value;
703                 UpdateVisual();
704             }
705         }
706
707         /// <summary>
708         /// Get or set the image area to be displayed.<br>
709         /// It is a rectangular area.<br>
710         /// The first two elements indicate the top-left position of the area, and the last two elements are the area width and height respectively.<br>
711         /// If not specified, the default value is Vector4(0.0, 0.0, 1.0, 1.0), i.e. the entire area of the image.<br>
712         /// For For Normal QUAD image only.<br>
713         /// Optional.
714         /// </summary>
715         public Vector4 PixelArea
716         {
717             get
718             {
719                 return _pixelArea ?? (new Vector4(0.0f, 0.0f, 1.0f, 1.0f));
720             }
721             set
722             {
723                 _pixelArea = value;
724                 UpdateVisual();
725             }
726         }
727
728         /// <summary>
729         /// Get or set the wrap mode for u coordinate.<br>
730         /// It decides how the texture should be sampled when the u coordinate exceeds the range of 0.0 to 1.0.<br>
731         /// If not specified, the default is WrapModeType.Default(CLAMP).<br>
732         /// For Normal QUAD image only.<br>
733         /// Optional.
734         /// </summary>
735         public WrapModeType WrapModeU
736         {
737             get
738             {
739                 return _wrapModeU ?? (WrapModeType.Default);
740             }
741             set
742             {
743                 _wrapModeU = value;
744                 UpdateVisual();
745             }
746         }
747
748         /// <summary>
749         /// Get or set the wrap mode for v coordinate.<br>
750         /// It decides how the texture should be sampled when the v coordinate exceeds the range of 0.0 to 1.0.<br>
751         /// The first two elements indicate the top-left position of the area, and the last two elements are the area width and height respectively.<br>
752         /// If not specified, the default is WrapModeType.Default(CLAMP).<br>
753         /// For Normal QUAD image only.
754         /// Optional.
755         /// </summary>
756         public WrapModeType WrapModeV
757         {
758             get
759             {
760                 return _wrapModeV ?? (WrapModeType.Default);
761             }
762             set
763             {
764                 _wrapModeV = value;
765                 UpdateVisual();
766             }
767         }
768
769         protected override void ComposingPropertyMap()
770         {
771             if (_url != null)
772             {
773                 _outputVisualMap = new PropertyMap();
774                 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
775                 _outputVisualMap.Add(ImageVisualProperty.URL, new PropertyValue(_url));
776                 if (_fittingMode != null) { _outputVisualMap.Add(ImageVisualProperty.FittingMode, new PropertyValue((int)_fittingMode)); }
777                 if (_samplingMode != null) { _outputVisualMap.Add(ImageVisualProperty.SamplingMode, new PropertyValue((int)_samplingMode)); }
778                 if (_desiredWidth != null) { _outputVisualMap.Add(ImageVisualProperty.DesiredWidth, new PropertyValue((int)_desiredWidth)); }
779                 if (_desiredHeight != null) { _outputVisualMap.Add(ImageVisualProperty.DesiredHeight, new PropertyValue((int)_desiredHeight)); }
780                 if (_synchronousLoading != null) { _outputVisualMap.Add(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading)); }
781                 if (_borderOnly != null) { _outputVisualMap.Add(ImageVisualProperty.BorderOnly, new PropertyValue((bool)_borderOnly)); }
782                 if (_pixelArea != null) { _outputVisualMap.Add(ImageVisualProperty.PixelArea, new PropertyValue(_pixelArea)); }
783                 if (_wrapModeU != null) { _outputVisualMap.Add(ImageVisualProperty.WrapModeU, new PropertyValue((int)_wrapModeU)); }
784                 if (_wrapModeV != null) { _outputVisualMap.Add(ImageVisualProperty.WrapModeV, new PropertyValue((int)_wrapModeV)); }
785                 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
786                 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
787                 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
788                 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
789             }
790         }
791     }
792
793     /// <summary>
794     /// A class encapsulating the property map of a text visual.
795     /// </summary>
796     public class TextVisual : VisualMap
797     {
798         public TextVisual() : base()
799         {
800         }
801
802         private string _text = null;
803         private string _fontFamily = null;
804         private PropertyMap _fontStyle = null;
805         private float? _pointSize = null;
806         private bool? _multiLine = null;
807         private string _horizontalAlignment = null;
808         private string _verticalAlignment = null;
809         private Color _textColor = null;
810         private bool? _enableMarkup = null;
811
812         /// <summary>
813         /// Get or set the text to display in UTF-8 format.<br>
814         /// Mandatory.
815         /// </summary>
816         public string Text
817         {
818             get
819             {
820                 return _text;
821             }
822             set
823             {
824                 _text = value;
825                 UpdateVisual();
826             }
827         }
828
829         /// <summary>
830         /// Get or set the requested font family to use.<br>
831         /// Optional.
832         /// </summary>
833         public string FontFamily
834         {
835             get
836             {
837                 return _fontFamily;
838             }
839             set
840             {
841                 _fontFamily = value;
842                 UpdateVisual();
843             }
844         }
845
846         /// <summary>
847         /// Get or set the requested font style to use.<br>
848         /// Optional.
849         /// </summary>
850         public PropertyMap FontStyle
851         {
852             get
853             {
854                 return _fontStyle;
855             }
856             set
857             {
858                 _fontStyle = value;
859                 UpdateVisual();
860             }
861         }
862
863         /// <summary>
864         /// Get or set the size of font in points.<br>
865         /// Mandatory.
866         /// </summary>
867         public float PointSize
868         {
869             get
870             {
871                 return _pointSize ?? (0.0f);
872             }
873             set
874             {
875                 _pointSize = value;
876                 UpdateVisual();
877             }
878         }
879
880         /// <summary>
881         /// Get or set the single-line or multi-line layout option.<br>
882         /// If not specified, the default is false.<br>
883         /// Optional.
884         /// </summary>
885         public bool MultiLine
886         {
887             get
888             {
889                 return _multiLine ?? (false);
890             }
891             set
892             {
893                 _multiLine = value;
894                 UpdateVisual();
895             }
896         }
897
898         /// <summary>
899         /// Get or set the line horizontal alignment.<br>
900         /// If not specified, the default is Begin.<br>
901         /// Optional.
902         /// </summary>
903         public HorizontalAlignment HorizontalAlignment
904         {
905             get
906             {
907                 switch (_horizontalAlignment)
908                 {
909                     case "BEGIN":
910                         return HorizontalAlignment.Begin;
911                     case "CENTER":
912                         return HorizontalAlignment.Center;
913                     case "END":
914                         return HorizontalAlignment.End;
915                     default:
916                         return HorizontalAlignment.Begin;
917                 }
918             }
919             set
920             {
921                 switch (value)
922                 {
923                     case HorizontalAlignment.Begin:
924                     {
925                         _horizontalAlignment = "BEGIN";
926                         break;
927                     }
928                     case HorizontalAlignment.Center:
929                     {
930                         _horizontalAlignment = "CENTER";
931                         break;
932                     }
933                     case HorizontalAlignment.End:
934                     {
935                         _horizontalAlignment = "END";
936                         break;
937                     }
938                     default:
939                     {
940                         _horizontalAlignment = "BEGIN";
941                         break;
942                     }
943                 }
944                 UpdateVisual();
945             }
946         }
947
948         /// <summary>
949         /// Get or set the line vertical alignment.<br>
950         /// If not specified, the default is Top.<br>
951         /// Optional.
952         /// </summary>
953         public VerticalAlignment VerticalAlignment
954         {
955             get
956             {
957                 switch (_verticalAlignment)
958                 {
959                     case "TOP":
960                         return VerticalAlignment.Top;
961                     case "CENTER":
962                         return VerticalAlignment.Center;
963                     case "BOTTOM":
964                         return VerticalAlignment.Bottom;
965                     default:
966                         return VerticalAlignment.Top;
967                 }
968             }
969             set
970             {
971                 switch (value)
972                 {
973                     case VerticalAlignment.Top:
974                     {
975                         _verticalAlignment = "TOP";
976                         break;
977                     }
978                     case VerticalAlignment.Center:
979                     {
980                         _verticalAlignment = "CENTER";
981                         break;
982                     }
983                     case VerticalAlignment.Bottom:
984                     {
985                         _verticalAlignment = "BOTTOM";
986                         break;
987                     }
988                     default:
989                     {
990                         _verticalAlignment = "TOP";
991                         break;
992                     }
993                 }
994                 UpdateVisual();
995             }
996         }
997
998         /// <summary>
999         /// Get or set the color of the text.<br>
1000         /// Optional.
1001         /// </summary>
1002         public Color TextColor
1003         {
1004             get
1005             {
1006                 return _textColor;
1007             }
1008             set
1009             {
1010                 _textColor = value;
1011                 UpdateVisual();
1012             }
1013         }
1014
1015         /// <summary>
1016         /// Get or set whether the mark-up processing is enabled.<br>
1017         /// Optional.
1018         /// </summary>
1019         public bool EnableMarkup
1020         {
1021             get
1022             {
1023                 return _enableMarkup ?? (false);
1024             }
1025             set
1026             {
1027                 _enableMarkup = value;
1028                 UpdateVisual();
1029             }
1030         }
1031
1032         protected override void ComposingPropertyMap()
1033         {
1034             if (_text != null && _pointSize != null)
1035             {
1036                 _outputVisualMap = new PropertyMap();
1037                 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
1038                 _outputVisualMap.Add(TextVisualProperty.Text, new PropertyValue(_text));
1039                 _outputVisualMap.Add(TextVisualProperty.PointSize, new PropertyValue((float)_pointSize));
1040                 if (_fontFamily != null) { _outputVisualMap.Add(TextVisualProperty.FontFamily, new PropertyValue(_fontFamily)); }
1041                 if (_fontStyle != null) { _outputVisualMap.Add(TextVisualProperty.FontStyle, new PropertyValue(_fontStyle)); }
1042                 if (_multiLine != null) { _outputVisualMap.Add(TextVisualProperty.MultiLine, new PropertyValue((bool)_multiLine)); }
1043                 if (_horizontalAlignment != null) { _outputVisualMap.Add(TextVisualProperty.HorizontalAlignment, new PropertyValue(_horizontalAlignment)); }
1044                 if (_verticalAlignment != null) { _outputVisualMap.Add(TextVisualProperty.VerticalAlignment, new PropertyValue(_verticalAlignment)); }
1045                 if (_textColor != null) { _outputVisualMap.Add(TextVisualProperty.TextColor, new PropertyValue(_textColor)); }
1046                 if (_enableMarkup != null) { _outputVisualMap.Add(TextVisualProperty.EnableMarkup, new PropertyValue((bool)_enableMarkup)); }
1047                 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1048                 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1049                 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1050                 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1051             }
1052         }
1053     }
1054
1055     /// <summary>
1056     /// A class encapsulating the property map of a border visual.
1057     /// </summary>
1058     public class BorderVisual : VisualMap
1059     {
1060         public BorderVisual() : base()
1061         {
1062         }
1063
1064         private Color _color = null;
1065         private float? _size = null;
1066         private bool? _antiAliasing = null;
1067
1068         /// <summary>
1069         /// Get or set the color of the border.<br>
1070         /// Mandatory.
1071         /// </summary>
1072         public Color Color
1073         {
1074             get
1075             {
1076                 return _color;
1077             }
1078             set
1079             {
1080                 _color = value;
1081                 UpdateVisual();
1082             }
1083         }
1084
1085         /// <summary>
1086         /// Get or set the width of the border (in pixels).<br>
1087         /// Mandatory.
1088         /// </summary>
1089         public float BorderSize
1090         {
1091             get
1092             {
1093                 return _size ?? (-1.0f);
1094             }
1095             set
1096             {
1097                 _size = value;
1098                 UpdateVisual();
1099             }
1100         }
1101
1102         /// <summary>
1103         /// Get or set whether anti-aliasing of the border is required.<br>
1104         /// If not supplied, default is false.<br>
1105         /// Optional.
1106         /// </summary>
1107         public bool AntiAliasing
1108         {
1109             get
1110             {
1111                 return _antiAliasing ?? (false);
1112             }
1113             set
1114             {
1115                 _antiAliasing = value;
1116                 UpdateVisual();
1117             }
1118         }
1119
1120         protected override void ComposingPropertyMap()
1121         {
1122             if (_color != null && _size != null)
1123             {
1124                 _outputVisualMap = new PropertyMap();
1125                 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Border));
1126                 _outputVisualMap.Add(BorderVisualProperty.Size, new PropertyValue((float)_size));
1127                 _outputVisualMap.Add(BorderVisualProperty.Color, new PropertyValue(_color));
1128                 if (_antiAliasing != null) { _outputVisualMap.Add(BorderVisualProperty.AntiAliasing, new PropertyValue((bool)_antiAliasing)); }
1129                 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1130                 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1131                 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1132                 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1133             }
1134         }
1135     }
1136
1137     /// <summary>
1138     /// A class encapsulating the property map of a color visual.
1139     /// </summary>
1140     public class ColorVisual : VisualMap
1141     {
1142         public ColorVisual() : base()
1143         {
1144         }
1145
1146         private Color _mixColorForColorVisual = null;
1147
1148         /// <summary>
1149         /// Get or set the solid color required.<br>
1150         /// Mandatory.
1151         /// </summary>
1152         public Color Color
1153         {
1154             get
1155             {
1156                 return _mixColorForColorVisual;
1157             }
1158             set
1159             {
1160                 _mixColorForColorVisual = value;
1161                 UpdateVisual();
1162             }
1163         }
1164
1165         protected override void ComposingPropertyMap()
1166         {
1167             if (_mixColorForColorVisual != null)
1168             {
1169                 _outputVisualMap = new PropertyMap();
1170                 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Color));
1171                 _outputVisualMap.Add(ColorVisualProperty.MixColor, new PropertyValue(_mixColorForColorVisual));
1172                 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1173                 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1174                 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1175             }
1176         }
1177     }
1178
1179     /// <summary>
1180     /// A class encapsulating the property map of a gradient visual.
1181     /// </summary>
1182     public class GradientVisual : VisualMap
1183     {
1184         public GradientVisual() : base()
1185         {
1186         }
1187
1188         private Vector2 _startPosition = null;
1189         private Vector2 _endPosition = null;
1190         private Vector2 _center = null;
1191         private float? _radius = null;
1192         private PropertyArray _stopOffset = null;
1193         private PropertyArray _stopColor = null;
1194         private GradientVisualUnitsType? _units = null;
1195         private GradientVisualSpreadMethodType? _spreadMethod = null;
1196
1197         /// <summary>
1198         /// Get or set the start position of a linear gradient.<br>
1199         /// Mandatory for Linear.<br>
1200         /// </summary>
1201         public Vector2 StartPosition
1202         {
1203             get
1204             {
1205                 return _startPosition;
1206             }
1207             set
1208             {
1209                 _startPosition = value;
1210                 UpdateVisual();
1211             }
1212         }
1213
1214         /// <summary>
1215         /// Get or set the end position of a linear gradient.<br>
1216         /// Mandatory for Linear.<br>
1217         /// </summary>
1218         public Vector2 EndPosition
1219         {
1220             get
1221             {
1222                 return _endPosition;
1223             }
1224             set
1225             {
1226                 _endPosition = value;
1227                 UpdateVisual();
1228             }
1229         }
1230
1231         /// <summary>
1232         /// Get or set the center point of a radial gradient.<br>
1233         /// Mandatory for Radial.<br>
1234         /// </summary>
1235         public Vector2 Center
1236         {
1237             get
1238             {
1239                 return _center;
1240             }
1241             set
1242             {
1243                 _center = value;
1244                 UpdateVisual();
1245             }
1246         }
1247
1248         /// <summary>
1249         /// Get or set the size of the radius of a radial gradient.<br>
1250         /// Mandatory for Radial.<br>
1251         /// </summary>
1252         public float Radius
1253         {
1254             get
1255             {
1256                 return _radius ?? (-1.0f);
1257             }
1258             set
1259             {
1260                 _radius = value;
1261                 UpdateVisual();
1262             }
1263         }
1264
1265         /// <summary>
1266         /// Get or set all the stop offsets.<br>
1267         /// A PropertyArray of float.<br>
1268         /// If not supplied, default is 0.0f and 1.0f.<br>
1269         /// Optional.
1270         /// </summary>
1271         public PropertyArray StopOffset
1272         {
1273             get
1274             {
1275                 return _stopOffset;
1276             }
1277             set
1278             {
1279                 _stopOffset = value;
1280                 UpdateVisual();
1281             }
1282         }
1283
1284         /// <summary>
1285         /// Get or set the color at the stop offsets.<br>
1286         /// A PropertyArray of Color.<br>
1287         /// At least 2 values required to show a gradient.<br>
1288         /// Mandatory.
1289         /// </summary>
1290         public PropertyArray StopColor
1291         {
1292             get
1293             {
1294                 return _stopColor;
1295             }
1296             set
1297             {
1298                 _stopColor = value;
1299                 UpdateVisual();
1300             }
1301         }
1302
1303         /// <summary>
1304         /// Get or set defines the coordinate system for certain attributes of the points in a gradient.<br>
1305         /// If not supplied, default is GradientVisualUnitsType.ObjectBoundingBox.<br>
1306         /// Optional.
1307         /// </summary>
1308         public GradientVisualUnitsType Units
1309         {
1310             get
1311             {
1312                 return _units ?? (GradientVisualUnitsType.ObjectBoundingBox);
1313             }
1314             set
1315             {
1316                 _units = value;
1317                 UpdateVisual();
1318             }
1319         }
1320
1321         /// <summary>
1322         /// Get or set indicates what happens if the gradient starts or ends inside the bounds of the target rectangle.<br>
1323         /// If not supplied, default is GradientVisualSpreadMethodType.Pad.<br>
1324         /// Optional.
1325         /// </summary>
1326         public GradientVisualSpreadMethodType SpreadMethod
1327         {
1328             get
1329             {
1330                 return _spreadMethod ?? (GradientVisualSpreadMethodType.Pad);
1331             }
1332             set
1333             {
1334                 _spreadMethod = value;
1335                 UpdateVisual();
1336             }
1337         }
1338
1339         protected override void ComposingPropertyMap()
1340         {
1341             if (((_startPosition != null && _endPosition != null) || (_center != null && _radius != null)) && _stopColor != null)
1342             {
1343                 _outputVisualMap = new PropertyMap();
1344                 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Gradient));
1345                 _outputVisualMap.Add(GradientVisualProperty.StopColor, new PropertyValue(_stopColor));
1346                 if (_startPosition != null) { _outputVisualMap.Add(GradientVisualProperty.StartPosition, new PropertyValue(_startPosition)); }
1347                 if (_endPosition != null) { _outputVisualMap.Add(GradientVisualProperty.EndPosition, new PropertyValue(_endPosition)); }
1348                 if (_center != null) { _outputVisualMap.Add(GradientVisualProperty.Center, new PropertyValue(_center)); }
1349                 if (_radius != null) { _outputVisualMap.Add(GradientVisualProperty.Radius, new PropertyValue((float)_radius)); }
1350                 if (_stopOffset != null) { _outputVisualMap.Add(GradientVisualProperty.StopOffset, new PropertyValue(_stopOffset)); }
1351                 if (_units != null) { _outputVisualMap.Add(GradientVisualProperty.Units, new PropertyValue((int)_units)); }
1352                 if (_spreadMethod != null) { _outputVisualMap.Add(GradientVisualProperty.SpreadMethod, new PropertyValue((int)_spreadMethod)); }
1353                 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1354                 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1355                 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1356                 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1357             }
1358         }
1359     }
1360
1361     /// <summary>
1362     /// A class encapsulating the property map of a mesh visual.
1363     /// </summary>
1364     public class MeshVisual : VisualMap
1365     {
1366         public MeshVisual() : base()
1367         {
1368         }
1369
1370         private string _objectURL = null;
1371         private string _materialtURL = null;
1372         private string _texturesPath = null;
1373         private MeshVisualShadingModeValue? _shadingMode = null;
1374         private bool? _useMipmapping = null;
1375         private bool? _useSoftNormals = null;
1376         private Vector3 _lightPosition = null;
1377
1378         /// <summary>
1379         /// Get or set the location of the ".obj" file.<br>
1380         /// Mandatory.
1381         /// </summary>
1382         public string ObjectURL
1383         {
1384             get
1385             {
1386                 return _objectURL;
1387             }
1388             set
1389             {
1390                 _objectURL = value;
1391                 UpdateVisual();
1392             }
1393         }
1394
1395         /// <summary>
1396         /// Get or set the location of the ".mtl" file.<br>
1397         /// If not specified, then a textureless object is assumed.<br>
1398         /// Optional.
1399         /// </summary>
1400         public string MaterialtURL
1401         {
1402             get
1403             {
1404                 return _materialtURL;
1405             }
1406             set
1407             {
1408                 _materialtURL = value;
1409                 UpdateVisual();
1410             }
1411         }
1412
1413         /// <summary>
1414         /// Get or set path to the directory the textures (including gloss and normal) are stored in.<br>
1415         /// Mandatory if using material.<br>
1416         /// </summary>
1417         public string TexturesPath
1418         {
1419             get
1420             {
1421                 return _texturesPath;
1422             }
1423             set
1424             {
1425                 _texturesPath = value;
1426                 UpdateVisual();
1427             }
1428         }
1429
1430         /// <summary>
1431         /// Get or set the type of shading mode that the mesh will use.<br>
1432         /// If anything the specified shading mode requires is missing, a simpler mode that can be handled with what has been supplied will be used instead.<br>
1433         /// If not specified, it will use the best it can support (will try MeshVisualShadingModeValue.TexturedWithDetailedSpecularLighting first).<br>
1434         /// Optional.
1435         /// </summary>
1436         public MeshVisualShadingModeValue ShadingMode
1437         {
1438             get
1439             {
1440                 return _shadingMode ?? (MeshVisualShadingModeValue.TexturedWithDetailedSpecularLighting);
1441             }
1442             set
1443             {
1444                 _shadingMode = value;
1445                 UpdateVisual();
1446             }
1447         }
1448
1449         /// <summary>
1450         /// Get or set whether to use mipmaps for textures or not.<br>
1451         /// If not specified, the default is true.<br>
1452         /// Optional.
1453         /// </summary>
1454         public bool UseMipmapping
1455         {
1456             get
1457             {
1458                 return _useMipmapping ?? (true);
1459             }
1460             set
1461             {
1462                 _useMipmapping = value;
1463                 UpdateVisual();
1464             }
1465         }
1466
1467         /// <summary>
1468         /// Get or set whether to average normals at each point to smooth textures or not.<br>
1469         /// If not specified, the default is true.<br>
1470         /// Optional.
1471         /// </summary>
1472         public bool UseSoftNormals
1473         {
1474             get
1475             {
1476                 return _useSoftNormals ?? (true);
1477             }
1478             set
1479             {
1480                 _useSoftNormals = value;
1481                 UpdateVisual();
1482             }
1483         }
1484
1485         /// <summary>
1486         /// Get or set the position, in stage space, of the point light that applies lighting to the model.<br>
1487         /// This is based off the stage's dimensions, so using the width and height of the stage halved will correspond to the center,
1488         /// and using all zeroes will place the light at the top left corner.<br>
1489         /// If not specified, the default is an offset outwards from the center of the screen.<br>
1490         /// Optional.
1491         /// </summary>
1492         public Vector3 LightPosition
1493         {
1494             get
1495             {
1496                 return _lightPosition;
1497             }
1498             set
1499             {
1500                 _lightPosition = value;
1501                 UpdateVisual();
1502             }
1503         }
1504
1505         protected override void ComposingPropertyMap()
1506         {
1507             if (_objectURL != null)
1508             {
1509                 _outputVisualMap = new PropertyMap();
1510                 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Mesh));
1511                 _outputVisualMap.Add(MeshVisualProperty.ObjectURL, new PropertyValue(_objectURL));
1512                 if (_materialtURL != null) { _outputVisualMap.Add(MeshVisualProperty.MaterialtURL, new PropertyValue(_materialtURL)); }
1513                 if (_texturesPath != null) { _outputVisualMap.Add(MeshVisualProperty.TexturesPath, new PropertyValue(_texturesPath)); }
1514                 if (_shadingMode != null) { _outputVisualMap.Add(MeshVisualProperty.ShadingMode, new PropertyValue((int)_shadingMode)); }
1515                 if (_useMipmapping != null) { _outputVisualMap.Add(MeshVisualProperty.UseMipmapping, new PropertyValue((bool)_useMipmapping)); }
1516                 if (_useSoftNormals != null) { _outputVisualMap.Add(MeshVisualProperty.UseSoftNormals, new PropertyValue((bool)_useSoftNormals)); }
1517                 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1518                 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1519                 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1520                 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1521             }
1522         }
1523     }
1524
1525     /// <summary>
1526     /// A class encapsulating the property map of a primetive visual.
1527     /// </summary>
1528     public class PrimitiveVisual : VisualMap
1529     {
1530         public PrimitiveVisual() : base()
1531         {
1532         }
1533
1534         private PrimitiveVisualShapeType? _shape = null;
1535         private Color _mixColorForPrimitiveVisual = null;
1536         private int? _slices = null;
1537         private int? _stacks = null;
1538         private float? _scaleTopRadius = null;
1539         private float? _scaleBottomRadius = null;
1540         private float? _scaleHeight = null;
1541         private float? _scaleRadius = null;
1542         private Vector3 _scaleDimensions = null;
1543         private float? _bevelPercentage = null;
1544         private float? _bevelSmoothness = null;
1545         private Vector3 _lightPosition = null;
1546
1547         /// <summary>
1548         /// Get or set the specific shape to render.<br>
1549         /// If not specified, the default is PrimitiveVisualShapeType.Sphere.<br>
1550         /// Optional.
1551         /// </summary>
1552         public PrimitiveVisualShapeType Shape
1553         {
1554             get
1555             {
1556                 return _shape ?? (PrimitiveVisualShapeType.Sphere);
1557             }
1558             set
1559             {
1560                 _shape = value;
1561                 UpdateVisual();
1562             }
1563         }
1564
1565         /// <summary>
1566         /// Get or set the color of the shape.<br>
1567         /// If not specified, the default is Color(0.5, 0.5, 0.5, 1.0).<br>
1568         /// Applies to ALL shapes.<br>
1569         /// Optional.
1570         /// </summary>
1571         public Color MixColor
1572         {
1573             get
1574             {
1575                 return _mixColorForPrimitiveVisual ?? (new Color(0.5f, 0.5f, 0.5f, 1.0f));
1576             }
1577             set
1578             {
1579                 _mixColorForPrimitiveVisual = value;
1580                 UpdateVisual();
1581             }
1582         }
1583
1584         /// <summary>
1585         /// Get or set the number of slices as you go around the shape.<br>
1586         /// For spheres and conical frustrums, this determines how many divisions there are as you go around the object.<br>
1587         /// If not specified, the default is 128.<br>
1588         /// The range is from 1 to 255.<br>
1589         /// Optional.
1590         /// </summary>
1591         public int Slices
1592         {
1593             get
1594             {
1595                 return _slices ?? (128);
1596             }
1597             set
1598             {
1599                 _slices = value;
1600                 UpdateVisual();
1601             }
1602         }
1603
1604         /// <summary>
1605         /// Get or set the number of stacks as you go down the shape.<br>
1606         /// For spheres, 'stacks' determines how many layers there are as you go down the object.<br>
1607         /// If not specified, the default is 128.<br>
1608         /// The range is from 1 to 255.<br>
1609         /// Optional.
1610         /// </summary>
1611         public int Stacks
1612         {
1613             get
1614             {
1615                 return _stacks ?? (128);
1616             }
1617             set
1618             {
1619                 _stacks = value;
1620                 UpdateVisual();
1621             }
1622         }
1623
1624         /// <summary>
1625         /// Get or set the scale of the radius of the top circle of a conical frustrum.<br>
1626         /// If not specified, the default is 1.0f.<br>
1627         /// Applies to: - PrimitiveVisualShapeType.ConicalFrustrum<br>
1628         /// Only values greater than or equal to 0.0f are accepted.<br>
1629         /// Optional.
1630         /// </summary>
1631         public float ScaleTopRadius
1632         {
1633             get
1634             {
1635                 return _scaleTopRadius ?? (1.0f);
1636             }
1637             set
1638             {
1639                 _scaleTopRadius = value;
1640                 UpdateVisual();
1641             }
1642         }
1643
1644         /// <summary>
1645         /// Get or set the scale of the radius of the bottom circle of a conical frustrum.<br>
1646         /// If not specified, the default is 1.5f.<br>
1647         /// Applies to:  - PrimitiveVisualShapeType.ConicalFrustrum<br>
1648         ///              - PrimitiveVisualShapeType.Cone<br>
1649         /// Only values greater than or equal to 0.0f are accepted.<br>
1650         /// Optional.
1651         /// </summary>
1652         public float ScaleBottomRadius
1653         {
1654             get
1655             {
1656                 return _scaleBottomRadius ?? (1.5f);
1657             }
1658             set
1659             {
1660                 _scaleBottomRadius = value;
1661                 UpdateVisual();
1662             }
1663         }
1664
1665         /// <summary>
1666         /// Get or set the scale of the height of a conic.<br>
1667         /// If not specified, the default is 3.0f.<br>
1668         /// Applies to:<br>
1669         ///      - PrimitiveVisualShapeType.ConicalFrustrum<br>
1670         ///      - PrimitiveVisualShapeType.Cone<br>
1671         ///      - PrimitiveVisualShapeType.Cylinder<br>
1672         /// Only values greater than or equal to 0.0f are accepted.<br>
1673         /// Optional.
1674         /// </summary>
1675         public float ScaleHeight
1676         {
1677             get
1678             {
1679                 return _scaleHeight ?? (3.0f);
1680             }
1681             set
1682             {
1683                 _scaleHeight = value;
1684                 UpdateVisual();
1685             }
1686         }
1687
1688         /// <summary>
1689         /// Get or set the scale of the radius of a cylinder.<br>
1690         /// If not specified, the default is 1.0f.<br>
1691         /// Applies to:<br>
1692         ///      - PrimitiveVisualShapeType.Cylinder<br>
1693         /// Only values greater than or equal to 0.0f are accepted.<br>
1694         /// Optional.
1695         /// </summary>
1696         public float ScaleRadius
1697         {
1698             get
1699             {
1700                 return _scaleRadius ?? (1.0f);
1701             }
1702             set
1703             {
1704                 _scaleRadius = value;
1705                 UpdateVisual();
1706             }
1707         }
1708
1709         /// <summary>
1710         /// Get or set the dimensions of a cuboid. Scales in the same fashion as a 9-patch image.<br>
1711         /// If not specified, the default is Vector3.One.<br>
1712         /// Applies to:<br>
1713         ///      - PrimitiveVisualShapeType.Cube<br>
1714         ///      - PrimitiveVisualShapeType.Octahedron<br>
1715         ///      - PrimitiveVisualShapeType.BevelledCube<br>
1716         /// Each vector3 parameter should be greater than or equal to 0.0f.<br>
1717         /// Optional.
1718         /// </summary>
1719         public Vector3 ScaleDimensions
1720         {
1721             get
1722             {
1723                 return _scaleDimensions ?? (Vector3.One);
1724             }
1725             set
1726             {
1727                 _scaleDimensions = value;
1728                 UpdateVisual();
1729             }
1730         }
1731
1732         /// <summary>
1733         /// Get or set determines how bevelled the cuboid should be, based off the smallest dimension.<br>
1734         /// Bevel percentage ranges from 0.0 to 1.0. It affects the ratio of the outer face widths to the width of the overall cube.<br>
1735         /// If not specified, the default is 0.0f (no bevel).<br>
1736         /// Applies to:<br>
1737         ///      - PrimitiveVisualShapeType.BevelledCube<br>
1738         /// The range is from 0.0f to 1.0f.<br>
1739         /// Optional.
1740         /// </summary>
1741         public float BevelPercentage
1742         {
1743             get
1744             {
1745                 return _bevelPercentage ?? (0.0f);
1746             }
1747             set
1748             {
1749                 _bevelPercentage = value;
1750                 UpdateVisual();
1751             }
1752         }
1753
1754         /// <summary>
1755         /// Get or set defines how smooth the bevelled edges should be.<br>
1756         /// If not specified, the default is 0.0f (sharp edges).<br>
1757         /// Applies to:<br>
1758         ///      - PrimitiveVisualShapeType.BevelledCube<br>
1759         /// The range is from 0.0f to 1.0f.<br>
1760         /// Optional.
1761         /// </summary>
1762         public float BevelSmoothness
1763         {
1764             get
1765             {
1766                 return _bevelSmoothness ?? (0.0f);
1767             }
1768             set
1769             {
1770                 _bevelSmoothness = value;
1771                 UpdateVisual();
1772             }
1773         }
1774
1775         /// <summary>
1776         /// Get or set the position, in stage space, of the point light that applies lighting to the model.<br>
1777         /// This is based off the stage's dimensions, so using the width and height of the stage halved will correspond to the center,
1778         /// and using all zeroes will place the light at the top left corner.<br>
1779         /// If not specified, the default is an offset outwards from the center of the screen.<br>
1780         /// Applies to ALL shapes.<br>
1781         /// Optional.
1782         /// </summary>
1783         public Vector3 LightPosition
1784         {
1785             get
1786             {
1787                 return _lightPosition;
1788             }
1789             set
1790             {
1791                 _lightPosition = value;
1792                 UpdateVisual();
1793             }
1794         }
1795
1796         protected override void ComposingPropertyMap()
1797         {
1798             _outputVisualMap = new PropertyMap(); ;
1799             _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Primitive));
1800             if (_shape != null) { _outputVisualMap.Add(PrimitiveVisualProperty.Shape, new PropertyValue((int)_shape)); }
1801             if (_mixColorForPrimitiveVisual != null) { _outputVisualMap.Add(PrimitiveVisualProperty.MixColor, new PropertyValue(_mixColorForPrimitiveVisual)); }
1802             if (_slices != null) { _outputVisualMap.Add(PrimitiveVisualProperty.Slices, new PropertyValue((int)_slices)); }
1803             if (_stacks != null) { _outputVisualMap.Add(PrimitiveVisualProperty.Stacks, new PropertyValue((int)_stacks)); }
1804             if (_scaleTopRadius != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleTopRadius, new PropertyValue((float)_scaleTopRadius)); }
1805             if (_scaleBottomRadius != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleBottomRadius, new PropertyValue((float)_scaleBottomRadius)); }
1806             if (_scaleHeight != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleHeight, new PropertyValue((float)_scaleHeight)); }
1807             if (_scaleRadius != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleRadius, new PropertyValue((float)_scaleRadius)); }
1808             if (_scaleDimensions != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleDimensions, new PropertyValue(_scaleDimensions)); }
1809             if (_bevelPercentage != null) { _outputVisualMap.Add(PrimitiveVisualProperty.BevelPercentage, new PropertyValue((float)_bevelPercentage)); }
1810             if (_bevelSmoothness != null) { _outputVisualMap.Add(PrimitiveVisualProperty.BevelSmoothness, new PropertyValue((float)_bevelSmoothness)); }
1811             if (_lightPosition != null) { _outputVisualMap.Add(PrimitiveVisualProperty.LightPosition, new PropertyValue(_lightPosition)); }
1812             if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1813             if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1814             if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1815         }
1816     }
1817
1818     /// <summary>
1819     /// A class encapsulating the property map of a n-patch image visual.
1820     /// </summary>
1821     public class NPatchVisual : VisualMap
1822     {
1823         public NPatchVisual() : base()
1824         {
1825         }
1826
1827         private string _url = null;
1828         private bool? _borderOnly = null;
1829         private Rectangle _border = null;
1830
1831         /// <summary>
1832         /// Get or set the URL of the image.<br>
1833         /// Mandatory.
1834         /// </summary>
1835         public string URL
1836         {
1837             get
1838             {
1839                 return _url;
1840             }
1841             set
1842             {
1843                 _url = value;
1844                 UpdateVisual();
1845             }
1846         }
1847
1848         /// <summary>
1849         /// Get or set whether to draws the borders only(If true).<br>
1850         /// If not specified, the default is false.<br>
1851         /// For N-Patch images only.<br>
1852         /// Optional.
1853         /// </summary>
1854         public bool BorderOnly
1855         {
1856             get
1857             {
1858                 return _borderOnly ?? false;
1859             }
1860             set
1861             {
1862                 _borderOnly = value;
1863                 UpdateVisual();
1864             }
1865         }
1866
1867         /// <summary>
1868         /// The border of the image in the order: left, right, bottom, top.<br>
1869         /// For N-Patch images only.<br>
1870         /// Optional.
1871         /// </summary>
1872         public Rectangle Border
1873         {
1874             get
1875             {
1876                 return _border;
1877             }
1878             set
1879             {
1880                 _border = value;
1881                 UpdateVisual();
1882             }
1883         }
1884
1885         protected override void ComposingPropertyMap()
1886         {
1887             if (_url != null)
1888             {
1889                 _outputVisualMap = new PropertyMap();
1890                 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
1891                 _outputVisualMap.Add(NpatchImageVisualProperty.URL, new PropertyValue(_url));
1892                 if (_borderOnly != null) { _outputVisualMap.Add(NpatchImageVisualProperty.BorderOnly, new PropertyValue((bool)_borderOnly)); }
1893                 if (_border != null) { _outputVisualMap.Add(NpatchImageVisualProperty.Border, new PropertyValue(_border)); }
1894                 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1895                 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1896                 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1897                 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1898             }
1899         }
1900     }
1901
1902     /// <summary>
1903     /// A class encapsulating the property map of a SVG visual.
1904     /// </summary>
1905     public class SVGVisual : VisualMap
1906     {
1907         public SVGVisual() : base()
1908         {
1909         }
1910
1911         private string _url = null;
1912
1913         public string URL
1914         {
1915             get
1916             {
1917                 return _url;
1918             }
1919             set
1920             {
1921                 _url = value;
1922                 UpdateVisual();
1923             }
1924         }
1925
1926         protected override void ComposingPropertyMap()
1927         {
1928             if (_url != null)
1929             {
1930                 _outputVisualMap = new PropertyMap();
1931                 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.SVG));
1932                 _outputVisualMap.Add(ImageVisualProperty.URL, new PropertyValue(_url));
1933                 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1934                 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1935                 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1936                 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1937             }
1938         }
1939     }
1940
1941     /// <summary>
1942     /// A class encapsulating the property map of a Animated Image(AGIF) visual.
1943     /// </summary>
1944     public class AnimatedImageVisual : VisualMap
1945     {
1946         public AnimatedImageVisual() : base()
1947         {
1948         }
1949
1950         private string _url = null;
1951
1952         public string URL
1953         {
1954             get
1955             {
1956                 return _url;
1957             }
1958             set
1959             {
1960                 _url = value;
1961                 UpdateVisual();
1962             }
1963         }
1964
1965         protected override void ComposingPropertyMap()
1966         {
1967             if (_url != null)
1968             {
1969                 _outputVisualMap = new PropertyMap();
1970                 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.AnimatedImage));
1971                 _outputVisualMap.Add(ImageVisualProperty.URL, new PropertyValue(_url));
1972                 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
1973                 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
1974                 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
1975                 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
1976             }
1977         }
1978     }
1979
1980     /// <summary>
1981     /// A class encapsulating the property map of a visual transition(Animator).
1982     /// </summary>
1983     public class AnimatorVisual : VisualMap
1984     {
1985         public AnimatorVisual() : base()
1986         {
1987         }
1988
1989         private string _alphaFunction = null;
1990         private int _startTime = 0;
1991         private int _endTime = 0;
1992         private string _target = null;
1993         private string _propertyIndex = null;
1994         private object _destinationValue = null;
1995
1996         public string AlphaFunction
1997         {
1998             get
1999             {
2000                 return _alphaFunction;
2001             }
2002             set
2003             {
2004                 _alphaFunction = value;
2005             }
2006         }
2007
2008         public int StartTime
2009         {
2010             get
2011             {
2012                 return _startTime;
2013             }
2014             set
2015             {
2016                 _startTime = value;
2017             }
2018         }
2019
2020         public int EndTime
2021         {
2022             get
2023             {
2024                 return _endTime;
2025             }
2026             set
2027             {
2028                 _endTime = value;
2029             }
2030         }
2031
2032         public string Target
2033         {
2034             get
2035             {
2036                 return _target;
2037             }
2038             set
2039             {
2040                 _target = value;
2041             }
2042         }
2043
2044         public string PropertyIndex
2045         {
2046             get
2047             {
2048                 return _propertyIndex;
2049             }
2050             set
2051             {
2052                 _propertyIndex = value;
2053             }
2054         }
2055
2056         public object DestinationValue
2057         {
2058             get
2059             {
2060                 return _destinationValue;
2061             }
2062             set
2063             {
2064                 _destinationValue = value;
2065             }
2066         }
2067
2068         protected override void ComposingPropertyMap()
2069         {
2070             PropertyMap _animator = new PropertyMap();
2071             _animator.Add("alphaFunction", new PropertyValue(_alphaFunction));
2072
2073             PropertyMap _timePeriod = new PropertyMap();
2074             _timePeriod.Add("duration", new PropertyValue((_endTime - _startTime) / 1000.0f));
2075             _timePeriod.Add("delay", new PropertyValue(_startTime / 1000.0f));
2076             _animator.Add("timePeriod", new PropertyValue(_timePeriod));
2077
2078             string _str1 = _propertyIndex.Substring(0, 1);
2079             string _str2 = _propertyIndex.Substring(1);
2080             string _str = _str1.ToLower() + _str2;
2081
2082             PropertyValue val = PropertyValue.CreateFromObject(_destinationValue);
2083
2084             PropertyMap _transition = new PropertyMap();
2085             _transition.Add("target", new PropertyValue(_target));
2086             _transition.Add("property", new PropertyValue(_str));
2087             _transition.Add("targetValue", val);
2088             _transition.Add("animator", new PropertyValue(_animator));
2089
2090             _outputVisualMap = _transition;
2091         }
2092     }
2093
2094 }