Esempio n. 1
0
        public override void WriteInitializationScript(TextWriter writer)
        {
            var options = new Dictionary <string, object>(Events);

            if (Palette == ColorPickerPalette.Basic)
            {
                options["palette"] = "basic";
            }
            else if (Palette == ColorPickerPalette.WebSafe)
            {
                options["palette"] = "websafe";
            }
            else if (PaletteColors != null && PaletteColors.Any())
            {
                options["palette"] = PaletteColors;
            }

            if (Opacity)
            {
                options["opacity"] = true;
            }

            if (!Buttons)
            {
                options["buttons"] = false;
            }

            if (!string.IsNullOrEmpty(ToolIcon))
            {
                options["toolIcon"] = ToolIcon;
            }

            if (!string.IsNullOrEmpty(Value))
            {
                options["value"] = Value;
            }

            if (TileSize != null)
            {
                var tileSize = TileSize as ColorPaletteTileSize;

                if (tileSize != null)
                {
                    options["tileSize"] = new { width = tileSize.Width, height = tileSize.Height };
                }
                else
                {
                    options["tileSize"] = (int)TileSize;
                }
            }

            writer.Write(Initializer.Initialize(Selector, "ColorPicker", options));

            base.WriteInitializationScript(writer);
        }
Esempio n. 2
0
        public override void WriteInitializationScript(TextWriter writer)
        {
            var options = new Dictionary <string, object>(Events);

            if (Palette == ColorPickerPalette.Basic)
            {
                options["palette"] = "basic";
            }
            else if (Palette == ColorPickerPalette.WebSafe)
            {
                options["palette"] = "websafe";
            }
            else if (PaletteColors != null && PaletteColors.Any())
            {
                options["palette"] = PaletteColors;
            }

            if (Columns != ColumnsDefault)
            {
                options["columns"] = Columns;
            }

            if (TileSize != null)
            {
                var tileSize = TileSize as ColorPaletteTileSize;

                if (tileSize != null)
                {
                    options["tileSize"] = new { width = tileSize.Width, height = tileSize.Height };
                }
                else
                {
                    options["tileSize"] = (int)TileSize;
                }
            }

            writer.Write(Initializer.Initialize(Selector, "ColorPalette", options));

            base.WriteInitializationScript(writer);
        }