public static GlassButton CreateGlassButton(string buttonTitle, UIColor color, float width, float height, ButtonClickDelegate touchUpInside) { GlassButton button = new GlassButton(new RectangleF(0, 0, width, height)); button.NormalColor = color; button.HighlightedColor = UIColor.LightGray; button.SetTitleColor(UIColor.FromRGBA(255, 255, 255, 255), UIControlState.Normal); button.SetTitleColor(UIColor.FromRGBA(0, 0, 0, 255), UIControlState.Highlighted); button.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; button.SetTitle(buttonTitle, UIControlState.Normal); button.TouchUpInside += (s, e) => { if (touchUpInside != null) touchUpInside(s, e); }; return button; }
public static GlassButton CreateGlassButton(string buttonTitle, UIColor color, float width, float height) { GlassButton button = new GlassButton(new RectangleF(0, 0, width, height)); button.NormalColor = color; button.HighlightedColor = UIColor.LightGray; button.SetTitleColor(UIColor.FromRGBA(255, 255, 255, 255), UIControlState.Normal); button.SetTitleColor(UIColor.FromRGBA(0, 0, 0, 255), UIControlState.Highlighted); button.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; button.SetTitle(buttonTitle, UIControlState.Normal); //TODO: Find a away to pass in an TouchUpInside delegate instead of a Uri //button.TouchUpInside += (sender, e) => { }; return button; }
private bool ConstructUI() { // check if UI has already been built if (!_uiContructed) { Title = "Welcome!"; UIImageView imgBackground = new UIImageView(new RectangleF(0, 0, 320, 480)); imgBackground.Image = UIImage.FromFile("images/Wallpaper.png"); this.Add(imgBackground); var loc = new PointF(10, 20); var size = new SizeF(300, 44); var rect = new RectangleF(loc, size); GlassButton b = new GlassButton(rect); b.SetTitleColor(UIColor.Black, UIControlState.Normal); b.NormalColor = UIColor.FromRGB(0x62, 0x63, 0x70); b.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; b.SetTitle("Next Screen", UIControlState.Normal); b.TouchUpInside += (o, e) => { MXTouchContainer.Navigate("Dashboard"); }; this.Add(b); // UI construction completed _uiContructed = true; } return(_uiContructed); }
Section CreateButtonSection(float labelHeight, float containerWidth) { Section buttonSection = new Section(); GlassButton button = new GlassButton(new RectangleF(0, 0, containerWidth, labelHeight)); button.SetTitleColor(UIColor.FromRGBA(255, 255, 0, 255), UIControlState.Normal); button.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; button.SetTitle("Create Dataset", UIControlState.Normal); button.TouchUpInside += (o, e) => { string name = _name.Summary(); if (string.IsNullOrEmpty(name)) { //show an alert if data is not filled new UIAlertView(string.Empty, "Enter a name", null, "OK", null).Show(); } else { // navigate to next screen MXTouchContainer.Navigate("Dashboard/CreateData/" + name); } }; UIViewElement imageElement = new UIViewElement(string.Empty, button, true); imageElement.Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent; buttonSection.Add(imageElement); return(buttonSection); }
public UIViewController GetFormService(RootElement rElement) { //if (DetailViewController.QuestionsView != null) //{ // DetailViewController.Title = ""; // DetailViewController.QuestionsView.Clear(); //} var bounds = UIScreen.MainScreen.Bounds; // show the loading overlay on the UI thread using the correct orientation sizing loadingOverlay = new LoadingOverlay(bounds); mvc = (DialogViewController)((UINavigationController)SplitViewController.ViewControllers[0]).TopViewController; mvc.Add(loadingOverlay); var dds = new DynaPadService.DynaPadService(); var dfElemet = (DynaFormRootElement)rElement; string origJson = dds.GetFormQuestions(dfElemet.FormID, dfElemet.PatientID, dfElemet.ApptID, dfElemet.IsDoctorForm); JsonHandler.OriginalFormJsonString = origJson; SelectedAppointment.SelectedQForm = JsonConvert.DeserializeObject <QForm>(origJson); var rootFormSections = new RootElement(SelectedAppointment.SelectedQForm.FormName); var sectionFormSections = new Section(); bool IsDoctorForm = dfElemet.IsDoctorForm; if (IsDoctorForm) { /* * TODO: make presets password protected (maybe not, since for doctors only?)! (maybe component: Passcode) */ var FormPresetNames = dds.GetAnswerPresets(SelectedAppointment.ApptFormId, null, SelectedAppointment.ApptPatientId, true, SelectedAppointment.ApptLocationId); var formPresetSection = new DynaSection("Form Preset Answers"); formPresetSection.Enabled = true; var formPresetGroup = new RadioGroup("FormPresetAnswers", SelectedAppointment.SelectedQForm.FormSelectedTemplateId); var formPresetsRoot = new DynaRootElement("Preset Answers", formPresetGroup); formPresetsRoot.IsPreset = true; foreach (string[] arrPreset in FormPresetNames) { var radioPreset = new MyRadioElement(arrPreset[1], "FormPresetAnswers"); radioPreset.OnSelected += delegate(object sender, EventArgs e) { string presetJson = arrPreset[2]; JsonHandler.OriginalFormJsonString = presetJson; SelectedAppointment.SelectedQForm = JsonConvert.DeserializeObject <QForm>(presetJson); LoadSectionView(SelectedAppointment.SelectedQForm.FormSections[0].SectionId, SelectedAppointment.SelectedQForm.FormSections[0].SectionName, SelectedAppointment.SelectedQForm.FormSections[0], IsDoctorForm); }; formPresetSection.Add(radioPreset); } var btnNewFormPreset = new GlassButton(new RectangleF(0, 0, (float)View.Frame.Width, 50)); btnNewFormPreset.Font = UIFont.BoldSystemFontOfSize(17); btnNewFormPreset.SetTitleColor(UIColor.Black, UIControlState.Normal); btnNewFormPreset.NormalColor = UIColor.FromRGB(224, 238, 240); btnNewFormPreset.SetTitle("Save New Form Preset", UIControlState.Normal); btnNewFormPreset.TouchUpInside += (sender, e) => { /* * TODO: popup to enter preset name (DONE?) */ //Create Alert var SavePresetPrompt = UIAlertController.Create("New Form Preset", "Necesito name", UIAlertControllerStyle.Alert); SavePresetPrompt.AddTextField((field) => { field.Placeholder = "Preset Name"; }); //Add Actions SavePresetPrompt.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, action => SavePreset(SavePresetPrompt.TextFields[0].Text))); SavePresetPrompt.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null)); //Present Alert PresentViewController(SavePresetPrompt, true, null); }; formPresetSection.Add(btnNewFormPreset); formPresetsRoot.Add(formPresetSection); formPresetsRoot.Enabled = true; sectionFormSections.Add(formPresetsRoot); } foreach (FormSection fSection in SelectedAppointment.SelectedQForm.FormSections) { sectionFormSections.Add(new StringElement(fSection.SectionName, delegate { LoadSectionView(fSection.SectionId, fSection.SectionName, fSection, IsDoctorForm); })); } sectionFormSections.Add(new StringElement("Finalize", delegate { LoadSectionView("Finalize", "Finalize", null, IsDoctorForm); })); rootFormSections.Add(sectionFormSections); var formDVC = new DialogViewController(rootFormSections, true); // TODO pull to refresh: (problamatic scrolling with it) //formDVC.RefreshRequested += delegate //{ // formDVC.ReloadComplete(); //}; if (!IsDoctorForm) { messageLabel = new UILabel(); formDVC.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIImage.FromBundle("Lock"), UIBarButtonItemStyle.Bordered, delegate(object sender, EventArgs e) { //Create Alert var BackPrompt = UIAlertController.Create("Exit Form", "Administrative use only. Please enter password to continue or tap Cancel", UIAlertControllerStyle.Alert); BackPrompt.AddTextField((field) => { field.SecureTextEntry = true; field.Placeholder = "Password"; }); BackPrompt.Add(messageLabel); BackPrompt.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, action => PopBack(BackPrompt.TextFields[0].Text))); BackPrompt.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null)); //Present Alert PresentViewController(BackPrompt, true, null); }); //formDVC.NavigationItem.LeftBarButtonItem.Title = "Back"; } loadingOverlay.Hide(); return(formDVC); }
private bool ConstructUI() { // check if UI has already been built if (!_uiContructed) { Title = "Dashboard"; UIImageView imgBackground = new UIImageView(new RectangleF(0, 0, 320, 480)); imgBackground.Image = UIImage.FromFile("images/Wallpaper.png"); this.Add(imgBackground); float yLoc = 0; float labelHeight = 44; var loc = new PointF(10, 75); var size = new SizeF(300, labelHeight); var viewRect = new RectangleF(loc, size); UIView statsView = new UIView(viewRect); statsView.BackgroundColor = UIColor.Clear; var labelSize = new SizeF(150, labelHeight); var rect = new RectangleF(new PointF(0, yLoc), labelSize); var userIdLabel = new UILabel(rect); userIdLabel.Text = "DataSet GUID:"; userIdLabel.Layer.BorderColor = new CGColor(1.0f, 0.0f, 0.0f, 1.0f); userIdLabel.Layer.CornerRadius = 15f; userIdLabel.BackgroundColor = UIColor.FromWhiteAlpha(0.5f, 0.5f); var labelRect = new RectangleF(); var labelStart = labelSize.Width - 20; labelRect.Width = size.Width - labelStart; labelRect.Height = labelHeight; labelRect.Location = new PointF(labelStart, yLoc); _userIdValueLabel = new UILabel(labelRect); _userIdValueLabel.BackgroundColor = UIColor.FromWhiteAlpha(0.5f, 0.5f); _userIdValueLabel.Layer.CornerRadius = 15f; _userIdValueLabel.Text = Model != null ? Model.Name : "NULL"; statsView.Add(userIdLabel); statsView.Add(_userIdValueLabel); this.Add(statsView); //float buttonStart = labelRect.Y + labelHeight + 10; loc = new PointF(10, 20); size = new SizeF(300, 44); rect = new RectangleF(loc, size); GlassButton b = new GlassButton(rect); b.SetTitleColor(UIColor.FromRGBA(255, 255, 0, 255), UIControlState.Normal); b.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; b.SetTitle("Delete Data", UIControlState.Normal); b.TouchUpInside += (o, e) => { string s = !string.IsNullOrEmpty(s) ? Model.Name : s = "NoData"; MXTouchContainer.Navigate("WelcomeScreen/Data/" + s); }; this.Add(b); var button = new UIBarButtonItem(UIBarButtonSystemItem.Refresh); button.Clicked += delegate(object sender, EventArgs e) { MXTouchContainer.Navigate("WelcomeScreen"); }; NavigationItem.SetRightBarButtonItem(button, true); // UI construction completed _uiContructed = true; } return(_uiContructed); }