Used to display switch on the screen.
Inheritance: BoolElement
Esempio n. 1
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
					},
				}
			};
		}
Esempio n. 2
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 override void LoadView ()
		{
			base.LoadView ();

			var root = new RootElement ("TARP Banks");

			var section = new Section ()
			{
				(usOnlyToggle = new BooleanElement("Show only US banks", false))
			};
			root.Add (section);

			//make a section from the banks. Keep a reference to it
			root.Add ((bankListSection = BuildBankSection (usOnlyToggle.Value)));

			//if the toggle changes, reload the items
			usOnlyToggle.ValueChanged += (sender, e) => {
				var newListSection = BuildBankSection(usOnlyToggle.Value);

				root.Remove(bankListSection, UITableViewRowAnimation.Fade);
				root.Insert(1, UITableViewRowAnimation.Fade, newListSection);
				bankListSection = newListSection;

			};


			Root = root;
		}
Esempio n. 4
0
        public OptionsRootElement(Model.Options options)
            : base("Bedside Clock")
        {
            customFontNames = new string[] { "LCDMono" };
            standardFontNames = UIFont.FamilyNames.OrderBy(f => f).ToArray();

            use24Hour = new BooleanElement("24 hour", options.Use24Hour);
            showSeconds = new BooleanElement("Seconds", options.ShowSeconds);
            fontGroup = new RadioGroup(GetIndexForSelectedFont(options.Font));

            var customFontSection = new Section("Custom");
            customFontSection.AddAll(customFontNames.Select(f => new FontEntryElement(f)));

            var fontSection = new Section("Standard Fonts");
            fontSection.AddAll(standardFontNames.Select(f => new FontEntryElement(f)));

            Add(new Section("Clock Display") {
                new StringElement("Color", "Green"),
                new RootElement("Font", fontGroup) { customFontSection, fontSection },
                use24Hour,
                showSeconds
            });
            Add(new Section("Brightness") {
                new FloatElement(null, null, 0.5f)
            });
        }
		public void Update(BooleanElement element){
			_element = element;
			if (_switch==null) 
				prepareCell();
			
			TextLabel.BackgroundColor = UIColor.Clear;
			TextLabel.Text = _element.Caption;
			_switch.On = _element.Value;
		}
Esempio n. 6
0
 public Element ElementForRequirement(Requirement req)
 {
     var status = RequirementStatus.ContainsKey(req.Id)? RequirementStatus[req.Id] : new RequirementStatus(){UserId = Person.Id,RequirementId = req.Id};
     BooleanElement element = new BooleanElement(req.Display,status.DateCompleted.HasValue);
     element.ValueChanged += delegate {
         //todo, save
     };
     return element;
 }
Esempio n. 7
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()
            });
        }
Esempio n. 8
0
		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 void ViewDidLoad ()
        {
            base.ViewDidLoad ();

            var del = UIApplication.SharedApplication.Delegate as AppDelegate;

            BooleanElement leftMenuEnabled = new BooleanElement ("Left menu enabled", del.Menu.LeftMenuEnabled);
            leftMenuEnabled.ValueChanged += (sender, e) => {
                del.Menu.LeftMenuEnabled = leftMenuEnabled.Value;
            };

            Root.Add (new Section () {
                new StyledStringElement("Home", () => { NavigationController.PushViewController(new HomeViewController(), true); }),
                leftMenuEnabled
            });
        }
Esempio n. 10
0
        public override void LoadView()
        {
            name = new LimitedEntryElement ("Name", "Enter the name of the pilot.", Pilot.Name);
            cfi = new BooleanElement ("Certified Flight Instructor", Pilot.IsCertifiedFlightInstructor);
            aifr = new BooleanElement ("Instrument Rated (Airplane)", Pilot.InstrumentRatings.HasFlag (InstrumentRating.Airplane));
            hifr = new BooleanElement ("Instrument Rated (Helicopter)", Pilot.InstrumentRatings.HasFlag (InstrumentRating.Helicopter));
            lifr = new BooleanElement ("Instrument Rated (Powered-Lift)", Pilot.InstrumentRatings.HasFlag (InstrumentRating.PoweredLift));
            certification = CreatePilotCertificationElement (Pilot.Certification);
            endorsements = CreateEndorsementsElement (Pilot.Endorsements);
            birthday = new DateEntryElement ("Date of Birth", Pilot.BirthDate);
            medical = new DateEntryElement ("Last Medical Exam", Pilot.LastMedicalExam);
            review = new DateEntryElement ("Last Flight Review", Pilot.LastFlightReview);

            base.LoadView ();

            Root.Add (new Section ("Pilot Information") { name, birthday, certification, endorsements, aifr, hifr, lifr, cfi });
            Root.Add (new Section ("Pilot Status") { medical, review });
        }
