protected override void Init() { int index = (int)Math.Ceiling(All.Class.Num.GetRandom(0.001f, flushlist.Length - 1)) - 1; All.Class.Reflex <Player.FlushMethod> r = new Class.Reflex <Player.FlushMethod>("All", string.Format("All.Control.Player.{0}", (FlushList)Enum.Parse(typeof(FlushList), flushlist.GetValue(index).ToString()))); f = (Player.FlushMethod)r.Get(); f.Init(Hwnd, Pic1, Pic2, Back, DelayTime, TickTime); f.FlushOver += f_FlushOver; }
/// <summary> /// 设置图片 /// </summary> /// <returns></returns> private bool SetPic() { bool result = false; if (backImage == null) { backImage = new Bitmap(Width, Height); } if (filePath == null || filePath.Count <= 0)//无图片,则显示背景色 { using (Graphics g = Graphics.FromImage(backImage)) { g.Clear(BackColor); } this.Invalidate(); if (PlayOver != null) { PlayOver(); } return(false); } else if (filePath.Count == 1)//单张图片,直接显示图片 { using (Graphics g = Graphics.FromImage(backImage)) { g.SmoothingMode = SmoothingMode.HighQuality; g.CompositingQuality = CompositingQuality.HighQuality; g.DrawImage(filePath[0], new Rectangle(0, 0, Width, Height), new Rectangle(0, 0, filePath[0].Width, filePath[0].Height), GraphicsUnit.Pixel); if (PlayOver != null) { PlayOver(); return(false); } } } else if (filePath.Count >= 2)//多张图片,开始轮播 { picPlayIndex++; if (picPlayIndex == filePath.Count) { if (PlayOver != null) { PlayOver(); return(false); } } picPlayIndex = (picPlayIndex % filePath.Count); Image1 = filePath[picPlayIndex]; int tmpPicPlayIndex = picPlayIndex; tmpPicPlayIndex++; tmpPicPlayIndex = (tmpPicPlayIndex % filePath.Count); Image2 = filePath[tmpPicPlayIndex]; if (flushMethod != null) { flushMethod.FlushOver -= flushMethod_FlushOver; flushMethod = null; } All.Class.Reflex <Player.FlushMethod> r = new Class.Reflex <Player.FlushMethod>("All", string.Format("All.Control.Player.{0}", flushList)); flushMethod = (Player.FlushMethod)r.Get(); flushMethod.Init(this.Handle, Image1, Image2, backImage, changeTime, TickTime); flushMethod.FlushOver += flushMethod_FlushOver; result = true; } this.Invalidate(); return(result); }