hello
can anybody help me in converting some of my java code to c#... i have done uptill this place and stock here now please help me someone.
The Bold taged and underlined part with StoneList.size( ) is more confusing.
Thanx.
Here is the part i'm stock with
i love ye all!
can anybody help me in converting some of my java code to c#... i have done uptill this place and stock here now please help me someone.
The Bold taged and underlined part with StoneList.size( ) is more confusing.
Thanx.
Here is the part i'm stock with
Code:
public void paint(Graphics g) {
Color BoardColor;
int x0, y0, x1, y1, n, i, j, stone_color;
Integer tempInt;
// Draw the background of the applet
offscreenG.setColor(Color.gray);
offscreenG.fillRect(0, 0, AppletWidth, AppletHeight);
// Paint the GO board
BoardColor = new Color(230,205,80); // Draw the board background
offscreenG.setColor(BoardColor);
offscreenG.fillRect(BoardLeft, BoardTop, BoardSize-1, BoardSize-1);
offscreenG.setColor(Color.black); // Draw the board grids
for (i=0; i<= 18; i++) {
x0 = BoardLeft; y0 = i*Delta + BoardTop;
x1 = 18*Delta + BoardLeft; y1 = i*Delta + BoardTop;
offscreenG.drawLine(x0, y0, x1, y1); // draw the row
x0 = i*Delta + BoardLeft; y0 = BoardTop;
x1 = i*Delta + BoardLeft; y1 = 18*Delta + BoardTop;
offscreenG.drawLine(x0, y0, x1, y1); // draw the column
}
for (i=0; i<3; i++) // Draw the board markers
for (j=0; j<3; j++) {
x0 = (3 + i*6) * Delta + BoardLeft - 2 ;
y0 = (3 + j*6) * Delta + BoardTop - 2;
offscreenG.fillRect(x0, y0, 5, 5);
}
// Paint the stone list
[U][B] for (n=0; n < StoneList.size(); n+=3) {
tempInt = (Integer) StoneList.elementAt(n);
i = tempInt.intValue();
tempInt = (Integer) StoneList.elementAt(n+1);
j = tempInt.intValue();
tempInt = (Integer) StoneList.elementAt(n+2);
stone_color = tempInt.intValue();[/B][/U]
if (stone_color==0) { // Draw the black stone
offscreenG.setColor(Color.black);
offscreenG.fillOval((int)((i-0.5)*Delta) + BoardLeft,
(int)((j-0.5)*Delta) + BoardTop, Delta, Delta);
} else { // Draw the white stone
offscreenG.setColor(Color.white);
offscreenG.fillOval((int)((i-0.5)*Delta) + BoardLeft + 1,
(int)((j-0.5)*Delta) + BoardTop + 1, Delta-2, Delta-2);
offscreenG.setColor(Color.black);
offscreenG.drawOval((int)((i-0.5)*Delta) + BoardLeft + 1,
(int)((j-0.5)*Delta) + BoardTop + 1, Delta-2, Delta-2);
}
// paint a marker on the current stone
if (n == StoneList.size()-3) {
if (stone_color==0) { // Draw the black marker
offscreenG.setColor(Color.white);
offscreenG.fillRect(i*Delta + BoardLeft - 1,
j*Delta + BoardTop - 1, 3, 3);
} else { // Draw the white marker
offscreenG.setColor(Color.black);
offscreenG.fillRect(i*Delta + BoardLeft -1,
j*Delta + BoardTop - 1, 3, 3);
}
}
}
// Paint the stone moving with the mouse
if (START!=0 && mouseMoveX > BoardLeft-3 && mouseMoveY > BoardTop-3 &&
mouseMoveX < BoardLeft+BoardSize+3
&& mouseMoveY < BoardTop+BoardSize+3) {
if (!REMOVE) { // plot stone if REMOVE state is false
if (StoneColor==0) { // Draw the black stone
offscreenG.setColor(Color.black);
offscreenG.fillOval(mouseMoveX-Delta/2 + 1,
mouseMoveY-Delta/2 + 1, Delta-2, Delta-2);
} else { // Draw the white stone
offscreenG.setColor(Color.white);
offscreenG.fillOval(mouseMoveX-Delta/2 + 1,
mouseMoveY-Delta/2 + 1, Delta-2, Delta-2);
offscreenG.setColor(Color.black);
offscreenG.drawOval(mouseMoveX-Delta/2,
mouseMoveY-Delta/2, Delta, Delta);
}
} else { // draw the removing cross symbol
x0 = mouseMoveX-Delta/2 + 2;
y0 = mouseMoveY-Delta/2 + 2;
x1 = x0 + Delta - 4;
y1 = y0 + Delta - 4;
offscreenG.setColor(Color.red);
offscreenG.drawLine(x0, y0, x1, y1);
offscreenG.drawLine(x0+1, y0, x1, y1-1);
offscreenG.drawLine(x0, y0+1, x1-1, y1);
offscreenG.drawLine(x0, y1, x1, y0);
offscreenG.drawLine(x0, y1-1, x1-1, y0);
offscreenG.drawLine(x0+1, y1, x1, y0+1);
}
}
g.drawImage(offscreenImg, 0, 0, this);
}