Esempio n. 1
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            switch (displayMode)
            {
                case "Menu":
                    _elmDefault = new Table();
                    _elmDefault.SetAttribute("mscui:controltype", ControlType);

                    _elmDefaultTbody = new TableBody();
                    _elmDefaultTbody.ClassName = "ms-cui-it";
                    _elmDefault.SetAttribute("cellspacing", "0");
                    _elmDefault.SetAttribute("cellpadding", "0");
                    _elmDefaultTbody.SetAttribute("cellspacing", "0");
                    _elmDefaultTbody.SetAttribute("cellpadding", "0");

                    _elmDefault.MouseOut += OnControlMouseOut;

                    EnsureDivArrays();

                    TableRow elmRow;
                    TableCell elmCell;
                    Anchor elmCellA;
                    Div elmDiv;
                    Div elmDivOuter;
                    int idx = 0;
                    for (int i = 0; i < 10; i++)
                    {
                        elmRow = new TableRow();
                        _elmDefaultTbody.AppendChild(elmRow);
                        for (int j = 0; j < 10; j++)
                        {
                            elmCell = new TableCell();
                            elmCell.Style.Padding = "0px";
                            elmRow.AppendChild(elmCell);

                            elmCellA = new Anchor();

                            Utility.NoOpLink(elmCellA);
                            Utility.SetAriaTooltipProperties(Properties, elmCellA);

                            elmCellA.Focus += OnCellFocus;
                            elmDiv = new Div();
                            elmDiv.ClassName = "ms-cui-it-inactiveCell";

                            elmDivOuter = new Div();
                            elmDivOuter.Id = this.Id + "-" + idx;
                            elmDivOuter.ClassName = "ms-cui-it-inactiveCellOuter";

                            elmCell.MouseOver += OnCellHover;
                            elmCell.Click += OnCellClick;
                            elmCell.AppendChild(elmDivOuter);
                            elmDivOuter.AppendChild(elmDiv);
                            elmDiv.AppendChild(elmCellA);

                            _innerDivs[idx] = elmDiv;
                            _outerDivs[idx] = elmDivOuter;
                            idx++;
                        }
                    }

                    _elmDefault.AppendChild(_elmDefaultTbody);
                    return _elmDefault;
                default:
                    EnsureValidDisplayMode(displayMode);
                    break;
            }
            return null;
        }
Esempio n. 2
0
        protected override void AppendChildrenToElement(HtmlElement elm)
        {
            int rows = Int32.Parse((Math.Ceiling((Double)Children.Count / (Double)Width)).ToString());

            // Create grid structure and put child elements in it
            TableRow tr;
            TableCell td;
            Component child;
            int c = 0;
            for (int i = 0; i < rows; i++)
            {
                tr = new TableRow();
                for (int j = 0; j < Width; j++)
                {
                    td = new TableCell();
                    td.ClassName = "ms-cui-gallery-td ms-cui-gallery-element-" + ElementDimensions.ToString();

                    // Insert empty cells to finish out row when out of children
                    if (c < Children.Count)
                    {
                        child = (Component)Children[c++];
                        child.EnsureDOMElement();
                        td.AppendChild(child.ElementInternal);
                        child.EnsureRefreshed();
                    }
                    tr.AppendChild(td);
                }
                elm.AppendChild(tr);
            }
        }