C# 向文本框添加边框时出现重载[CS0121]

C# 向文本框添加边框时出现重载[CS0121],c#,winforms,C#,Winforms,我正在尝试创建一个新组件。当我尝试在这个组件周围绘制一条边时,会出现负载过载。如果你能帮忙,我将不胜感激 FillBorderRentangle扩展代码 private static GraphicsPath GenerateRoundedRectangle(this Graphics graphics, RectangleF rectangle, float radius, RectangleEdgeFilter filter){ float diameter;

我正在尝试创建一个新组件。当我尝试在这个组件周围绘制一条边时,会出现负载过载。如果你能帮忙,我将不胜感激

FillBorderRentangle扩展代码

private static GraphicsPath GenerateRoundedRectangle(this Graphics graphics, RectangleF rectangle, float radius, RectangleEdgeFilter filter){
            float diameter;
            graphics.SmoothingMode = SmoothingMode.AntiAlias;
            GraphicsPath path = new GraphicsPath();
            if(radius <= 0.0F || filter == RectangleEdgeFilter.None) {
                path.AddRectangle(rectangle);
                path.CloseFigure();
                return path;
            } else {
                if(radius >= (Math.Min(rectangle.Width, rectangle.Height)) / 2.0)
                    return graphics.GenerateCapsule(rectangle);
                diameter = radius * 2.0F;
                SizeF sizeF = new SizeF(diameter, diameter);
                RectangleF arc = new RectangleF(rectangle.Location, sizeF);
                if((RectangleEdgeFilter.TopLeft & filter) == RectangleEdgeFilter.TopLeft)
                    path.AddArc(arc, 180, 90);
                else {
                    path.AddLine(arc.X, arc.Y + arc.Height, arc.X, arc.Y);
                    path.AddLine(arc.X, arc.Y, arc.X + arc.Width, arc.Y);
                }
                arc.X = rectangle.Right - diameter;
                if((RectangleEdgeFilter.TopRight & filter) == RectangleEdgeFilter.TopRight)
                    path.AddArc(arc, 270, 90);
                else {
                    path.AddLine(arc.X, arc.Y, arc.X + arc.Width, arc.Y);
                    path.AddLine(arc.X + arc.Width, arc.Y + arc.Height, arc.X + arc.Width, arc.Y);
                }
                arc.Y = rectangle.Bottom - diameter;
                if((RectangleEdgeFilter.BottomRight & filter) == RectangleEdgeFilter.BottomRight)
                    path.AddArc(arc, 0, 90);
                else {
                    path.AddLine(arc.X + arc.Width, arc.Y, arc.X + arc.Width, arc.Y + arc.Height);
                    path.AddLine(arc.X, arc.Y + arc.Height, arc.X + arc.Width, arc.Y + arc.Height);
                }
                arc.X = rectangle.Left;
                if((RectangleEdgeFilter.BottomLeft & filter) == RectangleEdgeFilter.BottomLeft)
                    path.AddArc(arc, 90, 90);
                else {
                    path.AddLine(arc.X + arc.Width, arc.Y + arc.Height, arc.X, arc.Y + arc.Height);
                    path.AddLine(arc.X, arc.Y + arc.Height, arc.X, arc.Y);
                }
                path.CloseFigure();
            }
            return path;
        }
 private static void FillRoundedRectangle(this Graphics graphics, Brush brush, float x, float y, float width, float height, float radius, RectangleEdgeFilter filter){
            RectangleF rectangle = new RectangleF(x, y, width, height);
            GraphicsPath path = graphics.GenerateRoundedRectangle(rectangle, radius, filter);
            SmoothingMode old = graphics.SmoothingMode;
            graphics.SmoothingMode = SmoothingMode.AntiAlias;
            graphics.FillPath(brush, path);
            graphics.SmoothingMode = old;
        }
 public static void FillRoundedRectangle(this Graphics graphics, Brush brush, Rectangle rectangle, int radius){
            graphics.FillRoundedRectangle(brush, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, radius, RectangleEdgeFilter.All);
        }
以下是部件的代码

public class MinaXTextBox : Control, IControl{
 protected override void OnPaint(PaintEventArgs e){
            var g = e.Graphics;
             if(_textActive) 
                    g.FillBorder(Color.Red,5,BorderStyle.None);
   }
}
因此:

由此产生的错误:

MinaXTextBox.cs(158,22):[CS0121][Şu001]这个调用是不明确的 在以下方法或特征中: 'MinaX.Extensions.BorderHelper.FillBorder(System.Drawing.Graphics, System.Drawing.Color、int、System.Windows.Forms.BorderStyle)“和” MinaX.Extensions.BorderHelper.FillBorder(系统、绘图、图形、, System.Drawing.Color,int,System.Windows.Forms.BorderStyle)'


很难理解这段代码的用途(以及它使用的对象)。你想在文本框周围画一个边框吗?我想在文本框外面画一个边框。像hereDo一样,你指的是边框厚度>2、圆角和光晕效果的文本框?或者只是一个1.5像素的彩色边框?您可以使用UserControls接近这一点,该控件使用文本框作为编辑组件,并在背景中绘制半透明位图。例如,请参见以下内容:。对于圆角,需要创建允许抗锯齿的圆角区域。请参阅示例。要绘制内边框,在WinForms中,通常会覆盖WndProc、陷阱WM_PAINT并使用来绘制与文本框中的标准不同的边框。外部边框很简单,也已经包含在与UserControl相关的示例代码中,并且已经链接了圆形边框。顺便说一句,对于*发光效果,您还可以使用如下内容:,为颜色选择正确的alpha。困难的部分是正确混合UserControl内的文本框。您最好使用RichTextBox,因为您可以更轻松地控制内部填充。您还可以扩展默认实现,修改基本RichEdit控件的行为,例如,是已重新启用块对齐(全文对齐)功能的扩展RichTextBox控件。
public class MinaXTextBox : Control, IControl{
 protected override void OnPaint(PaintEventArgs e){
            var g = e.Graphics;
             if(_textActive) 
                    g.FillBorder(Color.Red,5,BorderStyle.None);
   }
}