An element that can be used to enter text.
This element can be used to enter text both regular and password protected entries. The Text fields in a given section are aligned with each other.
Inheritance: Element
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var issuesFilterModel = _filterController.Filter.Clone();

            //Load the root
            var root = new RootElement(Title) {
                new Section("Filter") {
                    (_assignedTo = new InputElement("Assigned To", "Anybody", issuesFilterModel.AssignedTo) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }),
                    (_reportedBy = new InputElement("Reported By", "Anybody", issuesFilterModel.ReportedBy) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }),
                    (_kindChoice = CreateMultipleChoiceElement("Kind", issuesFilterModel.Kind)),
                    (_statusChoice = CreateMultipleChoiceElement("Status", issuesFilterModel.Status)),
                    (_priorityChoice = CreateMultipleChoiceElement("Priority", issuesFilterModel.Priority)),
                },
                new Section("Order By") {
                    (_orderby = CreateEnumElement("Field", (int)issuesFilterModel.OrderBy, typeof(IssuesFilterModel.Order))),
                },
                new Section() {
                    new StyledStringElement("Save as Default", () =>{
                        _filterController.ApplyFilter(CreateFilterModel(), true);
                        CloseViewController();
                    }, Images.Size) { Accessory = UITableViewCellAccessory.None },
                }
            };

            Root = root;
        }
		public override void ViewWillAppear (bool animated)
		{
			base.ViewWillAppear(animated);
			
			var items = new List<object>();
		
			for(int i = 0;i <= 10;i++)
			{
				items.Add (i);
			}
			chickenName = new EntryElement("Name Of", null, "");
			chickenName.Value = "Big Bird";
			
			rating = new PickerElement("Rating", items.ToArray(), null, this) {
				Width = 40f,
				ValueWidth = 202f, // use this to align picker value with other elements, for the life of me I can't find a calculation that automatically does it.
				Alignment = UITextAlignment.Left
			};			
			// set initial rating.
			rating.Value = "5";
			rating.SetSelectedValue(rating.Value);
			
			date = new DateTimeElement2("Date", DateTime.Now, this) {
				Alignment = UITextAlignment.Left,
				Mode = UIDatePickerMode.Date
			};
			
			Root = new RootElement("Rate Chicken") {
				new Section() {
					chickenName,
					rating,
					date
				}
			};		
		}
        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));
        }
 RootElement CreateRoot()
 {
     nameElement = new EntryElement ("Name", "", "");
     scoreElement = new EntryElement ("Score", "", "");
     difficultyGroup = new RadioGroup (0);
     return new RootElement ("Parse"){
         new Section("Add a score!"){
             nameElement,
             scoreElement,
             new RootElement ("Difficulty",difficultyGroup){
                 new Section ("Difficulty"){
                     new RadioElement ("Easy"),
                     new RadioElement ("Medium"),
                     new RadioElement ("Hard"),
                 },
             },
         },
         new Section()
         {
             new StringElement("Submit Score",submitScore),
         },
         new Section()
         {
             new StringElement("View High Scores", viewHighScores),
         }
     };
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
			Root = new RootElement(""){
                new Section(){
					(item = new EntryElement("Item","Enter Item name",presenter.Item)),
					(quantity = new StepperElement("Quantity", presenter.Quantity, new StepperView())),
					(location = new EntryElement("Location","Enter Location", presenter.Location)),
					new StyledStringElement("Take Picture", delegate {
						TakePicture();
					}){Accessory = UITableViewCellAccessory.DisclosureIndicator},
					new StringElement("View Picture",delegate {
						ShowPicture();
					}),
				}};


            this.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Save, async delegate
            {
                try
                {
                    presenter.Item = item.Value;
					presenter.Quantity = (int)quantity.Value;
                    presenter.Location = location.Value;
                    await presenter.SaveItem();
                    NavigationController.PopToRootViewController(true);
                }
                catch (Exception e)
                {
                    new UIAlertView("Error Saving",e.Message,null,"OK",null).Show();
                }
            });

        }
