1 using Tizen.NUI.BaseComponents;
2 using Tizen.NUI.Components;
5 namespace Tizen.NUI.Samples
7 public class ProgressSample : IExample
9 private TextLabel[] board = new TextLabel[4];
10 private Button[] button = new Button[2];
11 private Progress[] progressBar = new Progress[4];
12 private View[] layout = new View[4];
14 public void Activate()
16 Window window = NUIApplication.GetDefaultWindow();
18 layout[0] = new View()
20 Size = new Size(1920, 1080),
21 BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f),
23 layout[0].Layout = new LinearLayout()
25 LinearOrientation = LinearLayout.Orientation.Vertical,
26 LinearAlignment = LinearLayout.Alignment.Center
28 window.Add(layout[0]);
30 // Layout for progress parent layout.
31 layout[1] = new View()
33 Size = new Size(1000, 730)
35 layout[1].Layout = new LinearLayout()
37 LinearOrientation = LinearLayout.Orientation.Horizontal,
38 LinearAlignment = LinearLayout.Alignment.Center
40 layout[0].Add(layout[1]);
42 // Layout for progress layout which is created by properties.
43 layout[2] = new View()
45 Size = new Size(450, 630)
47 layout[2].Layout = new LinearLayout()
49 LinearOrientation = LinearLayout.Orientation.Vertical,
50 LinearAlignment = LinearLayout.Alignment.CenterHorizontal,
51 CellPadding = new Size2D(50, 100)
53 layout[1].Add(layout[2]);
55 // Layout for progress layout which is created by attributes.
56 layout[3] = new View()
58 Size = new Size(450, 630)
60 layout[3].Layout = new LinearLayout()
62 LinearOrientation = LinearLayout.Orientation.Vertical,
63 LinearAlignment = LinearLayout.Alignment.CenterHorizontal,
64 CellPadding = new Size2D(50, 100)
66 layout[1].Add(layout[3]);
70 CreateIndeterminateProgress();
71 layout[1].Add(layout[2]);
72 layout[1].Add(layout[3]);
74 board[0] = new TextLabel();
75 board[0].WidthSpecification = 900;
76 board[0].HeightSpecification = 100;
77 board[0].PointSize = 30;
78 board[0].HorizontalAlignment = HorizontalAlignment.Center;
79 board[0].VerticalAlignment = VerticalAlignment.Center;
80 board[0].BackgroundColor = Color.Magenta;
81 board[0].Text = "log pad";
82 layout[0].Add(board[0]);
83 board[0].Focusable = true;
84 board[0].FocusGained += Board_FocusGained;
85 board[0].FocusLost += Board_FocusLost;
86 board[0].UpFocusableView = button[0];
87 FocusManager.Instance.SetCurrentFocusView(button[0]);
90 void CreatePropElements()
92 ///////////////////////////////////////////////Create by Properties//////////////////////////////////////////////////////////
93 board[1] = new TextLabel();
94 board[1].WidthSpecification = 380;
95 board[1].HeightSpecification = 70;
96 board[1].PointSize = 20;
97 board[1].HorizontalAlignment = HorizontalAlignment.Center;
98 board[1].VerticalAlignment = VerticalAlignment.Center;
99 board[1].BackgroundColor = Color.Magenta;
100 board[1].Text = "Property construction";
101 layout[2].Add(board[1]);
102 board[1].Focusable = true;
103 board[1].FocusGained += Board_FocusGained;
104 board[1].FocusLost += Board_FocusLost;
106 progressBar[0] = new Progress();
107 progressBar[0].WidthSpecification = 240;
108 progressBar[0].HeightSpecification = 4;
109 progressBar[0].MaxValue = 100;
110 progressBar[0].MinValue = 0;
111 progressBar[0].CurrentValue = 45;
112 layout[2].Add(progressBar[0]);
114 progressBar[1] = new Progress();
115 progressBar[1].WidthSpecification = 240;
116 progressBar[1].HeightSpecification = 4;
117 progressBar[1].MaxValue = 100;
118 progressBar[1].MinValue = 0;
119 progressBar[1].CurrentValue = 30;
120 progressBar[1].TrackColor = Color.Yellow;
121 progressBar[1].ProgressColor = Color.Black;
122 layout[2].Add(progressBar[1]);
124 button[0] = new Button();
125 button[0].WidthSpecification = 140;
126 button[0].HeightSpecification = 50;
127 button[0].Text = "+";
128 button[0].BackgroundColor = Color.Green;
129 layout[2].Add(button[0]);
130 button[0].Focusable = true;
131 button[0].Clicked += ProgressAdd;
133 button[1] = new Button();
134 button[1].WidthSpecification = 140;
135 button[1].HeightSpecification = 50;
136 button[1].Text = "-";
137 button[1].BackgroundColor = Color.Green;
138 layout[2].Add(button[1]);
139 button[1].Focusable = true;
140 button[1].Clicked += ProgressMinus;
143 private void CreateAttrElements()
145 ///////////////////////////////////////////////Create by attributes//////////////////////////////////////////////////////////
146 board[2] = new TextLabel();
147 board[2].WidthSpecification = 380;
148 board[2].HeightSpecification = 70;
149 board[2].PointSize = 20;
150 board[2].HorizontalAlignment = HorizontalAlignment.Center;
151 board[2].VerticalAlignment = VerticalAlignment.Center;
152 board[2].BackgroundColor = Color.Magenta;
153 board[2].Text = "Attribute construction";
154 layout[3].Add(board[2]);
155 board[2].Focusable = true;
156 board[2].FocusGained += Board_FocusGained;
157 board[2].FocusLost += Board_FocusLost;
159 ProgressStyle attr = new ProgressStyle
161 Track = new ImageViewStyle
163 BackgroundColor = new Selector<Color>
168 Progress = new ImageViewStyle
170 BackgroundColor = new Selector<Color>
175 Buffer = new ImageViewStyle
177 BackgroundColor = new Selector<Color>
183 progressBar[2] = new Progress(attr);
184 progressBar[2].WidthSpecification = 240;
185 progressBar[2].HeightSpecification = 4;
186 progressBar[2].MaxValue = 100;
187 progressBar[2].MinValue = 0;
188 progressBar[2].CurrentValue = 30;
189 layout[3].Add(progressBar[2]);
192 private void CreateIndeterminateProgress()
194 board[3] = new TextLabel();
195 board[3].WidthSpecification = 380;
196 board[3].HeightSpecification = 70;
197 board[3].PointSize = 20;
198 board[3].HorizontalAlignment = HorizontalAlignment.Center;
199 board[3].VerticalAlignment = VerticalAlignment.Center;
200 board[3].BackgroundColor = Color.Magenta;
201 board[3].Text = "Indeterminate Progress";
202 layout[3].Add(board[3]);
203 board[3].Focusable = true;
204 board[3].FocusGained += Board_FocusGained; // Not sure to connect this event
205 board[3].FocusLost += Board_FocusLost;
207 progressBar[3] = new Progress();
208 progressBar[3].WidthSpecification = 240;
209 progressBar[3].HeightSpecification = 4;
210 progressBar[3].ProgressState = Progress.ProgressStatusType.Indeterminate;
211 layout[3].Add(progressBar[3]);
214 private void Board_FocusLost(object sender, global::System.EventArgs e)
216 board[0].BackgroundColor = Color.Magenta;
219 private void Board_FocusGained(object sender, global::System.EventArgs e)
221 board[0].BackgroundColor = Color.Cyan;
224 private void ProgressAdd(object sender, global::System.EventArgs e)
226 if (progressBar[0].CurrentValue == 100)
228 board[0].Text = "Current value is: 100";
232 board[0].Text = "Current value is: " + ++progressBar[0].CurrentValue;
235 private void ProgressMinus(object sender, global::System.EventArgs e)
237 if (progressBar[0].CurrentValue == 0)
239 board[0].Text = "Current value is: 0";
243 board[0].Text = "Current value is: " + --progressBar[0].CurrentValue;
247 public void Deactivate()
249 if (layout[0] != null)
251 layout[2].Remove(board[1]);
254 layout[2].Remove(progressBar[0]);
255 progressBar[0].Dispose();
256 progressBar[0] = null;
257 layout[2].Remove(progressBar[1]);
258 progressBar[1].Dispose();
259 progressBar[1] = null;
260 layout[2].Remove(button[0]);
263 layout[2].Remove(button[1]);
267 layout[3].Remove(board[2]);
270 layout[3].Remove(progressBar[2]);
271 progressBar[2].Dispose();
272 progressBar[2] = null;
274 layout[1].Remove(layout[2]);
277 layout[1].Remove(layout[3]);
281 layout[0].Remove(layout[1]);
284 layout[0].Remove(board[0]);
288 NUIApplication.GetDefaultWindow().Remove(layout[0]);