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
37 static CheckBoxGroup() { }
40 /// Construct CheckBoxGroup
42 /// <since_tizen> 6 </since_tizen>
43 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
44 [EditorBrowsable(EditorBrowsableState.Never)]
45 public CheckBoxGroup() : base()
50 /// Add CheckBox to the end of CheckBoxGroup.
52 /// <param name="check">The CheckBox to be added to the CheckBoxGroup</param>
53 /// <since_tizen> 6 </since_tizen>
54 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
55 [EditorBrowsable(EditorBrowsableState.Never)]
56 public void Add(CheckBox check)
58 if (null == check) return;
59 base.AddSelection(check);
60 check.ItemGroup = this;
64 /// Remove CheckBox from the CheckBoxGroup.
66 /// <param name="check">The CheckBox to remove from the CheckBoxGroup</param>
67 /// <since_tizen> 6 </since_tizen>
68 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
69 [EditorBrowsable(EditorBrowsableState.Never)]
70 public void Remove(CheckBox check)
72 if (null == check) return;
73 base.RemoveSelection(check);
74 check.ItemGroup = null;
78 /// Get the CheckBox object at the specified index.
80 /// <param name="index">The item index</param>
81 /// <returns>CheckBox</returns>
82 /// <since_tizen> 6 </since_tizen>
83 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
84 [EditorBrowsable(EditorBrowsableState.Never)]
85 public CheckBox GetItem(int index)
87 return ItemGroup[index] as CheckBox;
91 /// Get the index array of checked items.
93 /// <returns>The array of index</returns>
94 /// <since_tizen> 6 </since_tizen>
95 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
96 [EditorBrowsable(EditorBrowsableState.Never)]
97 public int[] GetCheckedIndices()
99 List<int> selectedItemsList = new List<int>();
100 for (int i = 0; i < ItemGroup.Count; i++)
102 if (ItemGroup[i].IsSelected)
104 selectedItemsList.Add(i);
108 return selectedItemsList.ToArray();
113 /// Get the CheckBox array of checked items.
115 /// <returns>The array of CheckBox</returns>
116 /// <since_tizen> 6 </since_tizen>
117 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
118 [EditorBrowsable(EditorBrowsableState.Never)]
119 public CheckBox[] GetCheckedItems()
121 List<CheckBox> selectedList = new List<CheckBox>();
123 foreach (CheckBox check in ItemGroup)
125 if (check.IsSelected)
127 selectedList.Add(check);
131 return selectedList.ToArray();
135 /// Determines whether every checkboxes in the CheckBoxGroup are checked
137 /// <returns>If all of CheckBoxes are checked, return true. otherwise false</returns>
138 /// <since_tizen> 6 </since_tizen>
139 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
140 [EditorBrowsable(EditorBrowsableState.Never)]
141 public bool IsCheckedAll()
143 foreach (CheckBox cb in ItemGroup)
154 /// Check or Uncheck all of child checkboxes by the specified value
156 /// <param name="state">The boolean state of the check box</param>
157 /// <since_tizen> 6 </since_tizen>
158 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
159 [EditorBrowsable(EditorBrowsableState.Never)]
160 public void CheckAll(bool state)
162 foreach (CheckBox cb in ItemGroup)
164 cb.IsSelected = state;