Inheritance: StyledStringElement, IElementSizing
		private RootElement GetRoot()
		{
			var rect = new RectangleF(PadX, 0, View.Bounds.Width - 30 - PadX * 2, 100);
			_detailView = new SeriesDetailView(_series, rect);
			
			_triangleView = new TriangleView (UIColor.FromRGB(247, 247, 247), UIColor.FromRGB (171, 171, 171)) {
				Frame = new RectangleF (43, _detailView.Bounds.Height - 7, 16, 8)
			};
			
			_containerView = new UIView(rect);
			_containerView.Add(_detailView);
			_containerView.Add(_triangleView);
			
			var text = new StyledMultilineElement(_series.Description);
			text.TextColor = UIColor.DarkGray;
			text.LineBreakMode = UILineBreakMode.WordWrap;
			text.Font = UIFont.ItalicSystemFontOfSize(14);
			text.DetailColor = text.TextColor;
						
			var main = new Section(_containerView)
			{
				text
			};
			
			var root = new RootElement("")
			{
				main
		 	};
			
			return root;
		}
		private void Initialize()
		{
			var loginWithWidgetBtn = new StyledStringElement ("Login with Widget", this.LoginWithWidgetButtonClick) {
				Alignment = UITextAlignment.Center
			};

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

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

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

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

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

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

			this.Root.Add (new Section[] { login1, login2, result });
		}
Exemplo n.º 3
0
        public override void ViewWillAppear(bool animated)
        {
            var logAsStr = String.Format ("welcome {0} {1}, you have {2} credits",
                            string.IsNullOrWhiteSpace (ConfigurationWorker.LastMessage) ? "" : "back",
                            RestManager.AuthenticationResult.FirstName,
                            RestManager.AuthenticationResult.NumberOfCredits);
            loggedAsElement = new StyledMultilineElement (logAsStr);
            loggedAsElement.Font = UIFont.SystemFontOfSize (11);
            loggedAsElement.TextColor = UIColor.DarkGray;
            loggedAsElement.Tapped += delegate{
                NavigationController.PopViewControllerAnimated (animated:true);
            };

            _currentCamperStr = ConfigurationWorker.LastCamper.ToString ();
            _currentCabinStr = ConfigurationWorker.LastCabin.ToString ();

            _chooseCamper = new StyledStringElement ("camper", _currentCamperStr);
            _chooseCamper.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            _chooseCamper.Tapped += () => NavigationController.PushViewController (new ChooseCamperScreen (), true);

            _chooseCabin = new StyledStringElement ("bunk", _currentCabinStr);
            _chooseCabin.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            _chooseCabin.Tapped += () => NavigationController.PushViewController (new ChooseCabinScreen (), true);
            Root = GetRoot ();

            base.ViewWillAppear (animated);
        }
Exemplo n.º 4
0
		public RootElement GetRoot()
		{
			CreateTweetView("...");
			
			var width = View.Bounds.Width - 30 - PadX * 2;
			var frame = new RectangleF(PadX, 0, width, 100);
			
			var headerView = new UIView(frame);			
			_view = new BioView(_bio, frame, true);
			headerView.Add(_view);
			
			// Speech bubble triangle
			var triangleFrame = new RectangleF(Util.IsPad() ? 63 : 43, _view.Bounds.Height - 7, 16, 8);
			var triangle = new TriangleView (UIColor.FromRGB(247, 247, 247), UIColor.FromRGB(171, 171, 171)) { Frame = triangleFrame };
			headerView.Add(triangle);
						
			_view.UrlTapped += delegate
			{
				WebViewController.OpenUrl(this, _bio.Url);
			};
					
			_main = new Section(headerView)
			{
				_tweetBox
			};
			
			var text = new StyledMultilineElement(AppManifest.Current.Biography);
			text.TextColor = UIColor.DarkGray;
			text.LineBreakMode = UILineBreakMode.WordWrap;
			text.Font = UIFont.ItalicSystemFontOfSize(15);
			text.DetailColor = text.TextColor;	
			text.SelectionStyle = UITableViewCellSelectionStyle.None;
						
			var secondary = new Section("About " + AppManifest.Current.FirstName)
			{
				text
			};
			
			var root = new RootElement("Bio")
			{
				_main,
				secondary
		 	};			
			
			// Required for resizing bubble for new tweets
			root.UnevenRows = true;
			
			return root;
		}
        public void Display (string strText, TrafficUpdates.TrafficMessage trafficMessage)
        {
            UIColor uiColor = UIColor.Black;
            if (trafficMessage == TrafficUpdates.TrafficMessage.Blocked) {
                uiColor = UIColor.Red;
            } else if (trafficMessage == TrafficUpdates.TrafficMessage.Heavy) {
                uiColor = UIColor.Orange;
            } else if (trafficMessage == TrafficUpdates.TrafficMessage.Normal) {
                uiColor = UIColor.Green;
            } else if (trafficMessage == TrafficUpdates.TrafficMessage.Low) {
                uiColor = UIColor.Purple;
            }
            StyledMultilineElement sme = new StyledMultilineElement (strText)
            {
                Font = font12,
                TextColor = uiColor,
            };
            //sme.

            AppDelegate.navigation.BeginInvokeOnMainThread(delegate {
                secOutput.Add (sme);
               
            });
        }
