private void frmAndonEventCancel_30_Shown(object sender, EventArgs e) { tcMain.SelectedTabPage = tpIDCardnoRead; ReplaceIDCardNoReadPanel(); image.Play(); }
public void Play() { if (AnimateImage != null) { image = new AnimateImage(AnimateImage); image.OnFrameChanged += new EventHandler <EventArgs>((o, ex) => { Invalidate(); }); SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); var owner = this; Image newImg = image.Image; var scWidth = owner.Width * 1.0f / image.Image.Width; var scHeight = owner.Height * 1.0f / image.Image.Height; var minScale = Math.Min(scWidth, scHeight); if (minScale < 1.0f) { newImg = new Bitmap(image.Image, new Size((int)(minScale * image.Image.Width), (int)(minScale * image.Image.Height))); } if (scWidth < scHeight) { owner.Height = newImg.Height; } else if (scWidth > scHeight) { owner.Width = newImg.Width; } image.Play(); } }