Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / GenGrid.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     /// It inherits System.EventArgs.
24     /// It contains Item which is <see cref="GenGridItem"/> type.
25     /// All events of GenGrid contain GenGridItemEventArgs as a parameter.
26     /// </summary>
27     public class GenGridItemEventArgs : EventArgs
28     {
29         /// <summary>
30         /// Gets or sets GenGrid item.The return type is <see cref="GenGridItem"/>.
31         /// </summary>
32         public GenGridItem Item { get; set; }
33
34         internal static GenGridItemEventArgs CreateFromSmartEvent(IntPtr data, IntPtr obj, IntPtr info)
35         {
36             GenGridItem item = ItemObject.GetItemByHandle(info) as GenGridItem;
37             return new GenGridItemEventArgs() { Item = item };
38         }
39     }
40
41     /// <summary>
42     /// It inherits <see cref="Layout"/>.
43     /// The GenGrid is a widget that aims to position objects in a grid layout while actually creating and rendering only the visible ones.
44     /// It has two direction in which a given GenGrid widget expands while placing its items, horizontal and vertical.
45     /// The GenGrid items are represented through <see cref="GenItemClass"/> definition field details.
46     /// </summary>
47     public class GenGrid : Layout
48     {
49         HashSet<GenGridItem> _children = new HashSet<GenGridItem>();
50
51         SmartEvent<GenGridItemEventArgs> _selected;
52         SmartEvent<GenGridItemEventArgs> _unselected;
53         SmartEvent<GenGridItemEventArgs> _activated;
54         SmartEvent<GenGridItemEventArgs> _pressed;
55         SmartEvent<GenGridItemEventArgs> _released;
56         SmartEvent<GenGridItemEventArgs> _doubleClicked;
57         SmartEvent<GenGridItemEventArgs> _realized;
58         SmartEvent<GenGridItemEventArgs> _unrealized;
59         SmartEvent<GenGridItemEventArgs> _longpressed;
60         SmartEvent _changed;
61
62         /// <summary>
63         /// Creates and initializes a new instance of the GenGrid class.
64         /// </summary>
65         /// <param name="parent">The parent is a given container which will be attached by GenGrid as a child. It's <see cref="EvasObject"/> type.</param>
66         public GenGrid(EvasObject parent) : base(parent)
67         {
68             InitializeSmartEvent();
69         }
70
71         /// <summary>
72         /// ItemSelected is raised when a new gengrid item is selected.
73         /// </summary>
74         public event EventHandler<GenGridItemEventArgs> ItemSelected;
75
76         /// <summary>
77         /// ItemUnselected is raised when the gengrid item is Unselected.
78         /// </summary>
79         public event EventHandler<GenGridItemEventArgs> ItemUnselected;
80
81         /// <summary>
82         /// ItemPressed is raised when a new gengrid item is pressed.
83         /// </summary>
84         public event EventHandler<GenGridItemEventArgs> ItemPressed;
85
86         /// <summary>
87         /// ItemReleased is raised when a new gengrid item is released.
88         /// </summary>
89         public event EventHandler<GenGridItemEventArgs> ItemReleased;
90
91         /// <summary>
92         /// ItemActivated is raised when a new gengrid item is double clicked or pressed (enter|return|spacebar).
93         /// </summary>
94         public event EventHandler<GenGridItemEventArgs> ItemActivated;
95
96         /// <summary>
97         /// ItemDoubleClicked is raised when a new gengrid item is double clicked.
98         /// </summary>
99         public event EventHandler<GenGridItemEventArgs> ItemDoubleClicked;
100
101         /// <summary>
102         /// ItemRealized is raised when a gengrid item is implementing through <see cref="GenItemClass"/>.
103         /// </summary>
104         public event EventHandler<GenGridItemEventArgs> ItemRealized;
105
106         /// <summary>
107         /// ItemUnrealized is raised when the gengrid item is deleted.
108         /// </summary>
109         public event EventHandler<GenGridItemEventArgs> ItemUnrealized;
110
111         /// <summary>
112         /// ItemLongPressed is raised when a gengrid item is pressed for a certain amount of time. By default it's 1 second.
113         /// </summary>
114         public event EventHandler<GenGridItemEventArgs> ItemLongPressed;
115
116         /// <summary>
117         ///  Changed is raised when an item is added, removed, resized or moved and when the gengrid is resized or gets "horizontal" property changes.
118         /// </summary>
119         public event EventHandler Changed;
120
121         /// <summary>
122         /// Gets or sets the item's grid alignment along x-axis within a given gengrid widget.
123         /// Accepted values are in the 0.0 to 1.0 range, with the special value -1.0 used to specify "justify" or "fill" by some users.
124         /// By default, value is 0.0, meaning that the gengrid has its items grid placed exactly in the left along x-axis.
125         /// </summary>
126         public double ItemAlignmentX
127         {
128             get
129             {
130                 double align;
131                 Interop.Elementary.elm_gengrid_align_get(RealHandle, out align, IntPtr.Zero);
132                 return align;
133             }
134             set
135             {
136                 double aligny = ItemAlignmentY;
137                 Interop.Elementary.elm_gengrid_align_set(RealHandle, value, aligny);
138             }
139         }
140
141         /// <summary>
142         /// Gets or sets the item's grid alignment on y-axis within a given gengrid widget.
143         /// Accepted values are in the 0.0 to 1.0 range, with the special value -1.0 used to specify "justify" or "fill" by some users.
144         /// By default, value is 0.0, meaning that the gengrid has its items grid placed exactly in the top along y-axis.
145         /// </summary>
146         public double ItemAlignmentY
147         {
148             get
149             {
150                 double align;
151                 Interop.Elementary.elm_gengrid_align_get(RealHandle, IntPtr.Zero, out align);
152                 return align;
153             }
154             set
155             {
156                 double alignx = ItemAlignmentX;
157                 Interop.Elementary.elm_gengrid_align_set(RealHandle, alignx, value);
158             }
159         }
160
161         /// <summary>
162         /// Gets or sets the manner in which the items grid is filled within a given gengrid widget.
163         /// It is filled if true, otherwise false.
164         /// </summary>
165         public bool FillItems
166         {
167             get
168             {
169                 return Interop.Elementary.elm_gengrid_filled_get(RealHandle);
170             }
171             set
172             {
173                 Interop.Elementary.elm_gengrid_filled_set(RealHandle, value);
174             }
175         }
176
177         /// <summary>
178         /// Gets or sets whether multi-selection is enabled or disabled for a given gengrid widget.
179         /// </summary>
180         /// <remarks>
181         /// Multi-selection is the ability to have more than one item selected, on a given gengrid, simultaneously.
182         /// When it is enabled, a sequence of clicks on different items makes them all selected, progressively.
183         /// A click on an already selected item unselects it. If interacting via the keyboard, multi-selection is enabled while holding the "Shift" key.
184         /// By default, multi-selection is disabled.
185         /// </remarks>
186         public bool MultipleSelection
187         {
188             get
189             {
190                 return Interop.Elementary.elm_gengrid_multi_select_get(RealHandle);
191             }
192             set
193             {
194                 Interop.Elementary.elm_gengrid_multi_select_set(RealHandle, value);
195             }
196         }
197
198         /// <summary>
199         /// Gets or sets the width for the items of a given gengrid widget.
200         /// </summary>
201         /// <remarks>
202         /// A gengrid, after creation, still has no information on the size to give to each of its cells.
203         /// The default width and height just have one finger wide.
204         /// Use this property to force a custom width for your items, making them as big as you wish.
205         /// </remarks>
206         public int ItemWidth
207         {
208             get
209             {
210                 int width;
211                 Interop.Elementary.elm_gengrid_item_size_get(RealHandle, out width, IntPtr.Zero);
212                 return width;
213             }
214             set
215             {
216                 int height = ItemHeight;
217                 Interop.Elementary.elm_gengrid_item_size_set(RealHandle, value, height);
218             }
219         }
220
221         /// <summary>
222         /// Gets or sets the height for the items of a given gengrid widget.
223         /// </summary>
224         /// <remarks>
225         /// A gengrid, after creation, still has no information on the size to give to each of its cells.
226         /// The default width and height just have one finger wide.
227         /// Use this property to force a custom height for your items, making them as big as you wish.
228         /// </remarks>
229         public int ItemHeight
230         {
231             get
232             {
233                 int height;
234                 Interop.Elementary.elm_gengrid_item_size_get(RealHandle, IntPtr.Zero, out height);
235                 return height;
236             }
237             set
238             {
239                 int width = ItemWidth;
240                 Interop.Elementary.elm_gengrid_item_size_set(RealHandle, width, value);
241             }
242         }
243
244         /// <summary>
245         /// Gets or sets the gengrid select mode by <see cref="GenGridSelectionMode"/>.
246         /// </summary>
247         public GenItemSelectionMode SelectionMode
248         {
249             get
250             {
251                 return (GenItemSelectionMode)Interop.Elementary.elm_gengrid_select_mode_get(RealHandle);
252             }
253             set
254             {
255                 Interop.Elementary.elm_gengrid_select_mode_set(RealHandle, (int)value);
256             }
257         }
258
259         /// <summary>
260         /// Gets or sets the direction for which a given gengrid widget expands while placing its items.
261         /// </summary>
262         /// <remarks>
263         /// If true, items are placed in columns from top to bottom and when the space for a column is filled, another one is started on the right, thus expanding the grid horizontally.
264         /// If false, items are placed in rows from left to right, and when the space for a row is filled, another one is started below, thus expanding the grid vertically.
265         /// </remarks>
266         public bool IsHorizontal
267         {
268             get
269             {
270                 return Interop.Elementary.elm_gengrid_horizontal_get(RealHandle);
271             }
272             set
273             {
274                 Interop.Elementary.elm_gengrid_horizontal_set(RealHandle, value);
275             }
276         }
277
278         /// <summary>
279         /// Gets or sets whether the gengrid items should be highlighted when an item is selected.
280         /// </summary>
281         public bool IsHighlight
282         {
283             get
284             {
285                 return Interop.Elementary.elm_gengrid_highlight_mode_get(RealHandle);
286             }
287             set
288             {
289                 Interop.Elementary.elm_gengrid_highlight_mode_set(RealHandle, value);
290             }
291         }
292
293         /// <summary>
294         /// Sets or gets the value of HorizontalScrollBarVisiblePolicy
295         /// </summary>
296         /// <remarks>
297         /// ScrollBarVisiblePolicy.Auto means the horizontal scrollbar is made visible if it is needed, and otherwise kept hidden.
298         /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
299         /// </remarks>
300         public ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy
301         {
302             get
303             {
304                 int policy;
305                 Interop.Elementary.elm_scroller_policy_get(RealHandle, out policy, IntPtr.Zero);
306                 return (ScrollBarVisiblePolicy)policy;
307             }
308             set
309             {
310                 ScrollBarVisiblePolicy v = VerticalScrollBarVisiblePolicy;
311                 Interop.Elementary.elm_scroller_policy_set(RealHandle, (int)value, (int)v);
312             }
313         }
314
315         /// <summary>
316         /// Sets or gets the value of VerticalScrollBarVisiblePolicy
317         /// </summary>
318         /// <remarks>
319         /// ScrollBarVisiblePolicy.Auto means the vertical scrollbar is made visible if it is needed, and otherwise kept hidden.
320         /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
321         /// </remarks>
322         public ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy
323         {
324             get
325             {
326                 int policy;
327                 Interop.Elementary.elm_scroller_policy_get(RealHandle, IntPtr.Zero, out policy);
328                 return (ScrollBarVisiblePolicy)policy;
329             }
330             set
331             {
332                 ScrollBarVisiblePolicy h = HorizontalScrollBarVisiblePolicy;
333                 Interop.Elementary.elm_scroller_policy_set(RealHandle, (int)h, (int)value);
334             }
335         }
336
337         /// <summary>
338         /// Gets the first item in a given gengrid widget.
339         /// </summary>
340         public GenGridItem FirstItem
341         {
342             get
343             {
344                 IntPtr handle = Interop.Elementary.elm_gengrid_first_item_get(RealHandle);
345                 return ItemObject.GetItemByHandle(handle) as GenGridItem;
346             }
347         }
348
349         /// <summary>
350         /// Gets the last item in a given gengrid widget.
351         /// </summary>
352         public GenGridItem LastItem
353         {
354             get
355             {
356                 IntPtr handle = Interop.Elementary.elm_gengrid_last_item_get(RealHandle);
357                 return ItemObject.GetItemByHandle(handle) as GenGridItem;
358             }
359         }
360
361         /// <summary>
362         /// Gets the items count in a given gengrid widget.
363         /// </summary>
364         public uint ItemCount
365         {
366             get
367             {
368                 return Interop.Elementary.elm_gengrid_items_count(RealHandle);
369             }
370         }
371
372         /// <summary>
373         /// Gets the selected item in a given gengrid widget.
374         /// </summary>
375         public GenGridItem SelectedItem
376         {
377             get
378             {
379                 IntPtr handle = Interop.Elementary.elm_gengrid_selected_item_get(RealHandle);
380                 return ItemObject.GetItemByHandle(handle) as GenGridItem;
381             }
382         }
383
384         /// <summary>
385         /// Gets or sets whether a given gengrid widget is or not able have items reordered.
386         /// </summary>
387         public bool ReorderMode
388         {
389             get
390             {
391                 return Interop.Elementary.elm_gengrid_reorder_mode_get(RealHandle);
392             }
393             set
394             {
395                 Interop.Elementary.elm_gengrid_reorder_mode_set(RealHandle, value);
396             }
397         }
398
399         /// <summary>
400         /// Appends a new item to a given gengrid widget. This adds an item to the end of the gengrid.
401         /// </summary>
402         /// <param name="itemClass">The itemClass defines how to display the data.</param>
403         /// <param name="data">The item data.</param>
404         /// <returns>Return a gengrid item that contains data and itemClass.</returns>
405         /// <seealso cref="GenItemClass"/>
406         /// <seealso cref="GenGridItem"/>
407         public GenGridItem Append(GenItemClass itemClass, object data)
408         {
409             GenGridItem item = new GenGridItem(data, itemClass);
410             IntPtr handle = Interop.Elementary.elm_gengrid_item_append(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, null, (IntPtr)item.Id);
411             item.Handle = handle;
412             AddInternal(item);
413             return item;
414         }
415
416         /// <summary>
417         /// Prepends a new item to a given gengrid widget. This adds an item to the beginning of the gengrid.
418         /// </summary>
419         /// <param name="itemClass">The itemClass defines how to display the data.</param>
420         /// <param name="data">The item data.</param>
421         /// <returns>Return a gengrid item that contains data and itemClass.</returns>
422         /// <seealso cref="GenItemClass"/>
423         /// <seealso cref="GenGridItem"/>
424         public GenGridItem Prepend(GenItemClass itemClass, object data)
425         {
426             GenGridItem item = new GenGridItem(data, itemClass);
427             IntPtr handle = Interop.Elementary.elm_gengrid_item_prepend(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, null, (IntPtr)item.Id);
428             item.Handle = handle;
429             AddInternal(item);
430             return item;
431         }
432
433         /// <summary>
434         /// Inserts an item before another in a gengrid widget. This inserts an item before another in the gengrid.
435         /// </summary>
436         /// <param name="itemClass">The itemClass defines how to display the data.</param>
437         /// <param name="data">The item data.</param>
438         /// <param name="before">The item before which to place this new one.</param>
439         /// <returns>Return a gengrid item that contains data and itemClass./></returns>
440         /// <seealso cref="GenItemClass"/>
441         /// <seealso cref="GenGridItem"/>
442         public GenGridItem InsertBefore(GenItemClass itemClass, object data, GenGridItem before)
443         {
444             GenGridItem item = new GenGridItem(data, itemClass);
445             IntPtr handle = Interop.Elementary.elm_gengrid_item_insert_before(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, before, null, (IntPtr)item.Id);
446             item.Handle = handle;
447             AddInternal(item);
448             return item;
449         }
450
451         /// <summary>
452         /// Inserts an item before another in a gengrid widget. This inserts an item after another in the gengrid.
453         /// </summary>
454         /// <param name="itemClass">The itemClass defines how to display the data.</param>
455         /// <param name="data">The item data.</param>
456         /// <param name="after">The item after which to place this new one.</param>
457         /// <returns>Return a gengrid item that contains data and itemClass.</returns>
458         /// <seealso cref="GenItemClass"/>
459         /// <seealso cref="GenGridItem"/>
460         public GenGridItem InsertAfter(GenItemClass itemClass, object data, GenGridItem after)
461         {
462             GenGridItem item = new GenGridItem(data, itemClass);
463             IntPtr handle = Interop.Elementary.elm_gengrid_item_insert_after(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, after, null, (IntPtr)item.Id);
464             item.Handle = handle;
465             AddInternal(item);
466             return item;
467         }
468
469         /// <summary>
470         /// Insert an item in a gengrid widget using a user-defined sort function.
471         /// </summary>
472         /// <param name="itemClass">The itemClass defines how to display the data.</param>
473         /// <param name="data">The item data.</param>
474         /// <param name="func">User defined comparison function that defines the sort order based on gengrid item and its data.</param>
475         /// <returns>Return a gengrid item that contains data and itemClass.</returns>
476         public GenGridItem InsertSorted(GenItemClass itemClass, object data, Comparison<object> comparison)
477         {
478             GenGridItem item = new GenGridItem(data, itemClass);
479
480             Interop.Elementary.Eina_Compare_Cb compareCallback = (handle1, handle2) =>
481             {
482                 GenGridItem first = (ItemObject.GetItemByHandle(handle1) as GenGridItem) ?? item;
483                 GenGridItem second = (ItemObject.GetItemByHandle(handle2) as GenGridItem) ?? item;
484                 return comparison(first.Data, second.Data);
485             };
486
487             IntPtr handle = Interop.Elementary.elm_gengrid_item_sorted_insert(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, compareCallback, null, (IntPtr)item.Id);
488             item.Handle = handle;
489             AddInternal(item);
490             return item;
491         }
492
493         /// <summary>
494         /// Shows a given item to the visible area of a gengrid.
495         /// </summary>
496         /// <param name="item">The gengrid item to display.</param>
497         /// <param name="position">The position of the item in the viewport.</param>
498         /// <param name="animated">The type of how to show the item.</param>
499         /// <remarks>
500         /// If animated is true, the gengrid shows item by scrolling if it's not fully visible.
501         /// If animated is false, the gengrid shows item by jumping if it's not fully visible.
502         /// </remarks>
503         /// <seealso cref="ScrollToPosition"/>
504         public void ScrollTo(GenGridItem item, ScrollToPosition position, bool animated)
505         {
506             if (animated)
507             {
508                 Interop.Elementary.elm_gengrid_item_bring_in(item.Handle, (int)position);
509             }
510             else
511             {
512                 Interop.Elementary.elm_gengrid_item_show(item.Handle, (int)position);
513             }
514         }
515
516         /// <summary>
517         /// Updates the contents of all the realized items.
518         /// This updates all realized items by calling all the <see cref="GenItemClass"/> again to get the content, text, and states.
519         /// Use this when the original item data has changed and the changes are desired to reflect.
520         /// </summary>
521         /// <remarks>
522         /// <see cref="GenItem.Update()"/> to update just one item.
523         /// </remarks>
524         public void UpdateRealizedItems()
525         {
526             Interop.Elementary.elm_gengrid_realized_items_update(RealHandle);
527         }
528
529         /// <summary>
530         /// Removes all items from a given gengrid widget.
531         /// This removes(and deletes) all items in obj, making it empty.
532         /// </summary>
533         /// <remarks>
534         /// <see cref="ItemObject.Delete()"/> to delete just one item.
535         /// </remarks>
536         public void Clear()
537         {
538             Interop.Elementary.elm_gengrid_clear(RealHandle);
539         }
540
541         /// <summary>
542         /// Get the item that is at the x, y canvas coords.
543         /// </summary>
544         /// <param name="x">The input x coordinate</param>
545         /// <param name="y">The input y coordinate</param>
546         /// <param name="positionX">The position relative to the item returned here.
547         /// -1, 0 or 1, depending if the coordinate is on the left portion of that item(-1), on the middle section(0) or on the right part(1).
548         /// </param>
549         /// <param name="positionY">The position relative to the item returned here
550         /// -1, 0 or 1, depending if the coordinate is on the upper portion of that item (-1), on the middle section (0) or on the lower part (1).
551         /// </param>
552         /// <returns></returns>
553         public GenGridItem GetItemByPosition(int x, int y, out int portionX, out int portionY)
554         {
555             IntPtr handle = Interop.Elementary.elm_gengrid_at_xy_item_get(RealHandle, x, y, out portionX, out portionY);
556             return ItemObject.GetItemByHandle(handle) as GenGridItem;
557         }
558
559         protected override IntPtr CreateHandle(EvasObject parent)
560         {
561             IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
562             Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
563
564             RealHandle = Interop.Elementary.elm_gengrid_add(handle);
565             Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
566
567             return handle;
568         }
569
570         void InitializeSmartEvent()
571         {
572             _selected = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "selected", GenGridItemEventArgs.CreateFromSmartEvent);
573             _unselected = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "unselected", GenGridItemEventArgs.CreateFromSmartEvent);
574             _activated = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "activated", GenGridItemEventArgs.CreateFromSmartEvent);
575             _pressed = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "pressed", GenGridItemEventArgs.CreateFromSmartEvent);
576             _released = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "released", GenGridItemEventArgs.CreateFromSmartEvent);
577             _doubleClicked = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "clicked,double", GenGridItemEventArgs.CreateFromSmartEvent);
578             _realized = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "realized", GenGridItemEventArgs.CreateFromSmartEvent);
579             _unrealized = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "unrealized", GenGridItemEventArgs.CreateFromSmartEvent);
580             _longpressed = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "longpressed", GenGridItemEventArgs.CreateFromSmartEvent);
581             _changed = new SmartEvent(this, this.RealHandle, "changed");
582
583             _selected.On += (s, e) => { if (e.Item != null) ItemSelected?.Invoke(this, e); };
584             _unselected.On += (s, e) => { if (e.Item != null) ItemUnselected?.Invoke(this, e); };
585             _activated.On += (s, e) => { if (e.Item != null) ItemActivated?.Invoke(this, e); };
586             _pressed.On += (s, e) => { if (e.Item != null) ItemPressed?.Invoke(this, e); };
587             _released.On += (s, e) => { if (e.Item != null) ItemReleased?.Invoke(this, e); };
588             _doubleClicked.On += (s, e) => { if (e.Item != null) ItemDoubleClicked?.Invoke(this, e); };
589             _realized.On += (s, e) => { if (e.Item != null) ItemRealized?.Invoke(this, e); };
590             _unrealized.On += (s, e) => { if (e.Item != null) ItemUnrealized?.Invoke(this, e); };
591             _longpressed.On += (s, e) => { if (e.Item != null) ItemLongPressed?.Invoke(this, e); };
592             _changed.On += (s, e) => { Changed?.Invoke(this, e); };
593         }
594
595         void AddInternal(GenGridItem item)
596         {
597             _children.Add(item);
598             item.Deleted += Item_Deleted;
599         }
600
601         void Item_Deleted(object sender, EventArgs e)
602         {
603             _children.Remove((GenGridItem)sender);
604         }
605     }
606 }