在winforms中平移地图并不顺利

时间:2017-07-28 08:58:47

标签: c# .net winforms

将多个小图像*(256 * 256)*组合成一个大图像(尺寸为picturebox)。现在,如果我试图平移/移动大图像,它将不会移动,直到差异为256像素。它不顺利平移。这是我的代码

private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Right)
    {
        if (isdragging)
        {
            mapCenterX += (-e.X + (startingpoint.X)) * Map.scaleX;

            mapCenterY -= (-e.Y + (startingpoint.Y)) * Map.scaleY;

            Map.DrawMap(mapCenterX, mapCenterY, mapZoom);

            startingpoint.X = e.X;
            startingpoint.Y = e.Y;
            pictureBox1.Invalidate();
        }
    }
}

private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Right)
    {
        isdragging = false;
    }
}

private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Right)
    {
        isdragging = true;
        startingpoint.X = e.X;
        startingpoint.Y = e.Y;
    }
}

0 个答案:

没有答案