public SetupDialogController() : base(UITableViewStyle.Grouped, null) { var nickname = new EntryElement (null, "Nickname", null); Root = new RootElement("Gablarski") { new Section { nickname }, new Section { new StringElement ("Continue", async () => { nickname.FetchValue(); Settings.Nickname = nickname.Value; await Settings.SaveAsync(); AppDelegate.StartSetup(); PresentViewController (new MainViewController(), true, null); }) } }; }
// // 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) { // create a new window instance based on the screen size window = new UIWindow (UIScreen.MainScreen.Bounds); entryElement = new EntryElement("","Type the text to speak here.",""); spearkBtn = new StringElement("Speak",delegate{ entryElement.FetchValue(); Flite.Flite.ConvertTextToWav(entryElement.Value,"test.wav",0); }); window.RootViewController = new DialogViewController(new RootElement("") { new Section(){ entryElement, spearkBtn } }); // If you have defined a view, add it here: // window.AddSubview (navigationController.View); // make the window visible window.MakeKeyAndVisible (); return true; }
UIViewController MakeLogin() { var login = new EntryElement ("Login", "Type 'Root'", ""); var pass = new EntryElement ("Password", "Type 'Root'", ""); var loginButton = new StringElement ("Login", delegate { login.FetchValue (); pass.FetchValue (); if (login.Value == "Root" && pass.Value == "Root"){ NSUserDefaults.StandardUserDefaults.SetBool (true, "loggedIn"); window.RootViewController.PresentViewController (MakeOptions (), true, delegate {}); } }); return new DialogViewController (new RootElement ("Login"){ new Section ("Enter login and password"){ login, pass, }, new Section (){ loginButton } }); }
// Creates the login dialog using Xauth, this is a nicer // user experience, but requires Twitter to approve your // app void NewAccountXAuth(DialogViewController parent, NSAction callback) { var login = new EntryElement (Locale.GetText ("Username"), Locale.GetText ("Your twitter username"), ""); var password = new EntryElement (Locale.GetText ("Password"), Locale.GetText ("Your password"), "", true); var root = new RootElement (Locale.GetText ("Login")){ new Section (){ login, password }, new Section (){ new LoadMoreElement (Locale.GetText ("Login to Twitter"), Locale.GetText ("Contacting twitter"), delegate { login.FetchValue (); password.FetchValue (); StartXauthLogin (login.Value.Trim (), password.Value.Trim (), callback); }, UIFont.BoldSystemFontOfSize (16), UIColor.Black) } }; MakeLoginDialog (parent, root); }
public VisitDetailsView(VisitDetailsViewController parent) { Parent = parent; BackgroundColor = UIColor.FromRGB(239,239,244); addVisitor = new UIButton { Frame = new RectangleF(0, 0, 150, 150), TintColor = UIColor.White, Layer = { CornerRadius = 75, MasksToBounds = true, } }; addVisitor.SetTitle("Add a visitor", UIControlState.Normal); addVisitor.ImageView.ContentMode = UIViewContentMode.ScaleAspectFill;; addVisitor.SetImage(Theme.UserImageDefaultLight.Value,UIControlState.Normal); addVisitor.TouchUpInside += (sender, args) => { if (Parent.PickVisitor != null) Parent.PickVisitor(); }; AddSubview(addVisitor); addEmployee = new UIButton { Frame = new RectangleF(0, 0, 150, 150), TintColor = UIColor.White, Layer = { CornerRadius = 75, MasksToBounds = true, } }; addEmployee.SetTitle("Add an employee", UIControlState.Normal); addEmployee.ImageView.ContentMode = UIViewContentMode.ScaleAspectFill; ; addEmployee.SetImage(Theme.UserImageDefaultLight.Value, UIControlState.Normal); addEmployee.TouchUpInside += (sender, args) => { if (Parent.PickEmployee != null) Parent.PickEmployee(); }; AddSubview(addEmployee); editButton = new UIButton(new RectangleF(0,0,40,40)); editButton.SetBackgroundImage(UIImage.FromBundle("edit"),UIControlState.Normal ); editButton.TouchUpInside += (sender, args) => { var vc = new EditVisitorViewController { Visitor = new VMVisitor{Visitor = visit.Visitor} }; this.Parent.NavigationController.PushViewController(vc,true); }; visitorLabel = new UILabel { Text = "Visitor", Font = UIFont.FromName(font2, 30), TextAlignment = UITextAlignment.Center, AdjustsFontSizeToFitWidth = true,}; visitorLabel.SizeToFit(); AddSubview(visitorLabel); employeeLabel = new UILabel { Text = "Employee", Font = UIFont.FromName(font2, 30), TextAlignment = UITextAlignment.Center, AdjustsFontSizeToFitWidth = true,}; employeeLabel.SizeToFit(); AddSubview(employeeLabel); date = new DateTimeElement("Date", DateTime.Now); comment = new EntryElement("Reason: ", "Reason", ""); comment.Changed += (sender, args) => { Console.WriteLine("Comment"); }; vehicle = new BooleanElement("Vehicle",false); licensePlate = new EntryElement("Lic Plate: ", "License Plate", ""); licensePlate.Changed += (sender, args) => { Console.WriteLine("licensePlate"); }; vehicle.ValueChanged += (sender, args) => { if (vehicle.Value) { if (!section.Elements.Contains(licensePlate)) section.Add(licensePlate); datadvc.ReloadData(); } else { licensePlate.FetchValue(); section.Remove(licensePlate); } }; datadvc = new DialogViewController(new RootElement("visit") { (section = new Section { date, comment, vehicle, licensePlate }) }); datadvc.TableView.SectionHeaderHeight = 0; datadvc.TableView.TableHeaderView = null; datadvc.View.BackgroundColor = UIColor.White; datadvc.View.Layer.CornerRadius = 5f; var height = Enumerable.Range(0, datadvc.TableView.Source.RowsInSection(datadvc.TableView,0)).Sum(x => datadvc.TableView.Source.GetHeightForRow(datadvc.TableView, NSIndexPath.FromRowSection(x, 0))); datadvc.View.Frame = new RectangleF(0,0,100,height); AddSubview(datadvc.View); this.Parent.AddChildViewController(datadvc); }
public void DebugPage() { TraceHelper.AddMessage("Debug: constructor"); // render URL and status var serviceUrl = new EntryElement("URL", "URL to connect to", WebServiceHelper.BaseUrl); var service = new Section("Service") { serviceUrl, new StringElement("Store New Service URL", delegate { serviceUrl.FetchValue(); // validate that this is a good URL before storing it (a bad URL can hose the phone client) Uri uri = null; if (Uri.TryCreate(serviceUrl.Value, UriKind.RelativeOrAbsolute, out uri) && (uri.Scheme == "http" || uri.Scheme == "https")) WebServiceHelper.BaseUrl = serviceUrl.Value; else serviceUrl.Value = WebServiceHelper.BaseUrl; }), new StringElement("Connected", App.ViewModel.LastNetworkOperationStatus.ToString()), }; // render user queue var userQueue = new Section("User Queue"); userQueue.Add(new StringElement( "Clear Queue", delegate { RequestQueue.DeleteQueue(RequestQueue.UserQueue); userQueue.Clear (); })); List<RequestQueue.RequestRecord> requests = RequestQueue.GetAllRequestRecords(RequestQueue.UserQueue); if (requests != null) { foreach (var req in requests) { string typename; string reqtype; string id; string name; RequestQueue.RetrieveRequestInfo(req, out typename, out reqtype, out id, out name); var sse = new StyledStringElement(String.Format(" {0} {1} {2} (id {3})", reqtype, typename, name, id)) { Font = UIFont.FromName("Helvetica", UIFont.SmallSystemFontSize), }; userQueue.Add (sse); } } // render system queue var systemQueue = new Section("System Queue"); systemQueue.Add(new StringElement( "Clear Queue", delegate { RequestQueue.DeleteQueue(RequestQueue.SystemQueue); systemQueue.Clear (); })); requests = RequestQueue.GetAllRequestRecords(RequestQueue.SystemQueue); if (requests != null) { foreach (var req in requests) { string typename; string reqtype; string id; string name; RequestQueue.RetrieveRequestInfo(req, out typename, out reqtype, out id, out name); var sse = new StyledStringElement(String.Format(" {0} {1} {2} (id {3})", reqtype, typename, name, id)) { Font = UIFont.FromName("Helvetica", UIFont.SmallSystemFontSize), }; systemQueue.Add (sse); } } var traceMessages = new Section("Trace Messages"); traceMessages.Add(new StringElement( "Clear Trace", delegate { TraceHelper.ClearMessages(); traceMessages.Clear (); })); traceMessages.Add(new StringElement( "Send Trace", delegate { TraceHelper.SendMessages(App.ViewModel.User); })); foreach (var m in TraceHelper.GetMessages().Split('\n')) { // skip empty messages if (m == "") continue; // create a new (small) string element with a detail indicator which // brings up a message box with the entire message var sse = new StyledStringElement(m) { Accessory = UITableViewCellAccessory.DetailDisclosureButton, Font = UIFont.FromName("Helvetica", UIFont.SmallSystemFontSize), }; string msg = m; // make a copy for the closure below sse.AccessoryTapped += delegate { var alert = new UIAlertView ("Detail", msg, null, "Ok"); alert.Show (); }; traceMessages.Add(sse); }; var root = new RootElement("Debug") { service, userQueue, systemQueue, traceMessages, }; var dvc = new DialogViewController (root, true); dvc.TableView.BackgroundColor = UIColorHelper.FromString(App.ViewModel.Theme.PageBackground); this.PushViewController (dvc, true); //this.NavigationController.PushViewController (dvc, true); }
public SignInViewController() : base(UITableViewStyle.Grouped, new RootElement ("Crisis Checkin"), false) { webService = WebServiceFactory.Create (); username = new EntryElement ("Email", "*****@*****.**", "") { KeyboardType = UIKeyboardType.EmailAddress, AutocorrectionType = UITextAutocorrectionType.No }; password = new EntryElement ("Password", "password", "", true) { AutocorrectionType = UITextAutocorrectionType.No }; Root = new RootElement ("Crisis Checkin") { new Section ("Already have an account?") { username, password, new StyledStringElement ("Sign In", async () => { username.ResignFirstResponder (true); password.ResignFirstResponder (true); //TODO: Show progress HUD ProgressHud.Show ("Signing In"); // You have to fetch values first from MonoTouch.Dialog elements username.FetchValue (); password.FetchValue (); // Actually sign in var r = await webService.SignInAsync(new SignInRequest { Username = username.Value, Password = password.Value }); if (!r.Succeeded) { // Show failure message Utility.ShowError ("Sign In Failed", "Invalid Username or Password"); return; } // Store our credentials for future web service calls AppDelegate.Settings.SignedInUsername = username.Value; AppDelegate.Settings.SignedInPassword = password.Value; //TODO: Hide progress hud ProgressHud.Dismiss (); // Navigate to commitments after successfuly login commitmentsViewController = new CommitmentsViewController (); NavigationController.PushViewController (commitmentsViewController, true); }) { Alignment = UITextAlignment.Center } }, new Section ("Don't have an account yet?") { new StyledStringElement ("Create an Account", () => { // Navigate to registration controller registerViewController = new RegisterViewController(); NavigationController.PushViewController (registerViewController, true); }) { Alignment = UITextAlignment.Center } } }; }