0

For1 には、次のコードがあります。

private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {     
                this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                pictureBox1.Load(file_array_satellite[file_indxs_satellite]);
                file_indxs_satellite = file_indxs_satellite - 1;
                if (file_indxs_satellite < 0)
                {
                    file_indxs_satellite = file_array_satellite.Length - 1;
                }
            }
            catch
            {
                timer1.Enabled = false;
            }
        }

        private void satellitesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            file_array_satellite = Directory.GetFiles(UrlsPath, "RainImage*.*");
            if (file_array_satellite.Length > 0)
            {
                DateTime[] creationTimes8 = new DateTime[file_array_satellite.Length];
                for (int i = 0; i < file_array_satellite.Length; i++)
                    creationTimes8[i] = new FileInfo(file_array_satellite[i]).CreationTime;
                Array.Sort(creationTimes8, file_array_satellite);
                file_indxs_satellite = 0;
                file_indxs_satellite = file_array_satellite.Length - 1;
                timer1.Enabled = true;
            }
        }

        private void pictureBox1_MouseEnter(object sender, EventArgs e)
        {
            this.pictureBox1.Size = new Size(500, 500);
            pictureBox1.Location = new Point(this.Bounds.Width / 2,
                            this.Bounds.Height / 2);
            this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            pictureBox1.BringToFront();
        }

        private void pictureBox1_MouseLeave(object sender, EventArgs e)
        {

                this.pictureBox1.Size = new Size(100, 100);
                pictureBox1.Location = new Point(12,
                                27);

        }

元のpicturebox1のサイズは100x100で、各画像はpictureBoxに収まるように引き伸ばされます。100x100 の場合はすべて問題なく、pictureBox に各画像のアニメーションが表示されます。

ここで、マウスでpictureBox領域に入ると、フォームの中央に移動して500x500にサイズ変更し、画像を引き伸ばして同じアニメーションを表示するイベントを行いました。そして、pictureBox領域を離れると、元のサイズと場所に戻るはずです。

マウスで pictureBox1 領域に入ると、pictureBox は消えてしまいます。pictureBox 領域を離れると、元の場所とサイズで 100x100 が表示されます。

マウスで pictureBox1 領域に入ると、サイズ 500x500 のフォームの中央に表示されないのはなぜですか?

file_array_satellite は string[] であり、file_indxs_satellite は int です。

RainImage*.* は、ダウンロード後のハードディスク上のファイル名です。

アイデアは、ハードディスクに出入りするたびにファイルサイズを変換/変更することではないため、pictureBox1領域に入ると、pictureBoxの現在の画像が引き伸ばされて表示されるようになりました。100x100 では機能しますが、500x500 では機能しません。

4

3 に答える 3

0

このような「その場で」ズームはどうですか?

    private void pictureBox1_MouseEnter(object sender, EventArgs e)
    {
        Rectangle rc = pictureBox1.Bounds;
        rc.Inflate(200, 200);
        pictureBox1.Bounds = rc;
        pictureBox1.BringToFront();
    }

    private void pictureBox1_MouseLeave(object sender, EventArgs e)
    {
        Rectangle rc = pictureBox1.Bounds;
        rc.Inflate(-200, -200);
        pictureBox1.Bounds = rc;
    }
于 2013-10-10T17:42:07.717 に答える