public void initializeUserInterface() { // 0. Seed Templates seedTemplateDict = new Dictionary<string, SeedTemplate> (); seedTemplateDict = LocalStorage.getLocalStorageManager ().loadSeedTemplate (); Section seedTemplateS = new Section ("Seed Template"); seedTemplate = new RadioGroup (0); Section stSection = new Section (); foreach(var templateName in seedTemplateDict){ var t = new myRadioElement(templateName.Value.templateName); t.OnSelected += delegate(object sender, EventArgs e) { InvokeOnMainThread(()=>{ loadValueFromTemplate(t.Caption); }); }; stSection .Add(t); } RootElement stRoot = new RootElement ("Seed Template", seedTemplate) { }; stRoot.Add(stSection); seedTemplateS.Add (stRoot); // 1. Seed Date Section seedDateS = new Section ("Seed Date"); this.seedDate = new DateElement ("", DateTime.Now); seedDateS.Add (this.seedDate); // 2. Seed Type Section seedTypeS = new Section ("Seed Types"); seedTypes = new EntryElement (" ", "Seed Types", ""); seedTypes.ShouldReturn += delegate { seedTypes.ResignFirstResponder(true); return true; }; seedTypes.ReturnKeyType = UIReturnKeyType.Done; seedTypeS.Add (seedTypes); // 3. Seeding Depth Section seedDepthS = new Section ("Seeding Depth (in)"); // seedDepth = new FloatElementEx (0, lockable: false) { // ShowCaption = true, // UseCaptionForValueDisplay = true, // MaxValue = 2, // }; seedDepth = new EntryElement(" ","Seed Depth", ""); seedDepth.ShouldReturn += delegate { seedDepth.ResignFirstResponder(true); return true; }; seedDepth.ReturnKeyType = UIReturnKeyType.Done; seedDepthS.Add(seedDepth); // 4. Implemented Used Section implementedUsedS = new Section ("Implemented Used"); tools = new EntryElement (" ","Tools",""); tools.ShouldReturn += delegate { tools.ResignFirstResponder(true); return true; }; tools.ReturnKeyType = UIReturnKeyType.Done; implementedUsedS.Add (tools); // 5. Variety Name Section varietyNameS = new Section ("Variety Name"); varietyName = new EntryElement (" ","Enter Variety Name",""); varietyName.ReturnKeyType = UIReturnKeyType.Done; varietyName.ShouldReturn += delegate { varietyName.ResignFirstResponder(true); return true; }; varietyNameS.Add (varietyName); // 6. Seed Rate Section seedRateS = new Section ("Seed Rate (lb/ac)"); seedRate = new FloatElementEx (0, lockable: false) { ShowCaption = true, UseCaptionForValueDisplay = true, MaxValue = 300, }; seedRateS.Add(seedRate); // 7. Seed Treatment Section seedTreatmentS = new Section ("Seed Treatment"); seedTreatment = new EntryElement (" ","Enter Seed Treatment",""); seedTreatment.ReturnKeyType = UIReturnKeyType.Done; seedTreatmentS.Add (seedTreatment); // 8. NH3 Section NH3S = new Section ("NH3 (lb/ac)"); NH3 = new FloatElementEx (0, lockable: false) { ShowCaption = true, UseCaptionForValueDisplay = true, MaxValue = 120, }; NH3S.Add (NH3); // 9. 11-52-20 Section _11S = new Section ("11-52-20 (lb/ac)"); _11 = new FloatElementEx (0, lockable: false) { ShowCaption = true, UseCaptionForValueDisplay = true, MaxValue = 100, }; _11S.Add(_11); // 10. Note Section noteS = new Section ("Notes"); note = new SimpleMultilineEntryElement ("", " ") { Editable = true }; noteS.Add (note); Root.Add (seedTemplateS); Root.Add (seedDateS); Root.Add (seedTypeS); Root.Add (implementedUsedS); Root.Add (seedDepthS); Root.Add (varietyNameS); Root.Add (seedRateS); Root.Add (seedTreatmentS); Root.Add (NH3S); Root.Add (_11S); Root.Add (noteS); }
public Cultivation(int num, SQLiteConnection s) : base(UITableViewStyle.Grouped, null) { sql = s; sql.CreateTable<CultivationData> (); fieldID = num; date = new DateElement (null, DateTime.Today); implement = new EntryElement (null, "Which implement was used?", null); depth = new FloatElementEx (0); notes = new SimpleMultilineEntryElement (null, null); depth.UseCaptionForValueDisplay = true; depth.ShowCaption = true; depth.MinValue = 0; depth.MaxValue = 2; implement.ShouldReturn += delegate { implement.ResignFirstResponder (true); return true; }; notes.Editable = true; this.Title = "Cultivation"; this.Pushing = true; this.NavigationItem.SetRightBarButtonItem ( new UIBarButtonItem (UIBarButtonSystemItem.Save, (sender,args) => { // button was clicked var cultivationData = new CultivationData { DbField = fieldID, DbDate = date.DateValue, DbImplement = implement.Value, DbDepth = depth.Value, DbNotes = notes.Value }; //insert to database sql.Insert (cultivationData); UIAlertView alert = new UIAlertView (); alert.Title = "Success"; alert.Message = "Your Data Has Been Saved"; alert.AddButton("OK"); alert.Clicked += delegate { this.NavigationController.PopViewControllerAnimated(true); } ; alert.Show(); }) , true); Root = new RootElement (null) { new Section ("Date"){ date, }, new Section ("Implement Used"){ implement, }, new Section("Depth (in)"){ depth, }, new Section ("Notes"){ notes, }, }; }
public Harvest(int num, SQLiteConnection s) : base(UITableViewStyle.Grouped, null) { sql = s; //Create the db table for this viewcontroller. sql.CreateTable<HarvestData> (); //The field Id passed to this controller. Represents a unique field on a farm. fieldID = num; //The Elements with their variables date = new DateElement (null, DateTime.Today); implement = new EntryElement (null, "Which implement was used?", null); yield = new FloatElementEx (0); moisture = new FloatElementEx (0); bin = new EntryElement (null, "Enter Bin #", null); notes = new SimpleMultilineEntryElement (null, null); //Specify element details yield.UseCaptionForValueDisplay = true; yield.ShowCaption = true; yield.MinValue = 0; yield.MaxValue = 120; moisture.UseCaptionForValueDisplay = true; moisture.ShowCaption = true; moisture.MinValue = 0; moisture.MaxValue = 25; notes.Editable = true; implement.ShouldReturn += delegate { implement.ResignFirstResponder (true); return true; }; bin.ShouldReturn += delegate { bin.ResignFirstResponder (true); return true; }; this.Title = "Harvest"; this.Pushing = true; //Create the save button this.NavigationItem.SetRightBarButtonItem ( new UIBarButtonItem (UIBarButtonSystemItem.Save, (sender,args) => { //Create table row with data. var harvestData = new HarvestData { DbField = fieldID, DbDate = date.DateValue, DbImplement = implement.Value, DbYield = yield.Value, DbMoisture = moisture.Value, DbBin = bin.Value, DbNotes = notes.Value }; //insert to database sql.Insert (harvestData); UIAlertView alert = new UIAlertView (); alert.Title = "Success"; alert.Message = "Your Data Has Been Saved"; alert.AddButton("OK"); alert.Clicked += delegate { this.NavigationController.PopViewControllerAnimated(true); } ; alert.Show(); }) , true); //Create the GUI Root = new RootElement (null) { new Section ("Date"){ date, }, new Section("Implement Used") { implement, }, new Section("Yield (bushel / acre)"){ yield, }, new Section("Moisture (%)"){ moisture, }, new Section ("Bin"){ bin, }, new Section("Notes") { notes, }, }; }