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[3];
10 private Button[] button = new Button[2];
11 private Progress[] progressBar = new Progress[3];
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 layout[1].Add(layout[2]);
71 layout[1].Add(layout[3]);
73 board[0] = new TextLabel();
74 board[0].WidthSpecification = 900;
75 board[0].HeightSpecification = 100;
76 board[0].PointSize = 30;
77 board[0].HorizontalAlignment = HorizontalAlignment.Center;
78 board[0].VerticalAlignment = VerticalAlignment.Center;
79 board[0].BackgroundColor = Color.Magenta;
80 board[0].Text = "log pad";
81 layout[0].Add(board[0]);
82 board[0].Focusable = true;
83 board[0].FocusGained += Board_FocusGained;
84 board[0].FocusLost += Board_FocusLost;
85 board[0].UpFocusableView = button[0];
86 FocusManager.Instance.SetCurrentFocusView(button[0]);
89 void CreatePropElements()
91 ///////////////////////////////////////////////Create by Properties//////////////////////////////////////////////////////////
92 board[1] = new TextLabel();
93 board[1].WidthSpecification = 380;
94 board[1].HeightSpecification = 70;
95 board[1].PointSize = 20;
96 board[1].HorizontalAlignment = HorizontalAlignment.Center;
97 board[1].VerticalAlignment = VerticalAlignment.Center;
98 board[1].BackgroundColor = Color.Magenta;
99 board[1].Text = "Property construction";
100 layout[2].Add(board[1]);
101 board[1].Focusable = true;
102 board[1].FocusGained += Board_FocusGained;
103 board[1].FocusLost += Board_FocusLost;
105 progressBar[0] = new Progress();
106 progressBar[0].WidthSpecification = 240;
107 progressBar[0].HeightSpecification = 4;
108 progressBar[0].MaxValue = 100;
109 progressBar[0].MinValue = 0;
110 progressBar[0].CurrentValue = 45;
111 layout[2].Add(progressBar[0]);
113 progressBar[1] = new Progress();
114 progressBar[1].WidthSpecification = 240;
115 progressBar[1].HeightSpecification = 4;
116 progressBar[1].MaxValue = 100;
117 progressBar[1].MinValue = 0;
118 progressBar[1].CurrentValue = 30;
119 progressBar[1].TrackColor = Color.Yellow;
120 progressBar[1].ProgressColor = Color.Black;
121 layout[2].Add(progressBar[1]);
123 button[0] = new Button();
124 button[0].WidthSpecification = 140;
125 button[0].HeightSpecification = 50;
126 button[0].Text = "+";
127 button[0].BackgroundColor = Color.Green;
128 layout[2].Add(button[0]);
129 button[0].Focusable = true;
130 button[0].ClickEvent += ProgressAdd;
132 button[1] = new Button();
133 button[1].WidthSpecification = 140;
134 button[1].HeightSpecification = 50;
135 button[1].Text = "-";
136 button[1].BackgroundColor = Color.Green;
137 layout[2].Add(button[1]);
138 button[1].Focusable = true;
139 button[1].ClickEvent += ProgressMinus;
142 private void CreateAttrElements()
144 ///////////////////////////////////////////////Create by attributes//////////////////////////////////////////////////////////
145 board[2] = new TextLabel();
146 board[2].WidthSpecification = 380;
147 board[2].HeightSpecification = 70;
148 board[2].PointSize = 20;
149 board[2].HorizontalAlignment = HorizontalAlignment.Center;
150 board[2].VerticalAlignment = VerticalAlignment.Center;
151 board[2].BackgroundColor = Color.Magenta;
152 board[2].Text = "Attribute construction";
153 layout[3].Add(board[2]);
154 board[2].Focusable = true;
155 board[2].FocusGained += Board_FocusGained;
156 board[2].FocusLost += Board_FocusLost;
158 ProgressStyle attr = new ProgressStyle
160 Track = new ImageViewStyle
162 BackgroundColor = new Selector<Color>
167 Progress = new ImageViewStyle
169 BackgroundColor = new Selector<Color>
174 Buffer = new ImageViewStyle
176 BackgroundColor = new Selector<Color>
182 progressBar[2] = new Progress(attr);
183 progressBar[2].WidthSpecification = 240;
184 progressBar[2].HeightSpecification = 4;
185 progressBar[2].MaxValue = 100;
186 progressBar[2].MinValue = 0;
187 progressBar[2].CurrentValue = 30;
188 layout[3].Add(progressBar[2]);
191 private void Board_FocusLost(object sender, global::System.EventArgs e)
193 board[0].BackgroundColor = Color.Magenta;
196 private void Board_FocusGained(object sender, global::System.EventArgs e)
198 board[0].BackgroundColor = Color.Cyan;
201 private void ProgressAdd(object sender, global::System.EventArgs e)
203 if (progressBar[0].CurrentValue == 100)
205 board[0].Text = "Current value is: 100";
209 board[0].Text = "Current value is: " + ++progressBar[0].CurrentValue;
212 private void ProgressMinus(object sender, global::System.EventArgs e)
214 if (progressBar[0].CurrentValue == 0)
216 board[0].Text = "Current value is: 0";
220 board[0].Text = "Current value is: " + --progressBar[0].CurrentValue;
224 public void Deactivate()
226 if (layout[0] != null)
228 layout[2].Remove(board[1]);
231 layout[2].Remove(progressBar[0]);
232 progressBar[0].Dispose();
233 progressBar[0] = null;
234 layout[2].Remove(progressBar[1]);
235 progressBar[1].Dispose();
236 progressBar[1] = null;
237 layout[2].Remove(button[0]);
240 layout[2].Remove(button[1]);
244 layout[3].Remove(board[2]);
247 layout[3].Remove(progressBar[2]);
248 progressBar[2].Dispose();
249 progressBar[2] = null;
251 layout[1].Remove(layout[2]);
254 layout[1].Remove(layout[3]);
258 layout[0].Remove(layout[1]);
261 layout[0].Remove(board[0]);
265 NUIApplication.GetDefaultWindow().Remove(layout[0]);