Esempio n. 11
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            window = new UIWindow (UIScreen.MainScreen.Bounds);

            var root = new RootElement ("Discreet Sample") {
                new Section ("Settings") {
                    (text2Show = new EntryElement ("Text2Show:", "Some text here", "I'm so Discreet")),
                    new StringElement ("Show", Show) {
                        Alignment = UITextAlignment.Center
                    },
                    new StringElement ("Hide", Hide) {
                        Alignment = UITextAlignment.Center
                    },
                    new StringElement ("Hide after 1 second", HideAfter1sec) {
                        Alignment = UITextAlignment.Center
                    },
                    (topBottom = new BooleanElement ("Top / Bottom", true)),
                    (showActivity = new BooleanElement ("Show Activity?", true))
                }
            };

            dvc = new DialogViewController (root);
            navController = new UINavigationController (dvc);

            window.RootViewController = navController;
            window.MakeKeyAndVisible ();

            notificationView = new GCDiscreetNotificationView (text:text2Show.Value,
                                                               activity: showActivity.Value,
                                                               presentationMode: topBottom.Value ? GCDNPresentationMode.Top : GCDNPresentationMode.Bottom,
                                                               view: dvc.View);
            showActivity.ValueChanged += ChangeActivity;
            topBottom.ValueChanged += ChangeTopBottom;
            text2Show.Changed += HandleChanged;

            return true;
        }
        void RunGrant (bool isPresenceGrant)
        {
            BooleanElement canRead = new BooleanElement ("Read", false);
            BooleanElement canWrite = new BooleanElement ("Write", false);
            EntryElement entryTtl = new EntryElement("TTL", "Enter TTL (default 1440)", "");
            entryTtl.KeyboardType = UIKeyboardType.NumberPad;

            string strHead = "Subscribe Grant";
            if (isPresenceGrant) {
                strHead = "Presence Grant";
            }

            var newroot = new RootElement (strHead, 0, 0){
                new Section (){
                    canRead,
                    canWrite,
                    entryTtl
                },
                new Section (""){
                    new StyledStringElement ("Grant", () => {
                        int iTtl;

                        Int32.TryParse(entryTtl.Value, out iTtl);
                        if (iTtl == 0) 
                        {
                            iTtl = 1440;
                            entryTtl.Value = "1440";
                        }

                        if (isPresenceGrant) {
                            Display("Running Presence Grant");
                            pubnub.GrantPresenceAccess<string>(Channel, canRead.Value, canWrite.Value, iTtl, DisplayReturnMessage, DisplayErrorMessage);
                        }else{
                            Display("Running Subscribe Grant");
                            pubnub.GrantAccess<string>(Channel, canRead.Value, canWrite.Value, iTtl, DisplayReturnMessage, DisplayErrorMessage);
                        }
                        AppDelegate.navigation.PopViewControllerAnimated(true);
                    })
                    {
                        BackgroundColor = UIColor.Blue,
                        TextColor = UIColor.White,
                        Alignment = UITextAlignment.Center
                    },
                },
            };
            dvc = new DialogViewController (newroot, true);
            AppDelegate.navigation.PushViewController (dvc, true);
        }
Esempio n. 13
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()
                });
            });
        }
Esempio n. 14
0
        public Settings(DialogViewController parent)
            : base(UITableViewStyle.Grouped, null)
        {
            this.parent = parent;
            var aboutUrl = NSUrl.FromFilename ("about.html");
            int cellStyle = Util.Defaults.IntForKey ("cellStyle");

            Root = new RootElement (Locale.GetText ("Settings")){
                MakeAccounts (),
                new Section (){
                    new RootElement (Locale.GetText ("Settings")){
                        new Section (Locale.GetText ("Style")){
                            (selfOnRight = new BooleanElement (Locale.GetText ("My tweets on right"), (cellStyle & 1) == 0)),
                            (shadows = new BooleanElement (Locale.GetText ("Avatar shadows"), (cellStyle & 2) == 0)),
                            (autoFav = new BooleanElement (Locale.GetText ("Favorite on Retweet"), Util.Defaults.IntForKey ("disableFavoriteRetweets") == 0)),
                            (compress = new RootElement (Locale.GetText ("Image Compression"), new RadioGroup ("group", Util.Defaults.IntForKey ("sizeCompression"))) {
                                new Section () {
                                    new RadioElement (Locale.GetText ("Maximum")),
                                    new RadioElement (Locale.GetText ("Medium")),
                                    new RadioElement (Locale.GetText ("None"))
                                }
                            })
                        },

                        new Section (Locale.GetText ("Auto Rotate")){
                            (rotateTimeline = new BooleanElement (Locale.GetText ("Timeline"), Util.Defaults.IntForKey ("disableRotateTimeline") == 0)),
                            (rotateComposer = new BooleanElement (Locale.GetText ("Compose Screen"), Util.Defaults.IntForKey ("disableRotateComposer") == 0))
                        },

                        new Section (Locale.GetText ("Inspiration"),
                                     Locale.GetText ("Twitter is best used when you are\n" +
                                     				 "inspired.  I picked music and audio\n" +
                                                     "that should inspire you to create\n" +
                                                     "clever tweets")){
                            (playMusic = new BooleanElement (Locale.GetText ("Music on Composer"), Util.Defaults.IntForKey ("disableMusic") == 0)),
                            (chicken = new BooleanElement (Locale.GetText ("Chicken noises"), Util.Defaults.IntForKey ("disableChickens") == 0)),
                        }
                    },
                    //new RootElement (Locale.GetText ("Services"))
                },

                new Section (){
                    new RootElement (Locale.GetText ("About")){
                        new Section (){
                            new HtmlElement (Locale.GetText ("About and Credits"), aboutUrl),
                            new HtmlElement (Locale.GetText ("Web site"), "http://tirania.org/tweetstation")
                        },
                        new Section (){
                            Twitterista ("migueldeicaza"),
                            Twitterista ("itweetstation"),
                        },
                        new Section (Locale.GetText ("Music")){
                            Twitterista ("kmacleod"),
                        },
                        new Section (Locale.GetText ("Conspirators")) {
                            Twitterista ("JosephHill"),
                            Twitterista ("kangamono"),
                            Twitterista ("lauradeicaza"),
                            Twitterista ("mancha"),
                            Twitterista ("mjhutchinson"),
                        },
                        new Section (Locale.GetText ("Contributors")){
                            Twitterista ("martinbowling"),
                            Twitterista ("conceptdev"),
                        },
                        new Section (Locale.GetText ("Includes X11 code from")) {
                            Twitterista ("escoz"),
                            Twitterista ("praeclarum"),
                        }
                    }
                }
            };
        }
Esempio n. 15
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() };
			});
		}