示例#6
0
        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);
        }
		private void Initialize()
		{
			var loginWithWidgetBtn = new StyledStringElement ("Login with Widget", this.LoginWithWidgetButtonClick) {
				Alignment = UITextAlignment.Center
			};

			var loginWithConnectionBtn = new StyledStringElement ("Login with Google", this.LoginWithConnectionButtonClick) {
				Alignment = UITextAlignment.Center
			};

			var loginBtn = new StyledStringElement ("Login", this.LoginWithUsernamePassword) {
				Alignment = UITextAlignment.Center
			};

			this.resultElement = new StyledMultilineElement (string.Empty, string.Empty, UITableViewCellStyle.Subtitle);

			var login1 = new Section ("Login");
			login1.Add (loginWithWidgetBtn);
			login1.Add (loginWithConnectionBtn);

			var login2 = new Section ("Login with user/password");
			login2.Add (this.userNameElement = new EntryElement ("User", string.Empty, string.Empty));
			login2.Add (this.passwordElement = new EntryElement ("Password", string.Empty, string.Empty, true));
			login2.Add (loginBtn);

			var result = new Section ("Result");
			result.Add(this.resultElement);

			this.Root.Add (new Section[] { login1, login2, result });
		}
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var model = _filterController.Filter.Clone();

            //Load the root
            var root = new RootElement(Title) {
                new Section("Filter") {
                    (_filter = CreateEnumElement("Type", model.FilterType)),
                    (_open = new TrueFalseElement("Open?", model.Open)),
                    (_labels = new InputElement("Labels", "bug,ui,@user", model.Labels) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }),
                },
                new Section("Order By") {
                    (_sort = CreateEnumElement("Field", model.SortType)),
                    (_asc = new TrueFalseElement("Ascending", model.Ascending))
                },
                new Section() {
                    new StyledStringElement("Save as Default", () =>{
                        _filterController.ApplyFilter(CreateFilterModel(), true);
                        CloseViewController();
                    }, Images.Size) { Accessory = UITableViewCellAccessory.None },
                }
            };

            Root = root;
        }
示例#9
0
		public Pubnub_MessagingMain () : base (UITableViewStyle.Grouped, null)
		{
			EntryElement entryChannelName = new EntryElement("Channel Name", "Enter Channel Name", "");
			EntryElement entryCipher = new EntryElement("Cipher", "Enter Cipher", "");
			BooleanElement bSsl = new BooleanElement ("Enable SSL", false);
			Root = new RootElement ("Pubnub Messaging") {
				new Section ("Basic Settings")
				{
					entryChannelName,
					bSsl
				},
				new Section ("Enter cipher key for encryption. Leave blank for unencrypted transfer.")
				{
					entryCipher
				},
				new Section()
				{
					new StyledStringElement ("Launch", () => {
						if(String.IsNullOrWhiteSpace (entryChannelName.Value.Trim()))
						{
							new UIAlertView ("Error!", "Please enter a channel name", null, "OK").Show (); 
						}
						else
						{
							new Pubnub_MessagingSub(entryChannelName.Value, entryCipher.Value, bSsl.Value);
						}
					})
					{
						BackgroundColor = UIColor.Blue,
						TextColor = UIColor.White,
						Alignment = UITextAlignment.Center
					},
				}
			};
		}
示例#10
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			window = new UIWindow (UIScreen.MainScreen.Bounds);

			var what = new EntryElement ("What ?", "e.g. pizza", String.Empty);
			var where = new EntryElement ("Where ?", "here", String.Empty);

			var section = new Section ();
			if (CLLocationManager.LocationServicesEnabled) {
				lm = new CLLocationManager ();
				lm.LocationsUpdated += delegate (object sender, CLLocationsUpdatedEventArgs e) {
					lm.StopUpdatingLocation ();
					here = e.Locations [e.Locations.Length - 1];
					var coord = here.Coordinate;
					where.Value = String.Format ("{0:F4}, {1:F4}", coord.Longitude, coord.Latitude);
				};
				section.Add (new StringElement ("Get Current Location", delegate {
					lm.StartUpdatingLocation ();
				}));
			}

			section.Add (new StringElement ("Search...", async delegate {
				await SearchAsync (what.Value, where.Value);
			}));

			var root = new RootElement ("MapKit Search Sample") {
				new Section ("MapKit Search Sample") { what, where },
				section
			};
			window.RootViewController = new UINavigationController (new DialogViewController (root, true));
			window.MakeKeyAndVisible ();
			return true;
		}
示例#11
0
        public LoginViewController () : base (UITableViewStyle.Grouped, null)
        {
			hostEntry = new EntryElement ("Host", "imap.gmail.com", "imap.gmail.com");
			portEntry = new EntryElement ("Port", "993", "993") {
				KeyboardType = UIKeyboardType.NumberPad
			};
			sslCheckbox = new CheckboxElement ("Use SSL", true);

			userEntry = new EntryElement ("Username", "Email / Username", "");
			passwordEntry = new EntryElement ("Password", "password", "", true);

            Root = new RootElement ("IMAP Login") {
                new Section ("Server") {
					hostEntry,
                    portEntry,
                    sslCheckbox
                },
                new Section ("Account") {
                    userEntry,
                    passwordEntry
                },
                new Section {
                    new StyledStringElement ("Login", Login)
                }
            };

			foldersViewController = new FoldersViewController ();
        }
