// This method is invoked when the application has loaded its UI and its ready to run public override bool FinishedLaunching(UIApplication app, NSDictionary options) { load(); string[] s; mainMenu = new Section("Blogs", "Click for a new Account"); for(int i = 0; i < titles.Count; i++){ s = titles.ElementAt(i); var a = new Account( s[0], s[1], s[2] ); accounts.Add( a ); a.SetDelegate(this); mainMenu.Add( a.GetRoot() ); } var nb = new StringElement("new Account", NewBlog); nb.Alignment = UITextAlignment.Center; mainMenu.Add( nb ); var dv = new ExtDialogViewController ( new RootElement("Blogs"){ mainMenu } ) { Autorotate = true, DisableUpsideDown = true }; window.AddSubview (navigation.View); navigation.PushViewController (dv, true); window.MakeKeyAndVisible (); return true; }
public LabelListScreen(IList<string> labels) : base(UITableViewStyle.Grouped, null) { // Navigation NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (sender, args) => { NavigationController.DismissViewController(true, null); }); NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, DoneButtonClicked); Root = new RootElement(""); var labelSection = new Section(); Root.Add(labelSection); foreach (var label in labels) { var element = new StringElement(label); element.Tapped += () => {}; labelSection.Add(element); } var customSection = new Section(); Root.Add(customSection); var customElement = new StringElement("Add Custom Label"); customElement.Tapped += () => {}; customSection.Add(customElement); }
private void FoundResults(ParseObject[] array, NSError error) { var easySection = new Section("Easy"); var mediumSection = new Section("Medium"); var hardSection = new Section("Hard"); var objects = array.Select(x=> x.ToObject<GameScore>()).OrderByDescending(x=> x.Score).ToList(); foreach(var score in objects) { var element = new StringElement(score.Player,score.Score.ToString("#,###")); switch(score.Dificulty) { case GameDificulty.Easy: easySection.Add(element); break; case GameDificulty.Medium: mediumSection.Add(element); break; case GameDificulty.Hard: hardSection.Add (element); break; } } Root = new RootElement("High Scores") { easySection, mediumSection, hardSection, }; }
public RepMaxView(Exercise exerciseToShow) : base("RepMaxView", null) { this._exercise = exerciseToShow; this._share = new RMShare(this); largestRMValue = 0.0; string dbname = "onerm.db"; string documents = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // This goes to the documents directory for your app string dbPath = Path.Combine (documents, dbname); db = new SQLiteConnection (dbPath); this.LoadRecords(); this._logRoot = new RootElement ("Records"); this._dvc = new DialogViewController (UITableViewStyle.Plain, this._logRoot, false); // load data from list this._logSect = new Section (); foreach (RmLog rm in this._rms) { StringElement recordString = new StringElement (rm.Weight.ToString(), rm.DateLogged.ToShortDateString()); this._logSect.Add(recordString); } this._logRoot.Add(this._logSect); }
public override void ViewDidLoad() { base.ViewDidLoad(); RootElement root = Root; root.UnevenRows = true; _imageView = new UIImageView(View.Frame); _messageElement = new StringElement(""); _button = new StyledStringElement("", delegate { if (OnButtonClick != null) { if (_progressView == null) _progressView = new ProgressView(); _progressView.Show("Please wait", delegate() { OnButtonClick(this, new EventArgs()); }); } } ); root.Add(new Section() {_button }); root.Add(new Section() {_messageElement}); root.Add(new Section() {_imageView}); }
public override void ViewDidLoad() { base.ViewDidLoad (); var vehicles = Vehicle.GetVehicles (); /// Create StringElement to store vehicle detail for each vehicle. StringElement[] VehicleElements = new StringElement[vehicles.Length]; for (int i = 0; i < VehicleElements.Length; i++) { VehicleElements [i] = new StringElement (vehicles [i].ToString ()); } /// Set Dialog View Controller root to show all vehicles this.Root = new RootElement ("Vehicles") { new Section() { VehicleElements } }; /// What to do when handoff has occurred. var appDelegate = (AppDelegate) UIApplication.SharedApplication.Delegate; appDelegate.HandoffOccurred += (object sender, HandoffArgs e) => { var vehicle = vehicles.First(x=>x.VIN == e.VIN); new UIAlertView("Handoff Occurred", "Vehicle Handed Off\n" + vehicle.ToString(), null, "OK").Show(); }; }
public MainViewController() : base(UITableViewStyle.Grouped, null) { SignIn.SharedInstance.Delegate = this; SignIn.SharedInstance.UIDelegate = this; // Automatically sign in the user. SignIn.SharedInstance.SignInUserSilently (); status = new StringElement ("Not Signed In", () => { // Sign out SignIn.SharedInstance.SignOutUser (); // Clear signed in app state currentAuth = null; Root[1].Clear (); ToggleAuthUI (); }); signinButton = new SignInButtonElement (); Root = new RootElement ("Sign In Migration") { new Section { signinButton, status, }, new Section { }, }; ToggleAuthUI (); }
public void EchoDicomServer() { RootElement root = null; Section resultSection = null; var hostEntry = new EntryElement("Host", "Host name of the DICOM server", "server"); var portEntry = new EntryElement("Port", "Port number", "104"); var calledAetEntry = new EntryElement("Called AET", "Called application AET", "ANYSCP"); var callingAetEntry = new EntryElement("Calling AET", "Calling application AET", "ECHOSCU"); var echoButton = new StyledStringElement("Click to test", delegate { if (resultSection != null) root.Remove(resultSection); string message; var echoFlag = DoEcho(hostEntry.Value, Int32.Parse(portEntry.Value), calledAetEntry.Value, callingAetEntry.Value, out message); var echoImage = new ImageStringElement(String.Empty, echoFlag ? new UIImage("yes-icon.png") : new UIImage("no-icon.png")); var echoMessage = new StringElement(message); resultSection = new Section(String.Empty, "C-ECHO result") { echoImage, echoMessage }; root.Add(resultSection); }) { Alignment = UITextAlignment.Center, BackgroundColor = UIColor.Blue, TextColor = UIColor.White }; root = new RootElement("Echo DICOM server") { new Section { hostEntry, portEntry, calledAetEntry, callingAetEntry}, new Section { echoButton }, }; var dvc = new DialogViewController (root, true) { Autorotate = true }; navigation.PushViewController (dvc, true); }
public TankMix_History_Fill(List<Fill> Fills,int F) : base(UITableViewStyle.Grouped, null) { this.Pushing = true; Root = new RootElement ("Fills"); var Section = new Section (); for(int i=1; i<=F; i++) { var btn = new StringElement ("Fill "+i, string.Empty); btn.Tapped += () => { //this.NavigationController.PushViewController(new TankMix_CalculationCreateFill (Convert.ToInt32(btn.Caption.Split(' ')[1]),Fills,F),true); var index = Convert.ToInt32(btn.Caption.Split(' ')[1])-1; try{ this.NavigationController.PushViewController(new TankMix_CalculationCreateNewFill(Fills[index],index+1),true); }catch{ new UIAlertView ("Error", "This fill has no data !", null, "Continue").Show (); } }; Section.Add (btn); } Root.Add (Section); }
public ProvisioningDialog() : base(UITableViewStyle.Grouped, null) { Root = new RootElement ("GhostPractice Mobile"); var topSec = new Section ("Welcome"); topSec.Add (new StringElement ("Please enter activation code")); activation = new EntryElement ("Code", "Activation Code", "999998-zcrdbrkqwogh"); topSec.Add (activation); var submit = new StringElement ("Send Code"); submit.Alignment = UITextAlignment.Center; submit.Tapped += delegate { if (activation.Value == null || activation.Value == string.Empty) { new UIAlertView ("Device Activation", "Please enter activation code", null, "OK", null).Show (); return; } if (!isBusy) { getAsyncAppAndPlatform (); } else { Wait (); } }; topSec.Add (submit); Root.Add (topSec); UIImage img = UIImage.FromFile ("Images/launch_small.png"); UIImageView v = new UIImageView (new RectangleF (0, 0, 480, 600)); v.Image = img; Root.Add (new Section (v)); }
public DatePickerDemoViewController() : base(UITableViewStyle.Grouped, new RootElement ("Demo"), true) { //NOTE: ENSURE THAT ROOT.UNEVENROWS IS SET TO TRUE // OTHERWISE THE DatePickerElement.Height function is not called Root.UnevenRows = true; // Create section to hold date picker Section section = new Section ("Date Picker Test"); // Create elements StringElement descriptionElement = new StringElement ("This demo shows how the date picker works within a section"); DatePickerElement datePickerElement = new DatePickerElement ("Select date", section, DateTime.Now, UIDatePickerMode.DateAndTime); EntryElement entryElement = new EntryElement ("Example entry box", "test", "test"); StringElement buttonElement = new StringElement ("Reset Date Picker", () => { // This is how you can set the date picker after it has been created datePickerElement.SelectedDate = DateTime.Now; }); StringElement buttonFinalElement = new StringElement ("Show Selected Date", () => { // This is how you can access the selected date from the date picker entryElement.Value = datePickerElement.SelectedDate.ToString(); }); // Add to section section.AddAll (new Element[] { descriptionElement, datePickerElement, entryElement, buttonElement, buttonFinalElement }); // Add section to root Root.Add (section); }
public SelectBin(int startBin) : base(UITableViewStyle.Grouped, null) { this.Pushing = true; Root = new RootElement ("Bin "+startBin+" - "+(startBin+14)) {}; //var bins = DBConnection.getBins(startBin); var section = new Section () { }; for(int i=0;i<15;i++){ var newBinID=startBin+i; var theBinElem=new StringElement("Bin "+newBinID,()=>{ Console.WriteLine("BinID is"+ newBinID); var theBin=new ModifyBin(newBinID); this.NavigationController.PushViewController(theBin,true); }); section.Add(theBinElem); } /* foreach(Bin bin in bins){ var newBinID=bin.binID; var theBinElem=new StringElement("Bin "+newBinID,()=>{ Console.WriteLine("BinID is"+ newBinID); var theBin=new ModifyBin(newBinID); this.NavigationController.PushViewController(theBin,true); }); section.Add(theBinElem); } */ Root.Add(section); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { window = new UIWindow (UIScreen.MainScreen.Bounds); dvc = new DialogViewController ( new RootElement ("Root") { new Section ("Main") { (button = new GlassButton (new RectangleF (0, 0, window.Bounds.Width - 20, 60))), (upper = new StringElement ("this should become uppercased")), (lower = new StringElement ("THIS SHOULD BECOME LOWERCASED")), } } ); button.SetTitle ("Test", UIControlState.Normal); button.Tapped += (obj) => { button.Enabled = false; Test (); }; window.RootViewController = dvc; window.MakeKeyAndVisible (); return true; }
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); }
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 override void ViewDidLoad() { base.ViewDidLoad(); RootElement root = Root; root.UnevenRows = true; UIImageView imageView = new UIImageView(View.Frame); StringElement messageElement = new StringElement(""); StringElement licenseElement = new StringElement(""); root.Add(new Section() { new StyledStringElement("Process", delegate { using (Image<Bgr, Byte> image = new Image<Bgr, byte>( "license-plate.jpg")) { LicensePlateDetector detector = new LicensePlateDetector("."); Stopwatch watch = Stopwatch.StartNew(); // time the detection process List<IInputOutputArray> licensePlateImagesList = new List<IInputOutputArray>(); List<IInputOutputArray> filteredLicensePlateImagesList = new List<IInputOutputArray>(); List<RotatedRect> licenseBoxList = new List<RotatedRect>(); List<string> words = detector.DetectLicensePlate( image, licensePlateImagesList, filteredLicensePlateImagesList, licenseBoxList); watch.Stop(); //stop the timer messageElement.Value = String.Format("{0} milli-seconds", watch.Elapsed.TotalMilliseconds); StringBuilder builder = new StringBuilder(); foreach (String w in words) builder.AppendFormat("{0} ", w); licenseElement.Value = builder.ToString(); messageElement.GetImmediateRootElement().Reload(messageElement, UITableViewRowAnimation.Automatic); licenseElement.GetImmediateRootElement().Reload(licenseElement, UITableViewRowAnimation.Automatic); foreach (RotatedRect box in licenseBoxList) { image.Draw(box, new Bgr(Color.Red), 2); } Size frameSize = FrameSize; using (Mat resized = new Mat()) { CvInvoke.ResizeForFrame(image, resized, frameSize); imageView.Image = resized.ToUIImage(); imageView.Frame = new RectangleF(PointF.Empty, resized.Size); } imageView.SetNeedsDisplay(); ReloadData(); } } )}); root.Add(new Section("Recognition Time") { messageElement }); root.Add(new Section("License Plate") { licenseElement }); root.Add(new Section() { imageView }); }
public SettingsViewController (FlyoutNavigationController navigation) : base(new RootElement("Settings")) { Navigation = navigation; nameElement = new EntryElement ("Name", null, null); nameElement.EntryEnded += (object sender, EventArgs e) => { App.UserName = nameElement.Value; HomeNavigationController.UpdateName(); }; url = new StringElement ("Url"); dialogId = new StringElement ("Dialog Id"); userId = new StringElement ("User Id"); Root.Add (new Section ("USER INFO"){ nameElement }); Root.Add( new Section ("WATSON CONFIGURATION") { url, dialogId, userId, }); var reconfigureElement = new StringElement ("RECONFIGURE", async () => { spinner.StartAnimating (); BluemixDialogService bluemixService; UIAlertController alert; bool isSuccess = false; bluemixService = new BluemixDialogService (); try { await bluemixService.ReConfigureService (); isSuccess = true; } catch (Exception ex) { bluemixService.ConfigureDefaultService(); System.Diagnostics.Debug.WriteLine ("Ask X: Exception Occurred: " + ex.Message); Xamarin.Insights.Report (ex); } finally { SetValues (true); spinner.StopAnimating (); if (isSuccess) alert = UIAlertController.Create("Watson Configuration", "Updated successfully!", UIAlertControllerStyle.Alert); else alert = UIAlertController.Create("Watson Configuration", "Oops! Configuration failed. Set to default.", UIAlertControllerStyle.Alert); alert.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Default, null)); PresentViewControllerAsync(alert, true); } }); reconfigureElement.Alignment = UITextAlignment.Center; Root.Add (new Section(null, "New configuration will be updated from the server."){reconfigureElement}); }
public Login() : base(UITableViewStyle.Grouped, null) { Root = new RootElement ("Login") {}; var input = new Section(){}; var userName=new EntryElement ("User Name", "Enter your user name",null); var password = new EntryElement ("Password", "Enter your password", null, true); input.Add (userName); input.Add (password); Root.Add (input); var submit = new Section () { }; var btnSubmit=new StringElement("Submit",()=>{ Console.WriteLine("user name is: "+userName.Value); Console.WriteLine("password is: "+password.Value); var pass=DBConnection.isUser(userName.Value,password.Value);//change this and use userName.Vale... if(pass){ // download templates, before go to another screen var webRequest = WebRequestManager.getWebRequestManager(); webRequest.downloadSeedTemplate(); webRequest.downloadChemicalTemplate(); webRequest.downloadUsers(); webRequest.downloadFarms(); // var farm=new SelectFarm(); this.NavigationController.PushViewController(farm,true); } else{ new UIAlertView ("Error", "Wrong UserName or Password!", null, "Continue").Show (); } }); submit.Add (btnSubmit); Root.Add (submit); /* //code to add user var addUser=new Section(){}; var btnAddUser=new StringElement("Adduser",()=>{ Console.WriteLine("Add user name: "+userName.Value); Console.WriteLine("The password is: "+password.Value); DBConnection.insertUser(userName.Value,password.Value); }); addUser.Add(btnAddUser); Root.Add(addUser); //end of code for add user */ }
public ListPickerPage(Guid itemTypeID, UINavigationController c, StringElement stringElement, PropertyInfo pi, object container, string caption, Item valueList, Item pickFromList) { // trace event TraceHelper.AddMessage("ListPicker: constructor"); this.itemTypeID = itemTypeID; this.controller = c; this.stringElement = stringElement; this.pi = pi; this.container = container; this.caption = caption; this.valueList = valueList; this.pickList = pickFromList; }
public UIViewController GetViewController () { #if TVOS var network = new StringElement (string.Format ("Enabled: {0}", EnableNetwork)); #else var network = new BooleanElement ("Enable", EnableNetwork); #endif var host = new EntryElement ("Host Name", "name", HostName); host.KeyboardType = UIKeyboardType.ASCIICapable; var port = new EntryElement ("Port", "name", HostPort.ToString ()); port.KeyboardType = UIKeyboardType.NumberPad; #if TVOS var sort = new StringElement (string.Format ("Sort Names: ", SortNames)); #else var sort = new BooleanElement ("Sort Names", SortNames); #endif var root = new RootElement ("Options") { new Section ("Remote Server") { network, host, port }, new Section ("Display") { sort } }; var dv = new DialogViewController (root, true) { Autorotate = true }; dv.ViewDisappearing += delegate { #if !TVOS EnableNetwork = network.Value; #endif HostName = host.Value; ushort p; if (UInt16.TryParse (port.Value, out p)) HostPort = p; else HostPort = -1; #if !TVOS SortNames = sort.Value; #endif var defaults = NSUserDefaults.StandardUserDefaults; defaults.SetBool (EnableNetwork, "network.enabled"); defaults.SetString (HostName ?? String.Empty, "network.host.name"); defaults.SetInt (HostPort, "network.host.port"); defaults.SetBool (SortNames, "display.sort"); }; return dv; }
public override bool FinishedLaunching (UIApplication app, NSDictionary options) { facebook = new Section ("Facebook"); facebook.Add (new StyledStringElement ("Log in", LoginToFacebook)); facebook.Add (facebookStatus = new StringElement (String.Empty)); dialog = new DialogViewController (new RootElement ("Xamarin.Auth Sample") { facebook, }); window = new UIWindow (UIScreen.MainScreen.Bounds); window.RootViewController = new UINavigationController (dialog); window.MakeKeyAndVisible (); return true; }
void Share (Service service, StringElement button) { Item item = new Item { Text = "I'm sharing great things using Xamarin!", Links = new List<Uri> { new Uri ("http://xamarin.com"), }, }; UIViewController vc = service.GetShareUI (item, shareResult => { dialog.DismissViewController (true, null); button.GetActiveCell().TextLabel.Text = service.Title + " shared: " + shareResult; }); dialog.PresentViewController (vc, true, null); }
public RainDetail(int farmID,string farmName) : base(UITableViewStyle.Grouped, null) { Root = new RootElement ("RainDetail") { }; this.Pushing=true; var section=new Section(farmName){}; var details=DBConnection.getRainDetails(farmID); int i=1; foreach(RainGauge rg in details){ Console.WriteLine(""+i); i++; var detailElem=new StringElement(rg.theDate.ToString()+" rain(mm):"+rg.rain.ToString()); section.Add(detailElem); } Root.Add (section); }
public override bool FinishedLaunching (UIApplication app, NSDictionary options) { traditionalBasicLogin = new Section ("Form Authenticator"); traditionalBasicLogin.Add (new StyledStringElement ("Log in", () => LoginToTraditionalBasic (true))); traditionalBasicLogin.Add (new StyledStringElement ("Log in (no cancel)", () => LoginToTraditionalBasic (false))); traditionalBasicLogin.Add (traditionalBasicLoginStatus = new StringElement (String.Empty)); dialog = new DialogViewController (new RootElement ("Xamarin.Auth Sample") { traditionalBasicLogin, }); window = new UIWindow (UIScreen.MainScreen.Bounds); window.RootViewController = new UINavigationController (dialog); window.MakeKeyAndVisible (); return true; }
//Boolean _isLast; public TankMix_CalculationCreateNewFill(Fill fill, int index) : base(UITableViewStyle.Grouped, null) { Root = new RootElement ("Fill " +index.ToString()); //this.Title = ; localFill = new Fill (); localFill = fill; this.Title = "Fill " + fill.Name + " Result"; var Section = new Section (); Remainder = new StringElement ("Remainder",string.Empty); AreaTreated = new StringElement ("Area Treated so far", string.Empty); AreaRemaining_S = new StringElement ("Area Remaining",string.Empty); TankFill = new StringElement ("Tank Fill", string.Empty); Net = new StringElement ("Net",string.Empty); TankArea = new StringElement ("Tank Area",string.Empty); Product = new StringElement ("Product",string.Empty); Adjuvant = new StringElement ("Adjuvant",string.Empty); Section.Add (Remainder); Section.Add (AreaTreated); Section.Add (AreaRemaining_S); Section.Add (TankFill); Section.Add (Net); Section.Add (TankArea); Section.Add (Product); Section.Add (Adjuvant); Root.Add (Section); var backBtn = new UIBarButtonItem (); backBtn.Title = "Back"; backBtn.Clicked += (object sender, EventArgs e) => { this.NavigationController.PopViewControllerAnimated(true); }; this.NavigationItem.LeftBarButtonItem = backBtn; update (localFill); }
public override void ViewDidLoad() { base.ViewDidLoad(); this.EdgesForExtendedLayout = UIRectEdge.None; viewModel = new TimerViewModel(); this.Root = new RootElement("Timer"){ new Section(){ (time = new StringElement(string.Empty, "4:00")), new StringElement("Start", ()=>{ viewModel.StartCommand.Execute(null);}), new StringElement("Pause", ()=>{ viewModel.PauseCommand.Execute(null);}), new StringElement("Stop", ()=>{ viewModel.StopCommand.Execute(null);}) } }; viewModel.PropertyChanged += viewModel_PropertyChanged; }
public SettingsViewCtrl() : base(null) { this.CardNumber = new EntryElement ("Card #", "6400130000000000", KeyStore.CardNumber) { KeyboardType = UIKeyboardType.NumberPad, TextAlignment = UITextAlignment.Right }; this.UID = new EntryElement ("U Number", "U012345678", KeyStore.UID) { TextAlignment = UITextAlignment.Right }; this.FirstName = new EntryElement ("First Name", "Rocky", KeyStore.FirstName) { TextAlignment = UITextAlignment.Right }; this.LastName = new EntryElement ("Last Name", "Bull", KeyStore.LastName) { TextAlignment = UITextAlignment.Right }; this.Save = new StringElement ("Save") { Alignment = UITextAlignment.Center }; this.Save.Tapped += Save_Tapped; Section Numbers = new Section () { this.CardNumber, this.UID }; Section Name = new Section () { this.FirstName, this.LastName }; Name.Footer = "Only your U Number OR First AND Last Name are required."; this.Root = new RootElement ("Account") { Numbers, Name, new Section() { this.Save } }; this.NavigationItem.RightBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Save, delegate { this.Save_Tapped(); }); this.NavigationItem.LeftBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Cancel, delegate { this.NavigationController.PopViewController(true); }); }
public override void ViewDidLoad () { base.ViewDidLoad (); _CookieJar = NSHttpCookieStorage.SharedStorage; foreach (var cookie in _CookieJar.Cookies) _CookieJar.DeleteCookie(cookie); JsFiles = new DirectoryInfo(Path.Combine(NSBundle.MainBundle.BundlePath, @"js")) .GetFiles("*.js", SearchOption.AllDirectories) .ToDictionary(x=>x.Name, x=>File.ReadAllText(x.FullName)); Client = new RestClient(@"https://signin.crm.dynamics.com/portal/signin/signin.aspx"); var req = new RestRequest(); req.AddHeader("User-Agent", @"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.5 Safari/535.2"); Response = Client.Execute(req); _WebView = new UIWebView(); _WebView.LoadFinished += HandleWebViewLoadFinished; _WebView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; _WebView.MultipleTouchEnabled = true; _UserNameElement = new EntryElement("UserName: "******"", "*****@*****.**"); _PasswordElement = new EntryElement("Password: "******"", "mscrm2011"); _OrganizationElement = new EntryElement("Organization:", "", "emergedata"); _SubmitElement = new StringElement("Submit", Handle_SubmitButtonClicked); _SubmitElement.Alignment = UITextAlignment.Center; var section = new Section("Login") { _UserNameElement, _PasswordElement, _OrganizationElement, _SubmitElement, }; this.Root.Add(section); }
private void FoundResults(ParseObject[] array, NSError error) { //If there was an error or no High scores found, create an emtpy list. if (array == null || error != null) { Root = new RootElement("High Scores"){ new Section(){ new StringElement("No Scores Found"), } }; return; } var easySection = new Section("Easy"); var mediumSection = new Section("Medium"); var hardSection = new Section("Hard"); var objects = array.Select(x=> x.ToObject<GameScore>()).OrderByDescending(x=> x.Score).ToList(); foreach(var score in objects) { var element = new StringElement(score.Player,score.Score.ToString("#,###")); switch(score.Dificulty) { case GameDificulty.Easy: easySection.Add(element); break; case GameDificulty.Medium: mediumSection.Add(element); break; case GameDificulty.Hard: hardSection.Add (element); break; } } Root = new RootElement("High Scores") { easySection, mediumSection, hardSection, }; }
// // Creates one of the various StringElement classes, based on the // properties set. It tries to load the most memory efficient one // StringElement, if not, it fallsback to MultilineStringElement or // StyledStringElement // static Element LoadString(JsonObject json, object data) { string value = null; string caption = value; string background = null; NSAction ontap = null; NSAction onaccessorytap = null; int? lines = null; UITableViewCellAccessory?accessory = null; UILineBreakMode? linebreakmode = null; UITextAlignment? alignment = null; UIColor textcolor = null, detailcolor = null; UIFont font = null; UIFont detailfont = null; UITableViewCellStyle style = UITableViewCellStyle.Value1; foreach (var kv in json) { string kvalue = (string)kv.Value; switch (kv.Key) { case "caption": caption = kvalue; break; case "value": value = kvalue; break; case "background": background = kvalue; break; case "style": style = ToCellStyle(kvalue); break; case "ontap": case "onaccessorytap": string sontap = kvalue; int p = sontap.LastIndexOf('.'); if (p == -1) { break; } NSAction d = delegate { string cname = sontap.Substring(0, p); string mname = sontap.Substring(p + 1); foreach (var a in AppDomain.CurrentDomain.GetAssemblies()) { Type type = a.GetType(cname); if (type != null) { var mi = type.GetMethod(mname, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (mi != null) { mi.Invoke(null, new object [] { data }); } break; } } }; if (kv.Key == "ontap") { ontap = d; } else { onaccessorytap = d; } break; case "lines": int res; if (int.TryParse(kvalue, out res)) { lines = res; } break; case "accessory": accessory = ToAccessory(kvalue); break; case "textcolor": textcolor = ParseColor(kvalue); break; case "linebreak": linebreakmode = ToLinebreakMode(kvalue); break; case "font": font = ToFont(kvalue); break; case "subtitle": value = kvalue; style = UITableViewCellStyle.Subtitle; break; case "detailfont": detailfont = ToFont(kvalue); break; case "alignment": alignment = ToAlignment(kvalue); break; case "detailcolor": detailcolor = ParseColor(kvalue); break; case "type": break; default: Console.WriteLine("Unknown attribute: '{0}'", kv.Key); break; } } if (caption == null) { caption = ""; } if (font != null || style != UITableViewCellStyle.Value1 || detailfont != null || linebreakmode.HasValue || textcolor != null || accessory.HasValue || onaccessorytap != null || background != null || detailcolor != null) { StyledStringElement styled; if (lines.HasValue) { styled = new StyledMultilineElement(caption, value, style); styled.Lines = lines.Value; } else { styled = new StyledStringElement(caption, value, style); } if (ontap != null) { styled.Tapped += ontap; } if (onaccessorytap != null) { styled.AccessoryTapped += onaccessorytap; } if (font != null) { styled.Font = font; } if (detailfont != null) { styled.SubtitleFont = detailfont; } if (detailcolor != null) { styled.DetailColor = detailcolor; } if (textcolor != null) { styled.TextColor = textcolor; } if (accessory.HasValue) { styled.Accessory = accessory.Value; } if (linebreakmode.HasValue) { styled.LineBreakMode = linebreakmode.Value; } if (background != null) { if (background.Length > 1 && background [0] == '#') { styled.BackgroundColor = ParseColor(background); } else { styled.BackgroundUri = new Uri(background); } } if (alignment.HasValue) { styled.Alignment = alignment.Value; } return(styled); } else { StringElement se; if (lines == 0) { se = new MultilineElement(caption, value); } else { se = new StringElement(caption, value); } if (alignment.HasValue) { se.Alignment = alignment.Value; } if (ontap != null) { se.Tapped += ontap; } return(se); } }
void Populate(object callbacks, object o, RootElement root) { MemberInfo last_radio_index = null; var members = o.GetType().GetMembers(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); Section section = null; foreach (var mi in members) { Type mType = GetTypeForMember(mi); if (mType == null) { continue; } string caption = null; object [] attrs = mi.GetCustomAttributes(false); bool skip = false; foreach (var attr in attrs) { if (attr is SkipAttribute || attr is System.Runtime.CompilerServices.CompilerGeneratedAttribute) { skip = true; } else if (attr is CaptionAttribute) { caption = ((CaptionAttribute)attr).Caption; } else if (attr is SectionAttribute) { if (section != null) { root.Add(section); } var sa = attr as SectionAttribute; section = new Section(sa.Caption, sa.Footer); } } if (skip) { continue; } if (caption == null) { caption = MakeCaption(mi.Name); } if (section == null) { section = new Section(); } Element element = null; if (mType == typeof(string)) { PasswordAttribute pa = null; AlignmentAttribute align = null; EntryAttribute ea = null; object html = null; NSAction invoke = null; bool multi = false; foreach (object attr in attrs) { if (attr is PasswordAttribute) { pa = attr as PasswordAttribute; } else if (attr is EntryAttribute) { ea = attr as EntryAttribute; } else if (attr is MultilineAttribute) { multi = true; } else if (attr is HtmlAttribute) { html = attr; } else if (attr is AlignmentAttribute) { align = attr as AlignmentAttribute; } if (attr is OnTapAttribute) { string mname = ((OnTapAttribute)attr).Method; if (callbacks == null) { throw new Exception("Your class contains [OnTap] attributes, but you passed a null object for `context' in the constructor"); } var method = callbacks.GetType().GetMethod(mname); if (method == null) { throw new Exception("Did not find method " + mname); } invoke = delegate { method.Invoke(method.IsStatic ? null : callbacks, new object [0]); }; } } string value = (string)GetValue(mi, o); if (pa != null) { element = new EntryElement(caption, pa.Placeholder, value, true); } else if (ea != null) { element = new EntryElement(caption, ea.Placeholder, value) { KeyboardType = ea.KeyboardType, AutocapitalizationType = ea.AutocapitalizationType, AutocorrectionType = ea.AutocorrectionType, ClearButtonMode = ea.ClearButtonMode } } ; else if (multi) { element = new MultilineElement(caption, value); } else if (html != null) { element = new HtmlElement(caption, value); } else { var selement = new StringElement(caption, value); element = selement; if (align != null) { selement.Alignment = align.Alignment; } } if (invoke != null) { ((StringElement)element).Tapped += invoke; } } else if (mType == typeof(float)) { var floatElement = new FloatElement(null, null, (float)GetValue(mi, o)); floatElement.Caption = caption; element = floatElement; foreach (object attr in attrs) { if (attr is RangeAttribute) { var ra = attr as RangeAttribute; floatElement.MinValue = ra.Low; floatElement.MaxValue = ra.High; floatElement.ShowCaption = ra.ShowCaption; } } } else if (mType == typeof(bool)) { bool checkbox = false; foreach (object attr in attrs) { if (attr is CheckboxAttribute) { checkbox = true; } } if (checkbox) { element = new CheckboxElement(caption, (bool)GetValue(mi, o)); } else { element = new BooleanElement(caption, (bool)GetValue(mi, o)); } } else if (mType == typeof(DateTime)) { var dateTime = (DateTime)GetValue(mi, o); bool asDate = false, asTime = false; foreach (object attr in attrs) { if (attr is DateAttribute) { asDate = true; } else if (attr is TimeAttribute) { asTime = true; } } if (asDate) { element = new DateElement(caption, dateTime); } else if (asTime) { element = new TimeElement(caption, dateTime); } else { element = new DateTimeElement(caption, dateTime); } } else if (mType.IsEnum) { var csection = new Section(); ulong evalue = Convert.ToUInt64(GetValue(mi, o), null); int idx = 0; int selected = 0; foreach (var fi in mType.GetFields(BindingFlags.Public | BindingFlags.Static)) { ulong v = Convert.ToUInt64(GetValue(fi, null)); if (v == evalue) { selected = idx; } CaptionAttribute ca = Attribute.GetCustomAttribute(fi, typeof(CaptionAttribute)) as CaptionAttribute; csection.Add(new RadioElement(ca != null ? ca.Caption : MakeCaption(fi.Name))); idx++; } element = new RootElement(caption, new RadioGroup(null, selected)) { csection }; } else if (mType == typeof(UIImage)) { element = new ImageElement((UIImage)GetValue(mi, o)); } else if (typeof(System.Collections.IEnumerable).IsAssignableFrom(mType)) { var csection = new Section(); int count = 0; if (last_radio_index == null) { throw new Exception("IEnumerable found, but no previous int found"); } foreach (var e in (IEnumerable)GetValue(mi, o)) { csection.Add(new RadioElement(e.ToString())); count++; } int selected = (int)GetValue(last_radio_index, o); if (selected >= count || selected < 0) { selected = 0; } element = new RootElement(caption, new MemberRadioGroup(null, selected, last_radio_index)) { csection }; last_radio_index = null; } else if (typeof(int) == mType) { foreach (object attr in attrs) { if (attr is RadioSelectionAttribute) { last_radio_index = mi; break; } } } else { var nested = GetValue(mi, o); if (nested != null) { var newRoot = new RootElement(caption); Populate(callbacks, nested, newRoot); element = newRoot; } } if (element == null) { continue; } section.Add(element); mappings [element] = new MemberAndInstance(mi, o); } root.Add(section); }
private void BuildElementPropertyMap() { _ElementPropertyMap = new Dictionary <Type, Func <MemberInfo, string, object, List <Binding>, Element> >(); _ElementPropertyMap.Add(typeof(MethodInfo), (member, caption, dataContext, bindings) => { Element element = null; var buttonAttribute = member.GetCustomAttribute <ButtonAttribute>(); if (buttonAttribute != null) { element = new ButtonElement(caption) { BackgroundColor = buttonAttribute.BackgroundColor, TextColor = buttonAttribute.TextColor, Command = GetCommandForMember(dataContext, member) }; } return(element); }); _ElementPropertyMap.Add(typeof(CLLocationCoordinate2D), (member, caption, dataContext, bindings) => { Element element = null; var mapAttribute = member.GetCustomAttribute <MapAttribute>(); var location = (CLLocationCoordinate2D)GetValue(member, dataContext); if (mapAttribute != null) { element = new MapElement(mapAttribute.Caption, mapAttribute.Value, location); } return(element); }); _ElementPropertyMap.Add(typeof(string), (member, caption, dataContext, bindings) => { Element element = null; var passwordAttribute = member.GetCustomAttribute <PasswordAttribute>(); var entryAttribute = member.GetCustomAttribute <EntryAttribute>(); var multilineAttribute = member.GetCustomAttribute <MultilineAttribute>(); var htmlAttribute = member.GetCustomAttribute <HtmlAttribute>(); var alignmentAttribute = member.GetCustomAttribute <AlignmentAttribute>(); if (passwordAttribute != null) { element = new EntryElement(caption, passwordAttribute.Placeholder, true); } else if (entryAttribute != null) { element = new EntryElement(caption, entryAttribute.Placeholder) { KeyboardType = entryAttribute.KeyboardType } } ; else if (multilineAttribute != null) { element = new MultilineElement(caption); } else if (htmlAttribute != null) { SetDefaultConverter(member, "Value", new UriConverter(), bindings); element = new HtmlElement(caption); } else { var selement = new StringElement(caption, (string)GetValue(member, dataContext)); if (alignmentAttribute != null) { selement.Alignment = alignmentAttribute.Alignment; } element = selement; } var tappable = element as ITappable; if (tappable != null) { ((ITappable)element).Command = GetCommandForMember(dataContext, member); } return(element); }); _ElementPropertyMap.Add(typeof(float), (member, caption, dataContext, bindings) => { Element element = null; var rangeAttribute = member.GetCustomAttribute <RangeAttribute>(); if (rangeAttribute != null) { var floatElement = new FloatElement() { }; floatElement.Caption = caption; element = floatElement; floatElement.MinValue = rangeAttribute.Low; floatElement.MaxValue = rangeAttribute.High; floatElement.ShowCaption = rangeAttribute.ShowCaption; } else { var entryAttribute = member.GetCustomAttribute <EntryAttribute>(); var placeholder = ""; var keyboardType = UIKeyboardType.NumberPad; if (entryAttribute != null) { placeholder = entryAttribute.Placeholder; if (entryAttribute.KeyboardType != UIKeyboardType.Default) { keyboardType = entryAttribute.KeyboardType; } } element = new EntryElement(caption, placeholder, "") { KeyboardType = keyboardType }; } return(element); }); _ElementPropertyMap.Add(typeof(Uri), (member, caption, dataContext, bindings) => { return(new HtmlElement(caption, (Uri)GetValue(member, dataContext))); }); _ElementPropertyMap.Add(typeof(bool), (member, caption, dataContext, bindings) => { Element element = null; var checkboxAttribute = member.GetCustomAttribute <CheckboxAttribute>(); if (checkboxAttribute != null) { element = new CheckboxElement(caption) { } } ; else { element = new BooleanElement(caption) { } }; return(element); }); _ElementPropertyMap.Add(typeof(DateTime), (member, caption, dataContext, bindings) => { Element element = null; var dateAttribute = member.GetCustomAttribute <DateAttribute>(); var timeAttribute = member.GetCustomAttribute <TimeAttribute>(); if (dateAttribute != null) { element = new DateElement(caption); } else if (timeAttribute != null) { element = new TimeElement(caption); } else { element = new DateTimeElement(caption); } return(element); }); _ElementPropertyMap.Add(typeof(UIImage), (member, caption, dataContext, bindings) => { return(new ImageElement()); }); _ElementPropertyMap.Add(typeof(int), (member, caption, dataContext, bindings) => { return(new StringElement(caption) { Value = GetValue(member, dataContext).ToString() }); }); }
public override bool FinishedLaunching (UIApplication app, NSDictionary options) { var root = new RootElement ("Xamarin.Social Sample"); var section = new Section ("Services"); var facebookButton = new StringElement ("Share with Facebook"); facebookButton.Tapped += delegate { Share (Facebook, facebookButton); }; section.Add (facebookButton); var twitterButton = new StringElement ("Share with Twitter"); twitterButton.Tapped += delegate { Share (Twitter, twitterButton); }; section.Add (twitterButton); var twitter5Button = new StringElement ("Share with built-in Twitter"); twitter5Button.Tapped += delegate { Share (Twitter5, twitter5Button); }; section.Add (twitter5Button); var flickr = new StringElement ("Share with Flickr"); flickr.Tapped += () => { var picker = new MediaPicker(); // Set breakpoint here picker.PickPhotoAsync().ContinueWith (t => { if (t.IsCanceled) return; var item = new Item ("I'm sharing great things using Xamarin!") { Images = new[] { new ImageData (t.Result.Path) } }; Console.WriteLine ("Picked image {0}", t.Result.Path); UIViewController viewController = Flickr.GetShareUI (item, shareResult => { dialog.DismissViewController (true, null); flickr.GetActiveCell().TextLabel.Text = "Flickr shared: " + shareResult; }); dialog.PresentViewController (viewController, true, null); }, TaskScheduler.FromCurrentSynchronizationContext()); }; section.Add (flickr); root.Add (section); dialog = new DialogViewController (root); window = new UIWindow (UIScreen.MainScreen.Bounds); window.RootViewController = new UINavigationController (dialog); window.MakeKeyAndVisible (); return true; }