Esempio n. 16
0
		public CalloutViewCtrl () : base(null)
		{
			this.CentersCheck = new CheckboxElement[Centers.Length];
			for (int i = 0; i < Centers.Length; i++) {
				var tmp = new CheckboxElement (Centers[i]);
				this.CentersCheck [i] = tmp;
			}

			this.FirstName = new EntryElement ("First Name", "Rocky", KeyStore.Get ("FirstName")) {
				TextAlignment = UITextAlignment.Right
			};

			this.LastName = new EntryElement ("Last Name", "D. Bull", KeyStore.Get ("LastName")) {
				TextAlignment = UITextAlignment.Right
			};

			this.Email = new EntryElement ("E-Mail", "*****@*****.**", KeyStore.Get ("Email")) {
				TextAlignment = UITextAlignment.Right,
				KeyboardType = UIKeyboardType.EmailAddress
			};

			OptionGroup = new RadioGroup ("type", 0);
			Callout = new RadioElement ("Call-Out", "type");
			Inlate = new RadioElement ("In Late", "type");

			StartDate = new DateElement ("Out On", DateTime.Today) {
				Alignment = UITextAlignment.Right
			};

			MultipleDays = new BooleanElement ("Out Multiple Days", false);
			EndDate = new DateElement ("Back On", DateTime.Today.AddDays (1)) { Alignment = UITextAlignment.Right };

			WhenInDate = new DateTimeElement ("Will Be In", DateTime.Today.AddHours (12)) { Alignment = UITextAlignment.Right };

			Explaination = new EntryElement ("Explaination", "reasons.", null) { TextAlignment = UITextAlignment.Right };

			Section Name = new Section () { FirstName, LastName, Email };
			Section Options = new Section () { Callout, Inlate };

			Section CalloutDates = new Section () { StartDate, MultipleDays };
			MultipleDays.ValueChanged += (sender, e) => {
				if (MultipleDays.Value) {
					CalloutDates.Add(EndDate);
				} else {
					CalloutDates.Remove(EndDate);
				}
			};

			Section LateDay = new Section () { WhenInDate };
			Callout.Tapped += delegate {
				this.Root.RemoveAt(2);
				this.Root.Insert(2, CalloutDates);
			};

			Inlate.Tapped += delegate {
				this.Root.RemoveAt(2);
				this.Root.Insert(2, LateDay);
			};

			this.Submit = new StringElement ("Submit") { Alignment = UITextAlignment.Center };
			this.Root = new RootElement ("Call-Out", OptionGroup) { 
				Name,
				Options,
				CalloutDates,
				new Section("Centers") {
					this.CentersCheck
				},
				new Section() { Explaination },
				new Section() { Submit }
			};


			this.Submit.Tapped += Submit_Tapped;

			this.NavigationItem.LeftBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Cancel, delegate {
				this.NavigationController.PopViewController(true);	
			});
		}
        public Pubnub_MessagingMain () : base (UITableViewStyle.Grouped, null)
        {
            UIView labelView = new UIView (new CGRect (0, 0, this.View.Bounds.Width, 24));
            int left = 20;
            string hardwareVer = DeviceHardware.Version.ToString ().ToLower ();
            if (hardwareVer.IndexOf ("ipad") >= 0) {
                left = 55;
            }

            labelView.AddSubview (new UILabel (new CGRect (left, 10, this.View.Bounds.Width - left, 24)) {
                Font = UIFont.BoldSystemFontOfSize (16),
                BackgroundColor = UIColor.Clear,
                TextColor = UIColor.FromRGB (76, 86, 108),
                Text = "Basic Settings"
            });

            var headerMultipleChannels = new UILabel (new CGRect (0, 0, this.View.Bounds.Width, 30)) {
                Font = UIFont.SystemFontOfSize (12),
                TextColor = UIColor.Brown,
                BackgroundColor = UIColor.Clear,
                LineBreakMode = UILineBreakMode.WordWrap,
                Lines = 0,
                TextAlignment = UITextAlignment.Center
            };
            headerMultipleChannels.Text = "Enter multiple channel/channelgroup names separated by comma";

            EntryElement entrySubscribeKey = new EntryElement ("Subscribe Key", "Enter Subscribe Key", "demo");
            entrySubscribeKey.AutocapitalizationType = UITextAutocapitalizationType.None;
            entrySubscribeKey.AutocorrectionType = UITextAutocorrectionType.No;

            EntryElement entryPublishKey = new EntryElement ("Publish Key", "Enter Publish Key", "demo");
            entryPublishKey.AutocapitalizationType = UITextAutocapitalizationType.None;
            entryPublishKey.AutocorrectionType = UITextAutocorrectionType.No;

            EntryElement entrySecretKey = new EntryElement ("Secret Key", "Enter Secret Key", "demo");
            entrySecretKey.AutocapitalizationType = UITextAutocapitalizationType.None;
            entrySecretKey.AutocorrectionType = UITextAutocorrectionType.No;

            EntryElement entryChannelName = new EntryElement ("Channel(s)", "Enter Channel Name", "");
            entryChannelName.AutocapitalizationType = UITextAutocapitalizationType.None;
            entryChannelName.AutocorrectionType = UITextAutocorrectionType.No;

            EntryElement entryChannelGroupName = new EntryElement ("ChannelGroup(s)", "Enter ChannelGroup Name", "");
            entryChannelGroupName.AutocapitalizationType = UITextAutocapitalizationType.None;
            entryChannelGroupName.AutocorrectionType = UITextAutocorrectionType.No;

            EntryElement entryCipher = new EntryElement ("Cipher", "Enter Cipher", "");
            entryCipher.AutocapitalizationType = UITextAutocapitalizationType.None;
            entryCipher.AutocorrectionType = UITextAutocorrectionType.No;

            EntryElement entryProxyServer = new EntryElement ("Server", "Enter Server", "");
            entryProxyServer.AutocapitalizationType = UITextAutocapitalizationType.None;
            entryProxyServer.AutocorrectionType = UITextAutocorrectionType.No;

            EntryElement entryProxyPort = new EntryElement ("Port", "Enter Port", "");

            EntryElement entryProxyUser = new EntryElement ("Username", "Enter Username", "");
            entryProxyUser.AutocapitalizationType = UITextAutocapitalizationType.None;
            entryProxyUser.AutocorrectionType = UITextAutocorrectionType.No;

            EntryElement entryProxyPassword = new EntryElement ("Password", "Enter Password", "", true);

            EntryElement entryCustonUuid = new EntryElement ("CustomUuid", "Enter Custom UUID", "");
            entryCustonUuid.AutocapitalizationType = UITextAutocapitalizationType.None;
            entryCustonUuid.AutocorrectionType = UITextAutocorrectionType.No;

            BooleanElement proxyEnabled = new BooleanElement ("Proxy", false);

            BooleanElement sslEnabled = new BooleanElement ("Enable SSL", true);
            Root = new RootElement ("Pubnub Messaging") {
                new Section (labelView) {
                },
                new Section (headerMultipleChannels) {
                },
                new Section ("Enter Subscribe Key.") {
                    entrySubscribeKey
                },
                new Section ("Enter Publish key.") {
                    entryPublishKey
                },
                new Section ("Enter Secret key.") {
                    entrySecretKey
                },
                new Section () {
                    entryChannelName,
                    sslEnabled
                },
                new Section(){
                    entryChannelGroupName
                },
                new Section ("Enter cipher key for encryption. Leave blank for unencrypted transfer.") {
                    entryCipher
                },
                new Section ("Enter custom UUID or leave blank to use the default UUID") {
                    entryCustonUuid
                },
                new Section () {
                    new RootElement ("Proxy Settings", 0, 0) {
                        new Section () {
                            proxyEnabled
                        },
                        new Section ("Configuration") {
                            entryProxyServer,
                            entryProxyPort,
                            entryProxyUser,
                            entryProxyPassword
                        },
                    }
                },
                new Section () {
                    new StyledStringElement ("Launch Example", () => {
                        bool errorFree = true;
                        errorFree = ValidateAndInitPubnub (entryChannelName.Value, entryChannelGroupName.Value, entryCipher.Value, sslEnabled.Value, 
                            entryCustonUuid.Value, proxyEnabled.Value, entryProxyPort.Value,
                            entryProxyUser.Value, entryProxyServer.Value, entryProxyPassword.Value, 
                            entrySubscribeKey.Value, entryPublishKey.Value, entrySecretKey.Value
                        );

                        if (errorFree) {
                            new Pubnub_MessagingSub (entryChannelName.Value, entryChannelGroupName.Value, entryCipher.Value, sslEnabled.Value, pubnub);
                        }
                    }) {
                        BackgroundColor = UIColor.Blue,
                        TextColor = UIColor.White,
                        Alignment = UITextAlignment.Center
                    },
                },
                /*new Section()
                {
                    new StyledStringElement ("Launch Speed Test", () => {
                        bool errorFree = true;
                        errorFree = ValidateAndInitPubnub(entryChannelName.Value, entryCipher.Value, sslEnabled.Value, 
                                                          entryCustonUuid.Value, proxyEnabled.Value, entryProxyPort.Value,
                                                          entryProxyUser.Value, entryProxyServer.Value, entryProxyPassword.Value
                                                          );
                        
                        if(errorFree)
                        {
                            new Pubnub_MessagingSpeedTest(entryChannelName.Value, entryCipher.Value, sslEnabled.Value, pubnub);
                        }
                    })
                    {
                        BackgroundColor = UIColor.Blue,
                        TextColor = UIColor.White,
                        Alignment = UITextAlignment.Center
                    },
                }*/
            };
        }
		private void buildMediaCaptureSettingsElements()
		{
			audioCaptureEnabledElement = new BooleanElement("Record Audio", settings.AudioCaptureEnabled );
			audioCaptureEnabledElement.ValueChanged += delegate 
			{
				EnforceDependencies();	
			};
			videoCaptureEnabledElement = new BooleanElement("Record Video", settings.VideoCaptureEnabled );
			videoCaptureEnabledElement.ValueChanged += delegate 
			{
				EnforceDependencies();	
			};
			autoRecordNextMovieElement = new BooleanElement("Loop Recordings", settings.AutoRecordNextMovie );
			
			// duration choices
			noLimitElement = new RadioElement("Unlimited");
			oneMinuteLimitElement = new RadioElement("1 Minute");
			fiveMinuteLimitElement = new RadioElement("5 Minutes");
			tenMinuteLimitElement = new RadioElement("10 Minutes");
			thirtyMinuteLimitElement = new RadioElement("30 Minutes");
			int index = 0;
			int duration = settings.MaxMovieDurationInSeconds;
			if ( duration <= 0 )         { index = 0; }
			else if ( duration <= 60 )   { index = 1; }
			else if ( duration <= 300 )  { index = 2; }
			else if ( duration <= 600 )  { index = 3; }
			else if ( duration <= 1800 ) { index = 4; }
			
			durationLimitGroup = new RadioGroup("DurationGroup", index );
			durationElement = new RootElement("Maximum Time", durationLimitGroup )
			{
				new Section()
				{
					noLimitElement,
					oneMinuteLimitElement,
					fiveMinuteLimitElement,
					tenMinuteLimitElement,
					thirtyMinuteLimitElement
				}
			};
		}