示例#12
0
		public UIViewController GetViewController ()
		{
			var network = new BooleanElement ("Remote Server", EnableNetwork);

			var host = new EntryElement ("Host Name", "name", HostName);
			host.KeyboardType = UIKeyboardType.ASCIICapable;
			
			var port = new EntryElement ("Port", "name", HostPort.ToString ());
			port.KeyboardType = UIKeyboardType.NumberPad;
			
			var root = new RootElement ("Options") {
				new Section () { network, host, port }
			};
				
			var dv = new DialogViewController (root, true) { Autorotate = true };
			dv.ViewDissapearing += delegate {
				EnableNetwork = network.Value;
				HostName = host.Value;
				ushort p;
				if (UInt16.TryParse (port.Value, out p))
					HostPort = p;
				else
					HostPort = -1;
				
				var defaults = NSUserDefaults.StandardUserDefaults;
				defaults.SetBool (EnableNetwork, "network.enabled");
				defaults.SetString (HostName ?? String.Empty, "network.host.name");
				defaults.SetInt (HostPort, "network.host.port");
			};
			
			return dv;
		}
        public SettingsViewController()
            : base(new RootElement("Einstellungen"))
        {
            var root = new RootElement("Einstellungen");
            var userEntry = new EntryElement("Benutzername", "benutzername", ApplicationSettings.Instance.UserCredentials.Name);
            var passwordEntry = new EntryElement("Passwort", "passwort", ApplicationSettings.Instance.UserCredentials.Password, true);
            userEntry.AutocorrectionType = MonoTouch.UIKit.UITextAutocorrectionType.No;
            userEntry.AutocapitalizationType = MonoTouch.UIKit.UITextAutocapitalizationType.None;
            userEntry.Changed += UsernameChanged;
            passwordEntry.Changed += PasswordChanged;

            root.Add(new Section("Benutzerinformationen"){
                userEntry,
                passwordEntry
            });

            root.Add(new Section("Stundenplaneinstellungen"){
                new StyledStringElement("Andere Stundenpläne", () => {NavigationController.PushViewController(new SettingsTimetablesDetailViewController(), true);}){
                    Accessory = UITableViewCellAccessory.DisclosureIndicator
                }
            });
            Root = root;
            Title = "Einstellungen";
            NavigationItem.Title = "Einstellungen";
            TabBarItem.Image = UIImage.FromBundle("Settings-icon");
        }
        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 override void ViewDidLoad()
        {

            base.ViewDidLoad();
            
            // Perform any additional setup after loading the view
            var info = new RootElement("Info") {
                new Section() {
                    { eventname = new EntryElement("Event Name", "Enter the Name", null) },
                    { recipients = new EntryElement("Recipients' Names", "Enter the Recipients", null) },
                    { location = new EntryElement("Enter Location", "Enter the Location", null) }
                },

                new Section()
                {
                    { date = new DateElement("Pick the Date", DateTime.Now) },
                    { timeelement = new TimeElement("Pick the Time", DateTime.Now) },
                    { description = new EntryElement("Description", "Enter a Description", null) }
                },

                new Section()
                {
                    new RootElement("Type", category = new RadioGroup("Type of Event", 0)) {
                        new Section() {
                            new RadioElement ("Meeting", "Type of Event"),
                            new RadioElement ("Company Event", "Type of Event"),
                            new RadioElement ("Machine Maintenance", "Type of Event"),
                            new RadioElement ("Emergency", "Type of Event")
                        }
                    },
                    
                    new RootElement("Priority", priority = new RadioGroup ("priority", 0))
                    {
                        new Section()
                        {
                            new RadioElement("Low", "priority"),
                            new RadioElement("Medium", "priority"), 
                            new RadioElement("High", "priority")
                        }
                    }
                },
            };

            Root.Add(info);

            UIButton createEventBtn = UIButton.FromType(UIButtonType.RoundedRect);
            createEventBtn.SetTitle("Add Event", UIControlState.Normal);
            createEventBtn.Frame = new Rectangle(0, 0, 320, 44);
            int y = (int)((View.Frame.Size.Height - createEventBtn.Frame.Size.Height)/1.15);
            int x = ((int)(View.Frame.Size.Width - createEventBtn.Frame.Size.Width)) / 2;
            createEventBtn.Frame = new Rectangle(x, y, (int)createEventBtn.Frame.Width, (int)createEventBtn.Frame.Height);
            View.AddSubview(createEventBtn);


            createEventBtn.TouchUpInside += async (object sender, EventArgs e) =>
            {
                await createEvent(info);
            };
        }
        public PhotoViewController()
            : base(UITableViewStyle.Grouped, null, true)
        {
            // Add the image that will be publish
            var imageView = new UIImageView (new CGRect (0, 0, View.Frame.Width, 220)) {
                Image = UIImage.FromFile ("wolf.jpg")
            };

            // Add a textbox that where you will be able to add a comment to the photo
            txtMessage = new EntryElement ("", "Say something nice!", "");

            Root = new RootElement ("Post photo!") {
                new Section () {
                    new UIViewElement ("", imageView, true) {
                        Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent,
                    },
                    txtMessage
                }
            };

            // Create the request to post a photo into your wall
            NavigationItem.RightBarButtonItem = new UIBarButtonItem ("Post", UIBarButtonItemStyle.Plain, ((sender, e) => {

                // Disable the post button for prevent another untill the actual one finishes
                (sender as UIBarButtonItem).Enabled = false;

                // Add the photo and text that will be publish
                var parameters = new NSDictionary ("picture", UIImage.FromFile ("wolf.jpg").AsPNG (), "caption", txtMessage.Value);

                // Create the request
                var request = new GraphRequest ("/" + Profile.CurrentProfile.UserID + "/photos", parameters, AccessToken.CurrentAccessToken.TokenString, null, "POST");
                var requestConnection = new GraphRequestConnection ();
                requestConnection.AddRequest (request, (connection, result, error) => {

                    // Enable the post button
                    (sender as UIBarButtonItem).Enabled = true;

                    // Handle if something went wrong
                    if (error != null) {
                        new UIAlertView ("Error...", error.Description, null, "Ok", null).Show ();
                        return;
                    }

                    // Do your magic if the request was successful
                    new UIAlertView ("Yay!!", "Your photo was published!", null, "Ok", null).Show ();

                    photoId = (result as NSDictionary) ["post_id"].ToString ();

                    // Add a button to allow to delete the photo posted
                    Root.Add (new Section () {
                        new StyledStringElement ("Delete Post", DeletePost) {
                            Alignment = UITextAlignment.Center,
                            TextColor = UIColor.Red
                        }
                    });
                });
                requestConnection.Start ();
            }));
        }
