2 using Tizen.NUI.BaseComponents;
3 using Tizen.NUI.Components;
5 namespace Tizen.NUI.Samples
7 public class ZItemViewSample : IExample
9 private const float MIN_SWIPE_DISTANCE = 15.0f;
10 private const float MIN_SWIPE_SPEED = 5.0f;
11 private const float SCROLL_TO_ITEM_ANIMATION_TIME = 5.0f;
12 private const float DEPTH_LAYOUT_ITEM_SIZE_FACTOR_PORTRAIT = 1.0f;
13 private const float DEPTH_LAYOUT_ITEM_SIZE_FACTOR_LANDSCAPE = 0.8f;
14 private const float DEPTH_LAYOUT_COLUMNS = 3.0f;
15 private const int BUTTON_BORDER = -10;
16 private const float ITEM_BORDER_SIZE = 2.0f;
17 private const int ITEM_COUNT = 300;
19 private string APPLICATION_TITLE = "ItemView";
20 private string SPIRAL_LABEL = "Spiral";
21 private string GRID_LABEL = "Grid";
22 private string DEPTH_LABEL = "Depth";
24 private string TOOLBAR_IMAGE = CommonResource.GetDaliResourcePath() + "ItemViewDemo/top-bar.png";
25 private string EDIT_IMAGE = CommonResource.GetDaliResourcePath() + "ItemViewDemo/icon-edit.png";
26 private string EDIT_IMAGE_SELECTED = CommonResource.GetDaliResourcePath() + "ItemViewDemo/icon-edit-selected.png";
27 private string DELETE_IMAGE = CommonResource.GetDaliResourcePath() + "ItemViewDemo/icon-delete.png";
28 private string DELETE_IMAGE_SELECTED = CommonResource.GetDaliResourcePath() + "ItemViewDemo/icon-delete-selected.png";
29 private string REPLACE_IMAGE = CommonResource.GetDaliResourcePath() + "ItemViewDemo/icon-replace.png";
30 private string REPLACE_IMAGE_SELECTED = CommonResource.GetDaliResourcePath() + "ItemViewDemo/icon-replace-selected.png";
31 private string INSERT_IMAGE = CommonResource.GetDaliResourcePath() + "ItemViewDemo/icon-insert.png";
32 private string INSERT_IMAGE_SELECTED = CommonResource.GetDaliResourcePath() + "ItemViewDemo/icon-insert-selected.png.png";
33 private string SELECTED_IMAGE = CommonResource.GetDaliResourcePath() + "ItemViewDemo/item-select-check.png";
35 private string SPIRAL_LAYOUT_IMAGE = CommonResource.GetDaliResourcePath() + "ItemViewDemo/icon-item-view-layout-spiral.png";
36 private string SPIRAL_LAYOUT_IMAGE_SELECTED = CommonResource.GetDaliResourcePath() + "ItemViewDemo/icon-item-view-layout-spiral-selected.png";
37 private string GRID_LAYOUT_IMAGE = CommonResource.GetDaliResourcePath() + "ItemViewDemo/icon-item-view-layout-grid.png";
38 private string GRID_LAYOUT_IMAGE_SELECTED = CommonResource.GetDaliResourcePath() + "ItemViewDemo/icon-item-view-layout-grid-selected.png";
39 private string DEPTH_LAYOUT_IMAGE = CommonResource.GetDaliResourcePath() + "ItemViewDemo/icon-item-view-layout-depth.png";
40 private string DEPTH_LAYOUT_IMAGE_SELECTED = CommonResource.GetDaliResourcePath() + "ItemViewDemo/icon-item-view-layout-depth-selected.png";
42 private ItemView mItemView;
43 private ItemFactoryWrapper mItemFactoryWrapper;
44 private PropertyMap mGridLayout;
45 private PropertyMap mDepthLayout;
46 private PropertyMap mSpiralLayout;
47 private PropertyArray mLayout;
48 private int mCurrentLayout = (int)AllImagesLayouts.SPIRAL_LAYOUT;
49 private Mode mMode = Mode.MODE_NORMAL;
51 private LongPressGestureDetector mLongPressGestureDetector;
52 private TapGestureDetector mTapDetector;
54 private Button mLayoutButton;
55 private Button mEditButton;
56 private Button mDeleteButton;
57 private Button mInsertButton;
58 private Button mReplaceButton;
59 private TextLabel mTitle;
61 private Layer mDefaultLayer;
62 private View mRootView;
63 private View mToolBarLayer;
64 private View mContentView;
66 private int mDurationSeconds = 250;
68 public static Vector3 DepthLayoutItemSizeFunctionPortrait(float layoutWidth)
70 float width = (layoutWidth / (DEPTH_LAYOUT_COLUMNS + 1.0f)) * DEPTH_LAYOUT_ITEM_SIZE_FACTOR_PORTRAIT;
73 return new Vector3(width, width, width);
76 public static Vector3 DepthLayoutItemSizeFunctionLandscape(float layoutWidth)
78 float width = (layoutWidth / (DEPTH_LAYOUT_COLUMNS + 1.0f)) * DEPTH_LAYOUT_ITEM_SIZE_FACTOR_LANDSCAPE;
81 return new Vector3(width, width, width);
84 private void SetTitle(string title)
92 public void CreateGridLayout()
94 mGridLayout = new PropertyMap();
95 mGridLayout.Insert((int)DefaultItemLayoutProperty.TYPE, new PropertyValue((int)DefaultItemLayoutType.GRID));
98 public void CreateDepthLayout()
100 mDepthLayout = new PropertyMap();
101 mDepthLayout.Insert((int)DefaultItemLayoutProperty.TYPE, new PropertyValue((int)DefaultItemLayoutType.DEPTH));
104 public void CreateSpiralLayout()
106 mSpiralLayout = new PropertyMap();
107 mSpiralLayout.Insert((int)DefaultItemLayoutProperty.TYPE, new PropertyValue((int)DefaultItemLayoutType.SPIRAL));
110 void SetLayoutImage()
114 switch (mCurrentLayout)
116 case (int)AllImagesLayouts.SPIRAL_LAYOUT:
118 var style = mLayoutButton.Style;
119 style.BackgroundImage = new Selector<string>() { Normal = SPIRAL_LAYOUT_IMAGE, Selected = SPIRAL_LAYOUT_IMAGE_SELECTED };
120 mLayoutButton.ApplyStyle(style);
124 case (int)AllImagesLayouts.GRID_LAYOUT:
126 var style = mLayoutButton.Style;
127 style.BackgroundImage = new Selector<string>() { Normal = GRID_LAYOUT_IMAGE, Selected = GRID_LAYOUT_IMAGE_SELECTED };
128 mLayoutButton.ApplyStyle(style);
132 case (int)AllImagesLayouts.DEPTH_LAYOUT:
134 var style = mLayoutButton.Style;
135 style.BackgroundImage = new Selector<string>() { Normal = DEPTH_LAYOUT_IMAGE, Selected = DEPTH_LAYOUT_IMAGE_SELECTED };
136 mLayoutButton.ApplyStyle(style);
147 Animation animation = new Animation(mDurationSeconds);
148 animation.Finished += AnimationFinished;
149 animation.AnimateTo(mItemView, "Opacity", 0.0f);
153 void AnimationFinished(object sender, EventArgs e)
155 SetLayout(mCurrentLayout);
156 Animation animation = new Animation(mDurationSeconds);
157 animation.AnimateTo(mItemView, "Opacity", 1.0f);
161 private PropertyMap CreateImageVisual(string url)
163 PropertyMap temp = new PropertyMap();
164 temp.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
165 temp.Insert(ImageVisualProperty.URL, new PropertyValue(url));
169 public void Activate()
171 Window window = NUIApplication.GetDefaultWindow();
172 mDefaultLayer = window.GetDefaultLayer();
173 mDefaultLayer.Behavior = Layer.LayerBehavior.Layer3D;
174 window.BackgroundColor = Color.Black;
176 mRootView = new View()
178 Size = new Size(1920, 1080)
180 mRootView.Layout = new LinearLayout()
182 LinearOrientation = LinearLayout.Orientation.Vertical
184 mDefaultLayer.Add(mRootView);
186 CreateToolBarLayer();
189 CreateInsertButton();
190 CreateReplaceButton();
191 CreateDeleteButton();
193 CreateSpiralLayout();
197 mLayout = new PropertyArray();
198 mLayout.PushBack(new PropertyValue(mSpiralLayout));
199 mLayout.PushBack(new PropertyValue(mDepthLayout));
200 mLayout.PushBack(new PropertyValue(mGridLayout));
202 mItemFactoryWrapper = new ItemFactoryWrapper();
203 mItemFactoryWrapper.GetNumberDelegate = GetNumberOfItems;
204 mItemFactoryWrapper.NewItemDelegate = NewItemView;
206 mItemView = new ItemView(mItemFactoryWrapper)
208 Size = new Size(800, 800, 800)
210 mContentView.Add(mItemView);
212 mItemView.Layout = mLayout;
213 mItemView.MinimumSwipeDistance = MIN_SWIPE_DISTANCE;
214 mItemView.MinimumSwipeSpeed = MIN_SWIPE_SPEED;
216 SetLayout((int)mCurrentLayout);
220 mLongPressGestureDetector = new LongPressGestureDetector();
221 mLongPressGestureDetector.Attach(mItemView);
222 mLongPressGestureDetector.Detected += OnLongPressGestureDetected;
225 private void OnLongPressGestureDetected(object source, LongPressGestureDetector.DetectedEventArgs e)
227 switch (e.LongPressGesture.State)
229 case Gesture.StateType.Started:
231 Size windowSize = NUIApplication.GetDefaultWindow().Size;
232 ItemRange range = new ItemRange(0, 0);
233 mItemView.GetItemsRange(range);
235 uint item = (e.LongPressGesture.ScreenPoint.Y < 0.5f * (float)windowSize.Height) ? range.begin : range.end;
237 mItemView.ScrollToItem(item, SCROLL_TO_ITEM_ANIMATION_TIME);
241 case Gesture.StateType.Finished:
243 PropertyMap attributes = new PropertyMap();
244 mItemView.DoAction("stopScrolling", attributes);
254 void SetLayout(int layoutId)
256 Window window = NUIApplication.GetDefaultWindow();
257 switch (mCurrentLayout)
259 case (int)AllImagesLayouts.SPIRAL_LAYOUT:
260 case (int)AllImagesLayouts.DEPTH_LAYOUT:
262 window.GetDefaultLayer().Behavior = Layer.LayerBehavior.Layer3D;
265 case (int)AllImagesLayouts.GRID_LAYOUT:
267 window.GetDefaultLayer().Behavior = Layer.LayerBehavior.LayerUI;
272 Size windowSize = window.Size;
274 if (layoutId == (int)AllImagesLayouts.DEPTH_LAYOUT)
276 mDepthLayout.Insert((int)DefaultItemLayoutProperty.ITEM_SIZE, new PropertyValue(DepthLayoutItemSizeFunctionPortrait(800)));
278 mLayout.PushBack(new PropertyValue(mSpiralLayout));
279 mLayout.PushBack(new PropertyValue(mDepthLayout));
280 mLayout.PushBack(new PropertyValue(mGridLayout));
281 mItemView.Layout = mLayout;
284 // Enable anchoring for depth layout only
285 mItemView.SetAnchoring(layoutId == (int)AllImagesLayouts.DEPTH_LAYOUT);
287 // Activate the layout
288 mItemView.ActivateLayout((uint)layoutId, new Vector3(800, 800, 800), 0.0f);
291 public uint GetNumberOfItems()
296 public View NewItemView(uint itemId)
298 // Create an image view for this item
299 string imagePath = CommonResource.GetDaliResourcePath() + "ItemViewDemo/gallery/gallery-medium-";
300 uint id = itemId % 53;
301 imagePath += id.ToString();
303 PropertyMap propertyMap = new PropertyMap();
304 propertyMap.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
305 propertyMap.Insert(ImageVisualProperty.URL, new PropertyValue(imagePath));
306 propertyMap.Insert(ImageVisualProperty.FittingMode, new PropertyValue((int)VisualFittingModeType.FitKeepAspectRatio));
307 ImageView actor = new ImageView();
308 actor.Image = propertyMap;
310 // Add a border image child actor
311 ImageView borderActor = new ImageView();
312 borderActor.ParentOrigin = ParentOrigin.Center;
313 borderActor.PivotPoint = PivotPoint.Center;
314 borderActor.PositionUsesPivotPoint = true;
315 borderActor.HeightResizePolicy = ResizePolicyType.SizeFixedOffsetFromParent;
316 borderActor.WidthResizePolicy = ResizePolicyType.SizeFixedOffsetFromParent;
317 borderActor.SetSizeModeFactor(new Vector3(2.0f * ITEM_BORDER_SIZE, 2.0f * ITEM_BORDER_SIZE, 0.0f));
318 borderActor.SetColorMode(ColorMode.UseParentColor);
320 PropertyMap borderProperty = new PropertyMap();
321 borderProperty.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Border));
322 borderProperty.Insert(BorderVisualProperty.Color, new PropertyValue(Color.White));
323 borderProperty.Insert(BorderVisualProperty.Size, new PropertyValue(ITEM_BORDER_SIZE));
324 borderProperty.Insert(BorderVisualProperty.AntiAliasing, new PropertyValue(true));
325 borderActor.Image = borderProperty;
327 actor.Add(borderActor);
329 Size spiralItemSize = new Size(30, 30, 0);
330 // Add a checkbox child actor; invisible until edit-mode is enabled
331 ImageView checkBox = new ImageView();
332 checkBox.Name = "CheckBox";
333 checkBox.SetColorMode(ColorMode.UseParentColor);
334 checkBox.ParentOrigin = ParentOrigin.TopRight;
335 checkBox.PivotPoint = PivotPoint.TopRight;
336 checkBox.Size = spiralItemSize;
337 checkBox.PositionZ = 0.1f;
339 PropertyMap solidColorProperty = new PropertyMap();
340 solidColorProperty.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Color));
341 solidColorProperty.Insert(ColorVisualProperty.MixColor, new PropertyValue(new Color(0.0f, 0.0f, 0.0f, 0.6f)));
342 checkBox.Image = solidColorProperty;
344 if (Mode.MODE_REMOVE_MANY != mMode &&
345 Mode.MODE_INSERT_MANY != mMode &&
346 Mode.MODE_REPLACE_MANY != mMode)
350 borderActor.Add(checkBox);
352 ImageView tick = new ImageView(SELECTED_IMAGE);
354 tick.ParentOrigin = ParentOrigin.TopRight;
355 tick.PivotPoint = PivotPoint.TopRight;
356 tick.Size = spiralItemSize;
362 mTapDetector.Attach(actor);
367 public void Deactivate()
369 if (mEditButton != null)
371 mToolBarLayer.Remove(mEditButton);
372 mEditButton.Dispose();
378 mToolBarLayer.Remove(mTitle);
383 if (mLayoutButton != null)
385 mToolBarLayer.Remove(mLayoutButton);
386 mLayoutButton.Dispose();
387 mLayoutButton = null;
390 if (mToolBarLayer != null)
392 mRootView.Remove(mToolBarLayer);
393 mToolBarLayer.Dispose();
394 mToolBarLayer = null;
397 if (mReplaceButton != null)
399 mReplaceButton.GetParent().Remove(mReplaceButton);
400 mReplaceButton.Dispose();
401 mReplaceButton = null;
404 if (mInsertButton != null)
406 mInsertButton.GetParent().Remove(mInsertButton);
407 mInsertButton.Dispose();
408 mInsertButton = null;
411 if (mDeleteButton != null)
413 mDeleteButton.GetParent().Remove(mDeleteButton);
414 mDeleteButton.Dispose();
415 mDeleteButton = null;
418 if (mItemView != null)
420 mContentView.Remove(mItemView);
425 if (mContentView != null)
427 mRootView.Remove(mContentView);
428 mContentView.Dispose();
432 if (mRootView != null)
434 mDefaultLayer.Remove(mRootView);
439 NUIApplication.GetDefaultWindow().GetDefaultLayer().Behavior = Layer.LayerBehavior.LayerUI;
442 public void CreateContentView()
444 mContentView = new View()
446 Size = new Size(1920, 1080)
448 mContentView.Layout = new LinearLayout()
450 LinearOrientation = LinearLayout.Orientation.Horizontal,
451 HorizontalAlignment = HorizontalAlignment.Center,
452 VerticalAlignment = VerticalAlignment.Center,
454 mRootView.Add(mContentView);
458 private void CreateToolBarLayer()
460 mToolBarLayer = new View()
463 Size = new Size(1920, 80),
464 BackgroundImage = TOOLBAR_IMAGE
466 mToolBarLayer.Layout = new LinearLayout()
468 LinearOrientation = LinearLayout.Orientation.Horizontal,
469 HorizontalAlignment = HorizontalAlignment.Center,
470 VerticalAlignment = VerticalAlignment.Center,
472 mRootView.Add(mToolBarLayer);
473 mToolBarLayer.RaiseToTop();
476 CreateToolBarTitle();
477 CreateLayoutButton();
480 public void CreateEditButton()
482 mEditButton = new Button();
483 var mEditButtonStyle = new ButtonStyle
486 BackgroundColor = new Selector<Color>(),
487 BackgroundImage = new Selector<string>() { Normal = EDIT_IMAGE, Selected = EDIT_IMAGE_SELECTED }
489 mEditButton.ApplyStyle(mEditButtonStyle);
490 mEditButton.IsSelectable = true;
491 mEditButton.Size = new Size(34, 34);
492 mEditButton.LeaveRequired = true;
493 mEditButton.Clicked += (obj, e) =>
497 mToolBarLayer.Add(mEditButton);
500 private void CreateToolBarTitle()
502 mTitle = new TextLabel();
503 mTitle.Size = new Size(1800, 80);
504 mTitle.PointSize = 10.0f;
505 mTitle.Text = APPLICATION_TITLE;
506 mTitle.VerticalAlignment = VerticalAlignment.Center;
507 mTitle.HorizontalAlignment = HorizontalAlignment.Center;
508 mToolBarLayer.Add(mTitle);
511 private void CreateLayoutButton()
513 mLayoutButton = new Button();
514 var mLayoutButtonStyle = new ButtonStyle
517 BackgroundImage = new Selector<string>()
519 Normal = SPIRAL_LAYOUT_IMAGE,
520 Selected = SPIRAL_LAYOUT_IMAGE_SELECTED
523 mLayoutButton.ApplyStyle(mLayoutButtonStyle);
524 mLayoutButton.IsSelectable = true;
525 mLayoutButton.Size = new Size(34, 34);
526 mLayoutButton.LeaveRequired = true;
527 mLayoutButton.Clicked += (obj, e) =>
529 mCurrentLayout = (mCurrentLayout + 1) % (int)mItemView.GetLayoutCount();
534 mToolBarLayer.Add(mLayoutButton);
537 private void SetLayoutTitle()
539 if (Mode.MODE_NORMAL == mMode)
541 string title = APPLICATION_TITLE;
542 switch (mCurrentLayout)
544 case (int)AllImagesLayouts.SPIRAL_LAYOUT:
545 title = title + ": " + SPIRAL_LABEL;
547 case (int)AllImagesLayouts.GRID_LAYOUT:
548 title = title + ": " + GRID_LABEL;
550 case (int)AllImagesLayouts.DEPTH_LAYOUT:
551 title = title + ": " + DEPTH_LABEL;
560 private void CreateDeleteButton()
562 mDeleteButton = new Button();
563 var mDeleteButtonStyle = new ButtonStyle
566 BackgroundColor = new Selector<Color>(),
567 BackgroundImage = new Selector<string>() { Normal = DELETE_IMAGE, Selected = DELETE_IMAGE_SELECTED }
569 mDeleteButton.ApplyStyle(mDeleteButtonStyle);
570 mDeleteButton.IsSelectable = true;
571 mDeleteButton.ParentOrigin = ParentOrigin.BottomRight;
572 mDeleteButton.PivotPoint = PivotPoint.BottomRight;
573 mDeleteButton.PositionUsesPivotPoint = true;
574 mDeleteButton.DrawMode = DrawModeType.Overlay2D;
575 mDeleteButton.Size = new Size(50, 50);
576 mDeleteButton.LeaveRequired = true;
577 mDeleteButton.Hide();
578 mDeleteButton.Clicked += (obj, e) =>
580 ItemIdCollection removeList = new ItemIdCollection();
581 for (uint i = 0; i < mItemView.ChildCount; ++i)
583 View child = mItemView.GetChildAt(i);
586 View tick = child.FindChildByName("Tick");
588 if (tick != null && tick.Visibility)
590 removeList.Add(mItemView.GetItemId(child));
595 if (removeList.Count != 0)
597 mItemView.RemoveItems(removeList, 0.5f);
600 NUIApplication.GetDefaultWindow().Add(mDeleteButton);
603 private void CreateInsertButton()
605 mInsertButton = new Button();
606 var mInsertButtonStyle = new ButtonStyle
609 BackgroundColor = new Selector<Color>(),
610 BackgroundImage = new Selector<string>() { Normal = INSERT_IMAGE, Selected = INSERT_IMAGE_SELECTED }
612 mInsertButton.ApplyStyle(mInsertButtonStyle);
613 mInsertButton.IsSelectable = true;
614 mInsertButton.ParentOrigin = ParentOrigin.BottomRight;
615 mInsertButton.PivotPoint = PivotPoint.BottomRight;
616 mInsertButton.PositionUsesPivotPoint = true;
617 mInsertButton.DrawMode = DrawModeType.Overlay2D;
618 mInsertButton.Size = new Size(50, 50);
619 mInsertButton.LeaveRequired = true;
620 mInsertButton.Hide();
621 mInsertButton.Clicked += (obj, e) =>
623 ItemCollection insertList = new ItemCollection();
624 Random random = new Random();
625 for (uint i = 0; i < mItemView.ChildCount; ++i)
627 View child = mItemView.GetChildAt(i);
630 View tick = child.FindChildByName("Tick");
632 if (tick != null && tick.Visibility)
634 insertList.Add(new Item(mItemView.GetItemId(child), NewItemView((uint)random.Next(52))));
638 if (insertList.Count != 0)
640 mItemView.InsertItems(insertList, 0.5f);
643 NUIApplication.GetDefaultWindow().Add(mInsertButton);
646 private void CreateReplaceButton()
648 mReplaceButton = new Button();
649 var mReplaceButtonStyle = new ButtonStyle
652 BackgroundColor = new Selector<Color>(),
653 BackgroundImage = new Selector<string>() { Normal = REPLACE_IMAGE, Selected = REPLACE_IMAGE_SELECTED }
655 mReplaceButton.ApplyStyle(mReplaceButtonStyle);
656 mReplaceButton.IsSelectable = true;
657 mReplaceButton.ParentOrigin = ParentOrigin.BottomRight;
658 mReplaceButton.PivotPoint = PivotPoint.BottomRight;
659 mReplaceButton.PositionUsesPivotPoint = true;
660 mReplaceButton.DrawMode = DrawModeType.Overlay2D;
661 mReplaceButton.Size = new Size(50, 50);
662 mReplaceButton.LeaveRequired = true;
663 mReplaceButton.Hide();
664 mReplaceButton.Clicked += (obj, e) =>
666 ItemCollection replaceList = new ItemCollection();
667 Random random = new Random();
668 for (uint i = 0; i < mItemView.ChildCount; ++i)
670 View child = mItemView.GetChildAt(i);
673 View tick = child.FindChildByName("Tick");
675 if (tick != null && tick.Visibility)
677 replaceList.Add(new Item(mItemView.GetItemId(child), NewItemView((uint)random.Next(52))));
682 if (replaceList.Count != 0)
684 mItemView.ReplaceItems(replaceList, 0.5f);
687 NUIApplication.GetDefaultWindow().Add(mReplaceButton);
690 void SwitchToNextMode()
694 case Mode.MODE_REMOVE:
697 mMode = Mode.MODE_REMOVE_MANY;
698 EnterRemoveManyMode();
702 case Mode.MODE_REMOVE_MANY:
704 ExitRemoveManyMode();
705 mMode = Mode.MODE_INSERT;
710 case Mode.MODE_INSERT:
713 mMode = Mode.MODE_INSERT_MANY;
714 EnterInsertManyMode();
718 case Mode.MODE_INSERT_MANY:
720 ExitInsertManyMode();
721 mMode = Mode.MODE_REPLACE;
726 case Mode.MODE_REPLACE:
729 mMode = Mode.MODE_REPLACE_MANY;
730 EnterReplaceManyMode();
734 case Mode.MODE_REPLACE_MANY:
736 ExitReplaceManyMode();
737 mMode = Mode.MODE_NORMAL;
742 case Mode.MODE_NORMAL:
745 mMode = Mode.MODE_REMOVE;
752 void EnterRemoveMode()
754 SetTitle("Edit: Remove");
755 mTapDetector = new TapGestureDetector();
757 for (uint i = 0; i < mItemView.ChildCount; ++i)
759 if (mItemView.GetChildAt(i) != null)
761 mTapDetector.Attach(mItemView.GetChildAt(i));
765 mTapDetector.Detected += (obj, e) =>
770 mItemView.RemoveItem(mItemView.GetItemId(item), 0.5f);
775 void ExitRemoveMode()
777 mTapDetector.DetachAll();
778 mTapDetector.Reset();
781 void EnterRemoveManyMode()
783 SetTitle("Edit: Remove Many");
784 mDeleteButton.Show();
786 mTapDetector = new TapGestureDetector();
788 for (uint i = 0; i < mItemView.ChildCount; ++i)
790 View child = mItemView.GetChildAt(i);
793 View box = child.FindChildByName("CheckBox");
796 mTapDetector.Attach(child);
802 mTapDetector.Detected += (obj, e) =>
807 Console.WriteLine("haha");
811 Console.WriteLine("hehe");
813 View tick = view.FindChildByName("Tick");
828 void ExitRemoveManyMode()
830 for (uint i = 0; i < mItemView.ChildCount; ++i)
832 View child = mItemView.GetChildAt(i);
835 View box = child.FindChildByName("CheckBox");
841 View tick = box.FindChildByName("Tick");
849 mTapDetector.Reset();
850 mDeleteButton.Hide();
853 void EnterInsertMode()
855 SetTitle("Edit: Insert");
856 mTapDetector = new TapGestureDetector();
858 for (uint i = 0; i < mItemView.ChildCount; ++i)
860 if (mItemView.GetChildAt(i) != null)
862 mTapDetector.Attach(mItemView.GetChildAt(i));
866 mTapDetector.Detected += (obj, e) =>
870 uint id = mItemView.GetItemId(e.View);
871 Random random = new Random();
873 View newActor = NewItemView((uint)random.Next(52));
875 mItemView.InsertItem(new Item(id, newActor), 0.5f);
879 Tizen.Log.Fatal("NUI", "e.View is null when EnterInsertMode!");
884 void ExitInsertMode()
886 mTapDetector.DetachAll();
887 mTapDetector.Reset();
889 void EnterInsertManyMode()
891 SetTitle("Edit: Insert Many");
892 mInsertButton.Show();
894 mTapDetector = new TapGestureDetector();
896 for (uint i = 0; i < mItemView.ChildCount; ++i)
898 View child = mItemView.GetChildAt(i);
901 View box = child.FindChildByName("CheckBox");
905 mTapDetector.Attach(child);
910 mTapDetector.Detected += (obj, e) =>
912 View tick = (e.View).FindChildByName("Tick");
927 void ExitInsertManyMode()
929 for (uint i = 0; i < mItemView.ChildCount; ++i)
931 View child = mItemView.GetChildAt(i);
934 View box = child.FindChildByName("CheckBox");
940 View tick = box.FindChildByName("Tick");
948 mTapDetector.Reset();
949 mInsertButton.Hide();
952 void EnterReplaceMode()
954 SetTitle("Edit: Replace");
955 mTapDetector = new TapGestureDetector();
957 for (uint i = 0; i < mItemView.ChildCount; ++i)
959 if (mItemView.GetChildAt(i) != null)
961 mTapDetector.Attach(mItemView.GetChildAt(i));
965 mTapDetector.Detected += (obj, e) =>
967 Random random = new Random();
968 mItemView.ReplaceItem(new Item(mItemView.GetItemId(e.View), NewItemView((uint)random.Next(52))), 0.5f);
972 void ExitReplaceMode()
974 mTapDetector.DetachAll();
975 mTapDetector.Reset();
979 void EnterReplaceManyMode()
981 SetTitle("Edit: Replace Many");
982 mReplaceButton.Show();
984 mTapDetector = new TapGestureDetector();
986 for (uint i = 0; i < mItemView.ChildCount; ++i)
988 View child = mItemView.GetChildAt(i);
989 View box = child.FindChildByName("CheckBox");
993 mTapDetector.Attach(child);
998 mTapDetector.Detected += (obj, e) =>
1000 View tick = (e.View).FindChildByName("Tick");
1003 if (tick.Visibility)
1014 void ExitReplaceManyMode()
1016 for (uint i = 0; i < mItemView.ChildCount; ++i)
1018 View child = mItemView.GetChildAt(i);
1019 View box = child.FindChildByName("CheckBox");
1025 View tick = box.FindChildByName("Tick");
1032 mTapDetector.Reset();
1033 mReplaceButton.Hide();