コード例 #1
0
ファイル: RibbonTab.cs プロジェクト: carlhuth/GenXSource
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.TextRenderingHint  = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            e.Graphics.SmoothingMode      = SmoothingMode.HighQuality;
            e.Graphics.InterpolationMode  = InterpolationMode.HighQualityBilinear;
            e.Graphics.CompositingQuality = CompositingQuality.HighQuality;

            e.Graphics.Clear(Color.FromArgb(83, 83, 83));

            Rectangle rect = new Rectangle(0, 0, this.Width - 1, this.Height - 1);

            Color[] col = new Color[] { Color.FromArgb(210, 214, 221), Color.FromArgb(193, 198, 207), Color.FromArgb(180, 187, 197), Color.FromArgb(231, 240, 241) };
            float[] pos = new float[] { 0.0f, 0.2f, 0.2f, 1.0f };

            ColorBlend blend = new ColorBlend();

            blend.Colors    = col;
            blend.Positions = pos;
            LinearGradientBrush brush = new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, LinearGradientMode.Vertical);

            brush.InterpolationColors = blend;

            RibbonControl.FillRoundRectangle(e.Graphics, brush, rect, 3f);

            RibbonControl.DrawRoundRectangle(e.Graphics, new Pen(Color.FromArgb(190, 190, 190)), rect, 3f);
            rect.Offset(1, 1);
            rect.Width  -= 2;
            rect.Height -= 2;
            RibbonControl.DrawRoundRectangle(e.Graphics, new Pen(new LinearGradientBrush(rect, Color.FromArgb(231, 233, 237), Color.Transparent, LinearGradientMode.ForwardDiagonal)), rect, 3f);
        }
コード例 #2
0
ファイル: RibbonTrack.cs プロジェクト: carlhuth/GenXSource
        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.TextRenderingHint  = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            e.Graphics.SmoothingMode      = SmoothingMode.HighQuality;
            e.Graphics.InterpolationMode  = InterpolationMode.HighQualityBilinear;
            e.Graphics.CompositingQuality = CompositingQuality.HighQuality;

            Rectangle rect = new Rectangle(0, 0, pictureBox1.Width - 1, pictureBox1.Height - 1);

            RibbonControl.FillRoundRectangle(e.Graphics, new LinearGradientBrush(e.ClipRectangle, this.startcolor, this.endcolor, LinearGradientMode.Horizontal), rect, 3f);

            StringFormat sf = new StringFormat();

            sf.Alignment     = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center;
            e.Graphics.DrawString(Math.Round(this.value, 3).ToString(), this.label1.Font, new SolidBrush(Color.FromArgb(218, 226, 226)), rect, sf);

            if (this.hover)
            {
                float x = this.np ? (float)((this.value + 1.0) / 2.0) * rect.Width : (float)this.value * rect.Width;
                e.Graphics.DrawLine(new Pen(new LinearGradientBrush(e.ClipRectangle, Color.FromArgb(255, 255, 247), Color.FromArgb(210, 192, 141), LinearGradientMode.Vertical), 3f), x, 0, x, rect.Height);
            }
            else
            {
                float x = this.np ? (float)((this.value + 1.0) / 2.0) * rect.Width : (float)this.value * rect.Width;
                e.Graphics.DrawLine(new Pen(new LinearGradientBrush(e.ClipRectangle, Color.FromArgb(223, 183, 136), Color.FromArgb(171, 161, 140), LinearGradientMode.Vertical), 3f), x, 0, x, rect.Height);
            }

            RibbonControl.DrawRoundRectangle(e.Graphics, new Pen(Color.FromArgb(172, 172, 172)), rect, 3f);

            rect.Offset(1, 1);
            rect.Width  -= 2;
            rect.Height -= 2;
            RibbonControl.DrawRoundRectangle(e.Graphics, new Pen(Color.FromArgb(96, 0, 0, 0)), rect, 3f);
            rect.Offset(1, 1);
            rect.Width  -= 2;
            rect.Height -= 2;
            RibbonControl.DrawRoundRectangle(e.Graphics, new Pen(Color.FromArgb(64, 0, 0, 0)), rect, 3f);
            rect.Offset(1, 1);
            rect.Width  -= 2;
            rect.Height -= 2;
            RibbonControl.DrawRoundRectangle(e.Graphics, new Pen(Color.FromArgb(32, 0, 0, 0)), rect, 3f);
        }
