/// <summary> /// Update the item /// </summary> /// <param name="index">The index of the item</param> /// <param name="view">the view</param> public override void UpdateItem(int index, View view) { TextItem textItem = view as TextItem; OptionListItemData itemData = GetData(index) as OptionListItemData; if (textItem != null) { if (textItem.StateEnabled != !itemData.IsDisabled) { textItem.StateEnabled = !itemData.IsDisabled; } if (textItem.StateFocused != itemData.IsFocused) { textItem.StateFocused = itemData.IsFocused; } if (textItem.StateSelected != itemData.IsSelected) { textItem.StateSelected = itemData.IsSelected; } textItem.MainText = itemData.TextString; } }
/// <summary> /// Get the item's height /// </summary> /// <param name="index">The index of the item</param> /// <returns>The height of the item</returns> public override int GetItemHeight(int index) { object data = GetData(index); OptionListItemData itemData = data as OptionListItemData; return(itemData.ItemHeight); }
/// <summary> /// Add OptionList item text string, only effect for UI style. /// </summary> /// <param name="textString">OptionList item text string</param> public void AddData(string textString) { OptionListItemData itemData = new OptionListItemData(); itemData.ItemHeight = ItemHeight; itemData.TextString = textString; (bridge as OptionListBridge).Add(itemData); }
/// <summary> /// The method will be called when the focus changed in the list /// </summary> /// <param name="index">The index of the item</param> /// <param name="view">The item view</param> /// <param name="flagFocused">The flag show the item is getting focus or losing focus</param> public override void FocusChange(int index, View view, bool flagFocused) { OptionListItemData itemData = GetData(index) as OptionListItemData; itemData.IsFocused = flagFocused; TextItem textItem = view as TextItem; textItem.StateFocused = flagFocused; }
/// <summary> /// Get text string. /// </summary> /// <param name="index">OptionList item index</param> /// <exception cref="System.IndexOutOfRangeException"> Thrown when item index out of range[0, NumOfItem-1] </exception> /// <example> /// <code> /// try /// { /// optionList.TextString(5); /// } /// catch(ArgumentException) /// { /// Log.Error(LogTag, "Item index out of range. " +e.Message); /// } /// </code> /// </example> /// <returns>the text string of the soecific index</returns> public string TextString(int index) { if (index < 0 || index >= list.NumOfItem) { Tizen.Log.Fatal("NUI", "Item index is out of range! Items count = " + list.NumOfItem + ", index = " + index); throw new IndexOutOfRangeException("Item index is out of range! Items count = " + list.NumOfItem + ", index = " + index); } OptionListItemData data = (bridge as OptionListBridge).GetData(index) as OptionListItemData; return(data.TextString); }
/// <summary> /// Get the item according to the index. /// </summary> /// <param name="index">The index of the item.</param> /// <returns>return the item</returns> public override View GetItemView(int index) { object data = GetData(index); OptionListItemData itemData = data as OptionListItemData; TextItem textItem = new TextItem(); textItem.Name = "OptionListItem"; textItem.MainText = itemData.TextString; textItem.StateEnabled = !itemData.IsDisabled; textItem.StateSelected = itemData.IsSelected; return(textItem); }
/// <summary> /// Enable or disable OptionList item. /// </summary> /// <param name="index">OptionList item index</param> /// <param name="disable">true is disable the item, false is enalbe the item</param> /// <exception cref="System.IndexOutOfRangeException"> Thrown when dim item index out of range[0, NumOfItem-1] </exception> /// <example> /// <code> /// try /// { /// optionList.RemoveData(5, 3); /// } /// catch(ArgumentException) /// { /// Log.Error(LogTag, "Disable item index out of range. " +e.Message); /// } /// </code> /// </example> public void DisableItem(int index, bool disable = true) { if (index < 0 || index >= list.NumOfItem) { Tizen.Log.Fatal("NUI", "Disable item index is out of range! Items count = " + list.NumOfItem + ", index = " + index); throw new IndexOutOfRangeException("Disable item index is out of range! Items count = " + list.NumOfItem + ", index = " + index); } OptionListItemData data = (bridge as OptionListBridge).GetData(index) as OptionListItemData; data.IsDisabled = disable; list.UpdateItem(index); }