[NUI] Fix NUITizenGallery to run on Ubuntu VS-Code debugging
[platform/core/csapi/tizenfx.git] / test / NUITizenGallery / Examples / ShadowFrameTest / ShadowFrameTest1Page.xaml.cs
1 using Tizen.NUI;
2 using Tizen.NUI.BaseComponents;
3 using Tizen.NUI.Components;
4
5 namespace NUITizenGallery
6 {
7     public partial class ShadowFrameTest1Page : ContentPage
8     {
9         private bool shadowToggleShow; // true if we show shadow
10         private Shadow CreateShadowFromeSliders()
11         {
12             return new Shadow
13             (
14                 ShadowBlurRadius.CurrentValue,
15                 new Color(
16                     ShadowColorRed.CurrentValue / 255.0f,
17                     ShadowColorGreen.CurrentValue / 255.0f,
18                     ShadowColorBlue.CurrentValue / 255.0f,
19                     ShadowOpacity.CurrentValue / 255.0f),
20                 new Vector2(
21                     ShadowOffsetX.CurrentValue,
22                     ShadowOffsetY.CurrentValue)
23             );
24         }
25         public ShadowFrameTest1Page()
26         {
27             InitializeComponent();
28             shadowToggleShow = true;
29
30             // CornerRadius
31             CornerTopLeft.ValueChanged += (o, e) =>
32             {
33                 Vector4 currentCornerRadius = target.CornerRadius;
34                 target.CornerRadius = new Vector4(CornerTopLeft.CurrentValue, currentCornerRadius.Y, currentCornerRadius.Z, currentCornerRadius.W);
35             };
36             CornerTopRight.ValueChanged += (o, e) =>
37             {
38                 Vector4 currentCornerRadius = target.CornerRadius;
39                 target.CornerRadius = new Vector4(currentCornerRadius.X, CornerTopRight.CurrentValue, currentCornerRadius.Z, currentCornerRadius.W);
40             };
41             CornerBottomRight.ValueChanged += (o, e) =>
42             {
43                 Vector4 currentCornerRadius = target.CornerRadius;
44                 target.CornerRadius = new Vector4(currentCornerRadius.X, currentCornerRadius.Y, CornerBottomRight.CurrentValue, currentCornerRadius.W);
45             };
46             CornerBottomLeft.ValueChanged += (o, e) =>
47             {
48                 Vector4 currentCornerRadius = target.CornerRadius;
49                 target.CornerRadius = new Vector4(currentCornerRadius.X, currentCornerRadius.Y, currentCornerRadius.Z, CornerBottomLeft.CurrentValue);
50             };
51
52             // Borderline Width/Offset
53             BorderlineWidthSlider.ValueChanged += (o, e) =>
54             {
55                 target.BorderlineWidth = BorderlineWidthSlider.CurrentValue;
56             };
57             BorderlineOffsetSlider.ValueChanged += (o, e) =>
58             {
59                 target.BorderlineOffset = BorderlineOffsetSlider.CurrentValue;
60             };
61
62             // Borderline Color
63             BorderlineRed.ValueChanged += (o, e) =>
64             {
65                 Color currentColor = target.BorderlineColor;
66                 target.BorderlineColor = new Color(BorderlineRed.CurrentValue / 255.0f, currentColor.G, currentColor.B, currentColor.A);
67             };
68             BorderlineGreen.ValueChanged += (o, e) =>
69             {
70                 Color currentColor = target.BorderlineColor;
71                 target.BorderlineColor = new Color(currentColor.R, BorderlineGreen.CurrentValue / 255.0f, currentColor.B, currentColor.A);
72             };
73             BorderlineBlue.ValueChanged += (o, e) =>
74             {
75                 Color currentColor = target.BorderlineColor;
76                 target.BorderlineColor = new Color(currentColor.R, currentColor.G, BorderlineBlue.CurrentValue / 255.0f, currentColor.A);
77             };
78             BorderlineAlpha.ValueChanged += (o, e) =>
79             {
80                 Color currentColor = target.BorderlineColor;
81                 target.BorderlineColor = new Color(currentColor.R, currentColor.G, currentColor.B, BorderlineAlpha.CurrentValue / 255.0f);
82             };
83
84             // Background Color
85             ViewRed.ValueChanged += (o, e) =>
86             {
87                 Color currentColor = target.BackgroundColor;
88                 target.BackgroundColor = new Color(ViewRed.CurrentValue / 255.0f, currentColor.G, currentColor.B, currentColor.A);
89             };
90             ViewGreen.ValueChanged += (o, e) =>
91             {
92                 Color currentColor = target.BackgroundColor;
93                 target.BackgroundColor = new Color(currentColor.R, ViewGreen.CurrentValue / 255.0f, currentColor.B, currentColor.A);
94             };
95             ViewBlue.ValueChanged += (o, e) =>
96             {
97                 Color currentColor = target.BackgroundColor;
98                 target.BackgroundColor = new Color(currentColor.R, currentColor.G, ViewBlue.CurrentValue / 255.0f, currentColor.A);
99             };
100             ViewAlpha.ValueChanged += (o, e) =>
101             {
102                 Color currentColor = target.BackgroundColor;
103                 target.BackgroundColor = new Color(currentColor.R, currentColor.G, currentColor.B, ViewAlpha.CurrentValue / 255.0f);
104             };
105
106             // Shadow Toggle
107             ShadowToggleButton.Clicked += (o, e) =>
108             {
109                 if(ShadowToggleButton.IsSelected)
110                 {
111                     shadowToggleShow = true;
112                 }
113                 else
114                 {
115                     shadowToggleShow = false;
116                 }
117
118                 if(shadowToggleShow)
119                 {
120                     if(target.BoxShadow == null)
121                     {
122                         target.BoxShadow = CreateShadowFromeSliders();
123                     }
124                 }
125                 else
126                 {
127                     if(target.BoxShadow != null)
128                     {
129                         target.BoxShadow = null;
130                     }
131                 }
132             };
133             // Shadow Offset
134             ShadowOffsetX.ValueChanged += (o, e) =>
135             {
136                 if(!shadowToggleShow) return;
137                 Shadow currentShadow = target.BoxShadow;
138                 if(currentShadow == null)
139                 {
140                     target.BoxShadow = CreateShadowFromeSliders();
141                     return;
142                 }
143                 Vector2 currentOffset = currentShadow.Offset;
144                 target.BoxShadow = new Shadow(currentShadow.BlurRadius, currentShadow.Color, new Vector2(ShadowOffsetX.CurrentValue, currentOffset.Y));
145             };
146             ShadowOffsetY.ValueChanged += (o, e) =>
147             {
148                 if(!shadowToggleShow) return;
149                 Shadow currentShadow = target.BoxShadow;
150                 if(currentShadow == null)
151                 {
152                     target.BoxShadow = CreateShadowFromeSliders();
153                     return;
154                 }
155                 Vector2 currentOffset = currentShadow.Offset;
156                 target.BoxShadow = new Shadow(currentShadow.BlurRadius, currentShadow.Color, new Vector2(currentOffset.X, ShadowOffsetY.CurrentValue));
157             };
158
159             // Shadow Color
160             ShadowColorRed.ValueChanged += (o, e) =>
161             {
162                 if(!shadowToggleShow) return;
163                 Shadow currentShadow = target.BoxShadow;
164                 if(currentShadow == null)
165                 {
166                     target.BoxShadow = CreateShadowFromeSliders();
167                     return;
168                 }
169                 Color currentColor = currentShadow.Color;
170                 target.BoxShadow = new Shadow(currentShadow.BlurRadius, new Color(ShadowColorRed.CurrentValue / 255.0f, currentColor.G, currentColor.B, currentColor.A), currentShadow.Offset);
171             };
172             ShadowColorGreen.ValueChanged += (o, e) =>
173             {
174                 if(!shadowToggleShow) return;
175                 Shadow currentShadow = target.BoxShadow;
176                 if(currentShadow == null)
177                 {
178                     target.BoxShadow = CreateShadowFromeSliders();
179                     return;
180                 }
181                 Color currentColor = currentShadow.Color;
182                 target.BoxShadow = new Shadow(currentShadow.BlurRadius, new Color(currentColor.R, ShadowColorGreen.CurrentValue / 255.0f, currentColor.B, currentColor.A), currentShadow.Offset);
183             };
184             ShadowColorBlue.ValueChanged += (o, e) =>
185             {
186                 if(!shadowToggleShow) return;
187                 Shadow currentShadow = target.BoxShadow;
188                 if(currentShadow == null)
189                 {
190                     target.BoxShadow = CreateShadowFromeSliders();
191                     return;
192                 }
193                 Color currentColor = currentShadow.Color;
194                 target.BoxShadow = new Shadow(currentShadow.BlurRadius, new Color(currentColor.R, currentColor.G, ShadowColorBlue.CurrentValue / 255.0f, currentColor.A), currentShadow.Offset);
195             };
196             ShadowOpacity.ValueChanged += (o, e) =>
197             {
198                 if(!shadowToggleShow) return;
199                 Shadow currentShadow = target.BoxShadow;
200                 if(currentShadow == null)
201                 {
202                     target.BoxShadow = CreateShadowFromeSliders();
203                     return;
204                 }
205                 Color currentColor = currentShadow.Color;
206                 target.BoxShadow = new Shadow(currentShadow.BlurRadius, new Color(currentColor.R, currentColor.G, currentColor.B, ShadowOpacity.CurrentValue / 255.0f), currentShadow.Offset);
207             };
208             // Shadow Radius
209             ShadowBlurRadius.ValueChanged += (o, e) =>
210             {
211                 if(!shadowToggleShow) return;
212                 Shadow currentShadow = target.BoxShadow;
213                 if(currentShadow == null)
214                 {
215                     target.BoxShadow = CreateShadowFromeSliders();
216                     return;
217                 }
218                 float currentRadius = ShadowBlurRadius.CurrentValue;
219                 target.BoxShadow = new Shadow(currentRadius, currentShadow.Color, currentShadow.Offset);
220             };
221         }
222     }
223 }