示例#17
0
        public AddEditContactScreen(UINavigationController nav)
            : base(UITableViewStyle.Grouped, null, true)
        {
            _rootContainerNavigationController = nav;

            // Navigation
            NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (sender, args) =>
            {
                NavigationController.DismissViewController(true, null);
            });
            NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, DoneButtonClicked);
            NavigationItem.Title = "New Contact";

            Root = new RootElement("");

            // Photo
            _photoSection = new Section();
            _photoBadge = new BadgeElement(UIImage.FromBundle("Images/UnknownIcon.jpg"), "Add Photo");
            _photoBadge.Tapped += PhotoBadgeTapped;
            _photoSection.Add(_photoBadge);
            Root.Add(_photoSection);

            // Name
            _nameSection = new Section();
            var firstName = new EntryElement(null, "First", null);
            var middleName = new EntryElement(null, "Middle", null);
            var lastName = new EntryElement(null, "Last", null);
            var org = new EntryElement(null, "Organization", null);
            _nameSection.Add(firstName);
            _nameSection.Add(middleName);
            _nameSection.Add(lastName);
            _nameSection.Add(org);
            Root.Add(_nameSection);

            // Phone numbers
            _phoneSection = new Section("Phone Numbers");
            Root.Add(_phoneSection);
            var phoneLoadMore = new LoadMoreElement("Add More Phone Numbers", "Loading...", PhoneLoadMoreTapped);
            _phoneSection.Add(phoneLoadMore);

            // Emails
            _emailSection = new Section("Emails");
            Root.Add(_emailSection);
            var emailLoadMore = new LoadMoreElement("Add More Emails", "Loading...", EmailLoadMoreTapped);
            _emailSection.Add(emailLoadMore);

            // Urls
            _urlSection = new Section("Urls");
            Root.Add(_urlSection);
            var urlLoadMore = new LoadMoreElement("Add More Urls", "Loading...", UrlLoadMoreTapped);
            _urlSection.Add(urlLoadMore);

            // IMs
            _instantMsgSection = new Section("Instant Messages");
            Root.Add(_instantMsgSection);
            var instantMsgLoadMore = new LoadMoreElement("Add More Instant Messages", "Loading...", InstantMsgLoadMoreTapped);
            _instantMsgSection.Add(instantMsgLoadMore);
        }
