2 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 using System.ComponentModel;
18 using System.Collections.Generic;
20 namespace Tizen.NUI.Components
23 /// The CheckboxGroup class is used to group together a set of CheckBox control
26 /// CheckBoxGroup checkGroup = new CheckBoxGroup();
27 /// CheckBox check1 = new CheckBox();
28 /// CheckBox check2 = new CheckBox();
29 /// checkGroup.Add(check1);
30 /// checkGroup.Add(check2);
32 /// <since_tizen> 6 </since_tizen>
33 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
34 [EditorBrowsable(EditorBrowsableState.Never)]
35 public class CheckBoxGroup : SelectGroup
38 /// Construct CheckBoxGroup
40 /// <since_tizen> 6 </since_tizen>
41 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
42 [EditorBrowsable(EditorBrowsableState.Never)]
43 public CheckBoxGroup() : base()
48 /// Add CheckBox to the end of CheckBoxGroup.
50 /// <param name="check">The CheckBox to be added to the CheckBoxGroup</param>
51 /// <since_tizen> 6 </since_tizen>
52 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
53 [EditorBrowsable(EditorBrowsableState.Never)]
54 public void Add(CheckBox check)
56 base.AddSelection(check);
57 check.ItemGroup = this;
61 /// Remove CheckBox from the CheckBoxGroup.
63 /// <param name="check">The CheckBox to remove from the CheckBoxGroup</param>
64 /// <since_tizen> 6 </since_tizen>
65 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
66 [EditorBrowsable(EditorBrowsableState.Never)]
67 public void Remove(CheckBox check)
69 base.RemoveSelection(check);
70 check.ItemGroup = null;
74 /// Get the CheckBox object at the specified index.
76 /// <param name="index">The item index</param>
77 /// <returns>CheckBox</returns>
78 /// <since_tizen> 6 </since_tizen>
79 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
80 [EditorBrowsable(EditorBrowsableState.Never)]
81 public CheckBox GetItem(int index)
83 return itemGroup[index] as CheckBox;
87 /// Get the index array of checked items.
89 /// <returns>The array of index</returns>
90 /// <since_tizen> 6 </since_tizen>
91 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
92 [EditorBrowsable(EditorBrowsableState.Never)]
93 public int[] GetCheckedIndices()
95 List<int> selectedItemsList = new List<int>();
96 for (int i = 0; i < itemGroup.Count; i++)
98 if (itemGroup[i].IsSelected)
100 selectedItemsList.Add(i);
104 return selectedItemsList.ToArray();
109 /// Get the CheckBox array of checked items.
111 /// <returns>The array of CheckBox</returns>
112 /// <since_tizen> 6 </since_tizen>
113 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
114 [EditorBrowsable(EditorBrowsableState.Never)]
115 public CheckBox[] GetCheckedItems()
117 List<CheckBox> selectedList = new List<CheckBox>();
119 foreach (CheckBox check in itemGroup)
121 if (check.IsSelected)
123 selectedList.Add(check);
127 return selectedList.ToArray();
131 /// Determines whether every checkboxes in the CheckBoxGroup are checked
133 /// <returns>If all of CheckBoxes are checked, return true. otherwise false</returns>
134 /// <since_tizen> 6 </since_tizen>
135 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
136 [EditorBrowsable(EditorBrowsableState.Never)]
137 public bool IsCheckedAll()
139 foreach (CheckBox cb in itemGroup)
150 /// Check or Uncheck all of child checkboxes by the specified value
152 /// <param name="state">The boolean state of the check box</param>
153 /// <since_tizen> 6 </since_tizen>
154 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
155 [EditorBrowsable(EditorBrowsableState.Never)]
156 public void CheckAll(bool state)
158 foreach (CheckBox cb in itemGroup)
160 cb.IsSelected = state;