/// <summary> /// Section Constructor /// </summary> /// <param name="ribbon">the Ribbon that this Section was created by and is a part of</param> /// <param name="id">Component id of the Secton</param> /// <param name="type">type of the section</param> internal Section(SPRibbon ribbon, string id, SectionType type, SectionAlignment alignment) : base(ribbon, id, "", "") { _type = type; _alignment = alignment; switch (type) { case SectionType.ThreeRow: AddChildInternal(new Row(ribbon, id + "-0"), false); AddChildInternal(new Row(ribbon, id + "-1"), false); AddChildInternal(new Row(ribbon, id + "-2"), false); break; case SectionType.TwoRow: AddChildInternal(new Row(ribbon, id + "-0"), false); AddChildInternal(new Row(ribbon, id + "-1"), false); break; case SectionType.OneRow: AddChildInternal(new Row(ribbon, id + "-0"), false); break; case SectionType.Divider: break; default: throw new ArgumentException("Invalid SectionType"); } }
private Section CreateSectionFromData(object data, DeclarativeTemplateBuildContext bc, Layout layout, int sectionNumber) { SectionType type; string strType = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.TYPE); string strAlignment = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.ALIGNMENT); switch (strType) { case DataNodeWrapper.ONEROW: type = SectionType.OneRow; break; case DataNodeWrapper.TWOROW: type = SectionType.TwoRow; break; case DataNodeWrapper.THREEROW: type = SectionType.ThreeRow; break; case DataNodeWrapper.DIVIDER: type = SectionType.Divider; break; default: throw new ArgumentOutOfRangeException("Invalid Section attribute \"Type\" found in XML: " + strType); } SectionAlignment alignment = SectionAlignment.Top; if (strAlignment == "Middle") { alignment = SectionAlignment.Middle; } Section section = bc.Ribbon.CreateSection(layout.Id + "-" + sectionNumber, type, alignment); if (type != SectionType.Divider) { HandleRow(section.GetRow(1), DataNodeWrapper.GetNodeChildren(data)[0], bc); if (section.Type == SectionType.TwoRow || section.Type == SectionType.ThreeRow) { HandleRow(section.GetRow(2), DataNodeWrapper.GetNodeChildren(data)[1], bc); } if (section.Type == SectionType.ThreeRow) { HandleRow(section.GetRow(3), DataNodeWrapper.GetNodeChildren(data)[2], bc); } } return(section); }
/// <summary> /// Creates a Section /// </summary> /// <param name="id">Component id of the Section</param> /// <param name="type">The type of Section to create</param> /// <returns>the created Section</returns> internal Section CreateSection(string id, SectionType type, SectionAlignment alignment) { return new Section(this, id, type, alignment); }