示例#18
0
        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);
        }
 private EntryElement CreateNicknameElement()
 {
     _nickname = new EntryElement("Nickname", "ninja wannabe", null)
         {
             AutocapitalizationType = UITextAutocapitalizationType.None,
             AutocorrectionType = UITextAutocorrectionType.No,
             ReturnKeyType = UIReturnKeyType.Next
         };
     return _nickname;
 }
示例#20
0
		public void Update(EntryElement element, UITableView tableView){
			_element = element;

			if (_entry==null){
				PrepareEntry(tableView);
			}

			_entry.Font = element.Appearance.TextFieldFont;
			_entry.TextColor = element.ReadOnly ? element.Appearance.DisabledLabelTextColor : element.Appearance.TextFieldFontTextColor;

			TextLabel.Font = element.Appearance.LabelFont;
			TextLabel.TextColor = element.ReadOnly ? element.Appearance.DisabledLabelTextColor : element.Appearance.LabelTextColor;
			TextLabel.HighlightedTextColor = element.Appearance.LabelHighlightedTextColor;

			_entry.Enabled = !element.ReadOnly;
			_entry.Text = element.Value ?? "";
			_entry.RightText = element.AppendedText;
			if (_entry.GetType()==typeof(CustomTextField)) {
				((UILabel)((CustomTextField)_entry).RightView).TextColor = element.ReadOnly ? element.Appearance.DisabledLabelTextColor : element.Appearance.LabelTextColor;
			}

			_entry.TextAlignment = element.TextAlignment;
			_entry.Placeholder = element.Placeholder ?? "";
			_entry.SecureTextEntry = element.IsPassword;
			if (element.KeyboardType==UIKeyboardType.EmailAddress || element.IsPassword){
				_entry.AutocorrectionType = UITextAutocorrectionType.No;
				_entry.AutocapitalizationType = UITextAutocapitalizationType.None;
			} else {
				_entry.AutocorrectionType = UITextAutocorrectionType.Default;
				_entry.AutocapitalizationType = element.AutoCapitalize;
			}
			
			_entry.KeyboardType = element.KeyboardType;
            _entry.ReturnKeyType = element.ReturnKeyType;
			_entry.AutocorrectionType = element.AutoCorrection;
			TextLabel.Text = element.Caption;
			_entry.Hidden = element.Hidden;
			this.BackgroundColor = element.ReadOnly ? element.Appearance.BackgroundColorDisabled : element.Appearance.BackgroundColorEditable;
			this.UserInteractionEnabled = !element.ReadOnly;

			
			if (element.ShowToolbar || element.KeyboardType == UIKeyboardType.DecimalPad) {
				var toolbar = new UIToolbar {Translucent = true, Frame = new RectangleF(0,0,320,44)};
				_entry.InputAccessoryView = toolbar;

				toolbar.Items = new UIBarButtonItem[]{
					new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null, null),
					new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (e, a)=>{

						this.ResignFirstResponder();
					}) ,
				};
			};
		}
 private EntryElement CreateGroupElement()
 {
     _group = new EntryElement("Group", "The Groupies", null)
         {
             AutocapitalizationType = UITextAutocapitalizationType.Words,
             AutocorrectionType = UITextAutocorrectionType.Yes,
             ReturnKeyType = UIReturnKeyType.Go,
             EntryEnded = (sender, args) => Done()
         };
     return _group;
 }
示例#22
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Root.Add(new Section
            {
                (_nameElement = new EntryElement("Name", string.Empty, _settings.Name)),
                (_protectionElement = new BooleanElement("Protect connection", _settings.IsProtected)),
                GetStatusRootView()
            });
        }
示例#23
0
		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});

		}
示例#24
0
        private void initView()
        {
            var root = new RootElement("Simple Barcode Example");
            var section = new Section("Collect Barcode");

            txtBarcode = new EntryElement("Barcode", "Please scan a barcode.", "");

            section.Add(txtBarcode);
            root.Add(section);

            this.Root = root;
        }
示例#25
0
        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
            */
        }
