Merge "[Multimedia] Fixed wrong formats in the doc-comments."
[platform/core/csapi/tizenfx.git] / src / ElmSharp.Wearable / ElmSharp.Wearable / MoreOption.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using System.Collections.Generic;
19 using System.Linq;
20
21 namespace ElmSharp.Wearable
22 {
23     /// <summary>
24     /// The MoreOption is a widget composed of the toggle(cue button) and more option view, and MoreOption can change a visibility through the toggle.
25     /// Inherits Layout
26     /// </summary>
27     public class MoreOption : Layout
28     {
29         /// <summary>
30         /// Sets or gets the list of more option item
31         /// </summary>
32         public IList<MoreOptionItem> Items { get; private set; }
33
34         /// <summary>
35         /// Selected will be triggered when the user selects an item.
36         /// </summary>
37         public event EventHandler<MoreOptionItemEventArgs> Selected;
38         /// <summary>
39         /// Clicked will be triggered when the user selects the already selected item again or selects a selector.
40         /// </summary>
41         public event EventHandler<MoreOptionItemEventArgs> Clicked;
42         /// <summary>
43         /// Opened will be triggered when more option view is shown.
44         /// </summary>
45         public event EventHandler Opened;
46         /// <summary>
47         /// Closed will be triggered when more option view is hidden.
48         /// </summary>
49         public event EventHandler Closed;
50
51         SmartEvent<PointerEventArgs> _selectedEvent;
52         SmartEvent<PointerEventArgs> _clickedEvent;
53         SmartEvent _openedEvent;
54         SmartEvent _closedEvent;
55
56         /// <summary>
57         /// Creates and initializes a new instance of MoreOption class.
58         /// </summary>
59         /// <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>
60         public MoreOption(EvasObject parent) : base(parent)
61         {
62             Items = new MoreOptionList(this);
63
64             _selectedEvent = new SmartEvent<PointerEventArgs>(this, "item,selected", (d, o, info) => new PointerEventArgs { Pointer = info });
65             _clickedEvent = new SmartEvent<PointerEventArgs>(this, "item,clicked", (d, o, info) => new PointerEventArgs { Pointer = info });
66             _openedEvent = new SmartEvent(this, "more,option,opened");
67             _closedEvent = new SmartEvent(this, "more,option,closed");
68
69             _selectedEvent.On += (s, e) =>
70             {
71                 MoreOptionItem selected = Items.FirstOrDefault(i => i.Handle == e.Pointer);
72                 Selected?.Invoke(this, new MoreOptionItemEventArgs() { Item = selected });
73             };
74
75             _clickedEvent.On += (s, e) =>
76             {
77                 MoreOptionItem selected = Items.FirstOrDefault(i => i.Handle == e.Pointer);
78                 Clicked?.Invoke(this, new MoreOptionItemEventArgs() { Item = selected });
79             };
80
81             _openedEvent.On += (s, e) => Opened?.Invoke(this, EventArgs.Empty);
82             _closedEvent.On += (s, e) => Closed?.Invoke(this, EventArgs.Empty);
83
84         }
85
86         /// <summary>
87         /// Creates a widget handle.
88         /// </summary>
89         /// <param name="parent">Parent EvasObject</param>
90         /// <returns>Handle IntPtr</returns>
91         protected override IntPtr CreateHandle(EvasObject parent)
92         {
93             return Interop.Eext.eext_more_option_add(parent);
94         }
95
96         /// <summary>
97         /// Sets or gets the direction of more option.
98         /// </summary>
99         public MoreOptionDirection Direction
100         {
101             get
102             {
103                 int dir = Interop.Eext.eext_more_option_direction_get(this);
104                 return (MoreOptionDirection)dir;
105             }
106
107             set
108             {
109                 Interop.Eext.eext_more_option_direction_set(this, (int)value);
110             }
111         }
112
113         /// <summary>
114         /// Sets or gets the visibility of more option view.
115         /// </summary>
116         public bool IsOpened
117         {
118             get
119             {
120                 return Interop.Eext.eext_more_option_opened_get(this);
121             }
122
123             set
124             {
125                 Interop.Eext.eext_more_option_opened_set(this, value);
126             }
127         }
128     }
129
130     /// <summary>
131     /// Enumeration for More Option Direction type.
132     /// </summary>
133     public enum MoreOptionDirection
134     {
135         /// <summary>
136         /// Top direction
137         /// </summary>
138         Top,
139         /// <summary>
140         /// Bottom direction
141         /// </summary>
142         Bottom,
143         /// <summary>
144         /// Left direction
145         /// </summary>
146         Left,
147         /// <summary>
148         /// Right direction
149         /// </summary>
150         Right
151     }
152 }