1

コードの構文について少し問題があります。これが私のコードです

int frames = Properties.Resources.LOGODENTER.GetFrameCount(FrameDimension.Time);

private void pictureBox1_MouseEnter(object sender, EventArgs e)
{
       pictureBox1.Enabled = true;
        pictureBox1.Image = Properties.Resources.LOGODENTER;
        if (frames == 7)
        {
            pictureBox1.Enabled = false;
        }       
}

private void pictureBox1_MouseLeave(object sender, EventArgs e)
{
        pictureBox1.Enabled = true;
        pictureBox1.Image = Properties.Resources.LOGOLEAVE1;
        if (frames == 6)
        {
            pictureBox1.Enabled = false;
        }
}

基本的に、私が本当にしたいことは、ポインタがコントロールpicturebox1に入ったときにそのイメージを変更しGIF(LOGODENTER)、マウスがその領域を離れたときにそのイメージを再び変更することGIF(LOGOLEAVE1)です。imageAnimator.Animate/StopAnimate は理解できますが、使い方がわかりません。しかし、私のコードロジックが何であるかも理解できると思います。

これは、gif のループの停止に関する 2 回目の記事です。これは最初のSystem.Drawing.ImageAnimator.Animate と System.Drawing.ImageAnimator.StopAnimate の説明です

4

1 に答える 1

0

あなたはそれをうまくやっているように私には思えます。このビデオを使用してリソースに画像を追加pictureBoxし、次のコードで a を使用しました:

private void InitializeComponent()
  {
     this.pictureBox1 = new System.Windows.Forms.PictureBox();
     this.pictureBox1.Location = new System.Drawing.Point(35, 28);
     this.pictureBox1.Name = "pictureBox1";
     this.pictureBox1.Size = new System.Drawing.Size(100, 50);
     this.pictureBox1.TabIndex = 0;
     this.pictureBox1.TabStop = false;
     this.pictureBox1.MouseLeave += new System.EventHandler(this.pictureBox1_MouseLeave);
     this.pictureBox1.MouseEnter += new System.EventHandler(this.pictureBox1_MouseEnter);
     pictureBox1.Image = Properties.Resources.confirmation;
}

private void pictureBox1_MouseEnter(object sender, EventArgs e)
{
     pictureBox1.Image = Properties.Resources.error;

}

private void pictureBox1_MouseLeave(object sender, EventArgs e)
{

     pictureBox1.Image = Properties.Resources.confirmation;
}

そしてそれは働いた

何か不足している場合はお知らせください

于 2013-07-21T05:54:32.000 に答える