コード例 #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (!base.Visible)
            {
                return;
            }
            //base.OnPaint(e);


            Graphics  g    = e.Graphics;
            Rectangle rect = Rectangle.Empty;

            switch (errorAlignment)
            {
            case ErrorAlignment.Top:
                rect = new Rectangle(0, 0, this.Width, this.Height - TriangleHeight);
                break;

            case ErrorAlignment.Right:
                //TriangleWidth = 15;
                rect = new Rectangle(TriangleWidth, 0, this.Width - TriangleWidth, this.Height);
                break;

            case ErrorAlignment.Left:
                rect = new Rectangle(0, 0, this.Width - TriangleWidth, this.Height);
                break;

            case ErrorAlignment.Bottom:
                rect = new Rectangle(0, TriangleHeight, this.Width, this.Height - TriangleHeight);
                break;

            default:
                break;
            }

            Point[]      point = GetPolygon();
            GraphicsPath path  = new GraphicsPath();

            path.AddPolygon(point);
            GraphicsPath dd = GraphicsPathHelper.DrawRoundRect(rect.X, rect.Y, rect.Width, rect.Height, 18);

            path.AddPath(dd, true);

            path.CloseAllFigures();
            this.Region = new Region(path);
            using (Brush hrush = new SolidBrush(this.backColor))
            {
                //抗锯齿
                g.SmoothingMode = SmoothingMode.AntiAlias;
                g.FillPath(hrush, path);
            }

            DrawText(g, rect);
        }