Add api comments for GenList,GenListItem,List,ListItem,SmartEvent
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / GenList.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
20 namespace ElmSharp
21 {
22     /// <summary>
23     /// Enumeration for setting genlist item type.
24     /// </summary>
25     public enum GenListItemType
26     {
27         /// <summary>
28         /// if Normal is set then this item is normal item.
29         /// </summary>
30         Normal = 0,
31         /// <summary>
32         /// If tree is set then this item is displayed as an item that is able to expand and have child items.
33         /// </summary>
34         Tree = (1 << 0),
35         /// <summary>
36         /// if Group is set then this item is group index item that is displayed at the top until the next group comes.
37         /// </summary>
38         Group = (1 << 1),
39     }
40
41     /// <summary>
42     /// Enumeration for setting genlist's resizing behavior, transverse axis scrolling and items cropping.
43     /// </summary>
44     public enum GenListMode
45     {
46         /// <summary>
47         /// The genlist won't set any of its size hints to inform how a possible container should resize it.
48         /// Then, if it's not created as a "resize object", it might end with zeroed dimensions.
49         /// The genlist will respect the container's geometry and, if any of its items won't fit into its transverse axis, one won't be able to scroll it in that direction.
50         /// </summary>
51         Compress = 0,
52         /// <summary>
53         /// This is the same as Compress, with the exception that if any of its items won't fit into its transverse axis, one will be able to scroll it in that direction.
54         /// </summary>
55         Scroll,
56         /// <summary>
57         /// Sets a minimum size hint on the genlist object, so that containers may respect it (and resize itself to fit the child properly).
58         /// More specifically, a minimum size hint will be set for its transverse axis, so that the largest item in that direction fits well.
59         /// This is naturally bound by the genlist object's maximum size hints, set externally.
60         /// </summary>
61         Limit,
62         /// <summary>
63         /// Besides setting a minimum size on the transverse axis, just like on Limit, the genlist will set a minimum size on th longitudinal axis, trying to reserve space to all its children to be visible at a time.
64         /// This is naturally bound by the genlist object's maximum size hints, set externally.
65         /// </summary>
66         Expand
67     }
68
69     /// <summary>
70     /// It inherits System.EventArgs.
71     /// It contains Item which is <see cref="GenListItem"/> type.
72     /// All events of GenList contain GenListItemEventArgs as a parameter.
73     /// </summary>
74     public class GenListItemEventArgs : EventArgs
75     {
76         /// <summary>
77         /// Gets or sets GenList item. The return type is <see cref="GenListItem"/>.
78         /// </summary>
79         public GenListItem Item { get; set; }
80
81         internal static GenListItemEventArgs CreateFromSmartEvent(IntPtr data, IntPtr obj, IntPtr info)
82         {
83             GenListItem item = ItemObject.GetItemByHandle(info) as GenListItem;
84             return new GenListItemEventArgs() { Item = item };
85         }
86     }
87
88     /// <summary>
89     /// Enumeration that defines where to position the item in the genlist.
90     /// </summary>
91     public enum ScrollToPosition
92     {
93         /// <summary>
94         /// Scrolls to nowhere.
95         /// </summary>
96         None = 0,
97         /// <summary>
98         /// Scrolls to the nearest viewport.
99         /// </summary>
100         In = (1 << 0),
101         /// <summary>
102         /// Scrolls to the top of the viewport.
103         /// </summary>
104         Top = (1 << 1),
105         /// <summary>
106         /// Scrolls to the middle of the viewport.
107         /// </summary>
108         Middle = (1 << 2),
109         /// <summary>
110         /// Scrolls to the bottom of the viewport.
111         /// </summary>
112         Bottom = (1 << 3)
113     }
114
115     /// <summary>
116     /// It inherits <see cref="Layout"/>.
117     /// The GenList is a widget that aims to have more expansive list than the simple <see cref="List"/> in ElmSharp that could have more flexible items and allow many more entries while still being fast and low on memory usage.
118     /// At the same time it was also made to be able to do tree structures.
119     /// But the price to pay is more complexity when it comes to usage.
120     /// If all you want is a simple list with icons and a single text, use the <see cref="List"/> widget.
121     /// </summary>
122     public class GenList : Layout
123     {
124         HashSet<GenListItem> _children = new HashSet<GenListItem>();
125
126         SmartEvent<GenListItemEventArgs> _selected;
127         SmartEvent<GenListItemEventArgs> _unselected;
128         SmartEvent<GenListItemEventArgs> _activated;
129         SmartEvent<GenListItemEventArgs> _pressed;
130         SmartEvent<GenListItemEventArgs> _released;
131         SmartEvent<GenListItemEventArgs> _doubleClicked;
132         SmartEvent<GenListItemEventArgs> _expanded;
133         SmartEvent<GenListItemEventArgs> _realized;
134         SmartEvent<GenListItemEventArgs> _unrealized;
135         SmartEvent<GenListItemEventArgs> _longpressed;
136         SmartEvent<GenListItemEventArgs> _moved;
137         SmartEvent<GenListItemEventArgs> _movedAfter;
138         SmartEvent<GenListItemEventArgs> _movedBefore;
139         SmartEvent _scrollAnimationStarted;
140         SmartEvent _scrollAnimationStopped;
141         SmartEvent _changed;
142
143         /// <summary>
144         /// Creates and initializes a new instance of the GenList class.
145         /// </summary>
146         /// <param name="parent">The parent is a given container which will be attached by GenList as a child. It's <see cref="EvasObject"/> type.</param>
147         public GenList(EvasObject parent) : base(parent)
148         {
149             InitializeSmartEvent();
150         }
151
152         /// <summary>
153         /// Gets or sets whether the homogeneous mode is enabled.
154         /// </summary>
155         /// <remarks>
156         /// If true, the genlist items have same height and width.
157         /// </remarks>
158         public bool Homogeneous
159         {
160             get
161             {
162                 return Interop.Elementary.elm_genlist_homogeneous_get(RealHandle);
163             }
164             set
165             {
166                 Interop.Elementary.elm_genlist_homogeneous_set(RealHandle, value);
167             }
168         }
169
170         /// <summary>
171         /// Gets or sets the horizontal stretching mode. This mode used for sizing items horizontally.
172         /// The default value is <see cref="GenListMode.Scroll"/> which means that if items are too wide to fit, the scroller scrolls horizontally.
173         /// If set <see cref="GenListMode.Compress"/> which means that the item width is fixed (restricted to a minimum of) to the list width when calculating its size in order to allow the height to be calculated based on it.
174         /// If set <see cref="GenListMode.Limit"/> which means that items are expanded to the viewport width and limited to that size.
175         /// if set <see cref="GenListMode.Expand"/> which means that genlist try to reserve space to all its items to be visible at a time.
176         /// </summary>
177         /// <remarks>
178         /// Compress makes genlist resize slower as it recalculates every item height again whenever the list width changes.
179         /// The homogeneous mode is so that all items in the genlist are of the same width/height. With Compress, genlist items are initialized fast.
180         /// However, there are no sub-objects in the genlist which can be on the flying resizable (such as TEXTBLOCK).
181         /// If so, then some dynamic resizable objects in the genlist would not be diplayed properly.
182         /// </remarks>
183         public GenListMode ListMode
184         {
185             get
186             {
187                 return (GenListMode)Interop.Elementary.elm_genlist_mode_get(RealHandle);
188             }
189             set
190             {
191                 Interop.Elementary.elm_genlist_mode_set(RealHandle, (int)value);
192             }
193         }
194
195         /// <summary>
196         /// Gets the first item in the genlist.
197         /// </summary>
198         public GenListItem FirstItem
199         {
200             get
201             {
202                 IntPtr handle = Interop.Elementary.elm_genlist_first_item_get(RealHandle);
203                 return ItemObject.GetItemByHandle(handle) as GenListItem;
204             }
205         }
206
207         /// <summary>
208         /// Gets the last item in the genlist.
209         /// </summary>
210         public GenListItem LastItem
211         {
212             get
213             {
214                 IntPtr handle = Interop.Elementary.elm_genlist_last_item_get(RealHandle);
215                 return ItemObject.GetItemByHandle(handle) as GenListItem;
216             }
217         }
218
219         /// <summary>
220         /// Gets or sets the reorder mode.
221         /// After turning on the reorder mode, longpress on a normal item triggers reordering of the item.
222         /// You can move the item up and down. However, reordering does not work with group items.
223         /// </summary>
224         public bool ReorderMode
225         {
226             get
227             {
228                 return Interop.Elementary.elm_genlist_reorder_mode_get(RealHandle);
229             }
230             set
231             {
232                 Interop.Elementary.elm_genlist_reorder_mode_set(RealHandle, value);
233             }
234         }
235
236         /// <summary>
237         /// ItemSelected is raised when a new genlist item is selected.
238         /// </summary>
239         public event EventHandler<GenListItemEventArgs> ItemSelected;
240
241         /// <summary>
242         /// ItemUnselected is raised when the genlist item is Unselected.
243         /// </summary>
244         public event EventHandler<GenListItemEventArgs> ItemUnselected;
245
246         /// <summary>
247         /// ItemPressed is raised when a new genlist item is pressed.
248         /// </summary>
249         public event EventHandler<GenListItemEventArgs> ItemPressed;
250
251         /// <summary>
252         /// ItemReleased is raised when a new genlist item is released.
253         /// </summary>
254         public event EventHandler<GenListItemEventArgs> ItemReleased;
255
256         /// <summary>
257         /// ItemActivated is raised when a new genlist item is double clicked or pressed (enter|return|spacebar).
258         /// </summary>
259         public event EventHandler<GenListItemEventArgs> ItemActivated;
260
261         /// <summary>
262         /// ItemDoubleClicked is raised when a new genlist item is double clicked.
263         /// </summary>
264         public event EventHandler<GenListItemEventArgs> ItemDoubleClicked;
265
266         /// <summary>
267         /// ItemExpanded is raised when a new genlist item is indicated to expand.
268         /// </summary>
269         public event EventHandler<GenListItemEventArgs> ItemExpanded;
270
271         /// <summary>
272         /// ItemRealized is raised when a new genlist item is created as a real object.
273         /// </summary>
274         public event EventHandler<GenListItemEventArgs> ItemRealized;
275
276         /// <summary>
277         /// ItemUnrealized is raised when a new genlist item is unrealized.
278         /// After calling unrealize, the item's content objects are deleted and the item object itself is deleted or is put into a floating cache.
279         /// </summary>
280         public event EventHandler<GenListItemEventArgs> ItemUnrealized;
281
282         /// <summary>
283         /// ItemLongPressed is raised when a genlist item is pressed for a certain amount of time. By default it's 1 second.
284         /// </summary>
285         public event EventHandler<GenListItemEventArgs> ItemLongPressed;
286
287         /// <summary>
288         /// ItemMoved is raised when a genlist item is moved in the reorder mode.
289         /// </summary>
290         public event EventHandler<GenListItemEventArgs> ItemMoved;
291
292         /// <summary>
293         /// ItemMovedAfter is raised when a genlist item is moved after another item in the reorder mode.
294         /// To get the relative previous item, use <see cref="GenListItem.Previous"/>.
295         /// </summary>
296         public event EventHandler<GenListItemEventArgs> ItemMovedAfter;
297
298         /// <summary>
299         /// ItemMovedBefore is raised when a genlist item is moved before another item in the reorder mode.
300         /// To get the relative next item, use <see cref="GenListItem.Next"/>.
301         /// </summary>
302         public event EventHandler<GenListItemEventArgs> ItemMovedBefore;
303
304         /// <summary>
305         /// Changed is raised when genlist is changed.
306         /// </summary>
307         public event EventHandler Changed
308         {
309             add { _changed.On += value; }
310             remove { _changed.On -= value; }
311         }
312
313         /// <summary>
314         /// ScrollAnimationStarted is raised when scrolling animation has started.
315         /// </summary>
316         public event EventHandler ScrollAnimationStarted
317         {
318             add { _scrollAnimationStarted.On += value; }
319             remove { _scrollAnimationStarted.On -= value; }
320         }
321
322         /// <summary>
323         /// ScrollAnimationStopped is raised when scrolling animation has stopped.
324         /// </summary>
325         public event EventHandler ScrollAnimationStopped
326         {
327             add { _scrollAnimationStopped.On += value; }
328             remove { _scrollAnimationStopped.On -= value; }
329         }
330
331         /// <summary>
332         /// Appends a new item to the end of a given genlist widget.
333         /// </summary>
334         /// <param name="itemClass">The itemClass defines how to display the data.</param>
335         /// <param name="data">The item data.</param>
336         /// <returns>Return a new added genlist item that contains data and itemClass.</returns>
337         /// <seealso cref="GenItemClass"/>
338         /// <seealso cref="GenListItem"/>
339         public GenListItem Append(GenItemClass itemClass, object data)
340         {
341             return Append(itemClass, data, GenListItemType.Normal);
342         }
343
344         /// <summary>
345         /// Appends a new item with <see cref="GenListItemType"/> to the end of a given genlist widget.
346         /// </summary>
347         /// <param name="itemClass">The itemClass defines how to display the data.</param>
348         /// <param name="data">The item data.</param>
349         /// <param name="type">The genlist item type.</param>
350         /// <returns>Return a new added genlist item that contains data and itemClass.</returns>
351         public GenListItem Append(GenItemClass itemClass, object data, GenListItemType type)
352         {
353             return Append(itemClass, data, type, null);
354         }
355
356         /// <summary>
357         /// Appends a new item with <see cref="GenListItemType"/> to the end of a given genlist widget or the end of the children list if the parent is given.
358         /// </summary>
359         /// <param name="itemClass">The itemClass defines how to display the data.</param>
360         /// <param name="data">The item data.</param>
361         /// <param name="type">The genlist item type.</param>
362         /// <param name="parent">The parent item, otherwise null if there is no parent item.</param>
363         /// <returns>Return a new added genlist item that contains data and itemClass.</returns>
364         public GenListItem Append(GenItemClass itemClass, object data, GenListItemType type, GenListItem parent)
365         {
366             GenListItem item = new GenListItem(data, itemClass);
367             IntPtr handle = Interop.Elementary.elm_genlist_item_append(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, parent, (int)type, null, (IntPtr)item.Id);
368             item.Handle = handle;
369             AddInternal(item);
370             return item;
371         }
372
373         /// <summary>
374         /// Prepends a new item to the beginning of a given genlist widget.
375         /// </summary>
376         /// <param name="itemClass">The itemClass defines how to display the data.</param>
377         /// <param name="data">The item data.</param>
378         /// <returns>Return a new added genlist item that contains data and itemClass.</returns>
379         public GenListItem Prepend(GenItemClass itemClass, object data)
380         {
381             return Prepend(itemClass, data, GenListItemType.Normal);
382         }
383
384         /// <summary>
385         /// Prepends a new item with <see cref="GenListItemType"/> to the beginning of a given genlist widget.
386         /// </summary>
387         /// <param name="itemClass">The itemClass defines how to display the data.</param>
388         /// <param name="data">The item data.</param>
389         /// <param name="type">The genlist item type.</param>
390         /// <param name="parent">The parent item, otherwise null if there is no parent item.</param>
391         /// <returns>Return a new added genlist item that contains data and itemClass.</returns>
392         public GenListItem Prepend(GenItemClass itemClass, object data, GenListItemType type)
393         {
394             return Prepend(itemClass, data, type, null);
395         }
396
397         /// <summary>
398         /// Prepends a new item with <see cref="GenListItemType"/> to the beginning of a given genlist widget or the beginning of the children list if the parent is given.
399         /// </summary>
400         /// <param name="itemClass">The itemClass defines how to display the data.</param>
401         /// <param name="data">The item data.</param>
402         /// <param name="type">The genlist item type.</param>
403         /// <param name="parent">The parent item, otherwise null if there is no parent item.</param>
404         /// <returns>Return a new added genlist item that contains data and itemClass.</returns>
405         public GenListItem Prepend(GenItemClass itemClass, object data, GenListItemType type, GenListItem parent)
406         {
407             GenListItem item = new GenListItem(data, itemClass);
408             IntPtr handle = Interop.Elementary.elm_genlist_item_prepend(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, parent, (int)type, null, (IntPtr)item.Id);
409             item.Handle = handle;
410             AddInternal(item);
411             return item;
412         }
413
414         /// <summary>
415         /// Inserts an item before another item in a genlist widget.
416         /// It is the same tree level or group as the item before which it is inserted.????
417         /// </summary>
418         /// <param name="itemClass">The itemClass defines how to display the data.</param>
419         /// <param name="data">The item data.</param>
420         /// <param name="before">The item before which to place this new one.</param>
421         /// <returns>Return a new added genlist item that contains data and itemClass.</returns>
422         public GenListItem InsertBefore(GenItemClass itemClass, object data, GenListItem before)
423         {
424             return InsertBefore(itemClass, data, before, GenListItemType.Normal);
425         }
426
427         /// <summary>
428         /// Inserts an item with <see cref="GenListItemType"/> before another item in a genlist widget.
429         /// It is the same tree level or group as the item before which it is inserted.????
430         /// </summary>
431         /// <param name="itemClass">The itemClass defines how to display the data.</param>
432         /// <param name="data">The item data.</param>
433         /// <param name="before">The item before which to place this new one.</param>
434         /// <param name="type">The genlist item type.</param>
435         /// <returns>Return a new added genlist item that contains data and itemClass.</returns>
436         public GenListItem InsertBefore(GenItemClass itemClass, object data, GenListItem before, GenListItemType type)
437         {
438             return InsertBefore(itemClass, data, before, type, null);
439         }
440
441         /// <summary>
442         /// Inserts an item with <see cref="GenListItemType"/> before another item under a parent in a genlist widget.
443         /// </summary>
444         /// <param name="itemClass">The itemClass defines how to display the data.</param>
445         /// <param name="data">The item data.</param>
446         /// <param name="before">The item before which to place this new one.</param>
447         /// <param name="type">The genlist item type.</param>
448         /// <param name="parent">The parent item, otherwise null if there is no parent item.</param>
449         /// <returns>Return a new added genlist item that contains data and itemClass.</returns>
450         public GenListItem InsertBefore(GenItemClass itemClass, object data, GenListItem before, GenListItemType type, GenListItem parent)
451         {
452             GenListItem item = new GenListItem(data, itemClass);
453             // insert before the `before` list item
454             IntPtr handle = Interop.Elementary.elm_genlist_item_insert_before(
455                 RealHandle, // genlist handle
456                 itemClass.UnmanagedPtr, // item class
457                 (IntPtr)item.Id, // data
458                 parent, // parent
459                 before, // before
460                 (int)type, // item type
461                 null, // select callback
462                 (IntPtr)item.Id); // callback data
463             item.Handle = handle;
464             AddInternal(item);
465             return item;
466         }
467
468         /// <summary>
469         /// Shows the given item with position type in a genlist.
470         /// When animated is true, genlist will jump to the given item and display it (by animatedly scrolling), if it is not fully visible. This may use animation and may take some time.
471         /// When animated is false, genlist will jump to the given item and display it (by jumping to that position), if it is not fully visible.
472         /// </summary>
473         /// <param name="item">The item to display.</param>
474         /// <param name="position">The position to show the given item to <see cref="ScrollToPosition"/>.</param>
475         /// <param name="animated">The animated indicates how to display the item, by scrolling or by jumping.</param>
476         public void ScrollTo(GenListItem item, ScrollToPosition position, bool animated)
477         {
478             if (animated)
479             {
480                 Interop.Elementary.elm_genlist_item_bring_in(item.Handle, (Interop.Elementary.Elm_Genlist_Item_Scrollto_Type)position);
481             }
482             else
483             {
484                 Interop.Elementary.elm_genlist_item_show(item.Handle, (Interop.Elementary.Elm_Genlist_Item_Scrollto_Type)position);
485             }
486         }
487
488         /// <summary>
489         /// Updates the content of all the realized items.
490         /// This updates all the realized items by calling all the <see cref="GenItemClass"/> again to get the content, text and states.
491         /// Use this when the original item data has changed and the changes are desired to reflect.
492         /// To update just one item, use <see cref="GenListItem.Update"/>.
493         /// </summary>
494         /// <seealso cref="GenListItem.Update"/>
495         public void UpdateRealizedItems()
496         {
497             Interop.Elementary.elm_genlist_realized_items_update(RealHandle);
498         }
499
500         /// <summary>
501         /// Removes all items from a given genlist widget.
502         /// This removes (and deletes) all items in obj, making it empty.
503         /// To delete just one item, use <see cref="ItemObject.Delete"/>.
504         /// </summary>
505         /// <seealso cref="ItemObject.Delete"/>
506         public void Clear()
507         {
508             Interop.Elementary.elm_genlist_clear(RealHandle);
509         }
510
511         protected override IntPtr CreateHandle(EvasObject parent)
512         {
513             IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
514             Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
515
516             RealHandle = Interop.Elementary.elm_genlist_add(handle);
517             Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
518
519             return handle;
520         }
521
522         void InitializeSmartEvent()
523         {
524             _selected = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "selected", GenListItemEventArgs.CreateFromSmartEvent);
525             _unselected = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "unselected", GenListItemEventArgs.CreateFromSmartEvent);
526             _activated = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "activated", GenListItemEventArgs.CreateFromSmartEvent);
527             _pressed = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "pressed", GenListItemEventArgs.CreateFromSmartEvent);
528             _released = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "released", GenListItemEventArgs.CreateFromSmartEvent);
529             _doubleClicked = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "clicked,double", GenListItemEventArgs.CreateFromSmartEvent);
530             _expanded = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "expanded", GenListItemEventArgs.CreateFromSmartEvent);
531             _realized = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "realized", GenListItemEventArgs.CreateFromSmartEvent);
532             _unrealized = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "unrealized", GenListItemEventArgs.CreateFromSmartEvent);
533             _longpressed = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "longpressed", GenListItemEventArgs.CreateFromSmartEvent);
534             _moved = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "moved", GenListItemEventArgs.CreateFromSmartEvent);
535             _movedAfter = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "moved,after", GenListItemEventArgs.CreateFromSmartEvent);
536             _movedBefore = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "moved,before", GenListItemEventArgs.CreateFromSmartEvent);
537             _scrollAnimationStarted = new SmartEvent(this, this.RealHandle, "scroll,anim,start");
538             _scrollAnimationStopped = new SmartEvent(this, this.RealHandle, "scroll,anim,stop");
539             _changed = new SmartEvent(this, this.RealHandle, "changed");
540
541             _selected.On += (s, e) => { if (e.Item != null) ItemSelected?.Invoke(this, e); };
542             _unselected.On += (s, e) => { if (e.Item != null) ItemUnselected?.Invoke(this, e); };
543             _activated.On += (s, e) => { if (e.Item != null) ItemActivated?.Invoke(this, e); };
544             _pressed.On += (s, e) => { if (e.Item != null) ItemPressed?.Invoke(this, e); };
545             _released.On += (s, e) => { if (e.Item != null) ItemReleased?.Invoke(this, e); };
546             _doubleClicked.On += (s, e) => { if (e.Item != null) ItemDoubleClicked?.Invoke(this, e); };
547             _expanded.On += (s, e) => { if (e.Item != null) ItemExpanded?.Invoke(this, e); };
548             _realized.On += (s, e) => { if (e.Item != null) ItemRealized?.Invoke(this, e); };
549             _unrealized.On += (s, e) => { if (e.Item != null) ItemUnrealized?.Invoke(this, e); };
550             _longpressed.On += (s, e) => { if (e.Item != null) ItemLongPressed?.Invoke(this, e); };
551             _moved.On += (s, e) => { if (e.Item != null) ItemMoved?.Invoke(this, e); };
552             _movedAfter.On += (s, e) => { if (e.Item != null) ItemMovedAfter?.Invoke(this, e); };
553             _movedBefore.On += (s, e) => { if (e.Item != null) ItemMovedBefore?.Invoke(this, e); };
554         }
555
556         void AddInternal(GenListItem item)
557         {
558             _children.Add(item);
559             item.Deleted += Item_Deleted;
560         }
561
562         void Item_Deleted(object sender, EventArgs e)
563         {
564             _children.Remove((GenListItem)sender);
565         }
566     }
567 }