How do i check or update a variable in trackBar Scroll when i move the Bar scroll it to the left ?

Answered How do i check or update a variable in trackBar Scroll when i move the Bar scroll it to the left ?

  • Thursday, April 05, 2012 1:07 AM
     
      Has Code

    Now in the scroll event i can update the List when i move the Bar to the right i start the program when the Bar is on frame 0 and i slide it to the right.

    And each frame each tick of the TrackBar i slide to the right i update the List.

    But when i move the trackBar slide it back to the left and the trackBar1.Value is counting down back i want to load from the List to each frame .

    But how do i know if i move the trackBar slider to the left or to the right ?

    private void trackBar1_Scroll(object sender, EventArgs e)
            {
                LoadPictureAt(trackBar1.Value, sender);
                currentFrameIndex = trackBar1.Value;
                textBox1.Text = "Frame Number : " + trackBar1.Value;
                WireObjectCoordinatesCloneFrame();
                wireObjectCoordinates1 = new WireObjectCoordinates();
                WireObjectCoordinatesList.Add(wireObjectCoordinates1);
                
                
            }


    danieli

All Replies

  • Thursday, April 05, 2012 1:14 AM
     
     

    What I would do is to either save the FrameNumber in the wireObjectsCoordiunates1 - object and search the list for the WireObjectCoordinates that has that number, or initially add as much empty WireObjectCoordinates-objects to the list and update the ones that are at the same index of the list as the trackBar's value.

    Regards,

      Thorsten


  • Thursday, April 05, 2012 1:26 AM
     
     Answered Has Code

    ... for instance add a Property FrameNUmber to your class WireObjectCoordinates:

        class WireObjectCoordinates
        {
            public int FrameNumber { get; set; }
    
            //...
        }

    then search the list like:

            private void trackBar1_Scroll(object sender, EventArgs e)
            {
                LoadPictureAt(trackBar1.Value, sender);
                currentFrameIndex = trackBar1.Value;
                textBox1.Text = "Frame Number : " + trackBar1.Value;
    
                int idx = -1;
    
                try
                {
                    var w = WireObjectCoordinatesList.First(a => a.FrameNumber == currentFrameIndex);
                    idx = WireObjectCoordinatesList.IndexOf(w);
                }
                catch
                {
    
                }
    
                if (idx > -1)
                {
                     //do the things you want to do when the list contains the object
                }
                else
                {
                    WireObjectCoordinatesCloneFrame();
                    wireObjectCoordinates1 = new WireObjectCoordinates() { FrameNumber = currentFrameIndex };
                    WireObjectCoordinatesList.Add(wireObjectCoordinates1);
                }       
            }

    Regards,

      Thorsten

    • Marked As Answer by chocolade Thursday, April 05, 2012 1:45 AM
    •