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.SetMinimumSwipeDistance(MIN_SWIPE_DISTANCE);
214 mItemView.SetMinimumSwipeSpeed(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 LinearAlignment = LinearLayout.Alignment.Center
453 mRootView.Add(mContentView);
457 private void CreateToolBarLayer()
459 mToolBarLayer = new View()
462 Size = new Size(1920, 80),
463 BackgroundImage = TOOLBAR_IMAGE
465 mToolBarLayer.Layout = new LinearLayout()
467 LinearOrientation = LinearLayout.Orientation.Horizontal,
468 LinearAlignment = LinearLayout.Alignment.Center
470 mRootView.Add(mToolBarLayer);
471 mToolBarLayer.RaiseToTop();
474 CreateToolBarTitle();
475 CreateLayoutButton();
478 public void CreateEditButton()
480 mEditButton = new Button();
481 var mEditButtonStyle = new ButtonStyle
484 BackgroundColor = new Selector<Color>(),
485 BackgroundImage = new Selector<string>() { Normal = EDIT_IMAGE, Selected = EDIT_IMAGE_SELECTED }
487 mEditButton.ApplyStyle(mEditButtonStyle);
488 mEditButton.IsSelectable = true;
489 mEditButton.Size = new Size(34, 34);
490 mEditButton.LeaveRequired = true;
491 mEditButton.ClickEvent += (obj, e) =>
495 mToolBarLayer.Add(mEditButton);
498 private void CreateToolBarTitle()
500 mTitle = new TextLabel();
501 mTitle.Size = new Size(1800, 80);
502 mTitle.PointSize = 10.0f;
503 mTitle.Text = APPLICATION_TITLE;
504 mTitle.VerticalAlignment = VerticalAlignment.Center;
505 mTitle.HorizontalAlignment = HorizontalAlignment.Center;
506 mToolBarLayer.Add(mTitle);
509 private void CreateLayoutButton()
511 mLayoutButton = new Button();
512 var mLayoutButtonStyle = new ButtonStyle
515 BackgroundImage = new Selector<string>()
517 Normal = SPIRAL_LAYOUT_IMAGE,
518 Selected = SPIRAL_LAYOUT_IMAGE_SELECTED
521 mLayoutButton.ApplyStyle(mLayoutButtonStyle);
522 mLayoutButton.IsSelectable = true;
523 mLayoutButton.Size = new Size(34, 34);
524 mLayoutButton.LeaveRequired = true;
525 mLayoutButton.ClickEvent += (obj, e) =>
527 mCurrentLayout = (mCurrentLayout + 1) % (int)mItemView.GetLayoutCount();
532 mToolBarLayer.Add(mLayoutButton);
535 private void SetLayoutTitle()
537 if (Mode.MODE_NORMAL == mMode)
539 string title = APPLICATION_TITLE;
540 switch (mCurrentLayout)
542 case (int)AllImagesLayouts.SPIRAL_LAYOUT:
543 title = title + ": " + SPIRAL_LABEL;
545 case (int)AllImagesLayouts.GRID_LAYOUT:
546 title = title + ": " + GRID_LABEL;
548 case (int)AllImagesLayouts.DEPTH_LAYOUT:
549 title = title + ": " + DEPTH_LABEL;
558 private void CreateDeleteButton()
560 mDeleteButton = new Button();
561 var mDeleteButtonStyle = new ButtonStyle
564 BackgroundColor = new Selector<Color>(),
565 BackgroundImage = new Selector<string>() { Normal = DELETE_IMAGE, Selected = DELETE_IMAGE_SELECTED }
567 mDeleteButton.ApplyStyle(mDeleteButtonStyle);
568 mDeleteButton.IsSelectable = true;
569 mDeleteButton.ParentOrigin = ParentOrigin.BottomRight;
570 mDeleteButton.PivotPoint = PivotPoint.BottomRight;
571 mDeleteButton.PositionUsesPivotPoint = true;
572 mDeleteButton.DrawMode = DrawModeType.Overlay2D;
573 mDeleteButton.Size = new Size(50, 50);
574 mDeleteButton.LeaveRequired = true;
575 mDeleteButton.Hide();
576 mDeleteButton.ClickEvent += (obj, e) =>
578 ItemIdContainer removeList = new ItemIdContainer();
579 for (uint i = 0; i < mItemView.GetChildCount(); ++i)
581 View child = mItemView.GetChildAt(i);
584 View tick = child.FindChildByName("Tick");
586 if (tick != null && tick.Visibility)
588 removeList.Add(mItemView.GetItemId(child));
593 if (removeList.Count != 0)
595 mItemView.RemoveItems(removeList, 0.5f);
598 NUIApplication.GetDefaultWindow().Add(mDeleteButton);
601 private void CreateInsertButton()
603 mInsertButton = new Button();
604 var mInsertButtonStyle = new ButtonStyle
607 BackgroundColor = new Selector<Color>(),
608 BackgroundImage = new Selector<string>() { Normal = INSERT_IMAGE, Selected = INSERT_IMAGE_SELECTED }
610 mInsertButton.ApplyStyle(mInsertButtonStyle);
611 mInsertButton.IsSelectable = true;
612 mInsertButton.ParentOrigin = ParentOrigin.BottomRight;
613 mInsertButton.PivotPoint = PivotPoint.BottomRight;
614 mInsertButton.PositionUsesPivotPoint = true;
615 mInsertButton.DrawMode = DrawModeType.Overlay2D;
616 mInsertButton.Size = new Size(50, 50);
617 mInsertButton.LeaveRequired = true;
618 mInsertButton.Hide();
619 mInsertButton.ClickEvent += (obj, e) =>
621 ItemContainer insertList = new ItemContainer();
622 Random random = new Random();
623 for (uint i = 0; i < mItemView.GetChildCount(); ++i)
625 View child = mItemView.GetChildAt(i);
628 View tick = child.FindChildByName("Tick");
630 if (tick != null && tick.Visibility)
632 insertList.Add(new Item(mItemView.GetItemId(child), NewItemView((uint)random.Next(52))));
636 if (insertList.Count != 0)
638 mItemView.InsertItems(insertList, 0.5f);
641 NUIApplication.GetDefaultWindow().Add(mInsertButton);
644 private void CreateReplaceButton()
646 mReplaceButton = new Button();
647 var mReplaceButtonStyle = new ButtonStyle
650 BackgroundColor = new Selector<Color>(),
651 BackgroundImage = new Selector<string>() { Normal = REPLACE_IMAGE, Selected = REPLACE_IMAGE_SELECTED }
653 mReplaceButton.ApplyStyle(mReplaceButtonStyle);
654 mReplaceButton.IsSelectable = true;
655 mReplaceButton.ParentOrigin = ParentOrigin.BottomRight;
656 mReplaceButton.PivotPoint = PivotPoint.BottomRight;
657 mReplaceButton.PositionUsesPivotPoint = true;
658 mReplaceButton.DrawMode = DrawModeType.Overlay2D;
659 mReplaceButton.Size = new Size(50, 50);
660 mReplaceButton.LeaveRequired = true;
661 mReplaceButton.Hide();
662 mReplaceButton.ClickEvent += (obj, e) =>
664 ItemContainer replaceList = new ItemContainer();
665 Random random = new Random();
666 for (uint i = 0; i < mItemView.GetChildCount(); ++i)
668 View child = mItemView.GetChildAt(i);
671 View tick = child.FindChildByName("Tick");
673 if (tick != null && tick.Visibility)
675 replaceList.Add(new Item(mItemView.GetItemId(child), NewItemView((uint)random.Next(52))));
680 if (replaceList.Count != 0)
682 mItemView.ReplaceItems(replaceList, 0.5f);
685 NUIApplication.GetDefaultWindow().Add(mReplaceButton);
688 void SwitchToNextMode()
692 case Mode.MODE_REMOVE:
695 mMode = Mode.MODE_REMOVE_MANY;
696 EnterRemoveManyMode();
700 case Mode.MODE_REMOVE_MANY:
702 ExitRemoveManyMode();
703 mMode = Mode.MODE_INSERT;
708 case Mode.MODE_INSERT:
711 mMode = Mode.MODE_INSERT_MANY;
712 EnterInsertManyMode();
716 case Mode.MODE_INSERT_MANY:
718 ExitInsertManyMode();
719 mMode = Mode.MODE_REPLACE;
724 case Mode.MODE_REPLACE:
727 mMode = Mode.MODE_REPLACE_MANY;
728 EnterReplaceManyMode();
732 case Mode.MODE_REPLACE_MANY:
734 ExitReplaceManyMode();
735 mMode = Mode.MODE_NORMAL;
740 case Mode.MODE_NORMAL:
743 mMode = Mode.MODE_REMOVE;
750 void EnterRemoveMode()
752 SetTitle("Edit: Remove");
753 mTapDetector = new TapGestureDetector();
755 for (uint i = 0; i < mItemView.GetChildCount(); ++i)
757 if (mItemView.GetChildAt(i) != null)
759 mTapDetector.Attach(mItemView.GetChildAt(i));
763 mTapDetector.Detected += (obj, e) =>
768 mItemView.RemoveItem(mItemView.GetItemId(item), 0.5f);
773 void ExitRemoveMode()
775 mTapDetector.DetachAll();
776 mTapDetector.Reset();
779 void EnterRemoveManyMode()
781 SetTitle("Edit: Remove Many");
782 mDeleteButton.Show();
784 mTapDetector = new TapGestureDetector();
786 for (uint i = 0; i < mItemView.GetChildCount(); ++i)
788 View child = mItemView.GetChildAt(i);
791 View box = child.FindChildByName("CheckBox");
794 mTapDetector.Attach(child);
800 mTapDetector.Detected += (obj, e) =>
805 Console.WriteLine("haha");
809 Console.WriteLine("hehe");
811 View tick = view.FindChildByName("Tick");
826 void ExitRemoveManyMode()
828 for (uint i = 0; i < mItemView.GetChildCount(); ++i)
830 View child = mItemView.GetChildAt(i);
833 View box = child.FindChildByName("CheckBox");
839 View tick = box.FindChildByName("Tick");
847 mTapDetector.Reset();
848 mDeleteButton.Hide();
851 void EnterInsertMode()
853 SetTitle("Edit: Insert");
854 mTapDetector = new TapGestureDetector();
856 for (uint i = 0; i < mItemView.GetChildCount(); ++i)
858 if (mItemView.GetChildAt(i) != null)
860 mTapDetector.Attach(mItemView.GetChildAt(i));
864 mTapDetector.Detected += (obj, e) =>
868 uint id = mItemView.GetItemId(e.View);
869 Random random = new Random();
871 View newActor = NewItemView((uint)random.Next(52));
873 mItemView.InsertItem(new Item(id, newActor), 0.5f);
877 Tizen.Log.Fatal("NUI", "e.View is null when EnterInsertMode!");
882 void ExitInsertMode()
884 mTapDetector.DetachAll();
885 mTapDetector.Reset();
887 void EnterInsertManyMode()
889 SetTitle("Edit: Insert Many");
890 mInsertButton.Show();
892 mTapDetector = new TapGestureDetector();
894 for (uint i = 0; i < mItemView.GetChildCount(); ++i)
896 View child = mItemView.GetChildAt(i);
899 View box = child.FindChildByName("CheckBox");
903 mTapDetector.Attach(child);
908 mTapDetector.Detected += (obj, e) =>
910 View tick = (e.View).FindChildByName("Tick");
925 void ExitInsertManyMode()
927 for (uint i = 0; i < mItemView.GetChildCount(); ++i)
929 View child = mItemView.GetChildAt(i);
932 View box = child.FindChildByName("CheckBox");
938 View tick = box.FindChildByName("Tick");
946 mTapDetector.Reset();
947 mInsertButton.Hide();
950 void EnterReplaceMode()
952 SetTitle("Edit: Replace");
953 mTapDetector = new TapGestureDetector();
955 for (uint i = 0; i < mItemView.GetChildCount(); ++i)
957 if (mItemView.GetChildAt(i) != null)
959 mTapDetector.Attach(mItemView.GetChildAt(i));
963 mTapDetector.Detected += (obj, e) =>
965 Random random = new Random();
966 mItemView.ReplaceItem(new Item(mItemView.GetItemId(e.View), NewItemView((uint)random.Next(52))), 0.5f);
970 void ExitReplaceMode()
972 mTapDetector.DetachAll();
973 mTapDetector.Reset();
977 void EnterReplaceManyMode()
979 SetTitle("Edit: Replace Many");
980 mReplaceButton.Show();
982 mTapDetector = new TapGestureDetector();
984 for (uint i = 0; i < mItemView.GetChildCount(); ++i)
986 View child = mItemView.GetChildAt(i);
987 View box = child.FindChildByName("CheckBox");
991 mTapDetector.Attach(child);
996 mTapDetector.Detected += (obj, e) =>
998 View tick = (e.View).FindChildByName("Tick");
1001 if (tick.Visibility)
1012 void ExitReplaceManyMode()
1014 for (uint i = 0; i < mItemView.GetChildCount(); ++i)
1016 View child = mItemView.GetChildAt(i);
1017 View box = child.FindChildByName("CheckBox");
1023 View tick = box.FindChildByName("Tick");
1030 mTapDetector.Reset();
1031 mReplaceButton.Hide();