Új hozzászólás Aktív témák

  • sztanozs

    veterán

    válasz cigam #6395 üzenetére

    De minek tekered időzítővel?
    Azért eseményvezérelt a rendszer, hogy az események vezéreljék, ne valami idióta időzítő.

    Amúgy:
    bool EltolE = false;
    Point Eredeti;
    Point Eltolas = new Point(), UjErtek;

    public Form1()
    {
    InitializeComponent();
    }

    private void pictureBox2_MouseDown(object sender, MouseEventArgs e)
    {
    Eredeti = e.Location;
    EltolE = true;
    }

    private void pictureBox2_MouseMove(object sender, MouseEventArgs e)
    {
    if (EltolE)
    {
    UjErtek = Eltolas - new Size(e.X - Eredeti.X, e.Y - Eredeti.Y);
    if (UjErtek.X < 0) UjErtek.X = 0;
    if (UjErtek.Y < 0) UjErtek.Y = 0;
    if (UjErtek.X > global::TestControlMove.Properties.Resources.Turn_Right_Ahead_Final.Width - pictureBox2.Width) UjErtek.X = global::TestControlMove.Properties.Resources.Turn_Right_Ahead_Final.Width - pictureBox2.Width;
    if (UjErtek.Y > global::TestControlMove.Properties.Resources.Turn_Right_Ahead_Final.Height - pictureBox2.Height) UjErtek.Y = global::TestControlMove.Properties.Resources.Turn_Right_Ahead_Final.Height - pictureBox2.Height;

    using (Graphics g = pictureBox2.CreateGraphics())
    {
    g.DrawImageUnscaled(global::TestControlMove.Properties.Resources.Turn_Right_Ahead_Final, new Point(-UjErtek.X, -UjErtek.Y));
    }
    }
    }

    private void pictureBox2_MouseUp(object sender, MouseEventArgs e)
    {
    EltolE = false;
    Eltolas = UjErtek;
    }

Új hozzászólás Aktív témák

Hirdetés