Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
345
igGridPhotoViewer Monotouched
posted

Greetings All! I am trying to convert the igGridPhotoViewer sample from objective-c to C# (Monotouch), but am stuck on what do to after ViewDidLoad ... I don't really have a need to edit/add filter or re-size the selected image. Below is what I have so far, but I'm at a loss as to what to do next! As always, I sure do appreciate your help!!!

[Register("igGridPhotoViewer")]
public class IgGridPhotoViewer : UIViewController
{
private UIView _resizeThumb;
private Point _originPoint;
private int _numberOfColumns, _maxNumberOfColumns, _portraitColumnCount;
private float _columnSize, _resizeThumbSize, _resizeThumbOffset;
private IGCellPath _editPath;
private Size _landscapeSize, _portraitSize;
private NSObject[] _photos;

private IGGridView _photoGridView, _thumbsGridView;

private IGGridViewColumnDefinition _col, _thumbCol;
private IGGridViewSingleRowSingleFieldDataSourceHelper _photoDs, _singleRowThumbDs;
private IGGridViewSingleFieldMultiColumnDataSourceHelper _thumbsDs;


bool IsPhone
{
get { return UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone; }
}

bool IsIphone5
{
get
{
return UIDevice.CurrentDevice.UserInterfaceIdiom
== UIUserInterfaceIdiom.Phone
&& UIScreen.MainScreen.Bounds.Size.Height
* UIScreen.MainScreen.Scale >= 1136;
}
}

public IgGridPhotoViewer()
{
}

public override void ViewDidLoad()
{
_columnSize = IsPhone ? 75 : 100;
_resizeThumbSize = IsPhone ? 30 : 50;
_maxNumberOfColumns = IsPhone && !IsIphone5 ? 2 : 3;
_portraitColumnCount = IsPhone ? 3 : 6;
_resizeThumbOffset = IsPhone ? 10 : 20;
_landscapeSize = IsPhone ? (!IsIphone5 ? new Size(480, 256) : new Size(568, 256)) : new Size(1024, 680);
_portraitSize = IsPhone ? (!IsIphone5 ? new Size(320, 392) : new Size(320, 480)) : new Size(768, 935);

base.ViewDidLoad();

View.BackgroundColor = UIColor.White;
View.Alpha = 1;

_photoGridView = new IGGridView(View.Frame, IGGridViewStyle.IGGridViewStyleSingleCellPaging);

_photoGridView.SelectionType = IGGridViewSelectionType.IGGridViewSelectionTypeNone;
_photoGridView.AlwaysBounceVertical = false;
_photoGridView.AlwaysBounceHorizontal = true;
View.AddSubview(_photoGridView);

_thumbsGridView = new IGGridView();
_thumbsGridView.RowSeparatorHeight = 0;
_thumbsGridView.SelectionType = IGGridViewSelectionType.IGGridViewSelectionTypeCell;
_thumbsGridView.HeaderHeight = 0;
_thumbsGridView.RowHeight = _columnSize;
View.AddSubview(_thumbsGridView);

_photos = GetAnimals().ToArray();

_col = new IGGridViewImageColumnDefinition(@"Image",
IGGridViewImageColumnDefinitionPropertyType
.IGGridViewImageColumnDefinitionPropertyTypeStringUrl);

_photoDs = new IGGridViewSingleRowSingleFieldDataSourceHelper(_col);
_photoDs.Data = _photos;

_thumbCol = new IGGridViewImageColumnDefinition(@"thumb",
IGGridViewImageColumnDefinitionPropertyType
.IGGridViewImageColumnDefinitionPropertyTypeStringUrl);

_thumbsDs = new IGGridViewSingleFieldMultiColumnDataSourceHelper(_thumbCol);
_thumbsDs.NumberOfColumns = 1;
_thumbsDs.Data = _photos;

_singleRowThumbDs = new IGGridViewSingleRowSingleFieldDataSourceHelper(_thumbCol);
_singleRowThumbDs.Data = _photos;

_thumbsGridView.DataSource = _thumbsDs;

_photoGridView.ScrollEnabled = true;

_thumbsGridView.ReloadData();

_thumbsGridView.PagingEnabled = true;

/* var selectPath = [ds deNormalizePath:selectPath];

[_thumbsGridView selectCellAtPath:selectPath animated:NO scrollPosition:IGGridViewScrollPositionNone];
[_thumbsGridView scrollToCellAtCellPath:selectPath atScrollPosition:IGGridViewScrollPositionNone animated:NO];*/


}

public List<PhotoData> GetAnimals()
{
var animals = new List<PhotoData>();
for (int i = 0; i < 100; i++)
{
animals.Add(new PhotoData(string.Format("http://placekitten.com/{0}/{0}", Random(20) + 300)));
}

return animals;
}

private readonly System.Random _random = new System.Random();
protected int Random(int count)
{
return _random.Next(count);
}


}


[Register("PhotoData")]
public class PhotoData : NSObject
{

public PhotoData(string image)
{
Image = image;
}

[Export("Image")]
public string Image { get; set; }
}

 

Parents
No Data
Reply
  • 40030
    Offline posted

    Hi Blake!

    I'd be happy to create a C# version of the sample for you. 

    Which part of the sample are you looking for? Do you want the thumbnails portion, the large viewer, or both. The only reason i ask is so that you don't get any extraneous code that you don't need. 

    Let me know and i'll put something together for you today. 

    -SteveZ

Children