public FieldImage(string farmName,int farmID,FlyoutNavigationController fnc,SelectField sf) : base(UITableViewStyle.Grouped, null) { Root = new RootElement (null) {}; this.Pushing = true; var section = new Section () {}; var totalRainGuage = new StringElement ("Total Raid Guage(mm): " + DBConnection.getRain (farmID),()=>{}); var rainGuage=new EntryElement ("New Rain Guage(mm): ",null," "); rainGuage.KeyboardType = UIKeyboardType.NumbersAndPunctuation; var update=new StringElement("Add",()=>{ try{ DBConnection.updateRain(farmID,Int32.Parse(rainGuage.Value)); } catch(Exception e){ new UIAlertView ("Error", "Wrong input format!", null, "Continue").Show (); return; } UIAlertView alert = new UIAlertView (); alert.Title = "Success"; alert.Message = "Your Data Has Been Saved"; alert.AddButton("OK"); alert.Show(); }); var showDetail=new StringElement("Show Rain Guage Detail",()=>{ RainDetail rd=new RainDetail(farmID,farmName); sf.NavigationController.PushViewController(rd,true); }); section.Add (totalRainGuage); section.Add (rainGuage); section.Add (update); section.Add (showDetail); Root.Add (section); var section2 = new Section () { }; var farmImg=UIImage.FromFile ("img/"+farmName+".jpg"); if(farmImg==null) farmImg=UIImage.FromFile ("Icon.png"); var imageView = new UIImageView (farmImg); if(farmImg==null) farmImg=UIImage.FromFile ("Icon.png"); var scrollView=new UIScrollView ( new RectangleF(0,0,fnc.View.Frame.Width-20,250) ); scrollView.ContentSize = imageView.Image.Size; scrollView.AddSubview (imageView); scrollView.MaximumZoomScale = 3f; scrollView.MinimumZoomScale = .1f; scrollView.ViewForZoomingInScrollView += (UIScrollView sv) => { return imageView; }; var imageElement=new UIViewElement(null,scrollView,false); section2.Add(imageElement); Root.Add (section2); }
public SelectFarm() : base(UITableViewStyle.Grouped, null) { Root = new RootElement (null){}; this.Pushing=true; //farm section var farms = DBConnection.getAllFarms(); int farmNumber=farms.Count(); var section = new Section ("Farms:"){}; foreach(Farm farm in farms){ int farmID = farm.farmID; string farmName = farm.farmName; int fieldNumber = DBConnection.getAllFields(farmID).Count (); var farmImg=UIImage.FromFile ("img/"+farmName+".jpg"); if(farmImg==null) farmImg=UIImage.FromFile ("Icon.png"); var theFarm=new BadgeElement(farmImg,farmName+" "+fieldNumber+" fields",()=>{ Console.WriteLine("Farm Name is: "+farmName); var field=new SelectField(farmName,farmID,fieldNumber); this.NavigationController.PushViewController(field,true); }); section.Add(theFarm); } Root.Add(section); //grain section var section2 = new Section ("Grain Inventory:"){}; var grin1 = new StringElement ("Bin (1-15)", () => { var selectBin=new SelectBin(1); this.NavigationController.PushViewController(selectBin,true); }); var grin2 = new StringElement ("Bin(16-30)", () => { var selectBin=new SelectBin(16); this.NavigationController.PushViewController(selectBin,true); }); var grin3 = new StringElement ("Bin(31-45)", () => { var selectBin=new SelectBin(31); this.NavigationController.PushViewController(selectBin,true); }); var grin4 = new StringElement ("Bin(46-60)", () => { var selectBin=new SelectBin(46); this.NavigationController.PushViewController(selectBin,true); }); var grin5 = new StringElement ("Bin(61-75)", () => { var selectBin=new SelectBin(61); this.NavigationController.PushViewController(selectBin,true); }); section2.Add (grin1); section2.Add (grin2); section2.Add (grin3); section2.Add (grin4); section2.Add (grin5); Root.Add (section2); }