void BtnFinishedClicked_TouchUpInside(object sender, EventArgs e)
        {
            //get the list of images
            List <Image> SelectedImages = AttributeImageSource.getSelectedImagesForImageStack();


            int index = 1;

            /*
             * Add images to the DB. get Index ID
             */

            List <ImageStackImages> imgCount = new DatabaseContext <ImageStackImages>().GetQuery("Select * From ImageStackImages Where ParentImageStackID = ? Order By ImageStackIndex ASC", SelectedImageStack.ID.ToString());

            if (imgCount.Count > 0)
            {
                //get the last image index
                index = imgCount[imgCount.Count - 1].ImageStackIndex + 1;
            }

            //index = 1;
            //add it to the database
            if (SelectedImageStack != null)
            {
                foreach (Image i in SelectedImages)
                {
                    ImageStackImages tempInsert = new ImageStackImages();
                    tempInsert.ImageID            = i.ID;
                    tempInsert.ParentImageStackID = SelectedImageStack.ID;
                    tempInsert.ImageStackIndex    = index;
                    index++;
                    new DatabaseContext <ImageStackImages>().Insert(tempInsert);
                }
            }
            //attributesCollectionView.clearCellSelection();
            AttributeImageSource.clearSelectedImages(attributesCollectionView.getCollection());
            MainTabBarController tab = (MainTabBarController)ParentViewController;

            tab.SelectedIndex = 2;
            tab.DismissModalViewController(true);
        }
        public override void MoveItem(UICollectionView collectionView, NSIndexPath sourceIndexPath, NSIndexPath destinationIndexPath)
        {
            // Reorder our list of items here
            var item = Cells[(int)sourceIndexPath.Item];

            Cells.RemoveAt((int)sourceIndexPath.Item);
            Cells.Insert((int)destinationIndexPath.Item, item);

            //update the Db here with the new Index
            int prevIndex = (int)sourceIndexPath.Item;
            int newIndex  = (int)destinationIndexPath.Item;

            ImageStackImages prev = Cells[prevIndex].ImgOBJ;
            ImageStackImages dest = Cells[newIndex].ImgOBJ;

            dest.ImageStackIndex = newIndex;
            prev.ImageStackIndex = prevIndex;
            //update swap
            new DatabaseContext <ImageStackImages>().Update(prev);
            new DatabaseContext <ImageStackImages>().Update(dest);
        }
 public ImageCell2(ImageStackImages imageOBJ)
 {
     ImgOBJ     = imageOBJ;
     isSelected = false;
 }