Esempio n. 19
0
 public override void PrepareForReuse()
 {
     base.PrepareForReuse();
     _element = null;
 }
Esempio n. 20
0
		void Populate (object callbacks, object o, RootElement root)
		{
			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);
				foreach (var attr in attrs){
					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 (caption == null)
					caption = MakeCaption (mi.Name);
				
				if (section == null)
					section = new Section ();
				
				Element element = null;
				if (mType == typeof (string)){
					PasswordAttribute pa = null;
					EntryAttribute ea = 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;
						
						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);
					else if (multi)
						element = new MultilineElement (caption, value);
					else
						element = new StringElement (caption, value);
					
					if (invoke != null)
						((StringElement) element).Tapped += invoke;
				} else if (mType == typeof (float)){
					var floatElement = new FloatElement (null, null, (float) GetValue (mi, o));
					element = floatElement;
					
					foreach (object attr in attrs){
						if (attr is RangeAttribute){
							var ra = attr as RangeAttribute;
							floatElement.MinValue = ra.Low;
							floatElement.MaxValue = ra.High;
						}
					}
				} 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;
						
						csection.Add (new RadioElement (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 {
					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);
		}
Esempio n. 21
0
		void Populate (object callbacks, object o, RootElement root)
		{
			MemberInfo last_radio_index = null;
			
			BindingFlags flags = BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance;
			if (Attribute.GetCustomAttribute(o.GetType (), typeof(SkipNonPublicAttribute)) == null)
				flags |= BindingFlags.NonPublic;
			var members = o.GetType ().GetMembers (flags);

			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)
						skip = true;
					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 };
					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;
						
						csection.Add (new RadioElement (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);
		}
        Section CreateAircraftTypeSection()
        {
            Section section = new Section ("Type of Aircraft") {
                (category = CreateCategoryElement (Aircraft.Category)),
                (classification = CreateClassificationElement (Aircraft.Category)),
                (isComplex = new BooleanElement ("Complex", Aircraft.IsComplex)),
                (isHighPerformance = new BooleanElement ("High Performance", Aircraft.IsHighPerformance)),
                (isTailDragger = new BooleanElement ("Tail Dragger", Aircraft.IsTailDragger)),
                (isSimulator = new BooleanElement ("Simulator", Aircraft.IsSimulator)),
            };

            classification.RadioSelected = ClassificationToIndex (Aircraft.Classification);

            return section;
        }
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();

            if(id > 0)
            {
                BTProgressHUD.Show("Loading...");
                await viewModel.Init(id);
                BTProgressHUD.Dismiss();
            }

            var delete = UIButton.FromType(UIButtonType.RoundedRect);
            delete.SetTitle("Delete", UIControlState.Normal);
            delete.Frame = new System.Drawing.RectangleF(0, 0, 320, 44);
            delete.TouchUpInside += async (sender, e) => 
            {
                await viewModel.ExecuteDeleteMovieCommand(viewModel.Id);
                NavigationController.PopToRootViewController(true);
            };

            var save = UIButton.FromType(UIButtonType.RoundedRect);
            save.SetTitle("Save", UIControlState.Normal);
            save.Frame = new System.Drawing.RectangleF(0, 0, 320, 44);
            save.TouchUpInside += async (sender, e) => 
            {
                viewModel.IsFavorite = isFavorite.Value;
                await viewModel.ExecuteSaveMovieCommand();
                NavigationController.PopToRootViewController(true);
            };

            this.Root = new RootElement(viewModel.Title)
            {
                new Section("Movie Details")
                {
                    (title = new StringElement("Title")),
                    (imdbId = new HtmlElement("Imdb", string.Empty)),
                    (runtime = new StringElement("Runtime")),
                    (releaseDate = new StringElement("Release Date")),
                    (isFavorite = new BooleanElement("Favorite?", false)),
                },
                new Section()
                {
                    delete,
                    save
                }
            };

                      
            title.Value = viewModel.Title;
            imdbId.Url = string.Format("http://m.imdb.com/title/{0}", viewModel.ImdbId);
            runtime.Value = viewModel.Runtime.ToString();
            releaseDate.Value = viewModel.ReleaseDate.ToShortDateString();
            isFavorite.Value = viewModel.IsFavorite;

            this.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Camera, async delegate
            {
                var picker = new Xamarin.Media.MediaPicker();
                if (picker.PhotosSupported)
                {
                    try
                    {
                        MediaFile file = await picker.PickPhotoAsync();
                        if (file != null)
                        {
                            viewModel.Image = file.GetStream();
                            await viewModel.ExecuteSaveMovieCommand();
                            NavigationController.PopToRootViewController(true);
                        }
                    }
                    catch { }
                }
            });
        }
