使用GDI + DrawArc时出错没有意义“ArgumentException未被用户代码处理”

时间:2013-02-19 15:44:10

标签: c# gdi+ indexer

有关生成错误的代码,请参见图片。我尝试过重新订购的东西,它总是在第二次调用DrawArc时发生。我只是复制粘贴线

g.DrawArc(SystemPens.ButtonFace, outerCircle[-1], 115, 220);

连续两次说明由于拼写错误或计算错误而未发生错误。 第一次运行正常,第二次运行错误。Code generating error and error message

调用ReLayout()的代码:

    public ButtonFan()
    {
        InitializeComponent();
        for (int i = 0; i < buttonLabels.Count(); i++)
        {
            buttonLabels[i] = new System.Windows.Forms.Label();
            this.buttonLabels[i].Name = "label"+i.ToString();
            this.buttonLabels[i].Size = new System.Drawing.Size(50, 23);
            this.buttonLabels[i].TabIndex = i;
            this.buttonLabels[i].Text = "label"+i.ToString();
        }
        ReLayout();
    }

1 个答案:

答案 0 :(得分:1)

原来在FIRST

中生成了错误
g.DrawArc(SystemPens.ButtonFace, outerCircle[-1], 115, 220);

语句。仍然不确定为什么它直到下一个才会抱怨,但我发现它的方式是添加一行:

Console.WriteLine("Finished first arc");
第一次抽签后

。然后在Console.WriteLine上弹出错误。 当然Console.WriteLine没有错误,所以这意味着它必须从前一个语句翻转,该语句试图将矩形调整为负大小并在其中绘制一个弧。

[-1]更改为[150]解决了问题。