/// <summary> /// Get the Layout Information for a Section. /// </summary> private SectionLayout GetSectionLayout(Section section, DataEntrySection dataEntrySection) { // Create the Section Layout var sectionLayout = new SectionLayout() { // The Name is what is Used to correlate sections across systems. // This is because the metadata has different IDs across all systems. DataEntrySectionName = dataEntrySection.Name, Description = section.Description, Fields = new List <FieldLayout>(), Label = section.Label, OrderBy = section.OrderBy, SubSections = new List <SubSectionLayout>() }; // Process SubSections foreach (var subSection in section.SubSections) { sectionLayout.SubSections.Add(GetSubSectionLayout(subSection, dataEntrySection)); } // Process Fields foreach (var field in section.Fields) { // Lookup the SubSection Name var subSectionName = field.SubSectionId == Guid.Empty ? null : section.GetSubSection(field.SubSectionId).Label; // Lookup the Metadata var dataEntryField = dataEntrySection.GetField(field.DataEntryFieldId); // Get the Field Layout. sectionLayout.Fields.Add(GetFieldLayout(field, dataEntryField, subSectionName)); } return(sectionLayout); }
public void SectionLayoutTest() { var inputs = new SectionLayoutInputs(true, 20.0, 20.0, 20.0, 20.0, 2.0, 0.5, "", "", new Dictionary <string, string>(), "", "", ""); var model = Model.FromJson(System.IO.File.ReadAllText("../../../../Envelope.json")); var outputs = SectionLayout.Execute(new Dictionary <string, Model> { { "Envelope", model } }, inputs); System.IO.File.WriteAllText("../../../../SectionLayout.json", outputs.model.ToJson()); outputs.model.ToGlTF("../../../../SectionLayout.glb"); }
public DynamicSectionContent(SectionContent SC, SectionLayout SL) { this.Title = SC.Title; this.SectionLayoutID = SC.SectionLayoutID; this.SubTitle = SC.SubTitle; this.BodyHTML = SC.BodyHTML; this.NextContentID = SC.NextContentID; this.PreviousContentID = SC.PreviousContentID; this.ContentID = SC.ContentID; this.LayoutName = SL.LayoutName; this.HeaderLink = SL.HeaderLink; this.Header = SL.Header; this.Footer = SL.Footer; this.CssClass = SL.CssClass; }
public override Layout?ReadJson( JsonReader reader, Type objectType, Layout?existingValue, bool hasExistingValue, JsonSerializer serializer) { var jo = JObject.ReadFrom(reader); var type = jo[nameof(Layout.type)]?.Value <string>(); switch (type) { case "header": existingValue = new HeaderLayout(); break; case "context": existingValue = new ContextLayout(); break; case "image": existingValue = new ImageLayout(); break; case "divider": existingValue = new DividerLayout(); break; case "section": existingValue = new SectionLayout(); break; case "input": existingValue = new InputLayout(); break; case "action": existingValue = new ActionsLayout(); break; default: return(default); } serializer.Populate(jo.CreateReader(), existingValue); return(existingValue); }
/// <summary> /// Apply Layout Information to an Existing Section. /// </summary> /// <param name="sectionLayout">The Section Layout Information.</param> /// <param name="section">The Section to apply the layout to.</param> /// <param name="sectionMetadata">Local Metadata for the Section.</param> private void ApplySectionLayout(SectionLayout sectionLayout, Section section, DataEntrySection sectionMetadata) { // Load the Section Information section.Description = sectionLayout.Description; section.OrderBy = sectionLayout.OrderBy; // Process SubSections foreach (var subSectionLayout in sectionLayout.SubSections) { // Make sure the SubSections Exist if (section.GetSubSection(subSectionLayout.Label) == null) { section.CreateSubSection(subSectionLayout.Label); } } // Process Fields foreach (var fieldLayout in sectionLayout.Fields) { // Find the appropriate SubSection if any. var subSection = string.IsNullOrWhiteSpace(fieldLayout.SubSectionName) ? null : section.GetSubSection(fieldLayout.SubSectionName); // Lookup the Field Metadata var fieldMeta = sectionMetadata.GetFieldByPath(fieldLayout.Path); if (fieldMeta == null) { _log.Error("WARNING: No Metadata can be found in Section {0} for field with path {1}!", section.Label, fieldLayout.Path); continue; } // Find or Create the Field var field = section.GetFieldByMetaId(fieldMeta.Id) ?? section.CreateField(fieldMeta.Id, fieldLayout.Label, subSection); // Load the Layout Information into the Field. field.AgencyValidation = fieldLayout.AgencyValidation; field.ColumnSpan = fieldLayout.ColumnSpan; field.DefaultValue = fieldLayout.DefaultValue; field.Description = fieldLayout.Description; field.Label = fieldLayout.Label; field.MasterIndexSearchable = fieldMeta.MasterIndexSearchable; // Pulled From Meta (This should be injected at runtime instead). field.OrderBy = fieldLayout.OrderBy; // field.ReportDisplayType = This is not yet supported in the Layout. field.SetCurrentDate = fieldMeta.SetCurrentDate; // This is pulled from the Meta, This should have been part of DefaultValue. } }
public Module(ModuleLayout layout) { _layout = layout; int[] labelsCount = new int[_layout.data.sectionsCount]; Array.Clear(labelsCount, 0, _layout.data.sectionsCount); Label[] labels = new Label[_layout.data.symbolsCount]; for (int i = 0; i < _layout.data.symbolsCount; i++) { SymbolLayout symbol = _layout.data.symbols[i]; labelsCount[symbol.sectionIndex]++; labels[i] = new Label() { Name = _layout.data.strings[symbol.nameIndex], Offset = symbol.blobEntryIndex, SectionId = symbol.sectionIndex }; } Sections = new Section[_layout.data.sectionsCount]; for (int i = 0; i < _layout.data.sectionsCount; i++) { SectionLayout section = _layout.data.sections[i]; int ind = 0; Sections[i] = new Section() { Data = _layout.data.blobs[section.blobIndex].data, Name = _layout.data.strings[section.bankNameIndex], Labels = new Label[labelsCount[i]] }; for (int j = 0; j < _layout.data.symbolsCount; j++) { if (labels[j].SectionId == i) { Sections[i].Labels[ind++] = labels[j]; } } } }
public ExampleHometabSurface(ISlackApp slackApp) : base(slackApp) { Title = "SlackDK Title"; var layouts = new List <Layout> { new HeaderLayout("SlackDK Home Page"), new SectionLayout { text = new Markdown("*Welcome* to the _new_ and _improved_ SlackDK ~inner-city apartment~ home page") }, (_statusLayout = new SectionLayout { text = ":wave: hello" }), new SectionLayout { text = "It's a kind of", block_id = "magic-block", accessory = new ButtonElement { action_id = "magic-button", text = "Magic", Clicked = ((surface, button, actions) => { _statusLayout.text = ":banana: :sob: Magic is hard"; slackApp.Update(this); }) } }, new InputLayout { block_id = "textinput-block", label = "What are you doing today", element = new TextInputElement("what-doing") { TextUpdated = (s, _, a) => { _statusLayout.text = new Markdown($"Keep talking brah. I'm listening. `{a.value ?? ""}`"); slackApp.Update(this); }, dispatch_action_config = DispatchAction.CharacterEntered }, dispatch_action = true }, new InputLayout { block_id = "checkboxes-block", label = "Update the following survey", element = new CheckboxesElement("what-survey") { options = new List <Option> { new Option("I love the historical sound of dialup", "dialup"), new Option("You can never get enough data", "enough-data"), new Option("73.6% of statistics are true", "lies-statistics"), new Option("The future is soo bright, I have to wear shades", "future-shades"), } } }, new InputLayout { block_id = "options-block", label = "Update the following option", element = new RadioButtonsElement("what-options") { options = new List <Option> { new Option("I love fake news", "fake-news"), new Option("Enough data is never enough", "more-data"), new Option("I trust 73.6% of statistics", "true-lies"), new Option("The future is yesterday", "vision"), } } }, new InputLayout { block_id = "date-block", label = "What date will it happen", element = new DatePickerElement("what-date") }, // still in beta //new InputLayout //{ // label = "What time will it happen", // element = new TimePickerElement("what-time") //}, new SectionLayout { block_id = "overflow-block", text = new Markdown("Whatever you do, :x: do not select a menu item"), accessory = new OverflowMenuElement("what-overflow") { action_id = "what-overflow", options = new List <Option> { new Option("Erase Everything", "over-erase"), new Option("Delete something", "over-delete"), new Option("Update whatever", "over-update"), }, Clicked = (s, _, a) => { _statusLayout.text = new Markdown($"I told ya bro. I'm listening. `{a.selected_option}`"); slackApp.Update(this); } } }, new SectionLayout { block_id = "select-block", text = new Markdown("Fixed list for selection"), accessory = new SlackSkills.Surface.SelectElement { action_id = "what-selection", options = new List <Option> { new Option("One", "select-one"), new Option("Two", "select-two"), new Option("Three", "select-three"), new Option("Four", "select-four"), new Option("Five", "select-five"), }, Clicked = (s, _, a) => { _statusLayout.text = new Markdown($"Fixed selection is the bomb. `{a.selected_option}`"); slackApp.Update(this); } } }, new SectionLayout { block_id = "select-external-block", text = "Dynamic list for selection", accessory = new SelectExternalElement { action_id = "what-select-dynamic", placeholder = "The start of something dynamic", Suggestions = value => new Options { options = new List <Option> { new(value + " One", value + "-select-one"), new(value + " Two", value + "-select-two"), new(value + " Three", value + "-select-three"), new(value + " Four", value + "-select-four"), new(value + " Five", value + "-select-five"), } },
public Section(SectionLayout sectionLayout, BinaryModuleLayout moduleLayout) { Name = moduleLayout.strings[sectionLayout.bankNameIndex].str; Blob = moduleLayout.blobs[sectionLayout.blobIndex].data; }