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); } }); }); }
public void Display(string strText) { StyledMultilineElement sme = new StyledMultilineElement(strText) { Font = font12 }; ThreadPool.QueueUserWorkItem(delegate { System.Threading.Thread.Sleep(2000); AppDelegate.navigation.BeginInvokeOnMainThread(delegate { //this.Animating = false; 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); }); }); }
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); }); }
private async Task RunAsync() { var hub = _connection.CreateHubProxy("SeattleTimesHub"); hub.On <IList <News> >("addNews", (items) => { _connection.TraceWriter.WriteLine("items.Count " + items.Count); foreach (var item in items) { var title = new StyledMultilineElement(item.Title, () => { UIApplication.SharedApplication.OpenUrl(new NSUrl(item.Link)); }) { Font = UIFont.BoldSystemFontOfSize(12f), }; var description = new StyledMultilineElement(item.Description) { Font = UIFont.SystemFontOfSize(10f), }; _context.Post(delegate { _layout.Add(title); _layout.Add(description); }, state: null); } }); await _connection.Start(); await hub.Invoke("Sync"); }
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 loginWithWidgetAndRefreshTokenBtn = new StyledStringElement("Login with Widget & refresh_token", this.LoginWithWidgetUsingRefreshTokenButtonClick) { Alignment = UITextAlignment.Center }; var loginWithConnectionBtn = new StyledStringElement("Login with Google", this.LoginWithConnectionButtonClick) { Alignment = UITextAlignment.Center }; var refreshJwtWithIdTokenBtn = new StyledStringElement("Get new ID using id_token", this.RefreshIdTokenWithIdToken) { Alignment = UITextAlignment.Center }; var refreshJwtWithRefreshTokenBtn = new StyledStringElement("Get new ID using refresh_token", this.RefreshIdTokenWithRefreshToken) { 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(loginWithWidgetAndRefreshTokenBtn); 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 refresh = new Section("Using refresh token"); refresh.Add(refreshJwtWithIdTokenBtn); refresh.Add(refreshJwtWithRefreshTokenBtn); var result = new Section("Result"); result.Add(this.resultElement); this.Root.Add(new Section[] { login1, login2, refresh, result }); }
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 override void ViewDidLoad() { base.ViewDidLoad(); Root = new RootElement(string.Format("Pull Request #{0}", ViewModel.PullRequestId)) { UnevenRows = true }; var description = new StyledMultilineElement(string.Empty); description.Font = UIFont.SystemFontOfSize(12f); var statusElement = new SplitElement { Button1 = new SplitElement.SplitButton(Images.Status.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), "Open") { Enabled = false }, Button2 = new SplitElement.SplitButton(Images.Group.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), "0 Participants", () => ViewModel.GoToParticipantsCommand.ExecuteIfCan()), }; var buildElement = new SplitElement { Button1 = new SplitElement.SplitButton(Images.Build.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), "0 Builds", () => ViewModel.GoToBuildStatusCommand.ExecuteIfCan()), Button2 = new SplitElement.SplitButton(Images.Comment.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), "0 Comments", () => ViewModel.GoToCommentsCommand.ExecuteIfCan()), }; Root.Add(new Section { statusElement, buildElement }); var changesElement = new StyledStringElement("Changes", () => ViewModel.GoToChangesCommand.ExecuteIfCan(), Images.File.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)); var commitsElement = new StyledStringElement("Commits", () => ViewModel.GoToCommitsCommand.ExecuteIfCan(), Images.Commit.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)); Root.Add(new Section { changesElement, commitsElement }); var mergeElement = new StyledStringElement("Merge", string.Empty); mergeElement.Image = Images.Merge; var commentsElement = new WebElement("comments"); var commentsSection = new Section() { commentsElement }; var header = new ImageAndTitleHeaderView { BackgroundColor = UIColor.GroupTableViewBackgroundColor, Image = Images.Avatar, Text = " " }; TableView.TableHeaderView = header; TableView.SectionFooterHeight = 0.3f; ViewModel.GoToCommentsCommand.Subscribe(_ => { if (commentsElement.GetImmediateRootElement() != null) { TableView.ScrollToRow(commentsElement.IndexPath, UITableViewScrollPosition.Middle, true); } }); ViewModel.WhenAnyValue(x => x.PullRequest).Where(x => x != null).Subscribe(x => { header.Text = x.Title; statusElement.Button1.Text = x.State; description.Caption = x.Description; if (description.GetImmediateRootElement() == null) { Root[0].Insert(0, UITableViewRowAnimation.Fade, description); } var selfLink = x.Author.User.Links["self"].FirstOrDefault(); if (selfLink != null && !string.IsNullOrEmpty(selfLink.Href)) { header.ImageUri = selfLink.Href + "/avatar.png"; } TableView.TableHeaderView = header; }); ViewModel.Participants.Changed.Subscribe(_ => { statusElement.Button2.Text = string.Format("{0} Participant{1}", ViewModel.Participants.Count, ViewModel.Participants.Count != 1 ? "s" : string.Empty); }); ViewModel.WhenAnyValue(x => x.BuildStatus).Where(x => x != null && x.Length > 0).Subscribe(x => { var first = x.FirstOrDefault(); if (string.Equals(first.State, "SUCCESSFUL", StringComparison.OrdinalIgnoreCase)) { buildElement.Button1.Image = Images.BuildOk.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); } else if (string.Equals(first.State, "FAILED", StringComparison.OrdinalIgnoreCase)) { buildElement.Button1.Image = Images.Error.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); } else { buildElement.Button1.Image = Images.Update.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); } buildElement.Button1.Text = string.Format("{0} Build{1}", x.Length, x.Length == 1 ? string.Empty : "s"); }); ViewModel.Activities.Changed.Subscribe(_ => { var commentCount = ViewModel.Activities.Where(x => x.Comment != null).Sum(x => CommentCount(x.Comment)); buildElement.Button2.Text = string.Format("{0} Comment{1}", commentCount, commentCount != 1 ? "s" : string.Empty); if (ViewModel.Activities.Count > 0) { if (commentsSection.GetImmediateRootElement() == null) { Root.Add(commentsSection); } var template = new CommentCellView { Model = ViewModel.Activities.ToList() }; commentsElement.Value = template.GenerateString(); } else { if (commentsSection.GetImmediateRootElement() != null) { Root.Remove(commentsSection, UITableViewRowAnimation.Fade); } } }); }
// // 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; Action ontap = null; Action 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; } Action 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); } }