Esempio n. 1
0
        public GridViewCell GridViewCellForItemAtIndex(GridView gridView, int index)
        {
            SizeF size = GridViewSizeForItemsInInterfaceOrientation(gridView,UIApplication.SharedApplication.StatusBarOrientation);

            GridViewCell cell = gridView.DequeueReusableCell();

            if (cell==null)
            {
                cell = new GridViewCell();
                cell.DeleteButtonIcon=null;
                cell.DeleteButtonOffset=new PointF(-15, -15);

                UIView view = new UIView(new RectangleF(0,0,size.Width,size.Height));
                view.BackgroundColor = UIColor.Red;
                view.Layer.MasksToBounds = false;
                view.Layer.CornerRadius = 8;

                cell.ContentView = view;
            }
            else
            {
                RectangleF f = cell.Frame;
                f.Size = size;
                cell.Frame = f;
                cell.Alpha = 1.0f;
            }
            cell.RemoveContentViewSubviews();

            UILabel label = new UILabel(cell.ContentView.Bounds);
            label.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            label.Text = currentData[index];
            label.TextAlignment = UITextAlignment.Center;
            label.BackgroundColor = UIColor.Clear;
            label.TextColor = UIColor.Black;
            label.HighlightedTextColor = UIColor.White;
            label.Font = UIFont.BoldSystemFontOfSize(20.0f);
            cell.ContentView.AddSubview(label);

            return cell;
        }
Esempio n. 2
0
 public bool GridViewShouldAllowShakingBehaviorWhenMovingCell(GridView gridView, GridViewCell view, int index)
 {
     return true;
 }
Esempio n. 3
0
 public SizeF GridViewSizeInFullSizeForCell(GridView gridView, GridViewCell cell, int index, UIInterfaceOrientation orientation)
 {
     if (GridViewConstants.IsIphone)
     {
         if (orientation.IsLandscape())
         {
             return new SizeF(320, 210);
         }
         else
         {
             return new SizeF(300, 310);
         }
     }
     else
     {
         if (orientation.IsLandscape())
         {
             return new SizeF(700, 530);
         }
         else
         {
             return new SizeF(600, 500);
         }
     }
 }
Esempio n. 4
0
        public void GridViewDidStartTransformingCell(GridView gridView, GridViewCell cell)
        {
            UIView.Animate(0.5,0,UIViewAnimationOptions.AllowUserInteraction,
            delegate
            {
                cell.ContentView.BackgroundColor = UIColor.Blue;
                cell.ContentView.Layer.ShadowOpacity = 0.7f;
            },
            delegate
            {

            });
        }
Esempio n. 5
0
        public UIView GridViewFullSizeViewForCell(GridView gridView, GridViewCell cell, int index)
        {
            UIView fullView = new UIView(new RectangleF());
            fullView.BackgroundColor = UIColor.Yellow;
            fullView.Layer.MasksToBounds = false;
            fullView.Layer.CornerRadius = 8.0f;

            SizeF size = GridViewSizeInFullSizeForCell(gridView,cell,index,UIApplication.SharedApplication.StatusBarOrientation);
            fullView.Bounds = new RectangleF(0, 0, size.Width, size.Height);

            UILabel label = new UILabel(fullView.Bounds);
            label.Text = String.Format("Fullscreen View for cell at index {0}", index);
            label.TextAlignment = UITextAlignment.Center;
            label.BackgroundColor = UIColor.Clear;
            label.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

            if (GridViewConstants.IsIphone)
            {
                label.Font = UIFont.BoldSystemFontOfSize(15.0f);
            }
            else
            {
                label.Font = UIFont.BoldSystemFontOfSize(20.0f);
            }

            fullView.AddSubview(label);

            return fullView;
        }
Esempio n. 6
0
        public void GridViewDidEndMovingCell(GridView gridView, GridViewCell cell)
        {
            UIView.Animate(0.3,0,UIViewAnimationOptions.AllowUserInteraction,
            delegate
            {
                cell.ContentView.BackgroundColor = UIColor.Red;
                cell.ContentView.Layer.ShadowOpacity = 0;
            },
            delegate
            {

            });
        }
Esempio n. 7
0
 public void GridViewDidEnterFullSizeForCell(GridView gridView, GridViewCell cell)
 {
 }
Esempio n. 8
0
        private void TransformingGestureDidBeginAtPosition(int position)
        {
            transformingItem = CellForItemAtIndex(position);
            if (transformingItem==null)
                return;
            RectangleF frameInMainView = ConvertRectToView(transformingItem.Frame,mainSuperView);

            transformingItem.RemoveFromSuperview();
            transformingItem.Frame = mainSuperView.Bounds;
            transformingItem.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            transformingItem.ContentView.Frame = frameInMainView;
            mainSuperView.AddSubview(transformingItem);
            mainSuperView.BringSubviewToFront(transformingItem);

            transformingItem.FullSize = transformDelegate.GridViewSizeInFullSizeForCell(this,transformingItem,position,UIApplication.SharedApplication.StatusBarOrientation);
            transformingItem.FullSizeView = transformDelegate.GridViewFullSizeViewForCell(this,transformingItem,position);

            transformDelegate.GridViewDidStartTransformingCell(this,transformingItem);
        }
