-1
整数配列で、マウスの各クリックを格納する方法 私はそれは私が保管しなければならない機能(空ポリゴン) だ書いたので、私はポリゴンを描きたかった今の線を描くことができます配列内の各クリックの座標と、その後、私の機能は彼らに を取得する必要があり、私はRadiobutton1はドローラインとradiobutton2です
をクリックして、それぞれを保存する方法がわからないが、ポリゴンに私はクラスのラインでそれを書いたブレゼンハムのアルゴリズムを持って
private void panel1_MouseClick(object sender, MouseEventArgs e)
{
if(radioButton1.Checked)
if (firstClick)
{
firstX = e.X;
firstY = e.Y;
firstClick = false;
}
else
{
Line l = new Line(firstX, firstY, e.X, e.Y, panel1.CreateGraphics(), Convert.ToInt32(textBox1.Text));
firstClick = true;
}
if(radioButton2.Checked)
{
//how to write here so as to store each click in array
}
}
private void button1_Click(object sender, EventArgs e)
{
int n = Convert.ToInt32(textBox2.Text);
Polygon(n, coor);
}
void Polygon(int n,int[] coordinates)
{
if(n>=2)
{
Line l=new Line(coordinates[0],coordinates[1],coordinates[2],coordinates[3],panel1.CreateGraphics(), Convert.ToInt32(textBox1.Text));
for(int count=1;count<(n-1);count++)
l=new Line(coordinates[(count*2)],coordinates[((count*2)+1)],coordinates[((count+1)*2)],coordinates[(((count+1)*2)+1)],panel1.CreateGraphics(), Convert.ToInt32(textBox1.Text));
}
多角形の別のアルゴリズムを楽しみにしています – Nickool
あなたは何をしたいのか分かりません。詳しい情報が必要な場合は別の質問をしてください。答えがあれば私の答えを記入してください。 – Hidde