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()
49 /// Add CheckBox to the end of CheckBoxGroup.
51 /// <param name="check">The CheckBox to be added to the CheckBoxGroup</param>
52 /// <since_tizen> 6 </since_tizen>
53 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
54 [EditorBrowsable(EditorBrowsableState.Never)]
55 public void Add(CheckBox check)
57 base.AddSelection(check);
58 check.ItemGroup = this;
62 /// Remove CheckBox from the CheckBoxGroup.
64 /// <param name="check">The CheckBox to remove from the CheckBoxGroup</param>
65 /// <since_tizen> 6 </since_tizen>
66 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
67 [EditorBrowsable(EditorBrowsableState.Never)]
68 public void Remove(CheckBox check)
70 base.RemoveSelection(check);
71 check.ItemGroup = null;
75 /// Get the CheckBox object at the specified index.
77 /// <param name="index">The item index</param>
78 /// <returns>CheckBox</returns>
79 /// <since_tizen> 6 </since_tizen>
80 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
81 [EditorBrowsable(EditorBrowsableState.Never)]
82 public CheckBox GetItemByIndex(int index)
84 return itemGroup[index] as CheckBox;
88 /// Get the index array of checked items.
90 /// <returns>The array of index</returns>
91 /// <since_tizen> 6 </since_tizen>
92 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
93 [EditorBrowsable(EditorBrowsableState.Never)]
94 public int[] GetCheckedIndexArray()
96 List<int> selectedItemsList = new List<int>();
97 for (int i = 0; i < itemGroup.Count; i++)
99 if (itemGroup[i].IsSelected)
101 selectedItemsList.Add(i);
105 return selectedItemsList.ToArray();
110 /// Get the CheckBox array of checked items.
112 /// <returns>The array of CheckBox</returns>
113 /// <since_tizen> 6 </since_tizen>
114 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
115 [EditorBrowsable(EditorBrowsableState.Never)]
116 public CheckBox[] GetCheckedItemArray()
118 List<CheckBox> selectedList = new List<CheckBox>();
120 foreach (CheckBox check in itemGroup)
122 if (check.IsSelected)
124 selectedList.Add(check);
128 return selectedList.ToArray();
132 /// Determines whether every checkboxes in the CheckBoxGroup are checked
134 /// <returns>If all of CheckBoxes are checked, return true. otherwise false</returns>
135 /// <since_tizen> 6 </since_tizen>
136 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
137 [EditorBrowsable(EditorBrowsableState.Never)]
138 public bool IsCheckedAll()
140 foreach (CheckBox cb in itemGroup)
151 /// Check or Uncheck all of child checkboxes by the specified value
153 /// <param name="state">The boolean state of the check box</param>
154 /// <since_tizen> 6 </since_tizen>
155 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
156 [EditorBrowsable(EditorBrowsableState.Never)]
157 public void CheckingAll(bool state)
159 foreach (CheckBox cb in itemGroup)
161 cb.IsSelected = state;