Kwadracik nie chce się przesuwać na pictureBoxie

0

C#,vistual studio 2012 prof, winform:
Kod mam taki:

private void czasElementoCiaguAr_Tick(object sender, EventArgs e)
        {
            if (czasElementoCiaguAr.Enabled == false)
                czasElementoCiaguAr.Enabled = true;

            rect.Location = new Point(rect.Location.X + count, rect.Location.Y - count);
            
            
            if (count < 300)
            {
                
                czasElementoCiaguAr.Start();
                count = count + 2;
            }
            
            
        }

Bilay kwadracik powinnien się przesuwać po czarnym tle,ale stoi w miejscu. Czy ma ktoś pomysł czem?

0

Wywal

czasElementuCiaguAr.Start()

z tego if'a, bo resetujesz Timer za każdym razem kiedy jest wywołany.

0

Kod samego pictureboxa:

private void AnimacjaElementowCiaguAr(object sender, PaintEventArgs e)
        {
            
            graph = e.Graphics;
            graph.Clear(Color.Black);
            PictureBoxAnimacjaElCAr.Location = new Point(10, 10);
            PictureBoxAnimacjaElCAr.Width = 500;
            PictureBoxAnimacjaElCAr.Height = 300;
            PictureBoxAnimacjaElCAr.BackColor = Color.Black;
            PictureBoxAnimacjaElCAr.Image = new Bitmap(PictureBoxAnimacjaElCAr.Width, PictureBoxAnimacjaElCAr.Height);
           
            Pen pen = new Pen(Color.White, 2);
            
           
            
            PictureBoxAnimacjaElCAr.Invalidate();
            
            
        }

kod button

private void uruchomAnimacjeCiaguAr_Click(object sender, EventArgs e)
        {


            if (czasElementoCiaguAr.Enabled == false)
                czasElementoCiaguAr.Enabled = true;

            if (rect.Location.X >=9)
            {
                czasElementoCiaguAr.Start();
            }
          
        }
0

Co to za metoda: AnimacjaElementowCiaguAr? Czy to jakiś event handler?
Czym są: graph i rect?

Tworzysz w pierwszej metodzie pen, ale nie dość, że nigdzie go nie używasz, to nawet go nie zwalniasz :|
Masz w ogóle tu coś nawalone. Napisz krok po kroku co chcesz uzyskać. Chcesz, żeby po PictureBox wędrował sobie czarny kwadrat?

1 użytkowników online, w tym zalogowanych: 0, gości: 1