コード例 #1
0
        private void DrawGradient()
        {
            Graphics graphics = Graphics.FromImage(gradientPanelBackBuffer);

            graphics.Clear(gradientPanel.BackColor);
            if (gradient != null)
            {
                Gradient.FillCheckerboardRectangle(graphics, gradientRectangle, 8);
                gradient.Draw(graphics, gradientRectangle, 0.0, 1.0, Gradient.Direction.Horizontal);
                graphics.DrawRectangle(Pens.Black, new Rectangle(gradientRectangle.Left - 1, gradientRectangle.Top - 1, gradientRectangle.Width + 2, gradientRectangle.Height + 1));

                DrawColorEntryMarkers();
            }
            graphics.Dispose();
        }
コード例 #2
0
        protected override void OnDrawItem(DrawItemEventArgs ea)
        {
            if (ea.Index != -1 && Items.Count > 0)
            {
                Gradient item               = (Gradient)Items[ea.Index];
                Bitmap   backBufferBitmap   = new Bitmap(ea.Bounds.Width, ea.Bounds.Height);
                Graphics backBufferGraphics = Graphics.FromImage(backBufferBitmap);


                backBufferGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

                Brush b = new SolidBrush(BackColor);
                ea.Graphics.FillRectangle(b, ea.Bounds);
                b.Dispose();
                ea.DrawBackground();

                Rectangle rect = new Rectangle(4, 4, backBufferBitmap.Width - this.NameWidth - 4, backBufferBitmap.Height - 8);
                Gradient.FillCheckerboardRectangle(backBufferGraphics, rect, 3);
                item.Draw(backBufferGraphics, rect, 0, 1, Gradient.Direction.Horizontal);
                backBufferGraphics.DrawRectangle(Pens.Black, new Rectangle(3, 3, backBufferBitmap.Width - this.NameWidth - 3, backBufferBitmap.Height - 7));

                Color textColor;
                if ((ea.State & DrawItemState.Selected).Equals(DrawItemState.Selected))
                {
                    textColor = SystemColors.HighlightText;
                }
                else
                {
                    textColor = this.ForeColor;
                }

                Size  textSize     = TextRenderer.MeasureText(backBufferGraphics, item.Name, this.Font);
                Point textLocation = new Point(backBufferBitmap.Width - this.NameWidth + this.NamePadding, (ea.Bounds.Height - textSize.Height) / 2);
                TextRenderer.DrawText(backBufferGraphics, item.Name, this.Font, textLocation, textColor);

                ea.Graphics.DrawImage(backBufferBitmap, ea.Bounds.Location);

                backBufferBitmap.Dispose();
                backBufferGraphics.Dispose();

                ea.DrawFocusRectangle();

                base.OnDrawItem(ea);
            }
        }
コード例 #3
0
ファイル: GradientViewer.cs プロジェクト: gabbe/quickroute
        // This method paints a graphical representation of the
        // selected value of the LightShpae property.
        public override void PaintValue(PaintValueEventArgs e)
        {
            Gradient gradient = (Gradient)e.Value;

            gradient.Draw(e.Graphics, e.Bounds, 0, 1, Gradient.Direction.Horizontal);
        }
コード例 #4
0
ファイル: GradientViewer.cs プロジェクト: gabbe/quickroute
 protected override void OnPaint(PaintEventArgs e)
 {
     base.OnPaint(e);
     gradient.Draw(this.CreateGraphics(), this.Bounds, 0, 1, Gradient.Direction.Horizontal);
 }