Exemple #1
0
        protected override void AppendChildrenToElement(HtmlElement elm)
        {
            foreach (Component child in Children)
            {
                // This is very important for performance
                // We should always try to append an empty child DOM Element
                // first and then call EnsureRefreshed() where the child fills it
                child.EnsureDOMElement();

                // Make sure the buttons are all floating the right way via CSS.
                switch (Alignment)
                {
                    case DataNodeWrapper.LEFTALIGN:
                        Utility.EnsureCSSClassOnElement(child.ElementInternal, "ms-cui-toolbar-button-left");
                        break;
                    case DataNodeWrapper.CENTERALIGN:
                        Utility.EnsureCSSClassOnElement(child.ElementInternal, "ms-cui-toolbar-button-center");
                        break;
                    case DataNodeWrapper.RIGHTALIGN:
                        Utility.EnsureCSSClassOnElement(child.ElementInternal, "ms-cui-toolbar-button-right");
                        break;
                    default:
                        throw new ArgumentOutOfRangeException(Alignment);
                }

                elm.AppendChild(child.ElementInternal);
                child.EnsureRefreshed();
            }
        }
Exemple #2
0
        protected override void AppendChildrenToElement(HtmlElement elm)
        {
            ListItem listItem;

            foreach (Component child in Children)
            {
                // Put all menu items into a list item for semantics
                listItem = new ListItem();
                listItem.ClassName = "ms-cui-menusection-items";

                // This is very important for performance
                // We should always try to append an empty child DOM Element
                // first and then call EnsureRefreshed() where the child fills it
                child.EnsureDOMElement();
                listItem.AppendChild(child.ElementInternal);
                elm.AppendChild(listItem);
                child.EnsureRefreshed();
            }
        }
Exemple #3
0
        /// <summary>
        /// Helper function to append the DOMElements of child Components to the passed in DOMElementInternal.  Used in conjunction with RefreshInternal().
        /// </summary>
        /// <seealso cref="RefreshInternal"/>
        /// <param name="elm">The DOMElement that the child Component's(the children of this Component) DOMElements should be appended to.</param>
        protected virtual void AppendChildrenToElement(HtmlElement elm)
        {
            // The document fragment trick is known to have twice as much
            // throughput as appending directly to the DOM tree
            List<HtmlElement> elts = new List<HtmlElement>();
            foreach (Component child in _children)
            {
                // This is very important for performance
                // We should always try to append an empty child DOM Element
                // first and then call EnsureRefreshed() where the child fills it
                child.EnsureDOMElement();
                child.EnsureRefreshed();
                elts.Add(child.ElementInternal);
            }

            // Now append those elements to the parent
            foreach (HtmlElement elt in elts)
                elm.AppendChild(elt);
        }
Exemple #4
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);
            }
        }
Exemple #5
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);
            }
        }