3 using System.Collections.Generic;
6 namespace ElmSharp.Wearable
9 /// The MoreOption is a widget composed of the toggle(cue button) and more option view, and MoreOption can change a visibility through the toggle.
12 public class MoreOption : Layout
15 /// Sets or gets the list of more option item
17 public IList<MoreOptionItem> Items { get; private set; }
20 /// Selected will be triggered when the user selects an item.
22 public event EventHandler<MoreOptionItemEventArgs> Selected;
24 /// Clicked will be triggered when the user selects the already selected item again or selects a selector.
26 public event EventHandler<MoreOptionItemEventArgs> Clicked;
28 /// Opened will be triggered when more option view is shown.
30 public event EventHandler Opened;
32 /// Closed will be triggered when more option view is hidden.
34 public event EventHandler Closed;
36 SmartEvent<PointerEventArgs> _selectedEvent;
37 SmartEvent<PointerEventArgs> _clickedEvent;
38 SmartEvent _openedEvent;
39 SmartEvent _closedEvent;
42 /// Creates and initializes a new instance of MoreOption class.
44 /// <param name="parent">The parent is a given container which will be attached by MoreOption as a child. It's <see cref="EvasObject"/> type.</param>
45 public MoreOption(EvasObject parent) : base(parent)
47 Items = new MoreOptionList(this);
49 _selectedEvent = new SmartEvent<PointerEventArgs>(this, "item,selected", (d, o, info) => new PointerEventArgs { Pointer = info });
50 _clickedEvent = new SmartEvent<PointerEventArgs>(this, "item,clicked", (d, o, info) => new PointerEventArgs { Pointer = info });
51 _openedEvent = new SmartEvent(this, "more,option,opened");
52 _closedEvent = new SmartEvent(this, "more,option,closed");
54 _selectedEvent.On += (s, e) =>
56 MoreOptionItem selected = Items.FirstOrDefault(i => i.Handle == e.Pointer);
57 Selected?.Invoke(this, new MoreOptionItemEventArgs() { Item = selected });
60 _clickedEvent.On += (s, e) =>
62 MoreOptionItem selected = Items.FirstOrDefault(i => i.Handle == e.Pointer);
63 Clicked?.Invoke(this, new MoreOptionItemEventArgs() { Item = selected });
66 _openedEvent.On += (s, e) => Opened?.Invoke(this, EventArgs.Empty);
67 _closedEvent.On += (s, e) => Closed?.Invoke(this, EventArgs.Empty);
71 protected override IntPtr CreateHandle(EvasObject parent)
73 return Interop.Eext.eext_more_option_add(parent);
77 /// Sets or gets the direction of more option.
79 public MoreOptionDirection Direction
83 int dir = Interop.Eext.eext_more_option_direction_get(this);
84 return (MoreOptionDirection)dir;
89 Interop.Eext.eext_more_option_direction_set(this, (int)value);
94 /// Sets or gets the visibility of more option view.
100 return Interop.Eext.eext_more_option_opened_get(this);
105 Interop.Eext.eext_more_option_opened_set(this, value);
111 /// Enumeration for More Option Direction type.
113 public enum MoreOptionDirection