基本信息
源码名称:C#绘制透明标尺
源码大小:0.03M
文件格式:.rar
开发语言:C#
更新时间:2019-09-20
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 3 元 
   源码介绍
C#绘制透明标尺,可调整大小及透明度等。

protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics graphics = e.Graphics;

            int height = Height;
            int width = Width;

            if (IsVertical)
            {
                graphics.RotateTransform(90);
                graphics.TranslateTransform(0, -Width 1);
                height = Width;
                width = Height;
            }

            LinearGradientBrush lgb = new LinearGradientBrush(new Point(0, 0), new Point(0, height), Color.Black, Color.White);
            // 渐变色
            Color[] colors =
            {
                Color.White,
                Color.White,
                Color.FromArgb(228,232,238),
                Color.FromArgb(202,212,222),
                Color.FromArgb(228,232,238),
                Color.White,
                Color.White
            };
            float[] positions =
            {
                0.0f,
                0.1f,
                0.36f,
                0.5f,
                0.64f,
                0.9f,
                1.0f
            };
            ColorBlend clrBlend = new ColorBlend
            {
                Colors = colors,
                Positions = positions
            };
            lgb.InterpolationColors = clrBlend;

            graphics.FillRectangle(lgb, 0, 0, width, height);

            DrawRuler(graphics, width, height);
        }