2 using System.Collections.Generic;
6 public enum ContextPopupDirection
15 public class ContextPopup : Layout
17 HashSet<ContextPopupItem> _children = new HashSet<ContextPopupItem>();
18 Interop.SmartEvent _dismissed;
19 Interop.Evas.SmartCallback _onSelected;
21 public ContextPopup(EvasObject parent) : base(parent)
23 _dismissed = new Interop.SmartEvent(this, Handle, "dismissed");
24 _dismissed.On += (sender, e) =>
26 Dismissed?.Invoke(this, EventArgs.Empty);
28 _onSelected = (data, obj, info) =>
30 ContextPopupItem item = ItemObject.GetItemById((int)data) as ContextPopupItem;
35 public event EventHandler Dismissed;
37 public ContextPopupDirection Direction
41 return (ContextPopupDirection)Interop.Elementary.elm_ctxpopup_direction_get(Handle);
45 public bool IsHorizontal
49 return Interop.Elementary.elm_ctxpopup_horizontal_get(Handle);
53 Interop.Elementary.elm_box_horizontal_set(Handle, value);
61 return !Interop.Elementary.elm_ctxpopup_auto_hide_disabled_get(Handle);
65 Interop.Elementary.elm_ctxpopup_auto_hide_disabled_set(Handle, !value);
69 public void SetDirectionPriorty(ContextPopupDirection first, ContextPopupDirection second, ContextPopupDirection third, ContextPopupDirection fourth)
71 Interop.Elementary.elm_ctxpopup_direction_priority_set(Handle, (int)first, (int)second, (int)third, (int)fourth);
74 public ContextPopupItem Append(string label)
76 return Append(label, null);
79 public ContextPopupItem Append(string label, EvasObject icon)
81 ContextPopupItem item = new ContextPopupItem(label, icon);
82 item.Handle = Interop.Elementary.elm_ctxpopup_item_append(Handle, label, icon, _onSelected, (IntPtr)item.Id);
89 Interop.Elementary.elm_ctxpopup_dismiss(Handle);
92 public bool IsAvailableDirection(ContextPopupDirection direction)
94 return Interop.Elementary.elm_ctxpopup_direction_available_get(Handle, (int)direction);
97 internal override IntPtr CreateHandle(EvasObject parent)
99 return Interop.Elementary.elm_ctxpopup_add(parent.Handle);
102 void AddInternal(ContextPopupItem item)
105 item.Deleted += Item_Deleted;
108 void Item_Deleted(object sender, EventArgs e)
110 _children.Remove((ContextPopupItem)sender);