Exemplo n.º 1
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            Graphics g          = e.Graphics;
            Color    BlockColor = Color.Empty;
            int      left       = RECTCOLOR_LEFT;

            if (e.State == DrawItemState.Selected || e.State == DrawItemState.None)
            {
                e.DrawBackground();
            }
            if (e.Index == -1)
            {
                BlockColor = SelectedIndex < 0 ? BackColor : DesignerUtility.ColorFromHtml(this.Text, Color.Empty);
            }
            else
            {
                BlockColor = DesignerUtility.ColorFromHtml((string)this.Items[e.Index], Color.Empty);
            }
            // Fill rectangle
            if (BlockColor.IsEmpty && this.Text.StartsWith("="))
            {
                g.DrawString("fx", this.Font, Brushes.Black, e.Bounds);
            }
            else
            {
                g.FillRectangle(new SolidBrush(BlockColor), left, e.Bounds.Top + RECTCOLOR_TOP, RECTCOLOR_WIDTH,
                                ItemHeight - 2 * RECTCOLOR_TOP);
            }
            base.OnDrawItem(e);
        }
Exemplo n.º 2
0
        private void bColor_Click(object sender, System.EventArgs e)
        {
            ColorDialog cd = new ColorDialog();

            cd.AnyColor = true;
            cd.FullOpen = true;

            cd.CustomColors = ReportDesigner.GetCustomColors();
            cd.Color        =
                DesignerUtility.ColorFromHtml(cbColor.Text, System.Drawing.Color.Black);
            try
            {
                if (cd.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                ReportDesigner.SetCustomColors(cd.CustomColors);
                if (sender == this.bColor)
                {
                    cbColor.Text = ColorTranslator.ToHtml(cd.Color);
                }
            }
            finally
            {
                cd.Dispose();
            }
            return;
        }
Exemplo n.º 3
0
        private void SetColor(ComboBox cbColor)
        {
            ColorDialog cd = new ColorDialog();

            cd.AnyColor = true;
            cd.FullOpen = true;

            cd.CustomColors = RdlDesignerForm.CustomColors;
            cd.Color        = DesignerUtility.ColorFromHtml(cbColor.Text, System.Drawing.Color.Empty);

            try
            {
                if (cd.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                RdlDesignerForm.CustomColors = cd.CustomColors;
                cbColor.Text = ColorTranslator.ToHtml(cd.Color);
            }
            finally
            {
                cd.Dispose();
            }

            return;
        }
Exemplo n.º 4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            //base.OnPaint(e);
            int row       = 0;
            int col       = 0;
            int max_rows  = MaxRows;
            int max_cols  = MaxColumns;
            int col_width = ColumnWidth;

            foreach (string c in StaticLists.ColorListColorSort)
            {
                Color clr = DesignerUtility.ColorFromHtml(c, Color.Empty);
                g.FillRectangle(new SolidBrush(clr),
                                new Rectangle((col * col_width) + ITEM_PAD, (row * ITEM_HEIGHT) + ITEM_PAD, col_width - ITEM_PAD, ITEM_HEIGHT - ITEM_PAD));
                row++;
                if (row >= max_rows)
                {
                    row = 0;
                    col++;
                }
            }
        }
Exemplo n.º 5
0
        private void bColor_Click(object sender, System.EventArgs e)
        {
            using (ColorDialog cd = new ColorDialog())
            {
                cd.AnyColor = true;
                cd.FullOpen = true;

                cd.CustomColors = RdlDesignerForm.CustomColors;
                cd.Color        =
                    DesignerUtility.ColorFromHtml(cbColor.Text, System.Drawing.Color.Black);

                if (cd.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                RdlDesignerForm.CustomColors = cd.CustomColors;
                if (sender == this.bColor)
                {
                    cbColor.Text = ColorTranslator.ToHtml(cd.Color);
                }
            }
            return;
        }
Exemplo n.º 6
0
        private void bFont_Click(object sender, System.EventArgs e)
        {
            FontDialog fd = new FontDialog();

            fd.ShowColor = true;

            // STYLE
            System.Drawing.FontStyle fs = 0;
            if (cbFontStyle.Text == "Italic")
            {
                fs |= System.Drawing.FontStyle.Italic;
            }

            if (cbTextDecoration.Text == "Underline")
            {
                fs |= FontStyle.Underline;
            }
            else if (cbTextDecoration.Text == "LineThrough")
            {
                fs |= FontStyle.Strikeout;
            }

            // WEIGHT
            switch (cbFontWeight.Text)
            {
            case "Bold":
            case "Bolder":
            case "500":
            case "600":
            case "700":
            case "800":
            case "900":
                fs |= System.Drawing.FontStyle.Bold;
                break;

            default:
                break;
            }
            float size = 10;

            size = DesignXmlDraw.GetSize(cbFontSize.Text);
            if (size <= 0)
            {
                size = DesignXmlDraw.GetSize(cbFontSize.Text + "pt"); // Try assuming pt
                if (size <= 0)                                        // still no good
                {
                    size = 10;                                        // just set default value
                }
            }
            Font drawFont = new Font(cbFontFamily.Text, size, fs);              // si.FontSize already in points


            fd.Font  = drawFont;
            fd.Color =
                DesignerUtility.ColorFromHtml(cbColor.Text, System.Drawing.Color.Black);
            try
            {
                DialogResult dr = fd.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    drawFont.Dispose();
                    return;
                }

                // Apply all the font info
                cbFontWeight.Text = fd.Font.Bold ? "Bold" : "Normal";
                cbFontStyle.Text  = fd.Font.Italic ? "Italic" : "Normal";
                cbFontFamily.Text = fd.Font.FontFamily.Name;
                cbFontSize.Text   = fd.Font.Size.ToString() + "pt";
                cbColor.Text      = ColorTranslator.ToHtml(fd.Color);
                if (fd.Font.Underline)
                {
                    this.cbTextDecoration.Text = "Underline";
                }
                else if (fd.Font.Strikeout)
                {
                    this.cbTextDecoration.Text = "LineThrough";
                }
                else
                {
                    this.cbTextDecoration.Text = "None";
                }
                drawFont.Dispose();
            }
            finally
            {
                fd.Dispose();
            }
            return;
        }