Click here to Skip to main content
15,891,529 members
Home / Discussions / C#
   

C#

 
GeneralRe: Creating Class library (COM object) Pin
Christian Graus24-Mar-08 11:13
protectorChristian Graus24-Mar-08 11:13 
GeneralListbox not updating when items are added from another thread. Pin
Jordanwb24-Mar-08 7:49
Jordanwb24-Mar-08 7:49 
GeneralRe: Listbox not updating when items are added from another thread. Pin
ptr2void24-Mar-08 19:21
ptr2void24-Mar-08 19:21 
GeneralRe: Listbox not updating when items are added from another thread. [modified] Pin
Jordanwb25-Mar-08 2:10
Jordanwb25-Mar-08 2:10 
QuestionHow to compare Date Field Value in Access Database with SystemDate and if matches then display in datagrid Pin
rizwan124-Mar-08 7:49
rizwan124-Mar-08 7:49 
GeneralRe: How to compare Date Field Value in Access Database with SystemDate and if matches then display in datagrid Pin
LongRange.Shooter24-Mar-08 8:00
LongRange.Shooter24-Mar-08 8:00 
QuestionRe: How to compare Date Field Value in Access Database with SystemDate and if matches then display in datagrid Pin
rizwan124-Mar-08 20:55
rizwan124-Mar-08 20:55 
GeneralCreatig ellipse on a picturebox and making ellipse a link Pin
Casper Hansen24-Mar-08 7:18
Casper Hansen24-Mar-08 7:18 
Hey im back with a new questions / problems Wink | ;)

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:
public void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
    System.Drawing.Graphics g = e.Graphics;<br />
    g.DrawEllipse(System.Drawing.Pens.Red, 125, 150, 2, 2);<br />
}


And on my form load:
public void Form1_Load(object sender, EventArgs e)<br />
{<br />
    pictureBox1.Paint += new PaintEventHandler(this.pictureBox1_Paint);<br />
    this.Controls.Add(pictureBox1);<br />
}


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:
public void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
		{<br />
			String line;<br />
			String data;<br />
<br />
			System.Drawing.Graphics g = e.Graphics;<br />
<br />
			// Reading txt file from fileLocation<br />
			using (StreamReader sr = new StreamReader(Convert.ToString(@fileLocation)))<br />
			{<br />
				while ((line = sr.ReadLine()) != null)<br />
				{<br />
					// Converting line to string from txt file<br />
					data = Convert.ToString(line);<br />
<br />
					// Splitting data into piecesMap[]<br />
					String[] piecesMap = data.Split('\t');<br />
<br />
					// Converting x/y cord to float from string<br />
					float xCord = float.Parse(piecesMap[3]);<br />
					float yCord = float.Parse(piecesMap[4]);<br />
<br />
					// Displaying ellipse<br />
					g.DrawEllipse(System.Drawing.Pens.Red, xCord, yCord, 2, 2);<br />
				}<br />
			}<br />
<br />
		}


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

Any suggestions?

My monstersetbase.txt:
3<br />
0	0	30	78	60	240	240	-1	5	// Red Dragon<br />
1	0	30	185	132	185	132	-1	10	  // Golden Titan<br />
2	0	30	183	128	188	135	-1	10	  // Golden Solider<br />
3	0	30	10	10	240	240	-1	12	  // Golden Goblin<br />
4	0	30	10	10	240	240	-1	8 	// Golden Dragon<br />
5	0	30	185	132	185	132	-1	7 	// Golden Lizard King<br />
6	0	30	132	83	132	83	-1	10	  // Golden Vepar<br />
7	0	30	183	128	188	135	-1	6 	// Golden Tantalos<br />
8	0	30	132	83	138	90	-1	10	  // Golden Wheel<br />
end<br />
1<br />
9	33	10	85	162	95	168	-1	5	// Kundun Demon<br />
10	29	30	40	113	45	116	-1	3	// Kundum Demon<br />
11	41	5	126	160	125	161	-1	2	// Kundum Demon<br />
12	38	5	106	161	111	160	-1	2	// Kundum Demon<br />
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?
GeneralRe: Creatig ellipse on a picturebox and making ellipse a link Pin
Christian Graus24-Mar-08 10:19
protectorChristian Graus24-Mar-08 10:19 
GeneralRe: Creatig ellipse on a picturebox and making ellipse a link Pin
Casper Hansen26-Mar-08 11:16
Casper Hansen26-Mar-08 11:16 
GeneralRe: Creatig ellipse on a picturebox and making ellipse a link Pin
Christian Graus26-Mar-08 12:31
protectorChristian Graus26-Mar-08 12:31 
GeneralRe: Creatig ellipse on a picturebox and making ellipse a link Pin
Casper Hansen27-Mar-08 3:20
Casper Hansen27-Mar-08 3:20 
GeneralEscape Characters in C# Pin
Vimalsoft(Pty) Ltd24-Mar-08 7:15
professionalVimalsoft(Pty) Ltd24-Mar-08 7:15 
GeneralRe: Escape Characters in C# Pin
m@u24-Mar-08 7:23
m@u24-Mar-08 7:23 
GeneralRe: Escape Characters in C# Pin
Giorgi Dalakishvili24-Mar-08 7:28
mentorGiorgi Dalakishvili24-Mar-08 7:28 
GeneralRe: Escape Characters in C# Pin
Vimalsoft(Pty) Ltd25-Mar-08 1:17
professionalVimalsoft(Pty) Ltd25-Mar-08 1:17 
GeneralRe: Escape Characters in C# Pin
Giorgi Dalakishvili25-Mar-08 7:42
mentorGiorgi Dalakishvili25-Mar-08 7:42 
Questionhow to populate a textboxi in a listview control?? Pin
pyde24-Mar-08 5:41
pyde24-Mar-08 5:41 
AnswerRe: how to populate a textboxi in a listview control?? Pin
pyde26-Mar-08 8:25
pyde26-Mar-08 8:25 
Questionverify edirectory value(?) exists Pin
4r3s24-Mar-08 4:45
4r3s24-Mar-08 4:45 
QuestionCan this code be generic? Pin
SteelIXB24-Mar-08 4:26
SteelIXB24-Mar-08 4:26 
AnswerRe: Can this code be generic? Pin
LongRange.Shooter24-Mar-08 5:13
LongRange.Shooter24-Mar-08 5:13 
GeneralRe: Can this code be generic? Pin
SteelIXB24-Mar-08 7:02
SteelIXB24-Mar-08 7:02 
GeneralLogical Ports.. Pin
ptr2void24-Mar-08 3:03
ptr2void24-Mar-08 3:03 
GeneralRe: Logical Ports.. Pin
ptr2void24-Mar-08 19:22
ptr2void24-Mar-08 19:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.