Click here to Skip to main content
15,887,175 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to create new VPN Connection through C#.net Pin
Christian Graus2-May-08 21:12
protectorChristian Graus2-May-08 21:12 
AnswerRe: How to create new VPN Connection through C#.net Pin
zeyad_aamer27-Jan-13 4:49
zeyad_aamer27-Jan-13 4:49 
Questionnot able 2 update in database Pin
sow_mj2-May-08 18:22
sow_mj2-May-08 18:22 
AnswerRe: not able 2 update in database Pin
Christian Graus2-May-08 21:10
protectorChristian Graus2-May-08 21:10 
QuestionSaving text manipulated data Pin
Casper Hansen2-May-08 17:13
Casper Hansen2-May-08 17:13 
AnswerRe: Saving text manipulated data Pin
Christian Graus2-May-08 17:22
protectorChristian Graus2-May-08 17:22 
AnswerRe: Saving text manipulated data Pin
Casper Hansen3-May-08 2:37
Casper Hansen3-May-08 2:37 
AnswerRe: Saving text manipulated data Pin
Casper Hansen3-May-08 14:48
Casper Hansen3-May-08 14:48 
Now I got the saving text working by not removing any data from the text file so my array looks like this:
// Test<br />
0<br />
0    0    0    15    15    7    // 0<br />
end<br />
<br />
1<br />
1    1    30    25    25    240    240    -1    5    // 1   <br />
end


But now I ran into another problem

I have a image where I draw ellipses on with the coordinates from my text file (X: 15 Y: 15 and the 2: X: 25, Y: 25). It triggers on the paint event from the image

I also have a mouse down event on my image

I save all my ellipses in a list called
List<rectangle> mapRectangleList = new List<rectangle>();</rectangle></rectangle>

When I do mouse down I see if the mouse is over a ellipse. If it is it jumps to a specific line in my MonsterDataArray, but the problem is when I save all my ellipses in the list I dont take end, 0, // and the other things from my text with. I only take:
1	0	30	25	25	240	240	-1	5 	// Red Dragon	<br />
2	0	30	35	35	185	132	-1	10  	// Golden Titan


So when I jump to specific line in my array the line doesnt match up

Yeah im kinda lost here..

Here is the mouse down part:
// Getting cursor position<br />
            Point p = mapImage.PointToClient(Cursor.Position);<br />
<br />
            for (int i = 0; i < mapRectangleList.Count; i++)<br />
            {<br />
                if (mapRectangleList[i].Contains(p))<br />
                {<br />
                    ellipseNum = i;<br />
                    break;<br />
                }<br />
            }<br />
            // If ellipsenum is over a ellipse<br />
            if (ellipseNum > -1)<br />
            {<br />
                MessageBox.Show(Convert.ToString(ellipseNum));<br />
                displayLine(ellipseNum);<br />
            }<br />
            else<br />
            {<br />
                // Else show alert<br />
                MessageBox.Show("Not currently over any ellipse");<br />
            }


Paint event:
            // Open the data file (msbr = monsterSetBaseRead)<br />
            StreamReader msbr = new StreamReader(new FileStream(@XMLmonsterSetBaseLocation, FileMode.Open));<br />
<br />
            // Reading all data<br />
            while ((MapMonsterSetBaseData = msbr.ReadLine()) != null)<br />
            {<br />
                // Splitting data into TxtPiecesMap[]<br />
                String[] TxtPiecesMap = MapMonsterSetBaseData.Split('\t');<br />
<br />
                // Checking if data is a correct monster<br />
                checkIf(MapMonsterSetBaseData);<br />
<br />
                // If it is then continue<br />
                if (checkIfStatus == true)<br />
                {<br />
                    // Getting the x and y cord<br />
                    MapXCord = Convert.ToInt16(TxtPiecesMap[3]) * 2;<br />
                    MapYCord = Convert.ToInt16(TxtPiecesMap[4]) * 2;<br />
<br />
                    // Creating grapic<br />
                    Graphics g = e.Graphics;<br />
<br />
                    // Creating rectangle with cords from coordinates<br />
                    Rectangle r = new Rectangle(MapXCord, MapYCord, 6, 6);<br />
<br />
                    // Drawing ellipse on map<br />
                    g.DrawEllipse(Pens.Gold, r);<br />
<br />
                    // Adding data for ToolTips and Rectangles lists<br />
                    mapRectangleList.Add(r);<br />
                }


And my checkif
private void checkIf(string data)<br />
{<br />
    // If monster string is correct<br />
    if (data != "" && data.Length != 3 && data != "end" && data.Substring(0, 1) != "/" && data.Length != 1)<br />
    {<br />
        // Passes<br />
        checkIfStatus = true;<br />
    }<br />
    else<br />
    {<br />
        // Failed<br />
        checkIfStatus = false;<br />
    }<br />
}


Dont know if this makes any sense

There might be an easier soloution, but I dont know it

Its allmost the same problem as before, but in a diffrent context
QuestionThreading events Pin
MarkB7772-May-08 16:56
MarkB7772-May-08 16:56 
AnswerRe: Threading events Pin
Christian Graus2-May-08 17:06
protectorChristian Graus2-May-08 17:06 
AnswerRe: Threading events Pin
Charith Jayasundara3-May-08 6:51
Charith Jayasundara3-May-08 6:51 
QuestionText bounds problem Pin
Richard Blythe2-May-08 10:47
Richard Blythe2-May-08 10:47 
AnswerRe: Text bounds problem Pin
Luc Pattyn2-May-08 12:05
sitebuilderLuc Pattyn2-May-08 12:05 
GeneralRe: Text bounds problem Pin
Richard Blythe3-May-08 4:12
Richard Blythe3-May-08 4:12 
GeneralRe: Text bounds problem Pin
Luc Pattyn3-May-08 4:31
sitebuilderLuc Pattyn3-May-08 4:31 
QuestionDynamic file reading Pin
ffowler2-May-08 9:45
ffowler2-May-08 9:45 
AnswerRe: Dynamic file reading Pin
PIEBALDconsult2-May-08 10:50
mvePIEBALDconsult2-May-08 10:50 
AnswerRe: Dynamic file reading Pin
Adeel Chaudhry2-May-08 11:13
Adeel Chaudhry2-May-08 11:13 
AnswerRe: Dynamic file reading Pin
Charith Jayasundara3-May-08 6:48
Charith Jayasundara3-May-08 6:48 
QuestionHelp with reading text files Pin
False Chicken2-May-08 9:38
False Chicken2-May-08 9:38 
AnswerRe: Help with reading text files Pin
Gareth H2-May-08 10:50
Gareth H2-May-08 10:50 
AnswerRe: Help with reading text files Pin
PIEBALDconsult2-May-08 10:52
mvePIEBALDconsult2-May-08 10:52 
AnswerRe: Help with reading text files Pin
Adeel Chaudhry2-May-08 11:08
Adeel Chaudhry2-May-08 11:08 
AnswerRe: Help with reading text files Pin
Christian Graus2-May-08 12:52
protectorChristian Graus2-May-08 12:52 
Question.Net COM interop challenge Pin
Jason McBurney2-May-08 8:48
Jason McBurney2-May-08 8:48 

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.