473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

java to c#

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


Expand|Select|Wrap|Line Numbers
  1. public void paint(Graphics g) {
  2.  
  3.     Color BoardColor;
  4.     int x0, y0, x1, y1, n, i, j, stone_color;
  5.     Integer tempInt;
  6.  
  7.     // Draw the background of the applet
  8.     offscreenG.setColor(Color.gray);
  9.     offscreenG.fillRect(0, 0, AppletWidth, AppletHeight);   
  10.  
  11.     // Paint the GO board
  12.     BoardColor = new Color(230,205,80); // Draw the board background
  13.     offscreenG.setColor(BoardColor);
  14.     offscreenG.fillRect(BoardLeft, BoardTop, BoardSize-1, BoardSize-1);   
  15.     offscreenG.setColor(Color.black);   // Draw the board grids
  16.     for (i=0; i<= 18; i++)  {
  17.     x0 = BoardLeft; y0 = i*Delta + BoardTop; 
  18.         x1 = 18*Delta + BoardLeft; y1 = i*Delta + BoardTop;
  19.         offscreenG.drawLine(x0, y0, x1, y1); // draw the row
  20.     x0 = i*Delta + BoardLeft; y0 = BoardTop; 
  21.         x1 = i*Delta + BoardLeft; y1 = 18*Delta + BoardTop;
  22.         offscreenG.drawLine(x0, y0, x1, y1); // draw the column
  23.     }
  24.     for (i=0; i<3; i++)                // Draw the board markers
  25.     for (j=0; j<3; j++) {
  26.         x0 = (3 + i*6) * Delta + BoardLeft - 2 ;  
  27.         y0 = (3 + j*6) * Delta + BoardTop - 2;
  28.         offscreenG.fillRect(x0, y0, 5, 5);
  29.         }
  30.  
  31.     // Paint the stone list
  32.     for (n=0; n < StoneList.size(); n+=3) {
  33.     tempInt = (Integer) StoneList.elementAt(n);
  34.         i = tempInt.intValue();
  35.         tempInt = (Integer) StoneList.elementAt(n+1);
  36.     j = tempInt.intValue();
  37.     tempInt = (Integer) StoneList.elementAt(n+2);
  38.         stone_color = tempInt.intValue();
  39.  
  40.         if (stone_color==0) {  // Draw the black stone
  41.           offscreenG.setColor(Color.black);
  42.        offscreenG.fillOval((int)((i-0.5)*Delta) + BoardLeft, 
  43.        (int)((j-0.5)*Delta) + BoardTop, Delta, Delta);
  44.         } else {               // Draw the white stone
  45.          offscreenG.setColor(Color.white);
  46.            offscreenG.fillOval((int)((i-0.5)*Delta) + BoardLeft + 1, 
  47.          (int)((j-0.5)*Delta) + BoardTop + 1, Delta-2, Delta-2);
  48.           offscreenG.setColor(Color.black);
  49.            offscreenG.drawOval((int)((i-0.5)*Delta) + BoardLeft + 1, 
  50.          (int)((j-0.5)*Delta) + BoardTop + 1, Delta-2, Delta-2);
  51.         }
  52.  
  53.         // paint a marker on the current stone
  54.         if (n == StoneList.size()-3) {
  55.            if (stone_color==0) {  // Draw the black marker
  56.               offscreenG.setColor(Color.white);
  57.           offscreenG.fillRect(i*Delta + BoardLeft - 1, 
  58.             j*Delta + BoardTop - 1, 3, 3);
  59.            } else {               // Draw the white marker
  60.               offscreenG.setColor(Color.black);
  61.               offscreenG.fillRect(i*Delta + BoardLeft -1, 
  62.             j*Delta + BoardTop - 1, 3, 3);
  63.            }
  64.         }
  65.     }
  66.  
  67.     // Paint the stone moving with the mouse
  68.     if (START!=0 && mouseMoveX > BoardLeft-3 && mouseMoveY > BoardTop-3 &&
  69.         mouseMoveX < BoardLeft+BoardSize+3 
  70.     && mouseMoveY < BoardTop+BoardSize+3) {
  71.  
  72.     if (!REMOVE) { // plot stone if REMOVE state is false
  73.            if (StoneColor==0) { // Draw the black stone 
  74.               offscreenG.setColor(Color.black);
  75.               offscreenG.fillOval(mouseMoveX-Delta/2 + 1, 
  76.             mouseMoveY-Delta/2 + 1, Delta-2, Delta-2); 
  77.            } else {             // Draw the white stone
  78.             offscreenG.setColor(Color.white);
  79.               offscreenG.fillOval(mouseMoveX-Delta/2 + 1, 
  80.             mouseMoveY-Delta/2 + 1, Delta-2, Delta-2); 
  81.               offscreenG.setColor(Color.black);
  82.               offscreenG.drawOval(mouseMoveX-Delta/2, 
  83.             mouseMoveY-Delta/2, Delta, Delta); 
  84.            }
  85.         } else { // draw the removing cross symbol
  86.        x0 = mouseMoveX-Delta/2 + 2; 
  87.        y0 = mouseMoveY-Delta/2 + 2;
  88.        x1 = x0 + Delta - 4;
  89.        y1 = y0 + Delta - 4;
  90.            offscreenG.setColor(Color.red);
  91.        offscreenG.drawLine(x0,   y0,   x1,   y1);
  92.        offscreenG.drawLine(x0+1, y0,   x1,   y1-1);
  93.        offscreenG.drawLine(x0,   y0+1, x1-1, y1);
  94.        offscreenG.drawLine(x0,   y1,   x1,   y0);
  95.        offscreenG.drawLine(x0,   y1-1, x1-1, y0);
  96.        offscreenG.drawLine(x0+1, y1,   x1,   y0+1);
  97.         }
  98.  
  99.     }
  100.  
  101.     g.drawImage(offscreenImg, 0, 0, this);
  102.  
  103.   }
i love ye all!
Feb 9 '08 #1
0 792

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
1
by: ptaz | last post by:
Hi I'm trying to run a web page but I get the following error. Ca anyone please tell me a solution to this. Thanks Ptaz HTTP Status 500 - type Exception report
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
0
by: mailkhurana | last post by:
Hii , I am trying to use a type 2 driver to connect to DB2 0n AIX 5 I have a small java test to class to establish a conneciton with the db .. I am NOT using WAS or any appserver When I try to...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
12
by: Mark Fink | last post by:
I wrote a Jython class that inherits from a Java class and (thats the plan) overrides one method. Everything should stay the same. If I run this nothing happens whereas if I run the Java class it...
0
by: jaywak | last post by:
Just tried running some code on Linux (2.4.21-32.0.1.EL and Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)) and Windows XPSP2 (with Java HotSpot(TM) Client VM (build...
1
by: jaimemartin | last post by:
hello, I want to validate an xml by means of a schema (xsd). To do that first of all I´m using a SchemaFactory. The problem is that if I run the code in Windows all works fine, but If I run it in...
0
oll3i
by: oll3i | last post by:
package library.common; import java.sql.ResultSet; public interface LibraryInterface { public ResultSet getBookByAuthor(String author); public ResultSet getBookByName(String name);
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.