/*
* Copyright(c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System.ComponentModel;
using System.Collections.Generic;
namespace Tizen.NUI.Components
{
///
/// The CheckboxGroup class is used to group together a set of CheckBox control
///
///
/// CheckBoxGroup checkGroup = new CheckBoxGroup();
/// CheckBox check1 = new CheckBox();
/// CheckBox check2 = new CheckBox();
/// checkGroup.Add(check1);
/// checkGroup.Add(check2);
///
/// 6
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public class CheckBoxGroup : SelectGroup
{
///
/// Construct CheckBoxGroup
///
/// 6
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public CheckBoxGroup() : base()
{
}
///
/// Add CheckBox to the end of CheckBoxGroup.
///
/// The CheckBox to be added to the CheckBoxGroup
/// 6
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public void Add(CheckBox check)
{
if (null == check) return;
base.AddSelection(check);
check.ItemGroup = this;
}
///
/// Remove CheckBox from the CheckBoxGroup.
///
/// The CheckBox to remove from the CheckBoxGroup
/// 6
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public void Remove(CheckBox check)
{
if (null == check) return;
base.RemoveSelection(check);
check.ItemGroup = null;
}
///
/// Get the CheckBox object at the specified index.
///
/// The item index
/// CheckBox
/// 6
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public CheckBox GetItem(int index)
{
return itemGroup[index] as CheckBox;
}
///
/// Get the index array of checked items.
///
/// The array of index
/// 6
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public int[] GetCheckedIndices()
{
List selectedItemsList = new List();
for (int i = 0; i < itemGroup.Count; i++)
{
if (itemGroup[i].IsSelected)
{
selectedItemsList.Add(i);
}
}
return selectedItemsList.ToArray();
}
///
/// Get the CheckBox array of checked items.
///
/// The array of CheckBox
/// 6
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public CheckBox[] GetCheckedItems()
{
List selectedList = new List();
foreach (CheckBox check in itemGroup)
{
if (check.IsSelected)
{
selectedList.Add(check);
}
}
return selectedList.ToArray();
}
///
/// Determines whether every checkboxes in the CheckBoxGroup are checked
///
/// If all of CheckBoxes are checked, return true. otherwise false
/// 6
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public bool IsCheckedAll()
{
foreach (CheckBox cb in itemGroup)
{
if (!cb.IsSelected)
{
return false;
}
}
return true;
}
///
/// Check or Uncheck all of child checkboxes by the specified value
///
/// The boolean state of the check box
/// 6
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public void CheckAll(bool state)
{
foreach (CheckBox cb in itemGroup)
{
cb.IsSelected = state;
}
}
}
}