How can i check if the List Length is smaller than the trackBar1.Value by 1 each time?

  • Thread starter Thread starter Chocolade1972
  • Start date Start date
C

Chocolade1972

Guest
This is the code so far in Form1 in the trackBar1_Scroll event:


private void trackBar1_Scroll(object sender, EventArgs e)
{
if (wireObjectAnimation1.wocl.Count < trackBar1.Value && (trackBar1.Value - wireObjectAnimation1.wocl.Count) == 1) // to make that this statement if true it will be only when moving to the right.
// so if i move to the right then inside to check if the list count is == to the trackbar1.value disable button. else enable button.
{
if (wireObjectAnimation1.wocl.Count == 1 && wireObjectAnimation1.wocl.Count == trackBar1.Value)
{
button16.Enabled = true;
}
button16.Enabled = true;
}
else
{
button16.Enabled = false;
}


I have a trackBar and pictureBox when i move to the right and left im moving between images.

Now this List wocl contain some coordinates of points i drawed on the pictureBox.

I want to check each time im moving the scroll bar the List Length .


The conditions should be:


1. When the scroll bar is first on image 0 then the List Count is already 1

2. When moving the scroll bar once to the right the button16 should be enabled true.

I need to check that when im moving it to the right that the difference between the trackBar Value and the List Count is 1.

If i jump or move the track bar to frame that is more then 1 between the List Count and trackbar value the button should be disable.


For example if i was on trackbar vlaue 3 and then jumped to value 8 then the button should be disable.

Only if i moved to the next value/image from 3 to 4 the button should be enabled.


3. When im moving to the left the button will be disable all the time.


I think now its working but my problem is that first time the List count is already 1

So if the trackbar value is 0 and im moving to the right so now the List and the value are the same both are 1

Then im moving to value 2 and the button is enable true but then the List count wont be the same.


I have this Add FRame button that each time i want to move to the next image/frame/value with the trackBar i need to click the Add FRame button to copy the drawings from the last image .

So once i clicked this button the button is disabled and when i move to the right once by 1 it will be enabled again .

But if i moved from the last trackbar position by more then 1 the button is disable.


Now when i click this add frame button it will add to the wocl List another index.

Thats why i have a problem in the beginning when the List is already 1 and the trackBar is on value 0.

If i move to the right one tick with the trackBar then the Value is 1 and the List Count is 1 too.

But in the logic the value 1 is bigger then 0 so im stuck here.


private void button16_Click(object sender, EventArgs e)
{
isanimoredit = true;
if (wireObjectAnimation1!=null)
wireObjectAnimation1.AddFrame();
currentFrameIndex = trackBar1.Value - 1;
textBox1.Text = "Frame Number : " + trackBar1.Value;
if (wireObject1!=null)
wireObject1.woc.Set(wireObjectAnimation1.GetFrame(currentFrameIndex));
setpicture(trackBar1.Value);
addFrame = true;
trackBar1.Select();
pictureBox1.Refresh();
button16.Enabled = false;
}


The reason that the List is starting already with 1 index count is that when im running my program im drawing some points lines then click a button that enable the trackBar and also add this points coordinates to the List already.

So When the trakcBar is enabled the List is already count 1 but the trackBar value is on 0. Then if i move by one to the right the List value is still 1 and the trackBar vlaue is 1 too. So the button will not be enable true.


And i must using this List Count to check all the conditions.

Continue reading...
 


Write your reply...
Back
Top