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