Пример #1
0
 internal void FillLayout(object data,
                          Layout layout,
                          DeclarativeTemplateBuildContext bc)
 {
     JSObject[] children = DataNodeWrapper.GetNodeChildren(data);
     int sectionCounter = 0;
     for (int i = 0; i < children.Length; i++)
     {
         string name = DataNodeWrapper.GetNodeName(children[i]);
         if (name == DataNodeWrapper.SECTION)
         {
             Section section = CreateSectionFromData(children[i], bc, layout, sectionCounter++);
             layout.AddChild(section);
         }
         else
         {
             // This must be an <OverflowSection>
             sectionCounter = HandleOverflow(children[i], bc, layout, sectionCounter);
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Selects a Layout(by Title of the Layout) that will be displayed in this Group.
        /// </summary>
        /// <param name="name"></param>
        public void SelectLayout(string name, string popupSize)
        {
            Layout layout = null;
            if (name != "Popup")
            {
                layout = string.IsNullOrEmpty(name) ? null : 
                   (Layout)GetChildByTitle(name);
            }
            else
            {
                // If popupSize is null, then we just use the default that came from the template
                // If popupSize is not null, then we use the passed in one that was specified
                // on the <ScaleStep> node.
                if (!string.IsNullOrEmpty(popupSize))
                    PopupLayoutTitle = popupSize;

                EnsurePopup();
                layout = _popupLayout;
            }

            // If this layout was already selected then we don't need to do anything
            if (layout == _selectedLayout ||
                    CUIUtility.IsNullOrUndefined(layout) &&
                    CUIUtility.IsNullOrUndefined(_selectedLayout))
                return;

            _selectedLayout = !CUIUtility.IsNullOrUndefined(layout) ? layout : null;
            // We have to set the layout to dirty because layout DOM subtrees share
            // DOM elements with other layouts.  So, it is possible that some of the
            // DOM elements in this layout's DOM subtree have been "snatched" via
            // ElementInternal.appendChild() for use in another layout's DOM subtree.  The
            // only way to ensure that this layout is graphically complete is to 
            // refresh it and thereby construct its DOM subtree again.
            if (!CUIUtility.IsNullOrUndefined(layout))
            {
                layout.SetDirtyRecursively(true);
                // If the Popup Layout it being selected, then we need to dirty its
                // Menu too.  It will not be dirtied by the call "layout.SErDirtyRecursively(true)"
                // because it is not attached to the hierarchy when it isn't showing.
                if (name == "Popup")
                    _popupMenu.SetDirtyRecursively(true);
            }
            this.OnDirtyingChange();
        }
Пример #3
0
        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;
        }