Esempio n. 24
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);
        }
Esempio n. 25
0
        void ShowAlertType2 (CommonDialogStates cds)
        {
            bool isPresenceGrant = false;
            bool showEntryText = true;
            bool showEntryText2 = false;
            bool boolval1 = false;
            UIKeyboardType keyboardType = UIKeyboardType.Default;

            string strHead = "", elementText1 = "", elementText2 = "", 
            elementText3 = "", elementSubText = "", buttonTitle = "", elementText4 = "", elementSubText2 = "";
            if (cds == CommonDialogStates.PresenceGrant) {
                strHead = "Presence Grant";
                elementText1 = "Read";
                elementText2 = "Write";
                elementText3 = "TTL";
                elementSubText = "Enter TTL (default 1440)";
                elementText4 = "Auth key";
                elementSubText2 = "optional";
                buttonTitle = "Grant";
                keyboardType = UIKeyboardType.NumberPad;
                isPresenceGrant = true;
                showEntryText2 = true;
            } else if (cds == CommonDialogStates.SubscribeGrant) {
                elementText1 = "Read";
                elementText2 = "Write";
                elementText3 = "TTL";
                elementSubText = "Enter TTL (default 1440)";
                elementText4 = "Auth key";
                elementSubText2 = "optional";
                strHead = "Subscribe Grant";
                buttonTitle = "Grant";
                keyboardType = UIKeyboardType.NumberPad;
                showEntryText2 = true;
            } else if (cds == CommonDialogStates.HereNow) {
                elementText1 = "Show UUID";
                elementText2 = "Include User State";
                elementText3 = "Channel";
                elementSubText = "Enter channel name";
                strHead = "Here now";
                buttonTitle = "Here Now";

                boolval1 = true;
            } else if (cds == CommonDialogStates.GlobalHereNow) {
                elementText1 = "Show UUID";
                elementText2 = "Include User State";
                strHead = "Global Here Now";
                buttonTitle = "Global Here Now";
                showEntryText = false;
                boolval1 = true;
            }

            BooleanElement be1 = new BooleanElement (elementText1, boolval1);
            BooleanElement be2 = new BooleanElement (elementText2, false);

            EntryElement entryText = null;
            EntryElement entryText2 = null;

            if (showEntryText) {
                entryText = new EntryElement (elementText3, elementSubText, "");
                entryText.KeyboardType = keyboardType;
                entryText.AutocapitalizationType = UITextAutocapitalizationType.None;
                entryText.AutocorrectionType = UITextAutocorrectionType.No;
            }
            if (showEntryText2) {
                entryText2 = new EntryElement (elementText4, elementSubText2, "");
                entryText2.AutocapitalizationType = UITextAutocapitalizationType.None;
                entryText2.AutocorrectionType = UITextAutocorrectionType.No;
            }

            var newroot = new RootElement (strHead, 0, 0) {
                new Section () {
                    be1,
                    be2,
                    entryText2,
                    entryText
                },
                new Section ("") {
                    new StyledStringElement (buttonTitle, () => {
                        if ((cds == CommonDialogStates.PresenceGrant) || (cds == CommonDialogStates.SubscribeGrant)) {
                            int iTtl;
                            Int32.TryParse (entryText.Value, out iTtl);
                            if (iTtl == 0) {
                                iTtl = 1440;
                                entryText.Value = "1440";
                            }
                            if (isPresenceGrant) {
                                Display ("Running Presence Grant");
                                pubnub.GrantPresenceAccess<string> (Channel, entryText2.Value, be1.Value, be2.Value, iTtl, DisplayReturnMessage, DisplayErrorMessage);
                            } else {
                                Display ("Running Subscribe Grant");
                                pubnub.GrantAccess<string> (Channel, entryText2.Value, be1.Value, be2.Value, iTtl, DisplayReturnMessage, DisplayErrorMessage);
                            }
                        } else if (cds == CommonDialogStates.HereNow) {
                            Display ("Running Here Now");
                            if(entryText.Value.Trim() != ""){
                                string[] channels = entryText.Value.Split (',');//Channel.Split (',');
                                foreach (string channel in channels) {
                                    pubnub.HereNow<string> (channel.Trim (), be1.Value, be2.Value, DisplayReturnMessage, DisplayErrorMessage);
                                }
                            } else {
                                Display ("Channel empty");
                            }
                        } else if (cds == CommonDialogStates.GlobalHereNow) {
                            pubnub.GlobalHereNow<string> (be1.Value, be2.Value, DisplayReturnMessage, DisplayErrorMessage);
                        }

                        AppDelegate.navigation.PopViewControllerAnimated (true);
                    }) {
                        BackgroundColor = UIColor.Blue,
                        TextColor = UIColor.White,
                        Alignment = UITextAlignment.Center
                    },
                },
            };
            dvc = new DialogViewController (newroot, true);
            AppDelegate.navigation.PushViewController (dvc, true);
        }
		private void buildImageCaptureSettingsElements()
		{
			imageCaptureEnabledElement = new BooleanElement("Capture", settings.ImageCaptureEnabled );
			imageCaptureEnabledElement.ValueChanged += delegate 
			{
				EnforceDependencies();
			};
			
			dontSaveImagesElement = new RadioElement("Don't Save");
			saveImagesToPhotoLibraryElement = new RadioElement("Photo Library");
			saveImagesToMyDocumentsElement = new RadioElement("My Documents");
			
			int index = 0;
			if ( settings.SaveCapturedImagesToPhotoLibrary )
			{
				index = 1;
			}
			else if ( settings.SaveCapturedImagesToMyDocuments )
			{
				index = 2;
			}
			saveImageGroup = new RadioGroup("SaveImagesGroup", index );
			saveImageElement = new RootElement("Save To", saveImageGroup )
			{
				new Section()
				{
					dontSaveImagesElement,
					saveImagesToPhotoLibraryElement,
					saveImagesToMyDocumentsElement
				}
			};
		}
