public void It_holds_parts_added_to_it() { var section = new Section("foo"); section.Add(new LiteralText("bar")); section.Add(new LiteralText("baz")); section.Parts.IsEqualTo(new LiteralText("bar"), new LiteralText("baz")); }
public void It_does_not_hold_template_definitions_with_other_parts() { var section = new Section("foo"); section.Add(new LiteralText("bar")); section.Add(new TemplateDefinition("baz")); section.Add(new LiteralText("quux")); section.Parts.IsEqualTo(new LiteralText("bar"), new LiteralText("quux")); }
public static Table CreateTable(ref Section section) { var table = new Table { Style = TableStyleName, Borders = { Color = Colors.Gray, Width = 0.25, Left = { Width = 0.5 }, Right = { Width = 0.5 } }, LeftPadding = 3, RightPadding = 3, Rows = { LeftIndent = 0, VerticalAlignment = VerticalAlignment.Center }, Format = { Alignment = ParagraphAlignment.Left, LeftIndent = 0, RightIndent = 0 } }; section?.Add(table); return(table); }
public MultipleChoiceEntryElement (string caption, params string[] options): base(caption, new RadioGroup(-1)) { var section = new Section(caption); foreach(var s in options) { section.Add(new RadioEntryElement(s)); } Add(section); }
// Creates the dynamic content from the twitter results RootElement CreateDynamicContent (XDocument doc) { var users = doc.XPathSelectElements ("./statuses/status/user").ToArray (); var texts = doc.XPathSelectElements ("./statuses/status/text").Select (x=>x.Value).ToArray (); var people = doc.XPathSelectElements ("./statuses/status/user/name").Select (x=>x.Value).ToArray (); var section = new Section (); var root = new RootElement ("Tweets") { section }; for (int i = 0; i < people.Length; i++){ var line = new RootElement (people [i]) { new Section ("Profile"){ new StringElement ("Screen name", users [i].XPathSelectElement ("./screen_name").Value), new StringElement ("Name", people [i]), new StringElement ("oFllowers:", users [i].XPathSelectElement ("./followers_count").Value) }, new Section ("Tweet"){ new StringElement (texts [i]) } }; section.Add((Element) line); } return root; }
private void Core() { var rootStyles = new RootElement ("Add New Styles"); var styleHeaderElement = new Section ("Style Header"); var manualEntryRootElement = new RootElement ("Manual Entry"); styleHeaderElement.Add (manualEntryRootElement); var quickFillElement = new Section ("Quick Fill"); var womenTops = new RootElement ("Womens Tops"); var womenOutwear = new RootElement ("Womens Outerwear"); var womenSweaters = new RootElement ("Womens Sweaters"); quickFillElement.AddAll (new [] { womenTops, womenOutwear, womenSweaters }); rootStyles.Add (new [] { styleHeaderElement, quickFillElement }); // DialogViewController derives from UITableViewController, so access all stuff from it var rootDialog = new DialogViewController (rootStyles); rootDialog.NavigationItem.BackBarButtonItem = new UIBarButtonItem("Back", UIBarButtonItemStyle.Bordered, null); EventHandler handler = (s, e) => { if(_popover != null) _popover.Dismiss(true); }; rootDialog.NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Bordered, handler), true); rootDialog.NavigationItem.SetRightBarButtonItem(new UIBarButtonItem("Create", UIBarButtonItemStyle.Bordered, null), true); NavigationPopoverContentViewController = new UINavigationController (rootDialog); }
public void DemoHeadersFooters () { var section = new Section () { HeaderView = new UIImageView (UIImage.FromFile ("caltemplate.png")), FooterView = new UISwitch (new RectangleF (0, 0, 80, 30)), }; // Fill in some data var linqRoot = new RootElement ("LINQ source"){ from x in new string [] { "one", "two", "three" } select new Section (x) { from y in "Hello:World".Split (':') select (Element) new StringElement (y) } }; section.Add ((Element) new RootElement ("Desert", new RadioGroup ("desert", 0)){ new Section () { new RadioElement ("Ice Cream", "desert"), new RadioElement ("Milkshake", "desert"), new RadioElement ("Chocolate Cake", "desert") }, }); var root = new RootElement ("Headers and Footers") { section, new Section () { (Element) linqRoot } }; var dvc = new DialogViewController (root, true); navigation.PushViewController (dvc, true); }
public void accept_visitor_calls_into_steps_as_well() { var visitor = MockRepository.GenerateMock<ITestVisitor>(); var step1 = MockRepository.GenerateMock<IStep>(); var step2 = MockRepository.GenerateMock<IStep>(); var step3 = MockRepository.GenerateMock<IStep>(); var section = new Section("something"); section.Add(step1); section.Add(step2); section.Add(step3); section.AcceptVisitor(visitor); step1.AssertWasCalled(x => x.AcceptVisitor(visitor)); step2.AssertWasCalled(x => x.AcceptVisitor(visitor)); step3.AssertWasCalled(x => x.AcceptVisitor(visitor)); }
public void It_allows_you_to_look_up_template_definitions_by_name() { var section = new Section("foo"); var templateDefinition = new TemplateDefinition("bar"); section.Add(templateDefinition); var actual = section.GetTemplateDefinition(templateDefinition.Name); Assert.AreSame(templateDefinition, actual); }
public void DemoLoadMore () { Section loadMore = new Section(); var s = new StyledStringElement ("Hola") { BackgroundUri = new Uri ("http://www.google.com/images/logos/ps_logo2.png") //BackgroundColor = UIColor.Red }; loadMore.Add (s); loadMore.Add (new StringElement("Element 1")); loadMore.Add (new StringElement("Element 2")); loadMore.Add (new StringElement("Element 3")); loadMore.Add (new LoadMoreElement("Load More Elements...", "Loading Elements...", lme => { // Launch a thread to do some work ThreadPool.QueueUserWorkItem (delegate { // We just wait for 2 seconds. System.Threading.Thread.Sleep(2000); // Now make sure we invoke on the main thread the updates navigation.BeginInvokeOnMainThread(delegate { lme.Animating = false; loadMore.Insert(loadMore.Count - 1, new StringElement("Element " + (loadMore.Count + 1)), new StringElement("Element " + (loadMore.Count + 2)), new StringElement("Element " + (loadMore.Count + 3))); }); }); }, UIFont.BoldSystemFontOfSize(14.0f), UIColor.Blue)); var root = new RootElement("Load More") { loadMore }; var dvc = new DialogViewController (root, true); navigation.PushViewController (dvc, true); }
private RootElement BuildRoot(string url) { var root = new RootElement (String.Empty); var section = new Section("TodoItems"); root.Add (section); var result = GetAzureResult (url); foreach (JsonObject item in result) { section.Add (new StringElement(item["text"])); } return root; }
public void OnSaveClicked(object sender, EventArgs args) { // create flow document and register necessary styles FlowDocument doc = new FlowDocument(); doc.Margin = new Thickness (10,10,10,10); // the style for all document's textblocks doc.StyleManager.RegisterStyle("TextBlock, TextBox", new Style() { Font = new Font("Helvetica",20), Color = RgbColors.Black, Display = Display.Block }); // the style for the section that contains employee data doc.StyleManager.RegisterStyle ("#border", new Style () { Padding = new Thickness(10,10,10,10), BorderColor = RgbColors.DarkRed, Border = new Border(5), BorderRadius=5 } ); // add PDF form fields for later processing doc.Fields.Add (new TextField ("firstName", currentEmployee.FirstName)); doc.Fields.Add (new TextField ("lastName", currentEmployee.LastName)); doc.Fields.Add (new TextField ("position", currentEmployee.CurrentPosition)); // create section and add text block inside Section section = new Section (){Id="border"}; // ios PDF preview doesn't display fields correctly, // uncomment this code to use simple text blocks instead of text boxes // section.Add(new TextBlock(string.Format("First name: {0}",currentEmployee.FirstName))); // section.Add(new TextBlock(string.Format("Last name: {0}",currentEmployee.LastName))); // section.Add(new TextBlock(string.Format("Position: {0}",currentEmployee.CurrentPosition))); section.Add(new TextBlock("First name: ")); section.Add(new TextBox("firstName")); section.Add(new TextBlock("Last name: ")); section.Add(new TextBox("lastName")); section.Add(new TextBlock("Position: ")); section.Add(new TextBox("position")); doc.Add (section); // get io service and generate output file path var fileManager = DependencyService.Get<IFileIO>(); string filePath = Path.Combine (fileManager.GetMyDocumentsPath (), "form.pdf"); // generate document using(Stream outputStream = fileManager.CreateFile(filePath)) { doc.Write (outputStream, new ResourceManager()); } // request preview DependencyService.Get<IPDFPreviewProvider>().TriggerPreview (filePath); }
private static Configuration DeserializeBinary(BinaryReader reader, Stream stream) { if (stream == null) throw new ArgumentNullException("stream"); bool ownReader = false; if (reader == null) { reader = new BinaryReader(stream); ownReader = true; } try { var config = new Configuration(); int sectionCount = reader.ReadInt32(); for (int i = 0; i < sectionCount; i++) { string sectionName = reader.ReadString(); int settingCount = reader.ReadInt32(); Section section = new Section(sectionName); DeserializeComments(reader, section); for (int j = 0; j < settingCount; j++) { Setting setting = new Setting( reader.ReadString(), reader.ReadString()); DeserializeComments(reader, setting); section.Add(setting); } config.Add(section); } return config; } finally { if (ownReader) reader.Close(); } }
void FqlSample() { // query to get all the friends var query = string.Format("SELECT uid,name,pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1={0}) ORDER BY name ASC", "me()"); if (isLoggedIn) { _fb.GetTaskAsync("fql", new { q = query }).ContinueWith(t => { if (!t.IsFaulted) { if (t.Exception != null) { new UIAlertView("Couldn't Load Info", "Reason: " + t.Exception.Message, null, "Ok", null).Show(); return; } var result = (IDictionary <string, object>)t.Result; var data = (IList <object>)result["data"]; var count = data.Count; if (dvcController.Root[0].Elements.Count == 3) { InvokeOnMainThread(() => { dvcController.Root[0].Elements.RemoveAt(2); dvcController.ReloadData(); }); } friends = new RootElement(count + " friends"); var section = new Section(); foreach (IDictionary <string, object> friend in data) { section.Add(new StringElement((string)friend["name"])); } friends.Add(section); BeginInvokeOnMainThread(() => { dvcController.Root[0].Add(friends); new UIAlertView("Info", "You have " + count + " friend(s).", null, "Ok", null).Show(); }); } }); } else { new UIAlertView("Not Logged In", "Please Log In First", null, "Ok", null).Show(); } }
void HandleDataMessage(NSDictionary data) { var notificationSection = new Section("Data Message"); foreach (var key in data.Keys) { if (data[key] is NSDictionary || data[key] is NSArray) { notificationSection.Add(new StringElement(key.ToString(), "Multiple values")); } else { notificationSection.Add(new StringElement(key.ToString(), data[key].ToString())); } } Root.Add(notificationSection); }
static public void PrepareCategories() { Categories = DataLayer.GetCategories(); CategoriesRoot = new RootElement("Категория"); var section = new Section(); foreach (Category cCategory in Categories) { section.Add(new RadioElement(cCategory.Title) { Value = cCategory.Id.ToString() }); } CategoriesRoot.Add(section); }
// Recursive function to load all folders and their subfolders async Task LoadChildFolders(Section foldersSection, IMailFolder folder) { if (!folder.IsNamespace) { foldersSection.Add(new StyledStringElement(folder.FullName, () => OpenFolder(folder))); } var subfolders = await folder.GetSubfoldersAsync(); foreach (var sf in subfolders) { await LoadChildFolders(foldersSection, sf); } }
private void _save() { var configuration = new Configuration(); foreach (KeyValuePair <Type, List <Guid> > pair in _commands) { var section = new Section(pair.Key.ToAssemblyQualifiedString()); foreach (Guid id in pair.Value) { section.Add("Id", id); } configuration.Add(section); } configuration.SaveToFile(_path); }
private void DisplaySettings() { _sc = new SwitchCell() { Text = "Remember user?", On = _user.Save }; _ec = new EntryCell() { Label = "Connect to:", Text = _user.Url }; HeaderLabel.Text = _user.Name + " Settings"; Section.Add(_sc); Section.Add(_ec); }
/// <summary> /// terminates run /// </summary> public virtual void Terminate() { // log sections _jour.Add(_secs); Section sec = (Section) new Section() .Construct(_jour.Entries.Count, "tables"); sec.Add(_tbls.ToArray <Data>()); _jour.Add(sec); DateTime _stop = DateTime.Now; _outp += "\n\nRun Stops:" + _stop + "\nTime elapsed:" + (_stop - _stat); }
// it's still fast enough for my iPad 1st gen - but it might need moving to a separate thread in the future static Section Populate() { Elements e = new Elements(); Section s = new Section(); foreach (FieldInfo fi in typeof(Elements).GetFields(BindingFlags.NonPublic | BindingFlags.Instance)) { if (!fi.Name.StartsWith("icon_")) { continue; } s.Add((Element)fi.GetValue(e)); } return(s); }
// Recursive function to load all folders and their subfolders async Task LoadChildFolders(Section foldersSection, IMailFolder imapFolder) { if (!string.IsNullOrWhiteSpace(imapFolder.FullName)) { foldersSection.Add(new StyledStringElement(imapFolder.FullName, () => OpenFolder(imapFolder))); } var subfolders = await imapFolder.GetSubfoldersAsync(); foreach (var sf in subfolders) { await LoadChildFolders(foldersSection, sf); } }
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 }); }
static void PopulateEndorsementSection(Section section, AircraftEndorsement endorsements, AircraftEndorsement mask) { string caption; foreach (AircraftEndorsement endorsement in Enum.GetValues(typeof(AircraftEndorsement))) { if (endorsement == AircraftEndorsement.None || !mask.HasFlag(endorsement)) { continue; } caption = endorsement.ToHumanReadableName(); section.Add(new BooleanElement(caption, endorsements.HasFlag(endorsement), endorsement.ToString())); } }
public override void ViewDidLoad() { base.ViewDidLoad(); var section = new Section(); section.Add(new LoadMoreElement("Failed...Click to Retry.", "Getting Drug Info...", (element) => { }) { Animating = true }); this.Root.Clear(); this.Root.Add(section); this.TableView.ReloadData(); }
private RootElement BuildLoginElement() { var loginElement = new RootElement("Login"); var credSection = new Section("Credentials"); usernameElement = new EntryElement("Username:"******"Enter username", string.Empty, false); credSection.Add(usernameElement); passwordElement = new EntryElement("Password:"******"Login", delegate { Console.WriteLine("Login btn clicked"); Console.WriteLine("username={0}&password={1}", usernameElement.Value, passwordElement.Value); })); loginElement.Add(btnSection); return(loginElement); }
public void CreateAddPositionScreen(Section section) { section.Clear(); EntryElement nameEntry = new EntryElement("Name", "", ""); EntryElement priceEntry = new EntryElement("Price", "price per unit", ""); EntryElement amountEntry = new EntryElement("Amount", "", ""); StringElement doneButton = new StringElement("DONE"); doneButton.Tapped += () => { CurrentOrder.AddPostion(new OrderPosition(0, nameEntry.Value, Convert.ToInt32(priceEntry.Value), Convert.ToInt32(amountEntry.Value))); CreateAddOrderScreen(section); }; section.Add(nameEntry); section.Add(priceEntry); section.Add(amountEntry); section.Add(doneButton); }
private void PopulateResults(RxConceptGroup[] conceptGroup) { var section = new Section(); if (conceptGroup.Any()) { foreach (var concept in conceptGroup.SelectMany(x => x.rxConcept)) { var element = new DrugSearchResultElement(concept, PushDrugViewController); section.Add(element); } } else { section.Add(new StringElement("No Results Found.")); } Root.Clear(); Root.Add(section); this.ReloadData(); HideSearchingView(); }
protected virtual void Render() { //Wait for the issue to load if (ViewModel.Issue == null) { return; } var root = new RootElement(Title); root.Add(new Section(_header)); var secDetails = new Section(); if (!string.IsNullOrEmpty(_descriptionElement.Value)) { secDetails.Add(_descriptionElement); } secDetails.Add(_assigneeElement); secDetails.Add(_milestoneElement); secDetails.Add(_labelsElement); root.Add(secDetails); if (!string.IsNullOrEmpty(_commentsElement.Value)) { root.Add(new Section { _commentsElement }); } root.Add(new Section { _addCommentElement }); Root = root; }
protected void UpdateView() { ICollection <Section> sections = new LinkedList <Section>(); var section = new Section(); sections.Add(section); _descriptionElement.Details = _model.Description; section.Add(_descriptionElement); var fileSection = new Section(); sections.Add(fileSection); foreach (var file in _model.Files.Keys) { var key = file; if (!_model.Files.ContainsKey(key) || _model.Files[file] == null || _model.Files[file].Content == null) { continue; } var elName = key; if (_model.Files[key].NewFileName != null) { elName = _model.Files[key].NewFileName; } var el = new FileElement(elName, key, _model.Files[key]); el.Clicked.Subscribe(MakeCallback(this, key)); fileSection.Add(el); } fileSection.Add(_addFileElement); Root.Reset(sections); }
private void UpdateRoot(IEnumerable <AgileZenStory> myStories) { var projects = (from c in myStories select c.Project).DistinctBy(project => project.Id); var projectSections = new List <Section>(); foreach (var project in projects) { var section = new Section(project.Name); var elements = GetMatchingStoriesToProject(project, myStories); section.Add(elements); projectSections.Add(section); } _dv.Root = UpdatedRoot(projectSections); }
public override void Render() { RootElement root = new RootElement(Model.CategoryDisplayName ?? Model.Category); Section section = new Section(); foreach (var book in Model) { string isbn = string.IsNullOrEmpty(book.ISBN10) ? book.ISBN13 : book.ISBN10; string uri = String.Format("{0}/{1}", book.CategoryEncoded, isbn); StringElement se = new StringElement(book.Title, () => { this.Navigate(uri); }); section.Add(se); } root.Add(section); Root = root; }
static RootElement CreatePilotCertificationElement(PilotCertification certification) { var root = new RootElement("Pilot Certification", new RadioGroup("PilotCertification", 0)); var section = new Section(); foreach (PilotCertification value in Enum.GetValues(typeof(PilotCertification))) { section.Add(new RadioElement(value.ToHumanReadableName(), "PilotCertification")); } root.Add(section); root.RadioSelected = (int)certification; return(root); }
RootElement CreateRoot(List <Movie> movies) { Section section = new Section(); foreach (var movie in movies) { var theMovie = movie; section.Add(new StringElement(movie.ToString(), delegate { ActivateController(new MovieDetailController(theMovie)); })); } return(new RootElement("Movies") { section }); }
private void BuildPreferences() { page = new Page(); Section main_section = new Section(); main_section.Order = -1; space_for_data = CreateSchema <long> ("space_for_data", 0, "How much space, in bytes, to reserve for data on the device.", ""); main_section.Add(space_for_data); page.Add(main_section); foreach (Section section in sync.PreferenceSections) { page.Add(section); } }
public override RootElement CreateRoot() { Requirements = Database.GetRequirements(Rank, 0).ToArray(); RequirementStatus = Database.GetRequirementsStatus(Rank, Person.Id); var section = new Section("RankImage"); foreach (var req in Requirements) { section.Add(ElementForRequirement(req)); } return(new RootElement(Person.FullName()) { section }); }
RootElement CreateRoot(List <Actor> actors) { var section = new Section(); foreach (var actor in actors) { var theActor = actor; section.Add(new StringElement(theActor.Name, delegate { ActivateController(new ActorDetailViewController(theActor)); })); } return(new RootElement("Actors") { section }); }
static RootElement CreateFlightTimeFormatElement(FlightTimeFormat format) { var root = new RootElement("Flight Time Format", new RadioGroup("FlightTimeFormat", 0)); var section = new Section(); foreach (FlightTimeFormat value in Enum.GetValues(typeof(FlightTimeFormat))) { section.Add(new RadioElement(value.ToHumanReadableName(), "FlightTimeFormat")); } root.Add(section); root.RadioSelected = (int)format; return(root); }
void LoadAircraft() { Section section = new Section(); AircraftElement element; foreach (var aircraft in LogBook.GetAllAircraft()) { element = new AircraftElement(aircraft); element.Changed += OnElementChanged; section.Add(element); } Root.Add(section); LogBook.AircraftAdded += OnAircraftAdded; }
void InitializeComponents() { countriesManager = CountriesManager.SharedInstance; var countriesSection = new Section(); foreach (var country in countriesManager.Countries) { var flag = countriesManager.CountryFlags [country.Key]; countriesSection.Add(new StringElement($"{country.Key} - {flag} {country.Value}", CountryTapped)); } Root = new RootElement("Countries") { countriesSection }; }
static RootElement CreateCategoryElement(AircraftCategory category) { var root = new RootElement("Category", new RadioGroup("AircraftCategory", 0)); var section = new Section(); foreach (AircraftCategory value in Enum.GetValues(typeof(AircraftCategory))) { section.Add(new RadioElement(value.ToHumanReadableName(), "AircraftCategory")); } root.Add(section); root.RadioSelected = CategoryToIndex(category); return(root); }
private void addTest(string name, Action <StepLeaf> configure) { var test = new Test(name); var section = new Section(typeof(SampleTableFixture).GetFixtureAlias()); test.Add(section); var step = new Step("Table1"); section.Add(step); var leaf = step.LeafFor("rows"); configure(leaf); AddTest(name, test); }
public MultipleChoiceViewController(string title, object obj) { _obj = obj; Title = title; Style = UITableViewStyle.Grouped; var sec = new Section(); var fields = obj.GetType().GetProperties(); foreach (var s in fields) { var copy = s; sec.Add(new StyledStringElement(s.Name, () => OnValueSelected(copy)) { Accessory = (bool)s.GetValue(_obj) ? UITableViewCellAccessory.Checkmark : UITableViewCellAccessory.None }); } Root.Add(sec); }
public IssueMilestonesFilterViewController(string user, string repo, bool alreadySelected) : base(UIKit.UITableViewStyle.Plain) { _username = user; _repository = repo; Title = "Milestones"; SearchPlaceholder = "Search Milestones"; var clearMilestone = new MilestoneModel { Title = "Clear milestone filter" }; var noMilestone = new MilestoneModel { Title = "Issues with no milestone" }; var withMilestone = new MilestoneModel { Title = "Issues with milestone" }; _milestones.CollectionChanged += (sender, e) => { var items = _milestones.ToList(); items.Insert(0, noMilestone); items.Insert(1, withMilestone); if (alreadySelected) items.Insert(0, clearMilestone); var sec = new Section(); foreach (var item in items) { var x = item; var element = new StringElement(x.Title); element.Clicked.Subscribe(_ => { if (MilestoneSelected != null) { if (x == noMilestone) MilestoneSelected(x.Title, null, "none"); else if (x == withMilestone) MilestoneSelected(x.Title, null, "*"); else if (x == clearMilestone) MilestoneSelected(null, null, null); else MilestoneSelected(x.Title, x.Number, x.Number.ToString()); } }); sec.Add(element); } InvokeOnMainThread(() => Root.Reset(sec)); }; }
public MultipleChoiceViewController(string title, object obj) : base(UITableViewStyle.Grouped) { _obj = obj; Title = title; var sec = new Section(); var fields = obj.GetType().GetProperties(); foreach (var s in fields) { var copy = s; var accessory = (bool)s.GetValue(_obj) ? UITableViewCellAccessory.Checkmark : UITableViewCellAccessory.None; var e = new StringElement(s.Name) { Accessory = accessory }; e.Clicked.Subscribe(_ => OnValueSelected(copy)); sec.Add(e); } Root.Add(sec); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // create from view var dialogListView = new DialogListView(this); SetContentView(dialogListView); RootElement root = new RootElement("Elements"); Section section = new Section(); root.Add(section); foreach (var item in _names) { section.Add(new StringElement(item.LastName, item.FirstName, "custom_string_element")); } dialogListView.Root = root; }
public override void ViewDidLoad() { base.ViewDidLoad(); var sec = new Section(); foreach (var val in _values) { var capture = val; var el = new StyledStringElement(val); if (string.Equals(val, _selected, StringComparison.OrdinalIgnoreCase)) el.Accessory = UIKit.UITableViewCellAccessory.Checkmark; el.Tapped += () => { if (SelectedValue != null) SelectedValue(capture); NavigationController.PopViewController(true); }; sec.Add(el); } Root = new RootElement(Title) { sec }; }
public override void ViewDidLoad() { base.ViewDidLoad(); var sec = new Section(); foreach (var val in _values) { var capture = val; var el = new StringElement(val); if (string.Equals(val, _selected, StringComparison.OrdinalIgnoreCase)) el.Accessory = UIKit.UITableViewCellAccessory.Checkmark; el.Clicked.Subscribe(_ => { SelectedValue?.Invoke(capture); NavigationController.PopViewController(true); }); sec.Add(el); } Root.Reset(sec); }
RootElement InitializeRoot() { RootElement root = new RootElement("Elements"); Section section = new Section("Section"); root.Add(section); section.Add(new EntryElement("Label 1", "Value 1")); section.Add(new EntryElement("Label 2", "Value 2")); section.Add(new EntryElement("Label 3", "Value 3")); section.Add(new EntryElement("Label 4", "Value 4")); section.Add(new EntryElement("Label 5", "Value 5")); section.Add(new EntryElement("Label 6", "Value 6")); section.Add(new WebContentElement("http://www.google.com") { WebContent = "<html><body><h1>My First Heading</h1><p>My first paragraph.</p></body></html>" }); //section.Add(new EntryElement("Label 7", "Value 7")); return root; }
public void RenderIssue() { if (ViewModel.Issue == null) return; var avatar = new Avatar(ViewModel.Issue.ReportedBy?.Avatar); NavigationItem.RightBarButtonItem.Enabled = true; HeaderView.Text = ViewModel.Issue.Title; HeaderView.SetImage(avatar.ToUrl(), Images.Avatar); HeaderView.SubText = ViewModel.Issue.Content ?? "Updated " + ViewModel.Issue.UtcLastUpdated.Humanize(); RefreshHeaderView(); var split = new SplitButtonElement(); split.AddButton("Comments", ViewModel.Comments.Items.Count.ToString()); split.AddButton("Watches", ViewModel.Issue.FollowerCount.ToString()); var root = new RootElement(Title); root.Add(new Section { split }); var secDetails = new Section(); if (!string.IsNullOrEmpty(ViewModel.Issue.Content)) { _descriptionElement.LoadContent(new MarkdownRazorView { Model = ViewModel.Issue.Content }.GenerateString()); secDetails.Add(_descriptionElement); } var split1 = new SplitElement(new SplitElement.Row { Image1 = Images.Cog, Image2 = Images.Priority }); split1.Value.Text1 = ViewModel.Issue.Status; split1.Value.Text2 = ViewModel.Issue.Priority; secDetails.Add(split1); var split2 = new SplitElement(new SplitElement.Row { Image1 = Images.Flag, Image2 = Images.ServerComponents }); split2.Value.Text1 = ViewModel.Issue.Metadata.Kind; split2.Value.Text2 = ViewModel.Issue.Metadata.Component ?? "No Component"; secDetails.Add(split2); var split3 = new SplitElement(new SplitElement.Row { Image1 = Images.SitemapColor, Image2 = Images.Milestone }); split3.Value.Text1 = ViewModel.Issue.Metadata.Version ?? "No Version"; split3.Value.Text2 = ViewModel.Issue.Metadata.Milestone ?? "No Milestone"; secDetails.Add(split3); var assigneeElement = new StyledStringElement("Assigned", ViewModel.Issue.Responsible != null ? ViewModel.Issue.Responsible.Username : "******", UITableViewCellStyle.Value1) { Image = Images.Person, Accessory = UITableViewCellAccessory.DisclosureIndicator }; assigneeElement.Tapped += () => ViewModel.GoToAssigneeCommand.Execute(null); secDetails.Add(assigneeElement); root.Add(secDetails); if (ViewModel.Comments.Any(x => !string.IsNullOrEmpty(x.Content))) { root.Add(new Section { _commentsElement }); } var addComment = new StyledStringElement("Add Comment") { Image = Images.Pencil }; addComment.Tapped += AddCommentTapped; root.Add(new Section { addComment }); Root = root; }
private void CreateTable() { var application = Mvx.Resolve<IApplicationService>(); var vm = (SettingsViewModel)ViewModel; var currentAccount = application.Account; var accountSection = new Section("Account"); var showOrganizationsInEvents = new BooleanElement("Show Organizations in Events", currentAccount.ShowOrganizationsInEvents); showOrganizationsInEvents.Changed.Subscribe(x => { currentAccount.ShowOrganizationsInEvents = x; application.Accounts.Update(currentAccount); }); var showOrganizations = new BooleanElement("List Organizations in Menu", currentAccount.ExpandOrganizations); showOrganizations.Changed.Subscribe(x => { currentAccount.ExpandOrganizations = x; application.Accounts.Update(currentAccount); }); var repoDescriptions = new BooleanElement("Show Repo Descriptions", currentAccount.ShowRepositoryDescriptionInList); repoDescriptions.Changed.Subscribe(x => { currentAccount.ShowRepositoryDescriptionInList = x; application.Accounts.Update(currentAccount); }); var startupView = new StringElement("Startup View", vm.DefaultStartupViewName, UITableViewCellStyle.Value1) { Accessory = UITableViewCellAccessory.DisclosureIndicator, }; startupView.Clicked.BindCommand(vm.GoToDefaultStartupViewCommand); var pushNotifications = new BooleanElement("Push Notifications", vm.PushNotificationsEnabled); pushNotifications.Changed.Subscribe(e => vm.PushNotificationsEnabled = e); accountSection.Add(pushNotifications); var source = new StringElement("Source Code"); source.Clicked.BindCommand(vm.GoToSourceCodeCommand); var follow = new StringElement("Follow On Twitter"); follow.Clicked.Subscribe(_ => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://twitter.com/CodeHubapp"))); var rate = new StringElement("Rate This App"); rate.Clicked.Subscribe(_ => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://itunes.apple.com/us/app/codehub-github-for-ios/id707173885?mt=8"))); var aboutSection = new Section("About", "Thank you for downloading. Enjoy!") { source, follow, rate }; if (vm.ShouldShowUpgrades) { var upgrades = new StringElement("Upgrades"); upgrades.Clicked.BindCommand(vm.GoToUpgradesCommand); aboutSection.Add(upgrades); } var appVersion = new StringElement("App Version", UIApplication.SharedApplication.GetVersion()) { Accessory = UITableViewCellAccessory.None, SelectionStyle = UITableViewCellSelectionStyle.None }; aboutSection.Add(appVersion); //Assign the root Root.Reset(accountSection, new Section("Appearance") { showOrganizationsInEvents, showOrganizations, repoDescriptions, startupView }, aboutSection); }
private void BuildPreferences() { conf_ns = "sync"; LegacyManuallyManage = dap.CreateSchema<bool> (conf_ns, "enabled", false, "", ""); auto_sync = dap.CreateSchema<bool> (conf_ns, "auto_sync", false, Catalog.GetString ("Sync when first plugged in and when the libraries change"), Catalog.GetString ("Begin synchronizing the device as soon as the device is plugged in or the libraries change.") ); sync_prefs = new Section ("sync", Catalog.GetString ("Sync Preferences"), 0); pref_sections.Add (sync_prefs); sync_prefs.Add (new VoidPreference ("library-options")); auto_sync_pref = sync_prefs.Add (auto_sync); auto_sync_pref.ValueChanged += OnAutoSyncChanged; }
private void InstallPreferences() { PreferenceService service = ServiceManager.Get<PreferenceService> (); if (service == null) { return; } pref_page = new Banshee.Preferences.SourcePage (this); pref_section = pref_page.Add (new Section ("mediatypes", Catalog.GetString ("Preferred Media Types"), 20)); pref_section.Add (new SchemaPreference<string> (AudioTypes, Catalog.GetString ("_Audio"), "")); pref_section.Add (new SchemaPreference<string> (VideoTypes, Catalog.GetString ("_Video"), "")); pref_section.Add (new SchemaPreference<string> (TextTypes, Catalog.GetString ("_Text"), "")); }
private void BuildPreferences() { page = new Page (); Section main_section = new Section (); main_section.Order = -1; space_for_data = CreateSchema<long> ("space_for_data", 0, "How much space, in bytes, to reserve for data on the device.", ""); main_section.Add (space_for_data); page.Add (main_section); foreach (Section section in sync.PreferenceSections) { page.Add (section); } }
protected void InstallPreferences() { if (!pref_installed) { preference_service.InstallWidgetAdapters += OnPreferencesServiceInstallWidgetAdapters; pref_page = preference_service.Add(new Page("clutterflow", AddinManager.CurrentLocalizer.GetString ("ClutterFlow"), 10)); general = pref_page.Add (new Section ("general", AddinManager.CurrentLocalizer.GetString ("General"), 1)); ClutterFlowSchemas.AddToSection (general, ClutterFlowSchemas.InstantPlayback, null); ClutterFlowSchemas.AddToSection (general, ClutterFlowSchemas.DisplayLabel, UpdateLabelVisibility); ClutterFlowSchemas.AddToSection (general, ClutterFlowSchemas.DisplayTitle, UpdateTitleVisibility); ClutterFlowSchemas.AddToSection (general, ClutterFlowSchemas.VisibleCovers, UpdateVisibleCovers); ClutterFlowSchemas.AddToSection (general, ClutterFlowSchemas.DragSensitivity, UpdateDragSensitivity); dimensions = pref_page.Add (new Section ("dimensions", AddinManager.CurrentLocalizer.GetString ("Dimensions"), 2)); dimensions.Add (new VoidPreference ("dimensions-desc")); ClutterFlowSchemas.AddToSection (dimensions, ClutterFlowSchemas.MinCoverSize, UpdateMinCoverSize); ClutterFlowSchemas.AddToSection (dimensions, ClutterFlowSchemas.MaxCoverSize, UpdateMaxCoverSize); ClutterFlowSchemas.AddToSection (dimensions, ClutterFlowSchemas.TextureSize, UpdateTextureSize); pref_installed = true; } }
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) 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; EventHandler 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, value) { Hint = pa.Placeholder, Password = true }; else if (ea != null) element = new EntryElement(caption, value) { Hint = ea.Placeholder }; else if (multi) element = new MultilineEntryElement(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).Click = invoke; } else if (mType == typeof(float)) { var floatElement = new FloatElement(null, null, (int)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, value: (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(ImageView)) { element = new ImageElement((ImageView)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); }
public void Render() { if (ViewModel.Commits == null || ViewModel.Commit == null) return; var titleMsg = (ViewModel.Commit.Message ?? string.Empty).Split(new [] { '\n' }, 2).FirstOrDefault(); var avatarUrl = ViewModel.Commit.Author?.User?.Links?.Avatar?.Href; var node = ViewModel.Node.Substring(0, ViewModel.Node.Length > 10 ? 10 : ViewModel.Node.Length); Title = node; HeaderView.Text = titleMsg ?? node; HeaderView.SubText = "Commited " + (ViewModel.Commit.Date).Humanize(); HeaderView.SetImage(new Avatar(avatarUrl).ToUrl(128), Images.Avatar); RefreshHeaderView(); var split = new SplitButtonElement(); split.AddButton("Comments", ViewModel.Comments.Items.Count.ToString()); split.AddButton("Participants", ViewModel.Commit.Participants.Count.ToString()); split.AddButton("Approvals", ViewModel.Commit.Participants.Count(x => x.Approved).ToString()); var commitModel = ViewModel.Commits; ICollection<Section> root = new LinkedList<Section>(); root.Add(new Section { split }); var detailSection = new Section(); root.Add(detailSection); var user = ViewModel.Commit.Author?.User?.DisplayName ?? ViewModel.Commit.Author.Raw ?? "Unknown"; detailSection.Add(new MultilinedElement(user, ViewModel.Commit.Message)); if (ViewModel.ShowRepository) { var repo = new StringElement(ViewModel.Repository) { Accessory = UIKit.UITableViewCellAccessory.DisclosureIndicator, Lines = 1, TextColor = StringElement.DefaultDetailColor, Image = AtlassianIcon.Devtoolsrepository.ToImage() }; repo.Clicked.BindCommand(ViewModel.GoToRepositoryCommand); detailSection.Add(repo); } if (_viewSegment.SelectedSegment == 0) { var paths = ViewModel.Commits.GroupBy(y => { var filename = "/" + y.File; return filename.Substring(0, filename.LastIndexOf("/", System.StringComparison.Ordinal) + 1); }).OrderBy(y => y.Key); foreach (var p in paths) { var fileSection = new Section(p.Key); foreach (var x in p) { var y = x; var file = x.File.Substring(x.File.LastIndexOf('/') + 1); var sse = new ChangesetElement(file, x.Type, x.Diffstat.Added, x.Diffstat.Removed); sse.Clicked.Select(_ => y).BindCommand(ViewModel.GoToFileCommand); fileSection.Add(sse); } root.Add(fileSection); } } else if (_viewSegment.SelectedSegment == 1) { var commentSection = new Section(); foreach (var comment in ViewModel.Comments) { var name = comment.User.DisplayName ?? comment.User.Username; var avatar = new Avatar(comment.User.Links?.Avatar?.Href); commentSection.Add(new CommentElement(name, comment.Content.Raw, comment.CreatedOn, avatar)); } if (commentSection.Elements.Count > 0) root.Add(commentSection); var addComment = new StringElement("Add Comment") { Image = AtlassianIcon.Addcomment.ToImage() }; addComment.Clicked.Subscribe(_ => AddCommentTapped()); root.Add(new Section { addComment }); } else if (_viewSegment.SelectedSegment == 2) { var likeSection = new Section(); likeSection.AddAll(ViewModel.Commit.Participants.Where(x => x.Approved).Select(l => { var avatar = new Avatar(l.User?.Links?.Avatar?.Href); var el = new UserElement(l.User.DisplayName, string.Empty, string.Empty, avatar); el.Clicked.Select(_ => l.User.Username).BindCommand(ViewModel.GoToUserCommand); return el; })); if (likeSection.Elements.Count > 0) root.Add(likeSection); StringElement approveButton; if (ViewModel.Commit.Participants.Any(x => x.User.Username.Equals(ViewModel.GetApplication().Account.Username) && x.Approved)) { approveButton = new StringElement("Unapprove") { Image = AtlassianIcon.Approve.ToImage() }; approveButton.Clicked.Subscribe(_ => this.DoWorkAsync("Unapproving...", ViewModel.Unapprove)); } else { approveButton = new StringElement("Approve") { Image = AtlassianIcon.Approve.ToImage() }; approveButton.Clicked.Subscribe(_ => this.DoWorkAsync("Approving...", ViewModel.Approve)); } root.Add(new Section { approveButton }); } Root.Reset(root); }
private void InstallPreferences () { pref_page = new Banshee.Preferences.SourcePage (PreferencesPageId, Name, "source-playlist", 500); pref_section = pref_page.Add (new Section ()); pref_section.ShowLabel = false; pref_section.Add (new SchemaPreference<int> (PlayedSongsNumberSchema, Catalog.GetString ("Number of _played songs to show"), null, delegate { played_songs_number = PlayedSongsNumberSchema.Get (); UpdatePlayQueue (); } )); pref_section.Add (new SchemaPreference<int> (UpcomingSongsNumberSchema, Catalog.GetString ("Number of _upcoming songs to show"), null, delegate { upcoming_songs_number = UpcomingSongsNumberSchema.Get (); UpdatePlayQueue (); } )); }
protected virtual void Render() { //Wait for the issue to load if (ViewModel.Issue == null) return; var participants = ViewModel.Events.Select(x => x.Actor.Login).Distinct().Count(); _splitButton1.Text = ViewModel.Issue.Comments.ToString(); _splitButton2.Text = participants.ToString(); ICollection<Section> sections = new LinkedList<Section>(); sections.Add(new Section { _split }); var secDetails = new Section(); if (_descriptionElement.HasValue) secDetails.Add(_descriptionElement); secDetails.Add(_assigneeElement); secDetails.Add(_milestoneElement); secDetails.Add(_labelsElement); sections.Add(secDetails); var commentsSection = new Section(); if (_commentsElement.HasValue) commentsSection.Add(_commentsElement); commentsSection.Add(_addCommentElement); sections.Add(commentsSection); Root.Reset(sections); }
public LastfmPreferences (LastfmSource source) { var service = ServiceManager.Get<PreferenceService> (); if (service == null) { return; } this.source = source; service.InstallWidgetAdapters += OnPreferencesServiceInstallWidgetAdapters; source_page = new Banshee.Preferences.SourcePage (source) { (account_section = new Section ("lastfm-account", Catalog.GetString ("Account"), 20) { (username_preference = new SchemaPreference<string> (LastfmSource.LastUserSchema, Catalog.GetString ("_Username")) { ShowLabel = false }), new VoidPreference ("lastfm-signup") }), (prefs_section = new Section ("lastfm-settings", Catalog.GetString ("Preferences"), 30)) }; scrobbler = ServiceManager.Get<Banshee.Lastfm.Audioscrobbler.AudioscrobblerService> (); if (scrobbler != null) { reporting_preference = new Preference<bool> ("enable-song-reporting", Catalog.GetString ("_Enable Song Reporting"), null, scrobbler.Enabled); reporting_preference.ValueChanged += root => scrobbler.Enabled = reporting_preference.Value; prefs_section.Add (reporting_preference); } }