Exemplo n.º 6
0
        //
        // Creates one of the various StringElement classes, based on the
        // properties set.   It tries to load the most memory efficient one
        // StringElement, if not, it fallsback to MultilineStringElement or
        // StyledStringElement
        //
        static Element LoadString(JsonObject json, object data)
        {
            string   value = null;
            string   caption = value;
            string   background = null;
            NSAction ontap = null;
            NSAction onaccessorytap = null;
            int?     lines = null;
            UITableViewCellAccessory?accessory = null;
            UILineBreakMode?         linebreakmode = null;
            UITextAlignment?         alignment = null;
            UIColor textcolor = null, detailcolor = null;
            UIFont  font = null;
            UIFont  detailfont         = null;
            UITableViewCellStyle style = UITableViewCellStyle.Value1;

            foreach (var kv in json)
            {
                string kvalue = (string)kv.Value;
                switch (kv.Key)
                {
                case "caption":
                    caption = kvalue;
                    break;

                case "value":
                    value = kvalue;
                    break;

                case "background":
                    background = kvalue;
                    break;

                case "style":
                    style = ToCellStyle(kvalue);
                    break;

                case "ontap":
                case "onaccessorytap":
                    string sontap = kvalue;
                    int    p      = sontap.LastIndexOf('.');
                    if (p == -1)
                    {
                        break;
                    }
                    NSAction d = delegate {
                        string cname = sontap.Substring(0, p);
                        string mname = sontap.Substring(p + 1);
                        foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
                        {
                            Type type = a.GetType(cname);

                            if (type != null)
                            {
                                var mi = type.GetMethod(mname, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
                                if (mi != null)
                                {
                                    mi.Invoke(null, new object [] { data });
                                }
                                break;
                            }
                        }
                    };
                    if (kv.Key == "ontap")
                    {
                        ontap = d;
                    }
                    else
                    {
                        onaccessorytap = d;
                    }
                    break;

                case "lines":
                    int res;
                    if (int.TryParse(kvalue, out res))
                    {
                        lines = res;
                    }
                    break;

                case "accessory":
                    accessory = ToAccessory(kvalue);
                    break;

                case "textcolor":
                    textcolor = ParseColor(kvalue);
                    break;

                case "linebreak":
                    linebreakmode = ToLinebreakMode(kvalue);
                    break;

                case "font":
                    font = ToFont(kvalue);
                    break;

                case "subtitle":
                    value = kvalue;
                    style = UITableViewCellStyle.Subtitle;
                    break;

                case "detailfont":
                    detailfont = ToFont(kvalue);
                    break;

                case "alignment":
                    alignment = ToAlignment(kvalue);
                    break;

                case "detailcolor":
                    detailcolor = ParseColor(kvalue);
                    break;

                case "type":
                    break;

                default:
                    Console.WriteLine("Unknown attribute: '{0}'", kv.Key);
                    break;
                }
            }
            if (caption == null)
            {
                caption = "";
            }
            if (font != null || style != UITableViewCellStyle.Value1 || detailfont != null || linebreakmode.HasValue || textcolor != null || accessory.HasValue || onaccessorytap != null || background != null || detailcolor != null)
            {
                StyledStringElement styled;

                if (lines.HasValue)
                {
                    styled       = new StyledMultilineElement(caption, value, style);
                    styled.Lines = lines.Value;
                }
                else
                {
                    styled = new StyledStringElement(caption, value, style);
                }
                if (ontap != null)
                {
                    styled.Tapped += ontap;
                }
                if (onaccessorytap != null)
                {
                    styled.AccessoryTapped += onaccessorytap;
                }
                if (font != null)
                {
                    styled.Font = font;
                }
                if (detailfont != null)
                {
                    styled.SubtitleFont = detailfont;
                }
                if (detailcolor != null)
                {
                    styled.DetailColor = detailcolor;
                }
                if (textcolor != null)
                {
                    styled.TextColor = textcolor;
                }
                if (accessory.HasValue)
                {
                    styled.Accessory = accessory.Value;
                }
                if (linebreakmode.HasValue)
                {
                    styled.LineBreakMode = linebreakmode.Value;
                }
                if (background != null)
                {
                    if (background.Length > 1 && background [0] == '#')
                    {
                        styled.BackgroundColor = ParseColor(background);
                    }
                    else
                    {
                        styled.BackgroundUri = new Uri(background);
                    }
                }
                if (alignment.HasValue)
                {
                    styled.Alignment = alignment.Value;
                }
                return(styled);
            }
            else
            {
                StringElement se;
                if (lines == 0)
                {
                    se = new MultilineElement(caption, value);
                }
                else
                {
                    se = new StringElement(caption, value);
                }
                if (alignment.HasValue)
                {
                    se.Alignment = alignment.Value;
                }
                if (ontap != null)
                {
                    se.Tapped += ontap;
                }
                return(se);
            }
        }
 public void Display (string strText)
 {
     StyledMultilineElement sme = new StyledMultilineElement (strText)
     {
         Font = font12
     };
     ThreadPool.QueueUserWorkItem (delegate {
         
         System.Threading.Thread.Sleep(2000);
         
         AppDelegate.navigation.BeginInvokeOnMainThread(delegate {
             if(secOutput.Count > 20)
             {
                 secOutput.RemoveRange(0, 10);
             }
             if (secOutput.Count > 0) {
                 secOutput.Insert (secOutput.Count, sme);                    }
             else
             {
                 secOutput.Add (sme);
             }
             this.TableView.ReloadData();
             var lastIndexPath = this.root.Last()[this.root.Last().Count-1].IndexPath;
             this.TableView.ScrollToRow(lastIndexPath, UITableViewScrollPosition.Middle, true);    
         });
     });
 }
Exemplo n.º 8
0
		//
		// Creates one of the various StringElement classes, based on the
		// properties set.   It tries to load the most memory efficient one
		// StringElement, if not, it fallsback to MultilineStringElement or
		// StyledStringElement
		//
		static Element LoadString (JsonObject json, object data)
		{
			string value = null;
			string caption = value;
			string background = null;
			NSAction ontap = null;
			NSAction onaccessorytap = null;
			int? lines = null;
			UITableViewCellAccessory? accessory = null;
			UILineBreakMode? linebreakmode = null;
			UITextAlignment? alignment = null;
			UIColor textcolor = null, detailcolor = null;
			UIFont font = null;
			UIFont detailfont = null;
			UITableViewCellStyle style = UITableViewCellStyle.Value1;

			foreach (var kv in json){
				string kvalue = (string) kv.Value;
				switch (kv.Key){
				case "caption":
					caption = kvalue;
					break;
				case "value":
					value = kvalue;
					break;
				case "background":	
					background = kvalue;
					break;
				case "style":
					style = ToCellStyle (kvalue);
					break;
				case "ontap": case "onaccessorytap":
					string sontap = kvalue;
					int p = sontap.LastIndexOf ('.');
					if (p == -1)
						break;
					NSAction d = delegate {
						string cname = sontap.Substring (0, p);
						string mname = sontap.Substring (p+1);
						foreach (var a in AppDomain.CurrentDomain.GetAssemblies ()){
							Type type = a.GetType (cname);
						
							if (type != null){
								var mi = type.GetMethod (mname, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
								if (mi != null)
									mi.Invoke (null, new object [] { data });
								break;
							}
						}
					};
					if (kv.Key == "ontap")
						ontap = d;
					else
						onaccessorytap = d;
					break;
				case "lines":
					int res;
					if (int.TryParse (kvalue, out res))
						lines = res;
					break;
				case "accessory":
					accessory = ToAccessory (kvalue);
					break;
				case "textcolor":
					textcolor = ParseColor (kvalue);
					break;
				case "linebreak":
					linebreakmode = ToLinebreakMode (kvalue);
					break;
				case "font":
					font = ToFont (kvalue);
					break;
				case "subtitle":
					value = kvalue;
					style = UITableViewCellStyle.Subtitle;
					break;
				case "detailfont":
					detailfont = ToFont (kvalue);
					break;
				case "alignment":
					alignment = ToAlignment (kvalue);
					break;
				case "detailcolor":
					detailcolor = ParseColor (kvalue);
					break;
				case "type":
					break;
				default:
					Console.WriteLine ("Unknown attribute: '{0}'", kv.Key);
					break;
				}
			}
			if (caption == null)
				caption = "";
			if (font != null || style != UITableViewCellStyle.Value1 || detailfont != null || linebreakmode.HasValue || textcolor != null || accessory.HasValue || onaccessorytap != null || background != null || detailcolor != null){
				StyledStringElement styled;
				
				if (lines.HasValue){
					styled = new StyledMultilineElement (caption, value, style);
					styled.Lines = lines.Value;
				} else {
					styled = new StyledStringElement (caption, value, style);
				}
				if (ontap != null)
					styled.Tapped += ontap;
				if (onaccessorytap != null)
					styled.AccessoryTapped += onaccessorytap;
				if (font != null)
					styled.Font = font;
				if (detailfont != null)
					styled.SubtitleFont = detailfont;
				if (detailcolor != null)
					styled.DetailColor = detailcolor;
				if (textcolor != null)
					styled.TextColor = textcolor;
				if (accessory.HasValue)
					styled.Accessory = accessory.Value;
				if (linebreakmode.HasValue)
					styled.LineBreakMode = linebreakmode.Value;
				if (background != null){
					if (background.Length > 1 && background [0] == '#')
						styled.BackgroundColor = ParseColor (background);
					else
						styled.BackgroundUri = new Uri (background);
				}
				if (alignment.HasValue)
					styled.Alignment = alignment.Value;
				return styled;
			} else {
				StringElement se;
				if (lines == 0)
					se = new MultilineElement (caption, value);
				else
					se = new StringElement (caption, value);
				if (alignment.HasValue)
					se.Alignment = alignment.Value;
				if (ontap != null)
					se.Tapped += ontap;
				return se;
			}
		}
		private void SetStatus(string status)
		{
			if (statusSection == null) {
				statusMultiline = new StyledMultilineElement ("", status);
				statusMultiline.LineBreakMode = UILineBreakMode.WordWrap;
				statusMultiline.Lines = 0;
				statusMultiline.TextColor = UIColor.Black;
				statusSection = new Section ("Results") {
					statusMultiline
				};
				root.Insert(0, statusSection);
			}
			else
			{
				statusMultiline.Value = status;
				root.Reload (statusMultiline, UITableViewRowAnimation.Fade);
			}
			root.TableView.ScrollToRow (statusMultiline.IndexPath, UITableViewScrollPosition.Top, true);
		}
Exemplo n.º 10
0
 public void Display (string strText)
 {
     StyledMultilineElement sme = new StyledMultilineElement (strText) {
         Font = font12
     };
     ThreadPool.QueueUserWorkItem (delegate {
         
         System.Threading.Thread.Sleep (500);
         
         AppDelegate.navigation.BeginInvokeOnMainThread (delegate {
             if (secOutput.Count > 20) {
                 secOutput.RemoveRange (20, secOutput.Count-1);
             }
             if (secOutput.Count > 0) {
                 secOutput.Insert (0, sme);
             } else {
                 secOutput.Add (sme);
             }                
         });
     });
 }
Exemplo n.º 11
0
        static StyledMultilineElement MakeElement(string caption, bool bold = false)
        {
            UIFont font = UIFont.SystemFontOfSize(14f);
            if(bold)
                font = UIFont.BoldSystemFontOfSize(14f);

            var q = new StyledMultilineElement(caption);
            q.Font = font;
            return q;
        }