public static IUIObject Create(AvaloniaObject obj) { return(obj switch { Window w => new AvaloniaWindow(w), StyledElement c => new AvaloniaElement(c), _ => new AvaObject(obj) });
public PseudoClassViewModel(string name, StyledElement source) { Name = name; _source = source; _pseudoClasses = _source.Classes; Update(); }
/// <summary> /// Helper for setting AccessibilityView property on a StyledElement. /// </summary> public static void SetAccessibilityView(StyledElement element, AccessibilityView value) { if (element == null) { throw new ArgumentNullException(nameof(element)); } element.SetValue(AccessibilityViewProperty, value); }
/// <summary> /// Helper for reading LabeledBy property from a StyledElement. /// </summary> public static IControl GetLabeledBy(StyledElement element) { if (element == null) { throw new ArgumentNullException(nameof(element)); } return(element.GetValue(LabeledByProperty)); }
/// <summary> /// Helper for reading Name property from a StyledElement. /// </summary> public static string GetName(StyledElement element) { if (element == null) { throw new ArgumentNullException(nameof(element)); } return((string)element.GetValue(NameProperty)); }
/// <summary> /// Helper for setting Name property on a StyledElement. /// </summary> public static void SetName(StyledElement element, string value) { if (element == null) { throw new ArgumentNullException(nameof(element)); } element.SetValue(NameProperty, value); }
/// <summary> /// Helper for setting SizeOfSet property on a StyledElement. /// </summary> public static void SetSizeOfSet(StyledElement element, int value) { if (element == null) { throw new ArgumentNullException(nameof(element)); } element.SetValue(SizeOfSetProperty, value); }
/// <summary> /// Helper for reading AutomationId property from a StyledElement. /// </summary> public static string GetAutomationId(StyledElement element) { if (element == null) { throw new ArgumentNullException(nameof(element)); } return(element.GetValue(AutomationIdProperty)); }
/// <summary> /// Helper for setting IsOffscreenBehavior property on a StyledElement. /// </summary> public static void SetIsOffscreenBehavior(StyledElement element, IsOffscreenBehavior value) { if (element == null) { throw new ArgumentNullException(nameof(element)); } element.SetValue(IsOffscreenBehaviorProperty, value); }
/// <summary> /// Helper for setting LabeledBy property on a StyledElement. /// </summary> public static void SetLabeledBy(StyledElement element, IControl value) { if (element == null) { throw new ArgumentNullException(nameof(element)); } element.SetValue(LabeledByProperty, value); }
/// <summary> /// Helper for reading LiveSetting property from a StyledElement. /// </summary> public static AutomationLiveSetting GetLiveSetting(StyledElement element) { if (element == null) { throw new ArgumentNullException(nameof(element)); } return((AutomationLiveSetting)element.GetValue(LiveSettingProperty)); }
/// <summary> /// Helper for reading IsOffscreenBehavior property from a StyledElement. /// </summary> public static IsOffscreenBehavior GetIsOffscreenBehavior(StyledElement element) { if (element == null) { throw new ArgumentNullException(nameof(element)); } return((IsOffscreenBehavior)element.GetValue(IsOffscreenBehaviorProperty)); }
/// <summary> /// Helper for reading IsRowHeader property from a StyledElement. /// </summary> public static bool GetIsRowHeader(StyledElement element) { if (element == null) { throw new ArgumentNullException(nameof(element)); } return((bool)element.GetValue(IsRowHeaderProperty)); }
/// <summary> /// Helper for setting IsRowHeader property on a StyledElement. /// </summary> public static void SetIsRowHeader(StyledElement element, bool value) { if (element == null) { throw new ArgumentNullException(nameof(element)); } element.SetValue(IsRowHeaderProperty, value); }
/// <summary> /// Helper for setting ControlTypeOverride property on a StyledElement. /// </summary> public static void SetControlTypeOverride(StyledElement element, AutomationControlType?value) { if (element == null) { throw new ArgumentNullException(nameof(element)); } element.SetValue(ControlTypeOverrideProperty, value); }
/// <summary> /// Helper for reading ControlTypeOverride property from a StyledElement. /// </summary> public static AutomationControlType?GetControlTypeOverride(StyledElement element) { if (element == null) { throw new ArgumentNullException(nameof(element)); } return(element.GetValue(ControlTypeOverrideProperty)); }
/// <summary> /// Helper for reading SizeOfSet property from a StyledElement. /// </summary> public static int GetSizeOfSet(StyledElement element) { if (element == null) { throw new ArgumentNullException(nameof(element)); } return((int)element.GetValue(SizeOfSetProperty)); }
/// <summary> /// Helper for reading AccessibilityView property from a StyledElement. /// </summary> public static AccessibilityView GetAccessibilityView(StyledElement element) { if (element == null) { throw new ArgumentNullException(nameof(element)); } return(element.GetValue(AccessibilityViewProperty)); }
/// <summary> /// Helper for setting LiveSetting property on a StyledElement. /// </summary> public static void SetLiveSetting(StyledElement element, AutomationLiveSetting value) { if (element == null) { throw new ArgumentNullException(nameof(element)); } element.SetValue(LiveSettingProperty, value); }
public void FindResource_Should_Find_Control_Resource() { var target = new StyledElement { Resources = { { "foo", "foo-value" }, } }; Assert.Equal("foo-value", target.FindResource("foo")); }
public void Setting_Logical_Parent_Raises_Child_ResourcesChanged() { var parent = new ContentControl(); var child = new StyledElement(); ((ISetLogicalParent)child).SetParent(parent); var raisedOnChild = false; child.ResourcesChanged += (_, __) => raisedOnChild = true; parent.Resources.Add("foo", "bar"); Assert.True(raisedOnChild); }
public override void ViewDidLoad() { base.ViewDidLoad(); _header = new HeaderView(View.Bounds.Width) { Title = Username }; Root.Add(new Section(_header)); var followers = new StyledElement("Followers", () => NavigationController.PushViewController(new UserFollowersController(Username), true), Images.Heart); var events = new StyledElement("Events", () => NavigationController.PushViewController(new EventsController(Username), true), Images.Buttons.Event); var groups = new StyledElement("Groups", () => NavigationController.PushViewController(new GroupController(Username), true), Images.Buttons.Group); var repos = new StyledElement("Repositories", () => { NavigationController.PushViewController(new RepositoryController(Username) { Model = Model == null ? null : Model.Repositories }, true); }, Images.Repo); Root.Add(new [] { new Section { followers, events, groups }, new Section { repos } }); }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); var root = new RootElement(Title); var accountSection = new Section("Accounts"); root.Add(accountSection); foreach (var account in Application.Accounts) { var thisAccount = account; var t = new AccountElement(thisAccount); t.Tapped += () => { Application.SetUser(thisAccount); DismissModalViewControllerAnimated(true); }; //Check to see if this account is the active account. Application.Account could be null //so make it the target of the equals, not the source. if (thisAccount.Equals(Application.Account)) { t.Accessory = UITableViewCellAccessory.Checkmark; } accountSection.Add(t); } var addAccount = new StyledElement("Add Account", () => { var ctrl = new GitHubLoginController(); ctrl.LoginComplete = (a) => NavigationController.PopToViewController(this, true); NavigationController.PushViewController(ctrl, true); }); //addAccount.Image = Images.CommentAdd; accountSection.Add(addAccount); var supportSection = new Section("Support"); root.Add(supportSection); supportSection.Add(new StyledElement("Feedback & Support", OpenUserVoice)); var aboutSection = new Section("About", "Thank you for downloading. Enjoy!"); root.Add(aboutSection); aboutSection.Add(new StyledElement("Follow On Twitter", () => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://twitter.com/Codebucketapp")))); aboutSection.Add(new StyledElement("Rate This App", () => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://itunes.apple.com/us/app/codebucket/id551531422?mt=8")))); aboutSection.Add(new StyledElement("App Version", NSBundle.MainBundle.InfoDictionary.ValueForKey(new NSString("CFBundleVersion")).ToString())); //Assign the root Root = root; }
public static TextInputOptions FromStyledElement(StyledElement avaloniaObject) { var result = new TextInputOptions { ContentType = GetContentType(avaloniaObject), Multiline = GetMultiline(avaloniaObject), AutoCapitalization = GetAutoCapitalization(avaloniaObject), IsSensitive = GetIsSensitive(avaloniaObject), Lowercase = GetLowercase(avaloniaObject), Uppercase = GetUppercase(avaloniaObject) }; return(result); }
protected override void OnRender() { var model = (ChangesetModel)Model; var sec = new Section(); _header.Subtitle = "Commited " + (model.Utctimestamp).ToDaysAgo(); var d = new MultilinedElement(model.Author, model.Message); sec.Add(d); if (Repo != null) { var repo = new StyledElement(Repo.Name, Images.Repo) { Accessory = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator, Lines = 1, Font = StyledElement.DefaultDetailFont, TextColor = StyledElement.DefaultDetailColor, }; repo.Tapped += () => NavigationController.PushViewController(new RepositoryInfoController(Repo), true); sec.Add(repo); } var sec2 = new Section(); model.Files.ForEach(x => { var file = x.File.Substring(x.File.LastIndexOf('/') + 1); var sse = new SubcaptionElement(file, x.Type) { Accessory = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator, LineBreakMode = MonoTouch.UIKit.UILineBreakMode.TailTruncation, Lines = 1 }; sse.Tapped += () => { string parent = null; if (model.Parents != null && model.Parents.Count > 0) parent = model.Parents[0]; var type = x.Type.Trim().ToLower(); NavigationController.PushViewController(new ChangesetDiffController(User, Slug, model.Node, parent, x.File) { Removed = type.Equals("removed"), Added = type.Equals("added") }, true); }; sec2.Add(sse); }); _header.SetNeedsDisplay(); var root = new RootElement(Title) { UnevenRows = Root.UnevenRows }; root.Add(new [] { new Section(_header), sec, sec2 }); Root = root; }
public void Setting_Logical_Parent_Raises_Style_ResourcesChanged() { var style = new Style(x => x.OfType <Canvas>()); var parent = new ContentControl(); var child = new StyledElement { Styles = { style } }; ((ISetLogicalParent)child).SetParent(parent); var raised = false; style.ResourcesChanged += (_, __) => raised = true; parent.Resources.Add("foo", "bar"); Assert.True(raised); }
public static TElement FindElement <TElement>(this StyledElement rootElement, string elementName) where TElement : class { if (rootElement == null) { return(null); } if (string.IsNullOrEmpty(elementName)) { return(rootElement as TElement); } if (rootElement.Name == elementName) { return(rootElement as TElement); } return(rootElement.GetLogicalDescendants().FirstOrDefault(child => (child as StyledElement)?.Name == elementName) as TElement); }
public void Adding_Resource_To_Nested_Style_Should_Raise_ResourceChanged() { Style style; var target = new StyledElement { Styles = { (style = new Style()), } }; var raised = false; target.ResourcesChanged += (_, __) => raised = true; style.Resources.Add("foo", "bar"); Assert.True(raised); }
private void LoadTable() { var imageCount = Data.Database.Main.Table <ProjectImage>().Count(); var allPatternsButton = new StyledElement("All UI Images", imageCount.ToString(), UITableViewCellStyle.Value1); if (imageCount > 0) { allPatternsButton.Accessory = UITableViewCellAccessory.DisclosureIndicator; allPatternsButton.Tapped += () => NavigationController.PushViewController(new LocalViewPatternsViewController() { Title = "All" }, true); } var section = new Section("Albums"); var projects = Data.Database.Main.Table <Project>(); foreach (var p in projects) { var project = p; var element = new ProjectElement(project); if (Data.Database.Main.Table <ProjectImage>().Where(a => a.ProjectId == project.Id).Count() > 0) { element.Accessory = UITableViewCellAccessory.DisclosureIndicator; element.Tapped += () => { NavigationController.PushViewController(new LocalViewPatternsViewController(project.Id) { Title = project.Name }, true); }; } section.Add(element); } var root = new RootElement(Title) { new Section() { allPatternsButton }, section }; Root = root; }
/// <summary> /// Finds the containing name scope for a styled element. /// </summary> /// <param name="styled">The styled element.</param> /// <returns>The containing name scope.</returns> public static INameScope FindNameScope(StyledElement styled) { Contract.Requires <ArgumentNullException>(styled != null); INameScope result; while (styled != null) { result = styled as INameScope ?? GetNameScope(styled); if (result != null) { return(result); } styled = (styled as ILogical)?.LogicalParent as StyledElement; } return(null); }
private void ConfirmPressHappened(StyledElement sender) { switch (sender.Name) { case "SearchLabel": SearchNames(); break; case "AddManualFilter": AddManualFilter(); break; case "AddTagBox": base.ConfirmPressHappened(sender as AutoCompleteBox); break; default: break; } }
public void FindResource_Should_Find_Styles_Resource() { var target = new StyledElement { Styles = { new Styles { Resources = { { "foo", "foo-value" }, } } }, Resources = { { "bar", "bar-value" }, }, }; Assert.Equal("foo-value", target.FindResource("foo")); }
private void PopulateRoot() { _title = new InputElement("Title", string.Empty, string.Empty); _assignedTo = new StyledElement("Responsible", Unassigned, UITableViewCellStyle.Value1) { Accessory = UITableViewCellAccessory.DisclosureIndicator, }; _assignedTo.Tapped += () => { var privileges = new PrivilegesController { Username = Username, RepoSlug = RepoSlug, Primary = new UserModel { Username = Username }, Title = _assignedTo.Caption, }; privileges.SelectedItem += obj => { _assignedTo.Value = obj.Username; NavigationController.PopViewControllerAnimated(true); }; NavigationController.PushViewController(privileges, true); }; _issueType = CreateEnumElement("Issue Type", Kinds[0], Kinds); _priority = CreateEnumElement("Priority", Priorities[0], Priorities); _content = new MultilinedElement("Description"); _content.Tapped += () => { var composer = new Composer { Title = "Issue Description", Text = _content.Value, ActionButtonText = "Save" }; composer.NewComment(this, () => { var text = composer.Text; _content.Value = text; composer.CloseComposer(); }); }; var root = new RootElement(Title) { new Section { _title, _assignedTo, _issueType, _priority }, new Section { _content } }; //See if it's an existing issue or not... if (ExistingIssue != null) { _title.Value = ExistingIssue.Title; if (ExistingIssue.Responsible != null) _assignedTo.Value = ExistingIssue.Responsible.Username; _issueType.Value = ExistingIssue.Metadata.Kind; _priority.Value = ExistingIssue.Priority; if (!string.IsNullOrEmpty(ExistingIssue.Content)) _content.Value = ExistingIssue.Content; _status = CreateEnumElement("Status", ExistingIssue.Status, Statuses); //Insert the status thing inbetween title and assigned to elements root[0].Insert(1, _status); var deleteButton = new StyledElement("Delete Issue", () => { var alert = new UIAlertView { Title = "Are you sure?", Message = "You are about to permanently delete issue #" + ExistingIssue.LocalId + "." }; alert.CancelButtonIndex = alert.AddButton("Cancel"); var ok = alert.AddButton("Delete"); alert.Clicked += (sender, e) => { if (e.ButtonIndex == ok) DeleteIssue(); }; alert.Show(); }, Images.BinClosed) { Accessory = UITableViewCellAccessory.None, BackgroundColor = UIColor.FromPatternImage(Images.TableCellRed), TextColor = UIColor.FromRGB(0.9f, 0.30f, 0.30f) }; root.Add(new Section { deleteButton }); } Root = root; }
private StyledElement CreateEnumElement(string title, string defaultVal, IEnumerable<string> values) { var element = new StyledElement(title, defaultVal, UITableViewCellStyle.Value1) { Accessory = UITableViewCellAccessory.DisclosureIndicator }; element.Tapped += () => { var en = new RadioChoiceViewController(element.Caption, values, element.Value); en.ValueSelected += obj => { element.Value = obj; NavigationController.PopViewControllerAnimated(true); }; NavigationController.PushViewController(en, true); }; return element; }
private void Populate() { var accountSection = new Section(); foreach (var account in Application.Accounts) { var thisAccount = account; var t = new AccountElement(thisAccount); t.Tapped += () => { AccountSelected(thisAccount); }; //Check to see if this account is the active account. Application.Account could be null //so make it the target of the equals, not the source. if (thisAccount.Equals(Application.Account)) t.Accessory = UITableViewCellAccessory.Checkmark; accountSection.Add(t); } var addAccountSection = new Section(); var addAccount = new StyledElement("Add Account", () => NavigationController.PushViewController(AddAccount(), true)); //addAccount.Image = Images.CommentAdd; addAccountSection.Add(addAccount); Root = new RootElement(Title) { accountSection, addAccountSection }; }
protected override void OnRender() { var model = Model; var root = new RootElement(Title) { UnevenRows = true }; _header.Subtitle = "Updated " + (model.UtcLastUpdated).ToDaysAgo(); if (!string.IsNullOrEmpty(model.Logo)) _header.Image = ImageLoader.DefaultRequestImage(new Uri(model.LargeLogo(64)), this); root.Add(new Section(_header)); var sec1 = new Section(); if (!string.IsNullOrEmpty(model.Description) && !string.IsNullOrWhiteSpace(model.Description)) { var element = new MultilinedElement(model.Description) { BackgroundColor = UIColor.White }; element.CaptionColor = element.ValueColor; element.CaptionFont = element.ValueFont; sec1.Add(element); } sec1.Add(new SplitElement(new SplitElement.Row { Text1 = model.Scm, Image1 = Images.ScmType, Text2 = model.Language, Image2 = Images.Language })); //Calculate the best representation of the size string size; if (model.Size / 1024f < 1) size = string.Format("{0}B", model.Size); else if ((model.Size / 1024f / 1024f) < 1) size = string.Format("{0:0.##}KB", model.Size / 1024f); else if ((model.Size / 1024f / 1024f / 1024f) < 1) size = string.Format("{0:0.##}MB", model.Size / 1024f / 1024f); else size = string.Format("{0:0.##}GB", model.Size / 1024f / 1024f / 1024f); sec1.Add(new SplitElement(new SplitElement.Row { Text1 = model.IsPrivate ? "Private" : "Public", Image1 = model.IsPrivate ? Images.Locked : Images.Unlocked, Text2 = size, Image2 = Images.Size })); sec1.Add(new SplitElement(new SplitElement.Row { Text1 = (model.UtcCreatedOn).ToString("MM/dd/yy"), Image1 = Images.Create, Text2 = model.ForkCount.ToString() + (model.ForkCount == 1 ? " Fork" : " Forks"), Image2 = Images.Fork })); var owner = new StyledElement("Owner", model.Owner) { Accessory = UITableViewCellAccessory.DisclosureIndicator }; owner.Tapped += () => NavigationController.PushViewController(new ProfileController(model.Owner), true); sec1.Add(owner); var followers = new StyledElement("Followers", "" + model.FollowersCount) { Accessory = UITableViewCellAccessory.DisclosureIndicator }; followers.Tapped += () => NavigationController.PushViewController(new RepoFollowersController(model.Owner, model.Slug), true); sec1.Add(followers); var events = new StyledElement("Events", () => NavigationController.PushViewController(new RepoEventsController(model.Owner, model.Slug), true), Images.Buttons.Event); var sec2 = new Section { events }; if (model.HasIssues) sec2.Add(new StyledElement("Issues", () => NavigationController.PushViewController(new IssuesController(model.Owner, model.Slug), true), Images.Buttons.Flag)); if (model.HasWiki) sec2.Add(new StyledElement("Wiki", () => NavigationController.PushViewController(new WikiInfoController(model.Owner, model.Slug), true), Images.Pencil)); var sec3 = new Section { new StyledElement("Changes", () => NavigationController.PushViewController(new ChangesetController(model.Owner, model.Slug), true), Images.Changes), new StyledElement("Branches", () => NavigationController.PushViewController(new BranchController(model.Owner, model.Slug), true), Images.Branch), new StyledElement("Tags", () => NavigationController.PushViewController(new TagController(model.Owner, model.Slug), true), Images.Tag) }; root.Add(new[] { sec1, sec2, sec3 }); if (!string.IsNullOrEmpty(model.Website)) { var web = new StyledElement("Website", () => UIApplication.SharedApplication.OpenUrl(NSUrl.FromString(model.Website)), Images.Webpage); root.Add(new Section { web }); } Root = root; }
public IssueInfoController(string user, string slug, int id) : base(typeof(InternalIssueInfoModel)) { User = user; Slug = slug; Id = id; Title = "Issue #" + id; NavigationItem.RightBarButtonItem = new UIBarButtonItem(NavigationButton.Create(CodeFramework.Images.Buttons.Edit, () => { var m = Model as InternalIssueInfoModel; var editController = new IssueEditController { ExistingIssue = m.Issue, Username = User, RepoSlug = Slug, Title = "Edit Issue", Success = EditingComplete, }; NavigationController.PushViewController(editController, true); })); NavigationItem.RightBarButtonItem.Enabled = false; Style = UITableViewStyle.Grouped; Root.UnevenRows = true; _header = new HeaderView(View.Bounds.Width) { ShadowImage = false }; Root.Add(new Section(_header)); _desc = new MultilinedElement("") { BackgroundColor = UIColor.White }; _desc.CaptionFont = _desc.ValueFont; _desc.CaptionColor = _desc.ValueColor; _split1 = new SplitElement(new SplitElement.Row { Image1 = Images.Buttons.Cog, Image2 = Images.Priority }) { BackgroundColor = UIColor.White }; _split2 = new SplitElement(new SplitElement.Row { Image1 = Images.Buttons.Flag, Image2 = Images.ServerComponents }) { BackgroundColor = UIColor.White }; _split3 = new SplitElement(new SplitElement.Row { Image1 = Images.SitemapColor, Image2 = Images.Milestone }) { BackgroundColor = UIColor.White }; _responsible = new StyledElement("Unassigned", Images.Buttons.Person) { Font = StyledElement.DefaultDetailFont, TextColor = StyledElement.DefaultDetailColor, }; _responsible.Tapped += () => { var m = Model as InternalIssueInfoModel; if (m != null && m.Issue.Responsible != null) NavigationController.PushViewController(new ProfileController(m.Issue.Responsible.Username), true); }; var addComment = new StyledElement("Add Comment", Images.Pencil); addComment.Tapped += AddCommentTapped; _comments = new Section(); _details = new Section { _split1, _split2, _split3, _responsible }; Root.Add(_details); Root.Add(_comments); Root.Add(new Section { addComment }); }