2 using System.Collections.Generic;
5 using System.Threading.Tasks;
9 public class ItemObject
11 private static Dictionary<int, ItemObject> s_IdToItemTable = new Dictionary<int, ItemObject>();
12 private static Dictionary<IntPtr, ItemObject> s_HandleToItemTable = new Dictionary<IntPtr, ItemObject>();
13 private static int s_globalId = 0;
15 Interop.Evas.SmartCallback _deleteCallback;
16 IntPtr _handle = IntPtr.Zero;
18 protected ItemObject(IntPtr handle)
20 _deleteCallback = DeleteCallbackHandler;
22 s_IdToItemTable[Id] = this;
28 if (Handle != IntPtr.Zero)
29 Interop.Elementary.elm_object_item_del(Handle);
32 public int Id { get; private set; }
36 get { return !Interop.Elementary.elm_object_item_disabled_get(Handle); }
37 set { Interop.Elementary.elm_object_item_disabled_set(Handle, !value); }
40 internal IntPtr Handle
51 if (_handle != IntPtr.Zero)
53 UnsetDeleteCallback();
57 s_HandleToItemTable[Handle] = this;
61 public event EventHandler Deleted;
65 Interop.Elementary.elm_object_item_del(Handle);
66 _handle = IntPtr.Zero;
69 public void SetPartContent(string part, EvasObject content)
71 SetPartContent(part, content, false);
74 public void SetPartContent(string part, EvasObject content, bool preserveOldContent)
76 if (preserveOldContent)
78 Interop.Elementary.elm_object_item_part_content_unset(Handle, part);
80 Interop.Elementary.elm_object_item_part_content_set(Handle, part, content);
83 public void SetPartText(string part, string text)
85 Interop.Elementary.elm_object_item_part_text_set(Handle, part, text);
88 public string GetPartText(string part)
90 return Interop.Elementary.elm_object_item_part_text_get(Handle, part);
93 public static implicit operator IntPtr(ItemObject obj)
100 protected virtual void OnInvalidate() { }
102 internal static ItemObject GetItemById(int id)
105 s_IdToItemTable.TryGetValue(id, out value);
109 internal static ItemObject GetItemByHandle(IntPtr handle)
112 s_HandleToItemTable.TryGetValue(handle, out value);
116 void DeleteCallbackHandler(IntPtr data, IntPtr obj, IntPtr info)
118 Deleted?.Invoke(this, EventArgs.Empty);
120 _handle = IntPtr.Zero;
123 void UnsetDeleteCallback()
125 Interop.Elementary.elm_object_item_del_cb_set(Handle, null);
128 void SetDeleteCallback()
130 if (Handle != IntPtr.Zero)
131 Interop.Elementary.elm_object_item_del_cb_set(Handle, _deleteCallback);
134 static int GetNextId()