コード例 #1
0
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            var rect = ClientRectangle;

            rect.Inflate(-3, -3);
            var shape = DrawHelper.CreateRoundPathFPoint(rect, 2);

            Region = new Region(shape);
            // DrawHelper.SetWindowRegion(this, 2);
            Invalidate();
        }
コード例 #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            var graphics = e.Graphics;

            // Share.GraphicSetup(graphics);
            //  base.OnPaint(e);
            //绘制质感的标题栏
            if (true)
            {
                var lgb = new LinearGradientBrush(CaptionRect, Share.LineTop, Share.LineBottom, 90f);
                graphics.FillRectangle(lgb, CaptionRect);
                lgb.Dispose();
                var p = new Pen(Share.Line, 1);
                graphics.DrawLine(p, new Point(0, CaptionRect.Height + 3),
                                  new Point(CaptionRect.Width, CaptionRect.Height + 3));
                //p.Color = Color.Blue;
                //  p.Width = 5;
                //  graphics.DrawLine(p, new Point(0, this.CaptionRect.Height + 1), new Point(this.CaptionRect.Width, this.CaptionRect.Height+1));
                p.Dispose();
            }
            //标题文字

            var size  = TextRenderer.MeasureText(Text, Font);
            var image = SkinTools.ImageLightEffect(Text, Font, ForeColor, Color.White, 4,
                                                   new Rectangle(0, 0, Width, size.Height), true);

            graphics.DrawImage(image, textRect.X - (4 / 2), textRect.Y - (4 / 2));
            //画图标
            if (Icon != null)
            {
                graphics.DrawIcon(Icon, IconRect);
            }
            //画关闭按钮
            graphics.DrawImage(btnImg, closeRect);
            //画边框
            var rect = ClientRectangle;

            rect.X      += 3;
            rect.Y      += 3;
            rect.Width  -= 7;
            rect.Height -= 7;
            using (var pen = new Pen(Color.DarkGray))
            {
                var path = DrawHelper.CreateRoundPathFPoint(rect, 2);
                graphics.DrawPath(pen, path);
                path.Dispose();
            }
        }