Inheritance: Element, IElementSizing
		private void TogglePicker(DialogViewController dvc, UITableView tableView, NSIndexPath path)
		{
			var sectionAndIndex = GetMySectionAndIndex(dvc);
			if(sectionAndIndex.Key != null)
			{
				Section section = sectionAndIndex.Key;
				int index = sectionAndIndex.Value;

				var cell = tableView.CellAt(path);

				if(isPickerPresent)
				{
					// Remove the picker.
					cell.DetailTextLabel.TextColor = UIColor.Gray;
					section.Remove(datePickerContainer);
					isPickerPresent = false;
				} 
				else
				{
					// Show the picker.
					cell.DetailTextLabel.TextColor = UIColor.Red;
					datePickerContainer = new UIViewElement(string.Empty, datePicker, false);
					section.Insert(index + 1, UITableViewRowAnimation.Bottom, datePickerContainer);
					isPickerPresent = true;
				}
			}
		}
        public AddHistoricInstanceDialog(iCheckpointCommandController checkPoints, RootElement root, CheckPoint checkpoint, bool pushing)
            : base()
        {
            this.Root = root;
            this.CheckPoints = checkPoints;
            this.checkPoint = checkpoint;

            this.picker = new UIDatePicker (){ Mode = UIDatePickerMode.DateAndTime };
            this.picker.MaximumDate = DateTime.UtcNow.ToNSDate();

            var pickerElement = new UIViewElement (string.Empty, this.picker, false);

            this.picker.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;

            this.nowSwitch = new BooleanElement ("Reset to now:", true);

            picker.ValueChanged += (s, e) => nowSwitch.Value=false;

            nowSwitch.ValueChanged += (s, e) => {
                if (nowSwitch.Value)
                    this.picker.Date = DateTime.UtcNow.ToNSDate ();
            };

            this.Root.Add(new CheckPointCellSection(this.checkPoint));

            this.Root.Add (new Section ("Completed on:")
                {
                    new MultilineElement("Specify the time of completion:"),
                    pickerElement,
                    nowSwitch});

            this.NavigationItem.SetRightBarButtonItem (new UIBarButtonItem (UIBarButtonSystemItem.Save,(s,e)=>this.Save()),true);
        }
Example #3
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);
        }
Example #4
0
        public MonthView()
            : base()
        {
            this.occurrencesByDate = PopulateOccurrences();

            this.Root = new RootElement("History");
            this.calendar = CreateCalendar();
            this.Occurrences = new Section("Completions");
            this.MissedGoals = new Section("Missed Goals");

            var c = new UIViewElement("", this.calendar, false);

            Root.Add(new Section("") { c });
            Root.Add(Occurrences);
            Root.Add(MissedGoals);
        }
		public void DemoInsets ()
		{
			var uiView = new UIViewElement ("", new UIView (new RectangleF (0, 0, 20, 20)){
				BackgroundColor = UIColor.Red
			}, false);
			
			var root = new RootElement ("UIViewElement Inset"){
				new Section ("Simple Rectangle"){
					uiView,
					new StringElement ("Pad Left", delegate { var i = uiView.Insets; i.Left += 10; uiView.Insets = i; }),
					new StringElement ("Pad Top", delegate { var i = uiView.Insets; i.Top += 10; uiView.Insets = i; }),
					new StringElement ("Pad Bottom", delegate { var i = uiView.Insets; i.Bottom += 10; uiView.Insets = i; })
				}
			};
						
			var dv = new DialogViewController (root, true);
			navigation.PushViewController (dv, true);				
		}
        public ContactViewController()
            : base(UITableViewStyle.Grouped, null, true)
        {
            ContactEntry = new EntryElement ("姓名", PromptString, String.Empty);
            PhoneEntry = new EntryElement ("電話", PromptString, String.Empty) {
                KeyboardType = UIKeyboardType.PhonePad
            };
            EmailEntry = new EntryElement ("Email", PromptString, String.Empty) {
                KeyboardType = UIKeyboardType.EmailAddress
            };
            AddressEntry = new EntryElement ("地址", PromptString, String.Empty);

            RectangleF Rect;

            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
                Rect = new RectangleF (10, 10, 300, 400);
            else
                Rect = new RectangleF (9, 9, 750, 1000);

            Photo = new UIImageView (Rect);
            PhotoEntry = new UIViewElement ("照片", Photo, true);

            Root = new RootElement ("詳細") {
                new Section ("聯絡人") {
                    ContactEntry,
                    PhoneEntry,
                    EmailEntry,
                    AddressEntry,
                },
                new Section("照片") {
                    PhotoEntry,
                },
            };

            NavigationItem.RightBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Action);

            OpenDatastore ();

            if (FieldsOfRecord == null) {
                FieldsOfRecord = new NSDictionary(KeyForName, "", KeyForPhone, "", KeyForEmail, "", KeyForAddress, "");
            }
        }
Example #7
0
		private void DownloadAsync()
		{
			try
			{
				if (!hasImage)
				{
					var imgElement = new UIImageView(Graphics.GetImgResource("messagenoposts"));
					imgElement.Frame = new System.Drawing.RectangleF(5, 5, 310, imgElement.Bounds.Height);
					var viewEl = new UIViewElement(null, imgElement, true);
					
					Root[0].Add(viewEl);
					ReloadComplete();
					return;
				}
				
				for (int i = 0; i < 7; i++) {
					Root[0].Add (new PhotosElement (this, i));
				}
				if (ShowLoadMorePhotos)
				{
					CustomLoadMoreElement more = null;
					more = new CustomLoadMoreElement (delegate 
						{					
							var wait = new ManualResetEventSlim(false);					
							AppDelegateIPhone.ShowRealLoading("Loading more photos", null, wait);
							
							// Launch a thread to do some work
							ThreadPool.QueueUserWorkItem (delegate 
							{
								AddMorePhotoElements(more, wait);
							});
						});
						
					more.Height = 60;
					more.Image = Graphics.GetImgResource("more");
					
					try {
						Root[0].Insert (Root[0].Count, UITableViewRowAnimation.None, more);
					}  catch { }
				}
			}
			catch (Exception ex)
			{
				Util.LogException("DownloadAsync", ex);
			}
		}
Example #8
0
		private void CreateTweetView(string tweet)
		{
			var boxWidth = View.Bounds.Width - 30 - PadX * 2;
			var tweetRect = new RectangleF (PadX, 0, boxWidth, 100);
						
			var tweetView = new TweetView(tweetRect, tweet, (t) =>
			{
				string url = t.Value;
				switch(t.Type)
				{
					case TweetView.TweetType.Url:
						break;
					case TweetView.TweetType.Mention:
						url = "http://twitter.com/" + t.Value;
						break;
					case TweetView.TweetType.Hashtag:
						url = "http://twitter.com/search/" + Uri.EscapeDataString(t.Value);
						break;
				}
				WebViewController.OpenUrl(this, url, true /* enableTitle */);
			}, null);
			_tweetBox = new UIViewElement("Twitter", tweetView, false);
		}