Esempio n. 27
0
		public Pubnub_MessagingMain () : base (UITableViewStyle.Grouped, null)
		{
			PubnubProxy proxy =  null;
			Pubnub pubnub = null;

			EntryElement entryChannelName = new EntryElement("Channel Name", "Enter Channel Name", "");
			EntryElement entryCipher = new EntryElement("Cipher", "Enter Cipher", "");

			EntryElement entryProxyServer = new EntryElement("Server", "Enter Server", "");
			EntryElement entryProxyPort = new EntryElement("Port", "Enter Port", "");

			EntryElement entryProxyUser = new EntryElement("Username", "Enter Username", "");
			EntryElement entryProxyPassword = new EntryElement("Password", "Enter Password", "", true);

			BooleanElement proxyEnabled = new BooleanElement ("Proxy", false);

			BooleanElement sslEnabled = new BooleanElement ("Enable SSL", false);
			Root = new RootElement ("Pubnub Messaging") {
				new Section ("Basic Settings")
				{
					entryChannelName,
					sslEnabled
				},
				new Section ("Enter cipher key for encryption. Leave blank for unencrypted transfer.")
				{
					entryCipher
				},
				new Section()
				{
					new RootElement ("Proxy Settings", 0, 0){
						new Section (){
							proxyEnabled
						},
						new Section ("Configuration"){
							entryProxyServer,
							entryProxyPort,
							entryProxyUser,
							entryProxyPassword
						},
					}
				},
				new Section()
				{
					new StyledStringElement ("Launch", () => {
						bool errorFree = true;
						if(String.IsNullOrWhiteSpace (entryChannelName.Value.Trim()))
						{
							errorFree = false;
							new UIAlertView ("Error!", "Please enter a channel name", null, "OK").Show (); 
						}

						if(errorFree)
						{
							pubnub = new Pubnub ("demo", "demo", "", entryCipher.Value, sslEnabled.Value);
						}

						if ((errorFree) && (proxyEnabled.Value))
						{
							int port;
							if(Int32.TryParse(entryProxyPort.Value, out port) && ((port >= 1) && (port <= 65535))) 
							{
								proxy = new PubnubProxy();
								proxy.ProxyServer = entryProxyServer.Value;
								proxy.ProxyPort = port;
								proxy.ProxyUserName = entryProxyUser.Value;
								proxy.ProxyPassword = entryProxyPassword.Value;

								try
								{
									pubnub.Proxy = proxy;
								}
								catch (MissingFieldException mse)
								{
									errorFree = false;
									proxyEnabled.Value = false;
									Console.WriteLine(mse.Message);
									new UIAlertView ("Error!", "Proxy settings invalid, please re-enter the details.", null, "OK").Show (); 
								}
							}
							else
							{
								errorFree = false;
								new UIAlertView ("Error!", "Proxy port must be a valid integer between 1 to 65535", null, "OK").Show (); 
							}
						}

						if(errorFree)
						{
							new Pubnub_MessagingSub(entryChannelName.Value, entryCipher.Value, sslEnabled.Value, pubnub);
						}
					})
					{
						BackgroundColor = UIColor.Blue,
						TextColor = UIColor.White,
						Alignment = UITextAlignment.Center
					},
				}
			};
		}
 Section CreateInstrumentSection()
 {
     return new Section ("Instrument Experience") {
         (actual = new HobbsMeterEntryElement ("Actual Time", "Time spent flying by instrumentation only.", Flight.InstrumentActual)),
         (hood = new HobbsMeterEntryElement ("Hood Time", "Time spent flying under a hood.", Flight.InstrumentHood)),
         (simulator = new HobbsMeterEntryElement ("Simulator Time", "Time spent practicing in a simulator.", Flight.InstrumentSimulator)),
         (approaches = new NumericEntryElement ("Approaches", "The number of approaches made.", Flight.InstrumentApproaches, 1, 99)),
         (actingSafety = new BooleanElement ("Acting Safety Pilot", false)),
         (safetyPilot = new LimitedEntryElement ("Safety Pilot", "The name of your safety pilot.", 40)),
     };
 }
        private void BuildButtons()
        {
            var sec = new Section ("");
            var btnSend = new StyledStringElement ("Send to Office");
            btnSend.TextColor = ColorHelper.GetGPLightPurple ();
            var switchNotify = new BooleanElement ("Notify?", true);
            btnSend.Tapped += delegate {
                //test
                if (isBusy) {
                    Busy ();
                    return;
                }
                if (selectedUser == null) {
                    new UIAlertView ("Fee Earner", "Please select a Fee Earner", null, "OK").Show ();
                    return;
                }
                var task = new TaskDTO ();
                DateTime dt = picker.Date;
                DateTime now = DateTime.Now;
                Console.WriteLine ("### Task Due Date picked: " + dt.ToLongDateString ());
                Console.WriteLine ("### Today is: " + now.ToLongDateString ());

                task.dueDate = Tools.ConvertDateTimeToJavaMS (dt);
                task.matterID = matter.matterID;
                task.userID = selectedUser.userID;
                task.taskDescription = narration.Value;
                if (switchNotify.Value == true) {
                    task.notifyWhenComplete = true;
                } else {
                    task.notifyWhenComplete = false;
                }

                if (narration.Value.Trim () == "") {
                    new UIAlertView ("Description", "Please enter Task description", null, "OK").Show ();
                    return;
                }
                sendAssignTaskRequest (task);

            };

            btnSend.Alignment = UITextAlignment.Center;
            sec.Add (switchNotify);
            sec.Add (btnSend);

            Root.Add (sec);
        }
        public SampleGoalBrowsingDialog()
        {
            this.Style = UIKit.UITableViewStyle.Grouped;
            var sampleDataModel = new DataModel(new JSONDataProvider(new BundlePathProvider()), false); ;
            this.samples = sampleDataModel.checkPoints.Values.ToList();

            this.Root = new RootElement("Add a Goal");
            this.Root.Add(
                new Section("Custom Goal:", "Create a custom goal with a name, target time, abbreviation, and more.")
                    {
                new StyledStringElement("Write your own...",()=>ShowCustomAddDialog()){Accessory=UIKit.UITableViewCellAccessory.DisclosureIndicator}
            });

            var categoryEmoji = new Dictionary<string, string>()
            {
                {"nutrition","\U0001F37D"},//U0001F37D
                {"wellness",EmojiSharp.Emoji.PERSON_WITH_FOLDED_HANDS.Unified},
                {"chores",EmojiSharp.Emoji.TOILET.Unified},
                {"health",EmojiSharp.Emoji.HEAVY_BLACK_HEART.Unified},//U+1F6E1
                {"work",EmojiSharp.Emoji.BRIEFCASE.Unified}
            };

            var byCategory = from goal in samples
                             where !string.IsNullOrEmpty(goal.Category)
                             orderby goal.TargetTime
                             group goal by goal.Category into bycat
                             orderby bycat.Key
                             select bycat;

            var categorySection = new Section("Browse Examples:",
             "After choosing an example, you can customize your goal by editing the name, abbreviation, and target time.  After you save your goal, you can specify alternative targets for different days of the week.");

            Func<CheckPoint,StringElement> goalToElement = (g) =>
            {
                var label = string.Format("{1} {0}", g.Name, g.Emoji);
                var e = new StringElement(label,g.TargetTime.ToAMPMString());
                e.Tapped += () => ShowCustomAddDialog(g);
                return e;
            };

            foreach (var category in byCategory)
            {
                var key = category.Key.ToLower();
                var categoryLabel = categoryEmoji.ContainsKey(key) ?
                                                 categoryEmoji[key] + " " + category.Key :
                                                 category.Key;
                var subRoot = new RootElement(categoryLabel);
                var catsec = new Section("example goals for " + category.Key);

                catsec.AddAll(category.Select(g =>goalToElement(g)));
                subRoot.Add(catsec);
                categorySection.Add(subRoot);
            }
            this.Root.Add(categorySection);

            var optionsSection = new Section("Option:","Go straight to the custom goal page, instead of showing examples.");

            var opt = new BooleanElement("Next time, Skip this screen.", ClockKingOptions.ShowExampleBrowser);
            opt.ValueChanged += (s,e) =>
            {
                if (ClockKingOptions.ShowExampleBrowser != opt.Value)
                {
                    ClockKingOptions.ShowExampleBrowser = opt.Value;
                }
            };

            optionsSection.Add(opt);

            this.Root.Add(optionsSection);
        }
