using System; using System.Collections.Generic; using System.Linq; namespace ElmSharp.Wearable { /// /// The MoreOption is a widget composed of the toggle(cue button) and more option view, and MoreOption can change a visibility through the toggle. /// Inherits Layout /// public class MoreOption : Layout { /// /// Sets or gets the list of more option item /// public IList Items { get; private set; } /// /// Selected will be triggered when the user selects an item. /// public event EventHandler Selected; /// /// Clicked will be triggered when the user selects the already selected item again or selects a selector. /// public event EventHandler Clicked; /// /// Opened will be triggered when more option view is shown. /// public event EventHandler Opened; /// /// Closed will be triggered when more option view is hidden. /// public event EventHandler Closed; SmartEvent _selectedEvent; SmartEvent _clickedEvent; SmartEvent _openedEvent; SmartEvent _closedEvent; /// /// Creates and initializes a new instance of MoreOption class. /// /// The parent is a given container which will be attached by MoreOption as a child. It's type. public MoreOption(EvasObject parent) : base(parent) { Items = new MoreOptionList(this); _selectedEvent = new SmartEvent(this, "item,selected", (d, o, info) => new PointerEventArgs { Pointer = info }); _clickedEvent = new SmartEvent(this, "item,clicked", (d, o, info) => new PointerEventArgs { Pointer = info }); _openedEvent = new SmartEvent(this, "more,option,opened"); _closedEvent = new SmartEvent(this, "more,option,closed"); _selectedEvent.On += (s, e) => { MoreOptionItem selected = Items.FirstOrDefault(i => i.Handle == e.Pointer); Selected?.Invoke(this, new MoreOptionItemEventArgs() { Item = selected }); }; _clickedEvent.On += (s, e) => { MoreOptionItem selected = Items.FirstOrDefault(i => i.Handle == e.Pointer); Clicked?.Invoke(this, new MoreOptionItemEventArgs() { Item = selected }); }; _openedEvent.On += (s, e) => Opened?.Invoke(this, EventArgs.Empty); _closedEvent.On += (s, e) => Closed?.Invoke(this, EventArgs.Empty); } /// /// Creates a widget handle. /// /// Parent EvasObject /// Handle IntPtr protected override IntPtr CreateHandle(EvasObject parent) { return Interop.Eext.eext_more_option_add(parent); } /// /// Sets or gets the direction of more option. /// public MoreOptionDirection Direction { get { int dir = Interop.Eext.eext_more_option_direction_get(this); return (MoreOptionDirection)dir; } set { Interop.Eext.eext_more_option_direction_set(this, (int)value); } } /// /// Sets or gets the visibility of more option view. /// public bool IsOpened { get { return Interop.Eext.eext_more_option_opened_get(this); } set { Interop.Eext.eext_more_option_opened_set(this, value); } } } /// /// Enumeration for More Option Direction type. /// public enum MoreOptionDirection { /// /// Top direction /// Top, /// /// Bottom direction /// Bottom, /// /// Left direction /// Left, /// /// Right direction /// Right } }