Creatig ellipse on a picturebox and making ellipse a link

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Mar 2008
Posts: 7
Reputation: Dumpen1337 is an unknown quantity at this point 
Solved Threads: 0
Dumpen1337 Dumpen1337 is offline Offline
Newbie Poster

Creatig ellipse on a picturebox and making ellipse a link

 
0
  #1
Mar 24th, 2008
Hey I got some quetions

Question 1:
I have a image that is in a picturebox which is called pictureBox1

I want to read monstersetbase.txt and add small ellipses to my image. The position of the ellipse comes from my monstersetbase.txt. The image is 256x256 and the coordinates is example 125x150.

I figured out a way to write a ellipse on the picturebox. It looks like this:
  1. public void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
  2. {
  3. System.Drawing.Graphics g = e.Graphics;
  4. g.DrawEllipse(System.Drawing.Pens.Red, 125, 150, 2, 2);
  5. }

And on my form load:
  1. public void Form1_Load(object sender, EventArgs e)
  2. {
  3. pictureBox1.Paint += new PaintEventHandler(this.pictureBox1_Paint);
  4. this.Controls.Add(pictureBox1);
  5. }

Now my problem is that I cant seem to figure out how to read the txt file properly when I need all the data

If I use for example:
  1. public void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
  2. {
  3. String line;
  4. String data;
  5.  
  6. System.Drawing.Graphics g = e.Graphics;
  7.  
  8. // Reading txt file from fileLocation
  9. using (StreamReader sr = new StreamReader(Convert.ToString(@fileLocation)))
  10. {
  11. while ((line = sr.ReadLine()) != null)
  12. {
  13. // Converting line to string from txt file
  14. data = Convert.ToString(line);
  15.  
  16. // Splitting data into piecesMap[]
  17. String[] piecesMap = data.Split('\t');
  18.  
  19. // Converting x/y cord to float from string
  20. float xCord = float.Parse(piecesMap[3]);
  21. float yCord = float.Parse(piecesMap[4]);
  22.  
  23. // Displaying ellipse
  24. g.DrawEllipse(System.Drawing.Pens.Red, xCord, yCord, 2, 2);
  25. }
  26. }
  27.  
  28. }

then im getting the error:
Index was outside the bounds of the array.

Any suggestions?

My monstersetbase.txt:
  1. 3
  2. 0 0 30 78 60 240 240 -1 5 // Red Dragon
  3. 1 0 30 185 132 185 132 -1 10 // Golden Titan
  4. 2 0 30 183 128 188 135 -1 10 // Golden Solider
  5. 3 0 30 10 10 240 240 -1 12 // Golden Goblin
  6. 4 0 30 10 10 240 240 -1 8 // Golden Dragon
  7. 5 0 30 185 132 185 132 -1 7 // Golden Lizard King
  8. 6 0 30 132 83 132 83 -1 10 // Golden Vepar
  9. 7 0 30 183 128 188 135 -1 6 // Golden Tantalos
  10. 8 0 30 132 83 138 90 -1 10 // Golden Wheel
  11. end
  12. 1
  13. 9 33 10 85 162 95 168 -1 5 // Kundun Demon
  14. 10 29 30 40 113 45 116 -1 3 // Kundum Demon
  15. 11 41 5 126 160 125 161 -1 2 // Kundum Demon
  16. 12 38 5 106 161 111 160 -1 2 // Kundum Demon
  17. end

78 and 60 is the x and y coordinates in the text above.

Question 2:
After I insert the ellipse I want it to be "link" like when I click on it something happens
I also want to display a tooltil when I have the mouse over my ellipse is that possible?
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 1
Reputation: viper1891 is an unknown quantity at this point 
Solved Threads: 0
viper1891 viper1891 is offline Offline
Newbie Poster

How to create a Spiral using DrawLine

 
0
  #2
Mar 9th, 2009
thers one thing that i dont get in picture boxes.. i hav got an assignment rite.. its bout robot trajectory.. im given x and y co-ordinates but i dont now how to write the code .. I want to use DrawLine function but not sure how to use it.. can anyone help me plz.. the co-ordinates look somewhat like this:-
0.000 0.000
0.010 0.001
0.020 0.003
0.029 0.006
0.039 0.010
0.048 0.015
0.056 0.022
0.063 0.030
0.070 0.039
0.076 0.048
0.081 0.059
0.085 0.070
0.087 0.082
0.089 0.095
0.089 0.108
0.088 0.121
0.086 0.135

Please help me out..
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C# Forum


Views: 2344 | Replies: 1
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC