private UINavigationController NewRMEntry(double prevBest) { CustomRootElement root = new CustomRootElement(" "); CustomDialogViewController dvc = new CustomDialogViewController(root, false); UINavigationController nav = new UINavigationController(dvc); dvc.BackgroundImage = "images/white_carbon"; dvc.NavigationBarColor = UIColor.FromRGB(39, 113, 205); dvc.NavigationBarImage = UIImage.FromBundle("images/navBar"); UIColor buttonColor = UIColor.FromRGB(39, 113, 205); UIBarButtonItem cancelButton = new UIBarButtonItem(UIBarButtonSystemItem.Cancel); cancelButton.TintColor = buttonColor; cancelButton.Clicked += delegate { dvc.NavigationController.DismissViewController(true, null); }; UIBarButtonItem saveButton = new UIBarButtonItem(UIBarButtonSystemItem.Save); saveButton.TintColor = buttonColor; dvc.NavigationItem.LeftBarButtonItem = cancelButton; dvc.NavigationItem.RightBarButtonItem = saveButton; Section newRMSection = new Section("Record Details") {}; string strPrevBest = String.Format("{0:000.0}", prevBest); if(prevBest == 0) strPrevBest = "100.0"; ResponsiveCounterElement newRMCounter = new ResponsiveCounterElement("New RM", strPrevBest); // TODO: grab the previous best and use that newRMCounter.SetCustomBackButton(UIImage.FromBundle("images/backbutton"), RectangleF.FromLTRB (0, 20, 50, 20)); DateElement newRMDate = new DateElement("Date", DateTime.Today); newRMSection.Add(newRMCounter); newRMSection.Add(newRMDate); root.Add(newRMSection); saveButton.Clicked += delegate { RmLog newEntry = new RmLog { DateLogged = newRMDate.DateValue, Weight = Convert.ToDouble(newRMCounter.Value), ExerciseID = this._exercise.ID }; dvc.NavigationController.DismissViewController(true, null); db.Insert(newEntry); this._rms.Add(newEntry); // refresh view this.RefreshRecords(); }; return nav; }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { window = new UIWindow (UIScreen.MainScreen.Bounds); root = new CustomRootElement("Penny Far Elements Sample"); Section section = new Section("Counter Element", "Has a ValueChanged event") { new ResponsiveCounterElement("Responsive Counter", "10.0") }; root.Add(section); Section customentry = new Section("Loop through the entries"); CustomKeyboardEntryElement firstElement = new CustomKeyboardEntryElement("entry 1", "", ""); CustomKeyboardEntryElement secondElement = new CustomKeyboardEntryElement("entry 2", "", ""); CustomKeyboardEntryElement thirdElement = new CustomKeyboardEntryElement("entry 3", "", ""); // Now set up the element order so it can go through them correctly firstElement.NextElement = secondElement; secondElement.PrevElement = firstElement; secondElement.NextElement = thirdElement; thirdElement.PrevElement = secondElement; customentry.Add(firstElement); customentry.Add(secondElement); customentry.Add(thirdElement); root.Add(customentry); Section subSection = new Section("Section with sub roots"); CustomRootElement subRoot = new CustomRootElement("Multi Options"); Section stuffSect = new Section("Showing Stuff"); StringElement stuff1 = new StringElement("Stuff"); StringElement stuff2 = new StringElement("More stuff"); TimeWithSecondsPickerElement tepe = new TimeWithSecondsPickerElement("new pick", new TimeSpan(4,3,1)); stuffSect.Add(stuff1); stuffSect.Add(stuff2); stuffSect.Add(tepe); subRoot.BackgroundImage= "images/norwegian_rose"; subRoot.Add(stuffSect); subSection.Add(subRoot); root.Add(subSection); cDVC = new CustomDialogViewController(root); // Add custom background cDVC.BackgroundImage = "images/norwegian_rose"; nav = new UINavigationController(cDVC); window.RootViewController = nav; window.MakeKeyAndVisible (); return true; }
private UINavigationController EditExerciseName() { CustomRootElement root = new CustomRootElement(" "); CustomDialogViewController dvc = new CustomDialogViewController(root, false); UINavigationController nav = new UINavigationController(dvc); dvc.BackgroundImage = "images/white_carbon"; dvc.NavigationBarColor = UIColor.FromRGB(39, 113, 205); dvc.NavigationBarImage = UIImage.FromBundle("images/navBar"); UIColor buttonColor = UIColor.FromRGB(39, 113, 205); UIBarButtonItem cancelButton = new UIBarButtonItem(UIBarButtonSystemItem.Cancel); cancelButton.TintColor = buttonColor; cancelButton.Clicked += delegate { dvc.NavigationController.DismissViewController(true, null); }; UIBarButtonItem saveButton = new UIBarButtonItem(UIBarButtonSystemItem.Save); saveButton.TintColor = buttonColor; dvc.NavigationItem.LeftBarButtonItem = cancelButton; dvc.NavigationItem.RightBarButtonItem = saveButton; Section nameSection = new Section("Edit Name") {}; EntryElement nameEdit = new EntryElement("Name", "", this._exercise.Name, false); nameSection.Add(nameEdit); root.Add(nameSection); // TODO: Add all the logs here and set them to delete mode saveButton.Clicked += delegate { this._exercise.Name = nameEdit.Value; dvc.NavigationController.DismissViewController(true, null); db.Update(this._exercise); if(this._exercise.Name.Length > 16) this.NavigationController.TabBarItem.Title = this._exercise.Name.Substring(0, 16); else this.NavigationController.TabBarItem.Title = this._exercise.Name; this.lblExName.Text = this._exercise.Name; }; return nav; }