コード例 #3
0
ファイル: RibbonControl.cs プロジェクト: carlhuth/GenXSource
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.TextRenderingHint  = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            e.Graphics.SmoothingMode      = SmoothingMode.HighQuality;
            e.Graphics.InterpolationMode  = InterpolationMode.HighQualityBilinear;
            e.Graphics.CompositingQuality = CompositingQuality.HighQuality;

            e.Graphics.Clear(Color.FromArgb(83, 83, 83));

            e.Graphics.DrawLine(new Pen(Color.FromArgb(115, 115, 115)), 0, 0, this.Width, 0);

            Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);

            if (this.Height > 26)
            {
                RibbonControl.FillRoundRectangle(e.Graphics, new SolidBrush(Color.FromArgb(32, Color.Black)), new Rectangle(5, this.Height - 20, this.Width - 10, 17), 3f);
                RibbonControl.FillRoundRectangle(e.Graphics, new SolidBrush(Color.FromArgb(32, Color.Black)), new Rectangle(5, this.Height - 20, this.Width - 10, 16), 3f);
            }

            int ti = 0;

            foreach (TabPage tab in this.TabPages)
            {
                Rectangle tabrect = this.GetTabRect(ti);
                tabrect.Height += 4;

                StringFormat sf = new StringFormat();
                sf.Alignment     = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;

                if (this.SelectedIndex > 0 && this.Height > 26 && tab == this.SelectedTab)
                {
                    RibbonControl.FillTopRoundRectangle(e.Graphics, new SolidBrush(Color.FromArgb(32, Color.Black)), new Rectangle(tabrect.X - 2, tabrect.Y, tabrect.Width + 4, tabrect.Height + 4), 3f);
                    RibbonControl.FillTopRoundRectangle(e.Graphics, new SolidBrush(Color.FromArgb(16, Color.Black)), new Rectangle(tabrect.X - 1, tabrect.Y, tabrect.Width + 2, tabrect.Height + 4), 3f);
                    RibbonControl.FillTopRoundRectangle(e.Graphics, new LinearGradientBrush(tabrect, Color.FromArgb(237, 238, 239), Color.FromArgb(206, 210, 217), LinearGradientMode.Vertical), tabrect, 3f);

                    RibbonControl.DrawTopRoundRectangle(e.Graphics, new Pen(Color.FromArgb(190, 190, 190)), tabrect, 3f);
                    tabrect.Offset(1, 1);
                    tabrect.Width -= 2;
                    tabrect.Height--;
                    RibbonControl.DrawRoundRectangle(e.Graphics, new Pen(new LinearGradientBrush(tabrect, Color.FromArgb(249, 249, 249), Color.Transparent, LinearGradientMode.ForwardDiagonal)), tabrect, 3f);

                    Region region = new Region();
                    region.Exclude(new Rectangle(tabrect.X - 4, 0, tabrect.Width + 1, 2));
                    tab.Region = region;

                    tabrect.Height -= 2;
                    e.Graphics.DrawString(tab.Text, tab.Font, new SolidBrush(Color.Black), tabrect, sf);
                }
                else if (ti == this.hoverindex && (!this.closed || ti == 0))
                {
                    tabrect.Width--;

                    if (ti == 0)
                    {
                        tabrect.X      += 2;
                        tabrect.Width  -= 2;
                        tabrect.Height -= 3;
                        RibbonControl.RenderSelection(e.Graphics, tabrect, 3f, this.pressed);
                        tabrect.X      -= 2;
                        tabrect.Width  += 2;
                        tabrect.Height += 3;
                    }
                    else
                    {
                        RibbonControl.RenderTopSelection(e.Graphics, tabrect, 3f, this.pressed);
                    }

                    tabrect.Width++;

                    tabrect.Height -= 2;
                    e.Graphics.DrawString(tab.Text, tab.Font, new SolidBrush(Color.Black), tabrect, sf);
                }
                else
                {
                    tabrect.Height -= 2;
                    e.Graphics.DrawString(tab.Text, tab.Font, new SolidBrush(Color.White), tabrect, sf);
                }

                ti++;
            }
        }