Example #1
0
        public void SetSectionSortOrder([NotNull] TemplateSection templateSection, [NotNull] string sectionId, int value)
        {
            Assert.ArgumentNotNull(templateSection, nameof(templateSection));
            Assert.ArgumentNotNull(sectionId, nameof(sectionId));

            Modified = true;

            foreach (var templateFieldse in Model)
            {
                foreach (var field in templateFieldse.Fields)
                {
                    if (field.SectionId != sectionId)
                    {
                        continue;
                    }

                    field.SectionSortOrder = value;

                    if (IsModifiedTracking == 0)
                    {
                        field.Modified = true;
                    }
                }
            }

            foreach (var s in Sections)
            {
                if (s != templateSection && s.SectionId == sectionId)
                {
                    s.SectionSortOrder.Text = value.ToString();
                }
            }
        }
Example #2
0
        private void RenderSections([NotNull] Field nextField)
        {
            Debug.ArgumentNotNull(nextField, nameof(nextField));

            var newSection = false;

            foreach (var template in Model)
            {
                if (template.Current >= template.VisibleFields.Count)
                {
                    continue;
                }

                var field = template.VisibleFields[template.Current];

                if (field.SortOrder == nextField.SortOrder && field.SectionName != template.CurrentSectionName)
                {
                    newSection = true;
                    break;
                }
            }

            if (!newSection)
            {
                return;
            }

            foreach (var template in Model)
            {
                UserControl control;

                if (template.Current >= template.VisibleFields.Count)
                {
                    control = new EmptyTemplateSection();
                }
                else
                {
                    var field = template.VisibleFields[template.Current];

                    if (field.SortOrder == nextField.SortOrder && field.SectionName != template.CurrentSectionName)
                    {
                        var templateSection = new TemplateSection();
                        templateSection.Initialize(this, template, field.SectionName, field.SectionSortOrder, field.SectionId);
                        template.CurrentSectionName = field.SectionName;

                        Sections.Add(templateSection);

                        control = templateSection;
                    }
                    else
                    {
                        control = new EmptyTemplateSection();
                    }
                }

                template.StackPanel.Children.Add(control);
            }
        }