Esempio n. 31
0
		private RootElement CreateRoot ()
		{
			Description = new MyEntryElement ("title", null, false, UIReturnKeyType.Default);
			FirstComment = new MyEntryElement ("first comment", null, false, UIReturnKeyType.Default);
			
			if (eventImage != null)
			{
				return new RootElement ("post") {
					new Section () {  Description, },
					new Section() { FirstComment, }
				};
			}
			else
			{
				createAlbumCbx = new BooleanElement (Locale.GetText ("create album"), false);
				createAlbumCbx.ValueChanged += (sender, e) => 
				{
					postOptions = createAlbumCbx.Value ? PostOptions.CreateAlbum : PostOptions.PostNew;
				};
				return new RootElement ("post") {
					new Section () {  Description, },
					new Section() { FirstComment, },
					new Section() { createAlbumCbx }
				};
			}
		}
Esempio n. 32
0
        private void BuildHeaderLabel()
        {
            string s = "Post Fee";
            if (isUnbillable) {
                s = "Post Unbillable Fee";
            }

            headerLabel = new UILabel (new RectangleF (10, 10, 480, 40)) {
                Font = UIFont.BoldSystemFontOfSize (20),
                BackgroundColor = ColorHelper.GetGPPurple (),
                TextAlignment = UITextAlignment.Center,
                TextColor = UIColor.White,
                Text = s
            };
            var view = new UIViewBordered ();
            view.Frame = new RectangleF (10, 10, 480, 40);
            view.Add (headerLabel);
            var topSection = new Section (view);

            Root.Add (topSection);
            String name = "";
            if (matter != null) {
                name = matter.matterName;
            }
            var sec = new Section (name);
            var timeBased = new BooleanElement (S.GetText (S.TIME_BASED_ACTIVITY), isTimeBased);

            timeBased.ValueChanged += delegate {
                if (isBusy) {
                    Busy ();
                    return;
                }
                selectedTariff = null;
                feeAmount.Value = null;
                if (timeBased.Value == true) {
                    isTimeBased = true;
                    if (IsTariffCacheFilled ()) {
                        RefreshFromCache ();
                        BuildInterface ();
                    } else {
                        GetTariffCodes (100, DataUtil.TARIFF_CODE_TYPE_FEES);
                    }

                } else {
                    isTimeBased = false;
                    if (IsTariffCacheFilled ()) {
                        RefreshFromCache ();
                        BuildInterface ();
                    } else {
                        GetTariffCodes (0, DataUtil.TARIFF_CODE_TYPE_FEES);
                    }
                }
            };
            sec.Add (timeBased);
            Root.Add (sec);
        }
        public SettingsController()
            : base(new RootElement ("Settings"), true)
        {
            Settings = Settings.Instance;

            var section = new Section ();
            Root.Add (section);

            var showListening = new BooleanElement ("Show listening sockets", Settings.ShowListening);
            showListening.ValueChanged += (sender, e) => {
                Settings.ShowListening = showListening.Value;
            };
            section.Add (showListening);

            var showLocal = new BooleanElement ("Show local connections", Settings.ShowLocal);
            showLocal.ValueChanged += (sender, e) => {
                Settings.ShowLocal = showLocal.Value;
            };
            section.Add (showLocal);

            var autoRefresh = new BooleanElement ("Auto refresh", Settings.AutoRefresh);
            autoRefresh.ValueChanged += (sender, e) => {
                Settings.AutoRefresh = autoRefresh.Value;
            };
            section.Add (autoRefresh);

            var filterSection = new Section ();
            Root.Add (filterSection);

            var usePortFilter = new BooleanElement ("Use Port filter", Settings.UsePortFilter);
            usePortFilter.ValueChanged += (sender, e) => {
                Settings.UsePortFilter = usePortFilter.Value;
            };
            filterSection.Add (usePortFilter);

            var portFilter = new EntryElement ("Port filter", "<port>", Settings.PortFilter.ToString ());
            portFilter.Changed += (sender, e) => {
                int port;
                if (!int.TryParse (portFilter.Value, out port))
                    portFilter.Value = Settings.PortFilter.ToString ();
                else
                    Settings.PortFilter = port;
            };
            filterSection.Add (portFilter);

            var spSection = new Section ();
            Root.Add (spSection);

            var connectionLimit = new EntryElement ("Connection limit", "<number>", Settings.ConnectionLimit.ToString ());
            connectionLimit.Changed += (sender, e) => {
                int value;
                if (!int.TryParse (connectionLimit.Value, out value))
                    connectionLimit.Value = Settings.ConnectionLimit.ToString ();
                else
                    Settings.ConnectionLimit = value;
            };
            spSection.Add (connectionLimit);

            var spIdle = new EntryElement ("SP idle time", "<idle-time>", Settings.ServicePointIdleTime.ToString ());
            spIdle.Changed += (sender, e) => {
                int value;
                if (!int.TryParse (spIdle.Value, out value))
                    spIdle.Value = Settings.ServicePointIdleTime.ToString ();
                else
                    Settings.ServicePointIdleTime = value;
            };
            spSection.Add (spIdle);

            Settings.Modified += (sender, e) => InvokeOnMainThread (() => {
                var newPfValue = Settings.PortFilter.ToString ();
                if (!string.Equals (portFilter.Value, newPfValue)) {
                    portFilter.Value = newPfValue;
                    Root.Reload (portFilter, UITableViewRowAnimation.Automatic);
                }

                if (usePortFilter.Value != Settings.UsePortFilter) {
                    usePortFilter.Value = Settings.UsePortFilter;
                    Root.Reload (usePortFilter, UITableViewRowAnimation.Automatic);
                }
            });
        }