[Tizen.WebView] Fix document build warnings
[platform/core/csapi/tizenfx.git] / src / ElmSharp.Wearable / ElmSharp.Wearable / MoreOption.cs
1
2 using System;
3 using System.Collections.Generic;
4 using System.Linq;
5
6 namespace ElmSharp.Wearable
7 {
8     /// <summary>
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.
10     /// Inherits Layout
11     /// </summary>
12     public class MoreOption : Layout
13     {
14         /// <summary>
15         /// Sets or gets the list of more option item
16         /// </summary>
17         public IList<MoreOptionItem> Items { get; private set; }
18
19         /// <summary>
20         /// Selected will be triggered when the user selects an item.
21         /// </summary>
22         public event EventHandler<MoreOptionItemEventArgs> Selected;
23         /// <summary>
24         /// Clicked will be triggered when the user selects the already selected item again or selects a selector.
25         /// </summary>
26         public event EventHandler<MoreOptionItemEventArgs> Clicked;
27         /// <summary>
28         /// Opened will be triggered when more option view is shown.
29         /// </summary>
30         public event EventHandler Opened;
31         /// <summary>
32         /// Closed will be triggered when more option view is hidden.
33         /// </summary>
34         public event EventHandler Closed;
35
36         SmartEvent<PointerEventArgs> _selectedEvent;
37         SmartEvent<PointerEventArgs> _clickedEvent;
38         SmartEvent _openedEvent;
39         SmartEvent _closedEvent;
40
41         /// <summary>
42         /// Creates and initializes a new instance of MoreOption class.
43         /// </summary>
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)
46         {
47             Items = new MoreOptionList(this);
48
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");
53
54             _selectedEvent.On += (s, e) =>
55             {
56                 MoreOptionItem selected = Items.FirstOrDefault(i => i.Handle == e.Pointer);
57                 Selected?.Invoke(this, new MoreOptionItemEventArgs() { Item = selected });
58             };
59
60             _clickedEvent.On += (s, e) =>
61             {
62                 MoreOptionItem selected = Items.FirstOrDefault(i => i.Handle == e.Pointer);
63                 Clicked?.Invoke(this, new MoreOptionItemEventArgs() { Item = selected });
64             };
65
66             _openedEvent.On += (s, e) => Opened?.Invoke(this, EventArgs.Empty);
67             _closedEvent.On += (s, e) => Closed?.Invoke(this, EventArgs.Empty);
68
69         }
70
71         protected override IntPtr CreateHandle(EvasObject parent)
72         {
73             return Interop.Eext.eext_more_option_add(parent);
74         }
75
76         /// <summary>
77         /// Sets or gets the direction of more option.
78         /// </summary>
79         public MoreOptionDirection Direction
80         {
81             get
82             {
83                 int dir = Interop.Eext.eext_more_option_direction_get(this);
84                 return (MoreOptionDirection)dir;
85             }
86
87             set
88             {
89                 Interop.Eext.eext_more_option_direction_set(this, (int)value);
90             }
91         }
92
93         /// <summary>
94         /// Sets or gets the visibility of more option view.
95         /// </summary>
96         public bool IsOpened
97         {
98             get
99             {
100                 return Interop.Eext.eext_more_option_opened_get(this);
101             }
102
103             set
104             {
105                 Interop.Eext.eext_more_option_opened_set(this, value);
106             }
107         }
108     }
109
110     /// <summary>
111     /// Enumeration for More Option Direction type.
112     /// </summary>
113     public enum MoreOptionDirection
114     {
115         Top,
116         Bottom,
117         Left,
118         Right
119     }
120 }