Ejemplo n.º 1
0
        public ColorPicker(Root root,
                           string id,
                           ColorPickerProperties properties,
                           ColorStyle[] colors)
            : base(root, id, properties)
        {
            AddDisplayMode("Menu");

            _colors = colors;
            _colorTable = new Table();
        }
Ejemplo n.º 2
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);
            }
        }