示例#26
0
        private RootElement CreateRoot()
        {
            var apiElement = new EntryElement ("Key", "Enter API key", _currentUser.ApiKey);
            apiElement.Changed += HandleChangedApiKey;

            return new RootElement ("Settings")
            {
                new Section (null,"API key as activated on AgileZen.com")
                {
                    apiElement
                }
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var title = expense == null ? "New Expense" : "Edit Expense";
            this.Root = new RootElement(title)
              {
            new Section("Expense Details")
            {
              (name = new EntryElement("Name", "Expense Name", string.Empty)),
              (total = new EntryElement("Total", "1.00", string.Empty){KeyboardType = UIKeyboardType.DecimalPad}),
              (billable = new CheckboxElement("Billable", true)),
              new RootElement("Category", categories = new RadioGroup("category", 0))
              {
            new Section()
            {
              from category in viewModel.Categories
                select (Element) new RadioElement(category)
            }
              },
              (due = new DateElement("Due Date", DateTime.Now))
            },
            new Section("Notes")
            {
              (notes = new EntryElement(string.Empty, "Enter expense notes.", string.Empty))
            }

              };

            billable.Value = viewModel.Billable;
            name.Value = viewModel.Name;
            total.Value = viewModel.Total;
            notes.Caption = viewModel.Notes;
            categories.Selected = viewModel.Categories.IndexOf(viewModel.Category);
            due.DateValue = viewModel.Due;

            this.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Save, async delegate
            {
                viewModel.Category = viewModel.Categories[categories.Selected];
                viewModel.Name = name.Value;
                viewModel.Billable = billable.Value;
                viewModel.Due = due.DateValue;
                viewModel.Notes = notes.Caption;
                viewModel.Total = total.Value;

                await viewModel.ExecuteSaveExpenseCommand();
                if (!viewModel.CanNavigate)
                    return;
                NavigationController.PopToRootViewController(true);

            });
        }
		public MainViewController ()
			: base(null)
		{
			_hostNameElement = new EntryElement ("Target", "google.com", "") { TextAlignment = UITextAlignment.Right };
			_pingButtonElement = new StyledStringElement ("Ping"){ Alignment = UITextAlignment.Center };
			_pingButtonElement.Tapped += OnPingButtonClicked;

			Root = new MonoTouch.Dialog.RootElement ("SimplePing") {
				new Section () { 
					_hostNameElement,
					_pingButtonElement,
				}
			};
		}
		public void Update(EntryElement element, UITableView tableView){
			_element = element;
			
			if (_entry==null){
				PrepareEntry(tableView);
			}
			
			_entry.Text = element.Value ?? "";
			_entry.Placeholder = element.Placeholder ?? "";
			_entry.SecureTextEntry = element.IsPassword;
			_entry.AutocapitalizationType = element.AutoCapitalize;
			_entry.KeyboardType = element.KeyboardType;
            _entry.ReturnKeyType = element.ReturnKeyType;
			TextLabel.Text = element.Caption;
		}
示例#30
0
 public Bullying()
     : base(UITableViewStyle.Grouped, null)
 {
     Title = NSBundle.MainBundle.LocalizedString ("Bullying", "Bullying");
     TabBarItem.Image = UIImage.FromBundle("bullying");
     //			var HelpButton = new UIButton(UIButtonType.RoundedRect);
     //			HelpButton.SetTitle("Help Me!", UIControlState.Normal);
     Root = new RootElement ("Student Guide") {
         new Section("Bullying"){
             new StyledStringElement ("Help me!", () => {
                 //AppDelegate.getControl.calling(); //Phones a number all like 'SAVE ME PLS'
             }){ TextColor=UIColor.Red,},
             new RootElement("Speak Up!") {
                 new Section("Speak up form") {
                     (FullName = new EntryElement("Full Name","Full Name","")),
                     (Incident = new EntryElement("Incedent","Incedent","",false)),
                     (Location = new EntryElement("Location of Incident","Location of Incident","")),
                     (ThoseInvolved = new EntryElement("Persons Involved","Persons Involved","")),
                 },
                 new Section() {
                     new StringElement("Submit", delegate {
                         UIAlertView popup = new UIAlertView("Alert","Do you wish to send an Email, a Text or cancel the form?",null,"Cancel","Text","Email");
                         popup.Show();
                         popup.Dismissed += delegate(object sender, UIButtonEventArgs e) {
                             if (e.ButtonIndex==1) {
                                 MFMessageComposeViewController msg = new MFMessageComposeViewController();
                                 msg.Recipients= new string[] {"07624808747"};
                                 msg.Body="Hello, I am being bullied by " + ThoseInvolved.Value + " they were " + Incident.Value + " this all happened " + Location.Value + "" + Environment.NewLine + "" + FullName.Value;
                                 this.NavigationController.PresentViewController(msg,true,null);
                             } else if (e.ButtonIndex==2) {
                                 MFMailComposeViewController email = new MFMailComposeViewController();
                                 email.SetSubject("Help me i'm being bullied");
                                 email.SetToRecipients(new string[] {"*****@*****.**"});
                                 email.SetMessageBody("Hello, I am being bullied by " + ThoseInvolved.Value + " they were " + Incident.Value + " this all happened " + Location.Value + "" + Environment.NewLine + "" + FullName.Value,false);
                                 this.NavigationController.PresentViewController(email,true,null);
                             }
                         };
                     }),
                 },
             },
             new RootElement("Bullying Information") {
                 from x in bullyingInfo
                     select (Section)Generate (x)
             },
         }
     };
 }
