Enable/disable buttons according to txt file
-
Hello. I this txt file:
// Comment
2
0 0 20 177 185 4 // comment
0 0 20 75 65 4 // hi!!
0 0 20 85 65 4 // asd
0 0 20 95 65 4 // (bbb
endWhere I divide the data into valid and unvalid lines All the data is saved into an array The valid data is:
0 0 20 177 185 4 // comment
0 0 20 75 65 4 // hi!!
0 0 20 85 65 4 // asd
0 0 20 95 65 4 // (bbbAnd the unvalid data is:
// Comment
2
endI go through the array using two buttons: Forward and previous I have a int variable called currentLineNumber which contains the selected line from the array When pressing forward the currentLineNumber is increased and decreased when pressing previous My problem is that I need to enable and disable these two buttons on a certain point For example if I am on the line
0 0 20 95 65 4 // (bbb
I want to disable the forward button since there is no valid data after that line My question is: How do I enable/disable these buttons when I reach the end of valid data? Hope you understand otherwise just ask
-
Hello. I this txt file:
// Comment
2
0 0 20 177 185 4 // comment
0 0 20 75 65 4 // hi!!
0 0 20 85 65 4 // asd
0 0 20 95 65 4 // (bbb
endWhere I divide the data into valid and unvalid lines All the data is saved into an array The valid data is:
0 0 20 177 185 4 // comment
0 0 20 75 65 4 // hi!!
0 0 20 85 65 4 // asd
0 0 20 95 65 4 // (bbbAnd the unvalid data is:
// Comment
2
endI go through the array using two buttons: Forward and previous I have a int variable called currentLineNumber which contains the selected line from the array When pressing forward the currentLineNumber is increased and decreased when pressing previous My problem is that I need to enable and disable these two buttons on a certain point For example if I am on the line
0 0 20 95 65 4 // (bbb
I want to disable the forward button since there is no valid data after that line My question is: How do I enable/disable these buttons when I reach the end of valid data? Hope you understand otherwise just ask
Casper Hansen wrote:
How do I enable/disable these buttons when I reach the end of valid data?
I guess you decide that, if you have no data to do it off, you have to define your own rules, surely ?
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
Casper Hansen wrote:
How do I enable/disable these buttons when I reach the end of valid data?
I guess you decide that, if you have no data to do it off, you have to define your own rules, surely ?
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
Yeah I know how to do that, but the problem is that there can be some unvalid data and I dont know how to enable/disable if the data is unvalid The text file is not the same all the time. The user can change it So it could look like this:
// Comment
2
0 0 20 177 185 4 // (If any)
0 0 20 75 65 4 // (If any)
0 0 20 85 65 4 // (If any)
0 0 20 95 65 4 // (If any)
0 0 20 15 65 4 // (If any)
0 0 20 55 65 4 // (If any)
0 0 20 91 65 4 // (If any)
endOr this:
// Comment
2
0 0 20 177 185 4 // (If any)
0 0 20 75 65 4 // (If any)
0 0 20 85 65 4 // (If any)
0 0 20 95 65 4 // (If any)
0 0 20 15 65 4 // (If any)
0 0 20 55 65 4 // (If any)
0 0 20 91 65 4 // (If any)
end
// End of this
// ShitOr
2
0 0 20 91 65 4 // (If any)
end
// No this is the endIf we take the last example the only valid data is 0 0 20 91 65 4 // (If any), so I want to disable the forward and previous button since there is no valid data to go to I thought of an example where I looped the whole array and searched for a valid data, but couldn seem to figure it out Here is how I read my text file:
while ((MonsterSetBaseLine = rds.ReadLine()) != null) { // If not then add normal MonsterSetBaseDataArray.Add(MonsterSetBaseLine); } }
You might want to see this video: http://youtube.com/watch?v=yLMDBRms-KU You can see there are two buttons (forward and previous) where I go through the text file So if the data is unvalid I skip it and go to the next valid data Now if there is no valid data left in the text file I want to disable the forward button Hope you understand my long post
-
Hello. I this txt file:
// Comment
2
0 0 20 177 185 4 // comment
0 0 20 75 65 4 // hi!!
0 0 20 85 65 4 // asd
0 0 20 95 65 4 // (bbb
endWhere I divide the data into valid and unvalid lines All the data is saved into an array The valid data is:
0 0 20 177 185 4 // comment
0 0 20 75 65 4 // hi!!
0 0 20 85 65 4 // asd
0 0 20 95 65 4 // (bbbAnd the unvalid data is:
// Comment
2
endI go through the array using two buttons: Forward and previous I have a int variable called currentLineNumber which contains the selected line from the array When pressing forward the currentLineNumber is increased and decreased when pressing previous My problem is that I need to enable and disable these two buttons on a certain point For example if I am on the line
0 0 20 95 65 4 // (bbb
I want to disable the forward button since there is no valid data after that line My question is: How do I enable/disable these buttons when I reach the end of valid data? Hope you understand otherwise just ask
// Current lines left in the array // Adding + 1 so it wont take the current line linesLeft = currentLineNumber + 1; // Looping through the rest of the lines from my array.Count for (int i = linesLeft; i < MonsterSetBaseDataArray.Count; i++) { // Check if the line is valid // CheckIf will return true or false (bool) checkIf(Convert.ToString(MonsterSetBaseDataArray\[i\])); // If the data is valid if (checkIfStatus == true) { // Stop the for break; } }
Here is what I got so far on my next / forward button I thought of doing it like this: If one of the remaining lines in the array is valid, the button will not be disabled, but if there is no valid lines left the button will be disabled. I just couldn figure out the last part Any ideas on this? I know how to disable the button, but I dont know when to do it. I disable my button like this: nxtButton.Enabled = false; Hope you can help, because im beginning to get desperate..