Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

How can i detect if the frame before or the next frame already have been filled or not when moving/scrolling the trackBar left or right ?

$
0
0

I have this trackBar scroll event:

private void trackBar1_Scroll(object sender, EventArgs e)
        {



            if (trackBar1.Value > trackValue)
            {
                if (isanimoredit == true)
                {
                    addFrame = true;
                    button16.Enabled = false;
                }
                else
                {
                    addFrame = false;
                    button16.Enabled = true;
                }
            }
            else
            {
                if (trackBar1.Value > 0)
                {
                }
                else
                {
                    addFrame = true;
                    button16.Enabled = false;
                }
            }


            
            if (addFrame == false)
            {
                //addFrame = true; // this is if i want to redraw and show the points on the pictureBox1 to check it what to do.
                currentFrameIndex = trackBar1.Value - 1;
                textBox1.Text = "Frame Number : " + trackBar1.Value;

                wireObject1.woc.Set(wireObjectAnimation1.GetFrame(currentFrameIndex));
                setpicture(trackBar1.Value);
                pictureBox1.Refresh();
            }
            else
            {
                currentFrameIndex = trackBar1.Value - 1;
                textBox1.Text = "Frame Number : " + trackBar1.Value;

                wireObject1.woc.Set(wireObjectAnimation1.GetFrame(currentFrameIndex));
                // only moving the scroll bar to the right its doing animation class getframe function and its good in wireobject coordinates
                // then the two lists in the set function are good. But in the mouse up event when doing the set for the animation if i didnt do get for the animation before for example in the scroll bar event
                // then its error the list is 0 empty. to check it \\
                // LoadPictureAt(trackBar1.Value, sender);

                trackBar1.Minimum = 0;
                trackBar1.Maximum = fi.Length - 1; // to make that if i moved the trackBar to far frame jumped over frames and did add frame it will jump to the last frame and add this frame
                // also the trackBar bar will jump to the place of the last frame !!!!!
                if (checkBox1.Checked)
                {
                    setpicture(trackBar1.Value);
                    Graphics g = Graphics.FromImage(pictureBox1.Image);
                    g.Clear(SystemColors.Control);
                    pictureBox1.Invalidate();
                }
                else
                {
                    setpicture(trackBar1.Value);
                }
                pictureBox1.Refresh();

                button1.Enabled = false;
                button2.Enabled = false;
                button3.Enabled = false;
                button4.Enabled = false;
                button8.Enabled = false;
                SaveFormPicutreBoxToBitMapIncludingDrawings(currentFrameIndex);

                return;

            }

In this part of the scroll event code im trying to detect if i already clicked the Add Frame button or not:

if (trackBar1.Value > trackValue)
            {
                if (isanimoredit == true)
                {
                    addFrame = true;
                    button16.Enabled = false;
                }
                else
                {
                    addFrame = false;
                    button16.Enabled = true;
                }
            }
            else
            {
                if (trackBar1.Value > 0)
                {
                }
                else
                {
                    addFrame = true;
                    button16.Enabled = false;
                }
            }

This is the add frame button code:

private void button16_Click(object sender, EventArgs e)
        {
            isanimoredit = true;
            wireObjectAnimation1.AddFrame(); // to check with add frame everything !
            currentFrameIndex = trackBar1.Value - 1;
            textBox1.Text = "Frame Number : " + trackBar1.Value;
            wireObject1.woc.Set(wireObjectAnimation1.GetFrame(currentFrameIndex));
            setpicture(trackBar1.Value);
            addFrame = true;
            trackBar1.Select();
            pictureBox1.Refresh();
        }

I used a flag to find out when i clicked or not the add frame button i called it : isanimationoredit and set it to true each time i click the add frame button.

The trackValue variable is int i use it :

private void trackBar1_ValueChanged(object sender, EventArgs e)
        {
            trackValue = this.trackBar1.Value;
        }

When i click the add frame button it will have to do two things:

1. If the next frame/trackBar.Value to the right empty then copy the last frame drawings to the next one.

2. If i move to the left if the frame is already drawed already clicked before add frame just show it.

    but if i moved left and i didn't clicked yet add frame before just dont do anything leave it empty.

If i didn't click the add frame button at all and just move right or left it will keep moving without drawing/adding anything to the pictureBox just will move between the images.

But the rules should be that : Moving right if its empty frame/image then enable true button16 so i can click the add frame button if i move to th right and there is already drawings enable button16 to false so i wont be able to add again a frame.

If i move to the left if its empty do nothing but enable button16 to true if there is drawings already  do nothing but then make button16 enabled false.

-----------------------------

Now what i could do is that the first frame all the time show the drawings on the pictureBox.

If i move to the right show empty frame and enable the button true.

The problems are:

1. If i click the add frame button then the variable the flag isanimationoredit all the time true so if i will keep move to the right i will see on each frame the drawings. But i want that only if i clicked the add frame button it will copy the last drawings.

2. How can i check/detect if i move the trackBar one to the left or to the right if the frame is empty or not ? And then according to this to enable/disable the button16 .


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>