示例#31
0
        protected virtual void PrepareEntry(UITableView tableview)
        {
            SizeF size = _computeEntryPosition(tableview);

            _entry          = new CustomTextField(new RectangleF(size.Width + 10, (ContentView.Bounds.Height - size.Height) / 2 - 10, 320 - size.Width - 20, size.Height + 20));
            _delegate       = new CustomTextFieldDelegate();
            _entry.Delegate = _delegate;

            _entry.VerticalAlignment = UIControlContentVerticalAlignment.Center;

            TextLabel.BackgroundColor = UIColor.Clear;
            _entry.AutoresizingMask   = UIViewAutoresizing.FlexibleWidth |
                                        UIViewAutoresizing.FlexibleLeftMargin;

            _entry.MaxCharacters = 5;

            _entry.Started += delegate {
                var position = tableview.IndexPathForCell(this);
                tableview.SelectRow(position, false, UITableViewScrollPosition.None);
            };

            _entry.ValueChanged += delegate {
                if (_element != null)
                {
                    _element.Value = _entry.Text;
                }
            };
            _entry.EnablesReturnKeyAutomatically = true;
            _entry.Ended += (object sender, EventArgs e) => {
                if (_element != null)
                {
                    _element.Value = _entry.Text;

                    if (_element.OnValueChanged != null)
                    {
                        _element.OnValueChanged(_element);
                    }
                }

                var position = tableview.IndexPathForCell(this);
                if (tableview.IndexPathForSelectedRow != null && position != null && position.Compare(tableview.IndexPathForSelectedRow) == 0)
                {
                    tableview.DeselectRow(position, false);
                }
            };
            _entry.ShouldChangeCharacters = (textField, range, replacement) =>
            {
                if (_element.MaxLength < 0)
                {
                    return(true);
                }
                if (_element.MaxLength == 0)
                {
                    return(false);
                }
                using (NSString original = new NSString(textField.Text))
                {
                    var replace = original.Replace(range, new NSString(replacement));
                    if (replace.Length > _element.MaxLength)
                    {
                        return(false);
                    }
                }
                return(true);
            };

            _entry.AddTarget((object o, EventArgs r) => {
                if (_element != null)
                {
                    _element.Value = _entry.Text;
                }
            }, UIControlEvent.EditingChanged);

            _entry.ShouldReturn += delegate {
                Element elementToFocusOn = null;

                foreach (var c in ((Section)_element.Parent).Elements)
                {
                    if (c == _element)
                    {
                        elementToFocusOn = c;
                    }
                    else if (elementToFocusOn != null && c is EntryElement)
                    {
                        elementToFocusOn = c as EntryElement;
                    }
                }
                if (elementToFocusOn != _element && elementToFocusOn != null)
                {
                    var cell = tableview.CellAt(elementToFocusOn.GetIndexPath());
                    cell.BecomeFirstResponder();
                }
                else
                {
                    _entry.ResignFirstResponder();
                }

                if (_entry.ReturnKeyType == UIReturnKeyType.Go)
                {
                    _element.FireGo(this, EventArgs.Empty);
                }

                return(true);
            };
            _entry.Started += delegate {
                EntryElement self       = null;
                var          returnType = _element.ReturnKeyType;

                if (returnType != UIReturnKeyType.Default)
                {
                    foreach (var e in (_element.Parent as Section).Elements)
                    {
                        if (e == _element)
                        {
                            self = _element;
                        }
                        else if (self != null && e is EntryElement)
                        {
                            returnType = UIReturnKeyType.Next;
                        }
                    }
                }
                _entry.ReturnKeyType = returnType;
            };

            ContentView.AddSubview(_entry);
        }
示例#32
0
        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);
        }
