Inheritance: Windows.UI.Xaml.Controls.ListViewItem
        protected override DependencyObject GetContainerForItemOverride()
        {
            var item = new CatrobatListViewItem(_verticalItemMargin, _reorderEnabled, GroupingEnabled, SelectionEnabled, _dragging == CatrobatListViewDragStaus.NotDragging);

            item.Tapped            += item_Tapped;
            item.ItemGroupEvent    += item_ItemGroupEvent;
            item.ItemSelectedEvent += item_ItemSelectedEvent;
            return(item);
        }
        private void SetYPositionTo(double y)
        {
            CatrobatListViewItem tmpDragClone = GetDraggingItemClone();

            if (tmpDragClone != null)
            {
                Canvas.SetTop(tmpDragClone, y - (_draggingItem.OrigHeight * ImageResizeFactor) / 2);
            }
        }
        private CatrobatListViewItem GenerateDraggingItemClone()
        {
            CatrobatListViewItem tmpItemClone = new CatrobatListViewItem(_verticalItemMargin, this._reorderEnabled, this.GroupingEnabled, SelectionEnabled);

            tmpItemClone.Content = _draggingItem.Content;

            tmpItemClone.ContentTemplate = _draggingItem.ContentTemplate;
            tmpItemClone.Style           = _draggingItem.Style;
            tmpItemClone.Width           = ActualWidth * ImageResizeFactor;
            tmpItemClone.IsGrouped       = _draggingItem.IsGrouped;
            return(tmpItemClone);
        }
 public CatrobatListViewWorker()
 {
     _verticalItemMargin = 0;
     _reorderEnabled     = false;
     GroupingEnabled     = true;
     _dragging           = CatrobatListViewDragStaus.NotDragging;
     _draggingItem       = null;
     SmartSelectedItems  = new ObservableCollection <object>();
     SmartSelectedItems.CollectionChanged += SmartSelectedItems_CollectionChanged;
     _autoScrollOldYValue = 0;
     _rearrangeOldYValue  = 0;
     SelectionEnabled     = false;
 }
        private void AddSnapshotToManipulationCanvas(double yPos)
        {
            _manipulationCanvas.Children.Clear();
            CatrobatListViewItem tmpItemClone = GenerateDraggingItemClone();

            if (_dragging == CatrobatListViewDragStaus.PrepareDraggin)
            {
                Items[Items.IndexOf(_originalDragContent.Content)] = _tmpDragContentControl;
                SetTmpDragContentHeight();
                _manipulationCanvas.Children.Add(tmpItemClone);

                Canvas.SetLeft(tmpItemClone, ActualWidth - tmpItemClone.Width);

                SetYPositionTo(yPos);
                _manipulationCanvas.Visibility = Visibility.Visible;
                _dragging = CatrobatListViewDragStaus.Dragging;
            }
        }
        private void EndDrag()
        {
            if (_dragging == CatrobatListViewDragStaus.NotDragging)
            {
                return;
            }
            _dragging = CatrobatListViewDragStaus.NotDragging;
            _manipulationCanvas.Visibility = Visibility.Collapsed;

            if (Items.IndexOf(_tmpDragContentControl) != -1)
            {
                ItemDragCompletedEvent(this, new CatrobatListViewEventArgs(_tmpDragContentControl, _originalDragContent, null, null, _draggingGroupList));
                if (_draggingGroupList != null && _draggingGroupList.Count > 0)
                {
                    _draggingGroupList.Clear();
                    _draggingItem = null;
                    var tmpItem = ContainerFromItem(_originalDragContent.Content) as CatrobatListViewItem;
                    GroupItem(tmpItem);
                }
            }
        }
        private void StartDrag(int index, double yPos)
        {
            var tmpItem = this.ContainerFromIndex(index) as CatrobatListViewItem;

            if (tmpItem == null || tmpItem.ReorderEnabled == false)
            {
                return;
            }
            _dragging     = CatrobatListViewDragStaus.PrepareDraggin;
            _draggingItem = tmpItem;

            InitDragContentObject();

            if (_draggingItem.IsGrouped)
            {
                InitDragGroupList();
            }

            MoveValidationCalculation(index);

            AddSnapshotToManipulationCanvas(yPos);
        }
        private void GroupItem(CatrobatListViewItem item)
        {
            int startIndex = Items.IndexOf(item.Content);

            int endIndex;

            if (item.Content is Script)
            {
                endIndex = CalcMaxReorderIndex(startIndex + 1, true);
                endIndex--;

                SmartSelectedItems.Remove(item.Content);
            }
            else
            {
                endIndex = GetEndBrickIndex(item.Content);
            }

            ChangeItemsVisibility(startIndex + 1, endIndex, (item.IsGrouped && SmartSelectedItems.Contains(item.Content)));

            item.IsGrouped = !item.IsGrouped;
        }
 public CatrobatListViewWorker()
 {
     _verticalItemMargin = 0;
     _reorderEnabled = false;
     GroupingEnabled = true;
     _dragging = CatrobatListViewDragStaus.NotDragging;
     _draggingItem = null;
     SmartSelectedItems = new ObservableCollection<object>();
     SmartSelectedItems.CollectionChanged += SmartSelectedItems_CollectionChanged;
     _autoScrollOldYValue = 0;
     _rearrangeOldYValue = 0;
     SelectionEnabled = false;
 }
 protected override DependencyObject GetContainerForItemOverride()
 {
     var item = new CatrobatListViewItem(_verticalItemMargin, _reorderEnabled, GroupingEnabled, SelectionEnabled, _dragging == CatrobatListViewDragStaus.NotDragging);
     item.Tapped += item_Tapped;
     item.ItemGroupEvent += item_ItemGroupEvent;
     item.ItemSelectedEvent += item_ItemSelectedEvent;
     return item;
 }
 private CatrobatListViewItem GenerateDraggingItemClone()
 {
     CatrobatListViewItem tmpItemClone = new CatrobatListViewItem(_verticalItemMargin, this._reorderEnabled, this.GroupingEnabled, SelectionEnabled);
     tmpItemClone.Content = _draggingItem.Content;
     
     tmpItemClone.ContentTemplate = _draggingItem.ContentTemplate;
     tmpItemClone.Style = _draggingItem.Style;
     tmpItemClone.Width = ActualWidth * ImageResizeFactor;
     tmpItemClone.IsGrouped = _draggingItem.IsGrouped;
     return tmpItemClone;
 }
        private void StartDrag(int index, double yPos)
        {
            var tmpItem = this.ContainerFromIndex(index) as CatrobatListViewItem;
            if (tmpItem == null || tmpItem.ReorderEnabled == false)
            {
                return;
            }
            _dragging = CatrobatListViewDragStaus.PrepareDraggin;
            _draggingItem = tmpItem;
            
            InitDragContentObject();

            if (_draggingItem.IsGrouped)
            {
                InitDragGroupList();
            }

            MoveValidationCalculation(index);

            AddSnapshotToManipulationCanvas(yPos);
        }
        private void EndDrag()
        {
            if (_dragging == CatrobatListViewDragStaus.NotDragging)
            {
                return;
            }
            _dragging = CatrobatListViewDragStaus.NotDragging;
            _manipulationCanvas.Visibility = Visibility.Collapsed;

            if (Items.IndexOf(_tmpDragContentControl) != -1)
            {
                ItemDragCompletedEvent(this, new CatrobatListViewEventArgs(_tmpDragContentControl, _originalDragContent, null, null, _draggingGroupList));
                if (_draggingGroupList != null && _draggingGroupList.Count > 0)
                {
                    _draggingGroupList.Clear();
                    _draggingItem = null;
                    var tmpItem = ContainerFromItem(_originalDragContent.Content) as CatrobatListViewItem;
                    GroupItem(tmpItem);
                }
            }

        }
        private void GroupItem(CatrobatListViewItem item)
        {
            int startIndex = Items.IndexOf(item.Content);

            int endIndex;
            if (item.Content is Script)
            {
                endIndex = CalcMaxReorderIndex(startIndex + 1, true);
                endIndex--;

                SmartSelectedItems.Remove(item.Content);
            }
            else
            {
                endIndex = GetEndBrickIndex(item.Content);
            }

            ChangeItemsVisibility(startIndex + 1, endIndex, (item.IsGrouped && SmartSelectedItems.Contains(item.Content)));

            item.IsGrouped = !item.IsGrouped;
        }
 public CatrobatListViewItemEventArgs(CatrobatListViewItem tappeItem)
 {
     this._tappedItem = tappeItem;
 }
 public CatrobatListViewItemEventArgs(CatrobatListViewItem tappeItem)
 {
     this._tappedItem = tappeItem;
 }