Esempio n. 9
0
 public void DisplayFullScreenForPosition(int position)
 {
     if (transformingItem!=null)
     {
         transformingItem.SwitchToFullSizeMode(false);
         transformDelegate.GridViewDidEndTransformingCell(this,transformingItem);
         transformingItem=null;
         ReloadData();
     }
     TransformingGestureDidBeginAtPosition(position);
     TransformingGestureDidEnd();
 }
Esempio n. 10
0
        void SortingMoveDidStopAtPoint(PointF point)
        {
            sortMovingItem.Shake(false);
            sortMovingItem.Tag = sortFuturePosition + kTagOffset;

            RectangleF frameInScroll = mainSuperView.ConvertRectToView(sortMovingItem.Frame,this);

            sortMovingItem.RemoveFromSuperview();
            sortMovingItem.Frame=frameInScroll;
            AddSubview(sortMovingItem);

            PointF newOrigin = layoutStrategy.OriginForItemAtPosition(sortFuturePosition);
            RectangleF newFrame = new RectangleF(newOrigin.X, newOrigin.Y, itemSize.Width, itemSize.Height);

            UIView.Animate(kDefaultAnimationDuration,0,0,
            delegate
            {
                sortMovingItem.Transform = CGAffineTransform.MakeIdentity();
                sortMovingItem.Frame = newFrame;
            },
            delegate
            {
                if (sortingDelegate!=null)
                {
                    sortingDelegate.GridViewDidEndMovingCell(this,sortMovingItem);
                }

                sortMovingItem = null;
                sortFuturePosition = GMGV_INVALID_POSITION;

                SetSubviewsCacheAsInvalid();
            });
        }
Esempio n. 11
0
        void SortingMoveDidStartAtPoint(PointF point)
        {
            int position = layoutStrategy.ItemPositionFromLocation(point);

            GridViewCell item = CellForItemAtIndex(position);
            BringSubviewToFront(item);
            sortMovingItem = item;

            RectangleF frameInMainView = ConvertRectToView(sortMovingItem.Frame,mainSuperView);

            sortMovingItem.RemoveFromSuperview();
            sortMovingItem.Frame = frameInMainView;
            mainSuperView .AddSubview(sortMovingItem);

            sortFuturePosition = sortMovingItem.Tag - kTagOffset;
            sortMovingItem.Tag = 0;

            if (sortingDelegate!=null)
            {
                sortingDelegate.GridViewDidStartMovingCell(this,sortMovingItem);
            }

            if (sortingDelegate!=null)
            {
                sortMovingItem.Shake(sortingDelegate.GridViewShouldAllowShakingBehaviorWhenMovingCell(this,sortMovingItem,position));
            }
            else
            {
                sortMovingItem.Shake(true);
            }
        }
Esempio n. 12
0
 private void QueueReusableCell(GridViewCell cell)
 {
     if (cell!=null)
     {
         cell.PrepareForReuse();
         cell.Alpha = 1;
         cell.BackgroundColor = UIColor.Clear;
         reusableCells.Add(cell);
     }
 }
Esempio n. 13
0
 private int PositionForItemSubview(GridViewCell view)
 {
     return view.Tag >= kTagOffset ? view.Tag - kTagOffset : GMGV_INVALID_POSITION;
 }
Esempio n. 14
0
        public void TransformingGestureDidFinish()
        {
            if (IsInTransformingState)
            {
                if (lastScale > 2 && !inTransformingState)
                {
                    TransformingGestureDidEnd();
                }
                else if (!inTransformingState)
                {
                    lastRotation = 0;
                    lastScale = 1.0f;

                    GridViewCell transformingView = transformingItem;
                    transformingItem = null;

                    int position = PositionForItemSubview(transformingView);
                    PointF origin = layoutStrategy.OriginForItemAtPosition(position);

                    RectangleF finalFrameInScroll = new RectangleF(origin.X, origin.Y, itemSize.Width, itemSize.Height);
                    RectangleF finalFrameInSuperview = ConvertRectToView(finalFrameInScroll,mainSuperView);

                    transformingView.SwitchToFullSizeMode(false);
                    transformingView.AutoresizingMask = UIViewAutoresizing.None;

                    UIView.Animate(kDefaultAnimationDuration,0,kDefaultAnimationOptions,
                    delegate
                    {
                        transformingView.ContentView.Transform = CGAffineTransform.MakeIdentity();
                        transformingView.ContentView.Frame = finalFrameInSuperview;
                        transformingView.BackgroundColor = UIColor.Clear;
                    },
                    delegate
                    {
                        transformingView.RemoveFromSuperview();
                        transformingView.Frame=finalFrameInScroll;
                        transformingView.ContentView.Frame = transformingView.Bounds;
                        AddSubview(transformingView);

                        transformingView.FullSizeView = null;
                        inFullSizeMode = false;

                        transformDelegate.GridViewDidEndTransformingCell(this,transformingView);

                        // Transfer the gestures back
                        AddGestureRecognizer(pinchGesture);
                        AddGestureRecognizer(rotationGesture);
                        AddGestureRecognizer(panGesture);
                    });
                }
            }
        }