Ejemplo n.º 1
0
        /// <summary>
        /// Create some rows or cells in _colorTable
        /// </summary>
        /// <param name="colorRules"></param>
        /// <param name="styleName"></param>
        private void AddColorCells(HtmlElement colorTableBody, ColorStyle[] colorRules)
        {
            int rowNumber = 0;
            TableRow row = new TableRow();
            int totalRows = colorRules.Length / ColumnSize;

            for (int i = 0; i < colorRules.Length; i++)
            {
                if ((i % ColumnSize) == 0)
                {
                    row = new TableRow();
                    colorTableBody.AppendChild(row);
                    rowNumber++;
                }

                TableCell cell = new TableCell();
                cell.ClassName = NormalCellCssClassName;
                cell.SetAttribute("arrayPosition", i.ToString());
                // Make the first row have spacing.
                if (rowNumber == 1)
                {
                    cell.Style.Padding = "2px";
                    cell.Style.Height = "16px";
                }

                row.AppendChild(cell);
                Anchor link = new Anchor();
                link.Href = "javascript:";
                string displayName = colorRules[i].Title;
                link.Title = displayName;
                link.ClassName = CellAnchorCssClassName;

                link.Focus += OnCellFocus;
                Div elmDiv = new Div();
                string color = colorRules[i].DisplayColor;
                elmDiv.Style.BackgroundColor = color;
                elmDiv.ClassName = CellDivClassName;
                int size = DefaultCellHeight;
                if (rowNumber == 1 || rowNumber == 2)
                {
                    elmDiv.Style.BorderTopWidth = "1px";
                    size--;
                }
                if (rowNumber == 1 || rowNumber == totalRows)
                {
                    elmDiv.Style.BorderBottomWidth = "1px";
                    size--;
                }
                if (size != DefaultCellHeight)
                {
                    elmDiv.Style.Height = size + "px";
                }

                Div internalelmDiv = new Div();
                internalelmDiv.ClassName = CellInternalDivClassName;

                link.MouseOver += OnCellHover;
                link.MouseOut += OnCellBlur;
                link.Click += OnCellClick;

                cell.AppendChild(link);
                link.AppendChild(elmDiv);
                elmDiv.AppendChild(internalelmDiv);

                cell.SetAttribute(ColorInformation + "Color", colorRules[i].Color);
                cell.SetAttribute(ColorInformation + "Style", colorRules[i].Style);

                // add the cell to _colorCells so that we could reset the highlight
                _colorCells.Add(cell);
            }
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
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);
            }
        }