2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Collections.Generic;
21 namespace ElmSharp.Wearable
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.
27 public class MoreOption : Layout
30 /// Sets or gets the list of more option item
32 public IList<MoreOptionItem> Items { get; private set; }
35 /// Selected will be triggered when the user selects an item.
37 public event EventHandler<MoreOptionItemEventArgs> Selected;
39 /// Clicked will be triggered when the user selects the already selected item again or selects a selector.
41 public event EventHandler<MoreOptionItemEventArgs> Clicked;
43 /// Opened will be triggered when more option view is shown.
45 public event EventHandler Opened;
47 /// Closed will be triggered when more option view is hidden.
49 public event EventHandler Closed;
51 SmartEvent<PointerEventArgs> _selectedEvent;
52 SmartEvent<PointerEventArgs> _clickedEvent;
53 SmartEvent _openedEvent;
54 SmartEvent _closedEvent;
57 /// Creates and initializes a new instance of MoreOption class.
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)
62 Items = new MoreOptionList(this);
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");
69 _selectedEvent.On += (s, e) =>
71 MoreOptionItem selected = Items.FirstOrDefault(i => i.Handle == e.Pointer);
72 Selected?.Invoke(this, new MoreOptionItemEventArgs() { Item = selected });
75 _clickedEvent.On += (s, e) =>
77 MoreOptionItem selected = Items.FirstOrDefault(i => i.Handle == e.Pointer);
78 Clicked?.Invoke(this, new MoreOptionItemEventArgs() { Item = selected });
81 _openedEvent.On += (s, e) => Opened?.Invoke(this, EventArgs.Empty);
82 _closedEvent.On += (s, e) => Closed?.Invoke(this, EventArgs.Empty);
87 /// Creates a widget handle.
89 /// <param name="parent">Parent EvasObject</param>
90 /// <returns>Handle IntPtr</returns>
91 protected override IntPtr CreateHandle(EvasObject parent)
93 return Interop.Eext.eext_more_option_add(parent);
97 /// Sets or gets the direction of more option.
99 public MoreOptionDirection Direction
103 int dir = Interop.Eext.eext_more_option_direction_get(this);
104 return (MoreOptionDirection)dir;
109 Interop.Eext.eext_more_option_direction_set(this, (int)value);
114 /// Sets or gets the visibility of more option view.
120 return Interop.Eext.eext_more_option_opened_get(this);
125 Interop.Eext.eext_more_option_opened_set(this, value);
131 /// Enumeration for More Option Direction type.
133 public enum MoreOptionDirection