Esempio n. 1
0
        private QAT BuildQATInternal(object data, QATBuildContext qbc)
        {
            if (CUIUtility.IsNullOrUndefined(data))
            {
                throw new ArgumentNullException("No QAT element was present in the data");
            }

            QAT = new QAT(DataNodeWrapper.GetAttribute(data, "Id"),
                          DataNodeWrapper.GetNodeAttributes(data).To <QATProperties>());

            // Handle the controls in the QAT
            // The XML structure looks like <QAT><Controls><Control></Control><Control></Control>...
            JSObject controlsParent = DataNodeWrapper.GetFirstChildNodeWithName(data, DataNodeWrapper.CONTROLS);

            JSObject[] controls = DataNodeWrapper.GetNodeChildren(controlsParent);
            for (int j = 0; j < controls.Length; j++)
            {
                if (!IsNodeTrimmed(controls[j]))
                {
                    Control control = BuildControl(controls[j], qbc);
                    QAT.AddChild(control.CreateComponentForDisplayMode("Small"));
                }
            }

            return(QAT);
        }
Esempio n. 2
0
        /// <summary>
        /// The toolbar doesn't require scaling code -- it just builds with a static set of display modes,
        /// since it only supports one display mode per control type.
        /// </summary>
        private Component BuildToolbarControlComponent(object data, ToolbarBuildContext buildContext)
        {
            Control control     = null;
            string  name        = DataNodeWrapper.GetNodeName(data);
            string  displayMode = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.DISPLAYMODE);

            switch (name)
            {
            case DataNodeWrapper.Button:
                control = BuildControl(data, buildContext);
                return(control.CreateComponentForDisplayMode(
                           string.IsNullOrEmpty(displayMode) ? "Small" : displayMode));

            case DataNodeWrapper.CheckBox:
                control = BuildControl(data, buildContext);
                return(control.CreateComponentForDisplayMode(
                           string.IsNullOrEmpty(displayMode) ? "Small" : displayMode));

            case DataNodeWrapper.ComboBox:
                control = BuildControl(data, buildContext);
                return(control.CreateComponentForDisplayMode("Medium"));

            case DataNodeWrapper.FlyoutAnchor:
                control = BuildControl(data, buildContext);
                return(control.CreateComponentForDisplayMode(
                           string.IsNullOrEmpty(displayMode) ? "Medium" : displayMode));

            case DataNodeWrapper.Label:
                control = BuildControl(data, buildContext);
                return(control.CreateComponentForDisplayMode(
                           string.IsNullOrEmpty(displayMode) ? "Small" : displayMode));

            case DataNodeWrapper.Separator:
                control = BuildControl(data, buildContext);
                return(control.CreateComponentForDisplayMode("Small"));

            case DataNodeWrapper.TextBox:
                control = BuildControl(data, buildContext);
                return(control.CreateComponentForDisplayMode(
                           string.IsNullOrEmpty(displayMode) ? "Medium" : displayMode));

            case DataNodeWrapper.ToggleButton:
                control = BuildControl(data, buildContext);
                return(control.CreateComponentForDisplayMode(
                           string.IsNullOrEmpty(displayMode) ? "Small" : displayMode));

            default:
                throw new InvalidOperationException("Invalid control type.");
            }
        }
Esempio n. 3
0
        private MenuSection BuildMenuSection(JSObject data, BuildContext bc)
        {
            string displayMode = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.DISPLAYMODE);

            if (CUIUtility.IsNullOrUndefined(displayMode))
            {
                displayMode = "Menu";
            }

            string      id          = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.ID);
            string      title       = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.TITLE);
            string      description = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.DESCRIPTION);
            bool        scrollable  = Utility.IsTrue(DataNodeWrapper.GetAttribute(data, DataNodeWrapper.SCROLLABLE));
            string      maxheight   = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.MAXHEIGHT);
            MenuSection ms          = Root.CreateMenuSection(id,
                                                             title,
                                                             description,
                                                             scrollable,
                                                             maxheight,
                                                             displayMode);

            JSObject[] menuSectionChildren = DataNodeWrapper.GetNodeChildren(data);
            JSObject   msChild             = menuSectionChildren[0];
            string     msChildName         = DataNodeWrapper.GetNodeName(msChild);

            if (msChildName == DataNodeWrapper.CONTROLS)
            {
                // Get the <MenuSection><Controls> node's children
                JSObject[] individualControls = DataNodeWrapper.GetNodeChildren(msChild);
                int        l = individualControls.Length;

                JSObject child = null;
                for (int i = 0; i < l; i++)
                {
                    child = individualControls[i];
                    if (IsNodeTrimmed(child))
                    {
                        continue;
                    }
                    Control control = BuildControl(child, bc);
                    ms.AddChild(control.CreateComponentForDisplayMode(displayMode));
                }
            }
            else if (msChildName == DataNodeWrapper.GALLERY)
            {
                Gallery gallery = BuildGallery(msChild, bc, true);
                ms.AddChild(gallery);
            }

            return(ms);
        }
