この問題について、回答を得るために Stackoverflow の同様の質問をくまなく調べました。それらの多くは役に立ちましたが、私の問題は解決しませんでした。私のプログラムは、次のように graphics.DrawLines メソッドを使用して winform にポリゴンを描画します。
g.DrawLines(thepen,pts);
しかし、「パラメータが無効です」というエラーが発生し続けます。そのため、そのコード行を次のように変更して、違いがあるかどうかを確認しました。
g.DrawLines(new pen(color.Black),pts);
繰り返しますが、同じエラーが発生しています。pts は system.drawing.point の配列であり、thepen は system.drawing.pen です。
完全にコメントアウトすると、プログラムにエラーが発生しないという問題はありません。しかし、奇妙なことに、過去 3、4 か月間は同じコードが問題なく動作していました。昨日から、どうもうまくいかないようです。
設定する必要がある winform のプロパティ設定はありますか?
更新これが実際の描画方法です
method TMakerPoly.Draw;
var
pts: Array of point;
i:integer;
theBrush1:HatchBrush;
theBrush2:SolidBrush;
begin
if (theBrushStyle = HatchStyle.Wave) then
theBrush1 := new HatchBrush(theBrushStyle,Color.Transparent,color.Transparent)
else if (theBrushStyle = HatchStyle.ZigZag) then
thebrush2 := new SolidBrush(FillColor)
else
theBrush1 := new HatchBrush(theBrushStyle,FillColor,color.Transparent);
if (thePen.DashStyle = DashStyle.Custom) then
thepen.Color := Color.Transparent;
pts := new point[pcount];
if pcount >= 2 then
begin
if Active then
begin
for i := 0 to pcount-1 do
pts[i] := point(points[i]);
Translate(var pts,pcount);
thepen.Color := EdgeColor(thepen.Color);
fillColor := self.BackColor(FillColor);
if visible then
begin
if filled then
begin
if theBrushStyle = HatchStyle.ZigZag then
g.FillPolygon(theBrush2,pts)
else
g.FillPolygon(thebrush1,pts);
g.DrawPolygon(thepen, pts);
end
else
g.DrawLines(thePen, pts);
end;
end
else
begin
for i := 0 to pcount-1 do
pts[i] := point(points[i]);
if filled then
begin
if theBrushStyle = HatchStyle.ZigZag then
g.FillPolygon(theBrush2,pts)
else
g.FillPolygon(thebrush1,pts);
g.DrawPolygon(thepen,pts);
end
else
g.DrawLines(new Pen(color.Black),pts);
end;
end;
end;
ヘルプ、ヒント、手がかりは大歓迎です。