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; }
public override void LoadView() { base.LoadView (); View.BackgroundColor = UIColor.White; int spacing = GridViewConstants.IsIphone ? 10 : 15; GridView aGridView = new GridView(View.Bounds); aGridView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; aGridView.BackgroundColor = UIColor.Clear; demoGridView = aGridView; View.AddSubview(demoGridView); demoGridView.Style = GridViewStyle.Swap; demoGridView.ItemSpacing = spacing; demoGridView.MinEdgeInsets = new UIEdgeInsets(spacing, spacing, spacing, spacing); demoGridView.CenterGrid = true; demoGridView.ActionDelegate = this; demoGridView.SortingDelegate = this; demoGridView.TransformDelegate = this; demoGridView.DataSource = this; UIButton infoButton = new UIButton(UIButtonType.InfoDark); infoButton.Frame = new RectangleF(View.Bounds.Size.Width - 40, View.Bounds.Size.Height - 40, 40, 40); infoButton.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleTopMargin; infoButton.AddTarget(this,new Selector("presentInfo"),UIControlEvent.TouchUpInside); View.AddSubview(infoButton); UISegmentedControl dataSegmentedControl = new UISegmentedControl(new String[]{"DataSet 1","DataSet 2"}); dataSegmentedControl.SizeToFit(); dataSegmentedControl.Frame = new RectangleF(5, View.Bounds.Size.Height - dataSegmentedControl.Bounds.Size.Height - 5, dataSegmentedControl.Bounds.Size.Width, dataSegmentedControl.Bounds.Size.Height); dataSegmentedControl.AutoresizingMask = UIViewAutoresizing.FlexibleRightMargin | UIViewAutoresizing.FlexibleTopMargin; dataSegmentedControl.TintColor = UIColor.Green; dataSegmentedControl.SelectedSegment = 0; dataSegmentedControl.AddTarget(this,new Selector("dataSetChange:"),UIControlEvent.ValueChanged); View.AddSubview(dataSegmentedControl); /* OptionsViewController *optionsController = [[OptionsViewController alloc] init]; optionsController.gridView = gmGridView; optionsController.contentSizeForViewInPopover = CGSizeMake(400, 500); _optionsNav = [[UINavigationController alloc] initWithRootViewController:optionsController]; if (INTERFACE_IS_PHONE) { UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(optionsDoneAction)]; optionsController.navigationItem.rightBarButtonItem = doneButton; }*/ }
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); } } }
public SizeF GridViewSizeForItemsInInterfaceOrientation(GridView gridView, UIInterfaceOrientation orientation) { if (GridViewConstants.IsIphone) { if (orientation.IsLandscape()) { return new SizeF(170, 135); } else { return new SizeF(140, 110); } } else { if (orientation.IsLandscape()) { return new SizeF(285, 205); } else { return new SizeF(230, 175); } } }
public bool GridViewShouldAllowShakingBehaviorWhenMovingCell(GridView gridView, GridViewCell view, int index) { return true; }
public void GridViewProcessDeleteActionForItemAtIndex(GridView gridView, int index) { //UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Confirm" message:@"Are you sure you want to delete this item?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Delete", nil]; //[alert show]; //_lastDeleteItemIndexAsked = index; }
/* - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 1) { [_currentData removeObjectAtIndex:_lastDeleteItemIndexAsked]; [_gmGridView removeObjectAtIndex:_lastDeleteItemIndexAsked withAnimation:GMGridViewItemAnimationFade]; } }*/ public void GridViewChangeEdit(GridView gridView, bool edit) { }
public bool GridViewCanDeleteItemAtIndex(GridView gridView, int index) { return true; }
public void GridViewExchangeItemAtIndex(GridView gridView, int index1, int index2) { currentData.ExchangeObjectAtIndex(index1,index2); }
public void GridViewDidTapOnItemAtIndex(GridView gridView, int position) { System.Console.WriteLine("Did tap at index {0}", position); }
public void GridViewDidTapOnEmptySpace(GridView gridView) { System.Console.WriteLine("Tap on empty space"); }
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 { }); }
public void GridViewDidEnterFullSizeForCell(GridView gridView, GridViewCell cell) { }
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 { }); }
public int NumberOfItemsInGridView(GridView gridView) { return (int)currentData.Count; }
public override void ViewDidUnload() { base.ViewDidUnload(); demoGridView = null; }
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; }
public void GridViewMoveItemAtIndex(GridView gridView, int oldIndex, int newIndex) { String obj = currentData[oldIndex]; currentData.Remove(obj); currentData.Insert(newIndex,obj); }
public GridGestureRecognizer(GridView gridView) : base() { this.gridView = gridView; }