不會寫Visual Web的問題題目?!

EX: 橘圓半徑: [ textbox1]

Rating

新增一個button

跟兩個textbox

調用

using System.Drawing;

using System.Drawing.Drawing2D;

計算類別

class bclass

{

Rectangle orange, yellow, blue;

int b1, o1, o2, y1, y2, y3;

string superficial;

public void bb(int i, int j)

{

b1 = (i * 2) + (j * 2);

blue = new Rectangle(0, 0, b1, b1);

o1 = (b1 / 2) - i;

o2 = i * 2;

orange = new Rectangle(0, o1, o2, o2);

y1 = b1 - (j * 2);

y2 = (b1 / 2) - j;

y3 = j * 2;

yellow = new Rectangle(y1, y2, y3, y3);

float sp = (i + j) * (i + j) * (float)3.14;

superficial = sp.ToString();

}

public Rectangle ORANGE

{

get

{

return orange;

}

}

public Rectangle YELLOW

{

get

{

return yellow;

}

}

public Rectangle BLUE

{

get

{

return blue;

}

}

public int B

{

get

{

return b1;

}

}

public string SUPERFICIAL

{

get

{

return superficial;

}

}

}

宣告屬性

bclass bget = new bclass();

SolidBrush sbOrange = new SolidBrush(Color.Orange);

SolidBrush sbYellow = new SolidBrush(Color.Yellow);

SolidBrush sbBlue = new SolidBrush(Color.Blue);

Pen p = new Pen(Color.White, 1);

button程式碼

try

{

if (int.Parse(TextBox1.Text) > 0 && int.Parse(TextBox2.Text) > 0)

{

bget.bb(int.Parse(TextBox1.Text), int.Parse(TextBox2.Text));

Bitmap bmp = new Bitmap(bget.B, bget.B);

Graphics g = Graphics.FromImage(bmp);

g.FillEllipse(sbBlue, bget.BLUE);

g.FillEllipse(sbOrange, bget.ORANGE);

g.FillEllipse(sbYellow, bget.YELLOW);

g.DrawString(bget.SUPERFICIAL, new Font("Arial", 15), sbYellow, 10, 10);

bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);

Response.ContentType = "image/gif";

}

}

catch { }