示例#33
0
        public void Update(EntryElement element, UITableView tableView)
        {
            _element = element;

            if (_entry == null)
            {
                PrepareEntry(tableView);
            }

            _entry.Font      = element.Appearance.TextFieldFont;
            _entry.TextColor = element.ReadOnly ? element.Appearance.DisabledLabelTextColor : element.Appearance.TextFieldFontTextColor;

            TextLabel.Font                 = element.Appearance.LabelFont;
            TextLabel.TextColor            = element.ReadOnly ? element.Appearance.DisabledLabelTextColor : element.Appearance.LabelTextColor;
            TextLabel.HighlightedTextColor = element.Appearance.LabelHighlightedTextColor;

            _entry.Enabled   = !element.ReadOnly;
            _entry.Text      = element.Value ?? "";
            _entry.RightText = element.AppendedText;
            if (_entry.GetType() == typeof(CustomTextField))
            {
                ((UILabel)((CustomTextField)_entry).RightView).TextColor = element.ReadOnly ? element.Appearance.DisabledLabelTextColor : element.Appearance.LabelTextColor;
            }

            _entry.TextAlignment   = element.TextAlignment;
            _entry.Placeholder     = element.Placeholder ?? "";
            _entry.SecureTextEntry = element.IsPassword;
            if (element.KeyboardType == UIKeyboardType.EmailAddress || element.IsPassword)
            {
                _entry.AutocorrectionType     = UITextAutocorrectionType.No;
                _entry.AutocapitalizationType = UITextAutocapitalizationType.None;
            }
            else
            {
                _entry.AutocorrectionType     = UITextAutocorrectionType.Default;
                _entry.AutocapitalizationType = element.AutoCapitalize;
            }

            _entry.KeyboardType         = element.KeyboardType;
            _entry.ReturnKeyType        = element.ReturnKeyType;
            _entry.AutocorrectionType   = element.AutoCorrection;
            TextLabel.Text              = element.Caption;
            _entry.Hidden               = element.Hidden;
            this.BackgroundColor        = element.ReadOnly ? element.Appearance.BackgroundColorDisabled : element.Appearance.BackgroundColorEditable;
            this.UserInteractionEnabled = !element.ReadOnly;


            if (element.ShowToolbar || element.KeyboardType == UIKeyboardType.DecimalPad)
            {
                var toolbar = new UIToolbar {
                    Translucent = true, Frame = new RectangleF(0, 0, 320, 44)
                };
                _entry.InputAccessoryView = toolbar;

                toolbar.Items = new UIBarButtonItem[] {
                    new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null, null),
                    new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, (e, a) => {
                        this.ResignFirstResponder();
                    }),
                };
            }
            ;
        }
示例#34
0
        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()
                });
            });
        }
示例#35
0
        public override void InitializeControls(UITableView tableView)
        {
            if (Entry == null)
            {
                SizeF size   = ComputeEntryPosition(tableView, Cell);
                var   _entry = new UITextField(new RectangleF(size.Width, (Cell.ContentView.Bounds.Height - size.Height) / 2 - 1, 290 - size.Width, size.Height))
                {
                    Tag = 1, Placeholder = _Placeholder ?? "", SecureTextEntry = _IsPassword
                };
                _entry.Font = UIFont.SystemFontOfSize(17);
                _entry.AddTarget(delegate { Value = _entry.Text; }, UIControlEvent.ValueChanged);

                Entry = _entry;

                Entry.Ended += delegate
                {
                    Value = Entry.Text;
                };

                Entry.ShouldReturn += delegate
                {
                    EntryElement focus = null;
                    foreach (var e in (Parent as ISection).Elements)
                    {
                        if (e == this)
                        {
                            focus = this;
                        }
                        else if (focus != null && e is EntryElement)
                        {
                            focus = e as EntryElement;
                        }
                    }

                    if (focus != this)
                    {
                        tableView.ScrollToRow(focus.IndexPath, UITableViewScrollPosition.Middle, true);
                        focus.Entry.BecomeFirstResponder();
                    }
                    else
                    {
                        focus.Entry.ResignFirstResponder();
                    }

                    return(true);
                };

                Entry.Started += delegate
                {
                    var bindingExpression = GetBindingExpression("Value");

                    if (bindingExpression != null)
                    {
                        Entry.Text = (string)bindingExpression.ConvertbackValue(Value);
                    }
                    else
                    {
                        Entry.Text = Value;
                    }

                    EntryElement self       = null;
                    var          returnType = UIReturnKeyType.Done;

                    foreach (var e in (Parent as ISection).Elements)
                    {
                        if (e == this)
                        {
                            self = this;
                        }
                        else if (self != null && e is EntryElement)
                        {
                            returnType = UIReturnKeyType.Next;
                        }
                    }

                    Entry.ReturnKeyType = returnType;
                };
            }

            Entry.KeyboardType  = KeyboardType;
            Entry.TextAlignment = UITextAlignment.Right;

            Entry.Text = Value;

            Cell.TextLabel.Text = Caption;

            Cell.ContentView.AddSubview(Entry);
        }