Esempio n. 4
0
        private int HandleOverflow(object data, DeclarativeTemplateBuildContext bc, Component parent, int sectionCounter)
        {
            string alias = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.TEMPLATEALIAS);

            string name = DataNodeWrapper.GetNodeName(data);

            List <Control> rec = bc.Controls.ContainsKey(alias) ? bc.Controls[alias] : null;

            // No Controls need to be added to this overflowarea so we return without doing anything
            if (CUIUtility.IsNullOrUndefined(rec))
            {
                return(sectionCounter);
            }

            bool dividerBefore = false;
            bool dividerAfter  = false;

            SectionType sectionType = SectionType.OneRow;

            if (name == DataNodeWrapper.OVERFLOWSECTION)
            {
                dividerBefore = Utility.IsTrue(DataNodeWrapper.GetAttribute(data, DataNodeWrapper.DIVIDERBEFORE));
                dividerAfter  = Utility.IsTrue(DataNodeWrapper.GetAttribute(data, DataNodeWrapper.DIVIDERAFTER));
                if (dividerBefore)
                {
                    Section section = bc.Ribbon.CreateSection(parent.Id + "-" + sectionCounter++, SectionType.Divider, SectionAlignment.Top);
                    parent.AddChild(section);
                }

                string secType = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.TYPE);

                switch (secType)
                {
                case DataNodeWrapper.ONEROW:
                    sectionType = SectionType.OneRow;
                    break;

                case DataNodeWrapper.TWOROW:
                    sectionType = SectionType.TwoRow;
                    break;

                case DataNodeWrapper.THREEROW:
                    sectionType = SectionType.ThreeRow;
                    break;

                default:
                    throw new ArgumentOutOfRangeException("Invalid Section attribute \"Type\" found in XML: " + secType);
                }
            }

            string displayMode = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.DISPLAYMODE);

            if (rec.Count > 1)
            {
                Section currentSection = null;
                for (int i = 0; i < rec.Count; i++)
                {
                    Control control = rec[i];
                    if (name == DataNodeWrapper.OVERFLOWSECTION)
                    {
                        if (sectionType == SectionType.OneRow)
                        {
                            if (CUIUtility.IsNullOrUndefined(currentSection))
                            {
                                currentSection = bc.Ribbon.CreateSection(parent.Id + "-" + sectionCounter++, SectionType.OneRow, SectionAlignment.Top);
                                parent.AddChild(currentSection);
                            }
                            currentSection.GetRow(1).AddChild(control.CreateComponentForDisplayMode(displayMode));
                        }
                        else if (sectionType == SectionType.ThreeRow)
                        {
                            // ThreeRow Sections
                            if (CUIUtility.IsNullOrUndefined(currentSection))
                            {
                                currentSection = bc.Ribbon.CreateSection(parent.Id + "-" + sectionCounter++, SectionType.ThreeRow, SectionAlignment.Top);
                                parent.AddChild(currentSection);
                            }
                            currentSection.GetRow((i % 3) + 1).AddChild(control.CreateComponentForDisplayMode(displayMode));

                            // If we have just filled the third row of a section with a ControlComponent, then
                            // we need to signal that we need to start a new section the next time through the loop
                            if (i % 3 == 2)
                            {
                                currentSection = null;
                            }
                        }
                        else
                        {
                            // Two Row Sections
                            if (CUIUtility.IsNullOrUndefined(currentSection))
                            {
                                currentSection = bc.Ribbon.CreateSection(parent.Id + "-" + sectionCounter++, SectionType.TwoRow, SectionAlignment.Top);
                                parent.AddChild(currentSection);
                            }
                            currentSection.GetRow((i % 2) + 1).AddChild(control.CreateComponentForDisplayMode(displayMode));

                            // If we have just filled the third row of a section with a ControlComponent, then
                            // we need to signal that we need to start a new section the next time through the loop
                            if (i % 2 == 1)
                            {
                                currentSection = null;
                            }
                        }
                    }
                    else
                    {
                        // <OverflowArea> tag
                        parent.AddChild(control.CreateComponentForDisplayMode(displayMode));
                    }
                }
            }
            else
            {
                Control control = rec[0];

                if (name == DataNodeWrapper.OVERFLOWSECTION)
                {
                    Section section;
                    if (sectionType == SectionType.OneRow)
                    {
                        section = bc.Ribbon.CreateSection(parent.Id + "-" + sectionCounter++, SectionType.OneRow, SectionAlignment.Top);
                        section.GetRow(1).AddChild(control.CreateComponentForDisplayMode(displayMode));
                    }
                    else if (sectionType == SectionType.ThreeRow)
                    {
                        // Three Row Section
                        section = bc.Ribbon.CreateSection(parent.Id + "-" + sectionCounter++, SectionType.ThreeRow, SectionAlignment.Top);
                        section.GetRow(1).AddChild(control.CreateComponentForDisplayMode(displayMode));
                    }
                    else
                    {
                        // Two Row Section
                        section = bc.Ribbon.CreateSection(parent.Id + "-" + sectionCounter++, SectionType.TwoRow, SectionAlignment.Top);
                        section.GetRow(1).AddChild(control.CreateComponentForDisplayMode(displayMode));
                    }
                    parent.AddChild(section);
                }
                else
                {
                    // <OverflowArea> tag
                    parent.AddChild(control.CreateComponentForDisplayMode(displayMode));
                }
            }

            if (dividerAfter)
            {
                Section section = bc.Ribbon.CreateSection(parent.Id + "-" + sectionCounter++, SectionType.Divider, SectionAlignment.Top);
                parent.AddChild(section);
            }

            return(sectionCounter);
        }
Esempio n. 5
0
 internal override Component Clone(bool deep)
 {
     return(Control.CreateComponentForDisplayMode(DisplayMode));
 }