private void SecondScreen_FormClosing(object sender, FormClosingEventArgs e) { if (_my_effect != null) { _my_effect.Dispose(); _my_effect.Ready -= new Effects.ReadyDelegate(_my_effect_Ready); _my_effect.PercentComplete -= new Effects.PercentCompletedDelegate(_my_effect_PercentComplete); _my_effect = (Effects.IEffect)null; } GC.Collect(); if (_mci == null) { return; } if (_mci.IsOpen) { _mci.Close(); } _mci.Dispose(); _mci = (Mci)null; }
private void _my_effect_Ready(Effects.IEffect sender) { _my_effect_ready = true; }
private void _my_effect_PercentComplete(Effects.IEffect sender, int value) { }
private void _get_effect(int EffectIndex) { switch (_effect_names[EffectIndex]) { case "None": _my_effect = (Effects.IEffect) new Effects.None(); break; case "Alpha": _my_effect = (Effects.IEffect) new Effects.Alpha(); break; case "TopDown": _my_effect = (Effects.IEffect) new Effects.Down(); break; case "BottomUp": _my_effect = (Effects.IEffect) new Effects.Up(); break; case "RightToLeft": _my_effect = (Effects.IEffect) new Effects.Left(); break; case "LeftToRight": _my_effect = (Effects.IEffect) new Effects.Right(); break; case "RectangleUpperLeftToLowerRight": _my_effect = (Effects.IEffect) new Effects.RectangleUpperLeftToLowerRight(); break; case "RectangleUpperRightToLowerLeft": _my_effect = (Effects.IEffect) new Effects.RectangleUpperRightToLowerLeft(); break; case "RectangleLowerLeftToUpperRight": _my_effect = (Effects.IEffect) new Effects.RectangleLowerLeftToUpperRight(); break; case "RectangleLowerRightToUpperLeft": _my_effect = (Effects.IEffect) new Effects.RectangleLowerRightToUpperLeft(); break; case "DiagonalUpperLeftToLowerRight": _my_effect = (Effects.IEffect) new Effects.DiagonalUpperLeftToLowerRight(); break; case "DiagonalUpperRightToLowerLeft": _my_effect = (Effects.IEffect) new Effects.DiagonalUpperRightToLowerLeft(); break; case "DiagonalLowerLeftToUpperRight": _my_effect = (Effects.IEffect) new Effects.DiagonalLowerLeftToUpperRight(); break; case "DiagonalLowerRightToUpperLeft": _my_effect = (Effects.IEffect) new Effects.DiagonalLowerRightToUpperLeft(); break; case "EllipticFromInside": _my_effect = (Effects.IEffect) new Effects.EllipticFromInside(); break; case "EllipticFromOutside": _my_effect = (Effects.IEffect) new Effects.EllipticFromOutside(); break; case "RectangleFromInside": _my_effect = (Effects.IEffect) new Effects.RectangleFromInside(); break; case "RectangleFromOutside": _my_effect = (Effects.IEffect) new Effects.RectangleFromOutside(); break; case "ZoomIn": _my_effect = (Effects.IEffect) new Effects.ZoomIn(); break; case "ZoomOut": _my_effect = (Effects.IEffect) new Effects.ZoomOut(); break; case "CurtainDown": _my_effect = (Effects.IEffect) new Effects.CurtainDown(); break; case "CurtainUp": _my_effect = (Effects.IEffect) new Effects.CurtainUp(); break; case "CurtainRight": _my_effect = (Effects.IEffect) new Effects.CurtainRight(); break; case "CurtainLeft": _my_effect = (Effects.IEffect) new Effects.CurtainLeft(); break; case "SlideDown": _my_effect = (Effects.IEffect) new Effects.SlideDown(); break; case "SlideUp": _my_effect = (Effects.IEffect) new Effects.SlideUp(); break; case "SlideRight": _my_effect = (Effects.IEffect) new Effects.SlideRight(); break; case "SlideLeft": _my_effect = (Effects.IEffect) new Effects.SlideLeft(); break; case "Mosaic": _my_effect = (Effects.IEffect) new Effects.Mosaic(); break; } }
public void ShowGraphic(string FileName, bool GraphicInWindow, int EffectIndex) { do { Thread.Sleep(1); }while (_loading); try { if (!File.Exists(FileName) || !_my_effect_ready) { return; } Point point = new Point(0, 0); Size newSize = Size; if (GraphicInWindow) { newSize = _graphic_size; } Bitmap bitmap = new Bitmap(Image.FromFile(FileName), newSize); _filename = FileName; if (_mci != null) { _mci.Close(); _mci.Dispose(); _mci = (Mci)null; } if (_mci_timer != null) { _mci_timer.Tick -= new EventHandler(_mci_timer_Tick); _mci_timer.Dispose(); } showPictureBoxAsync(pictureBox1, GraphicInWindow); if (_actual_picture == null) { _actual_picture = (Image) new Bitmap(newSize.Width, newSize.Height); Graphics.FromImage(_actual_picture).Clear(Color.Black); } _get_effect(EffectIndex); try { Image image = Image.FromFile(FileName); FrameDimension dimension = new FrameDimension(image.FrameDimensionsList[0]); if (image.GetFrameCount(dimension) > 1) { _my_effect = (Effects.IEffect)null; _actual_picture = image; } } catch { } if (_my_effect != null) { do { Thread.Sleep(1); }while (!_my_effect_ready); _my_effect_ready = false; _my_effect.Ready += new Effects.ReadyDelegate(_my_effect_Ready); _my_effect.PercentComplete += new Effects.PercentCompletedDelegate(_my_effect_PercentComplete); _my_effect.Fade(pictureBox1, _actual_picture, (Image)bitmap); _actual_picture = Image.FromFile(FileName); } else { pictureBox1.Image = Image.FromFile(FileName); } } catch { try { if (_mci != null) { _mci.Close(); _mci.Dispose(); _mci = (Mci)null; } if (_mci_timer != null) { _mci_timer.Tick -= new EventHandler(_mci_timer_Tick); _mci_timer.Dispose(); } _mci = new Mci(); _mci.Open(FileName, (Control)pictureBox1); showPictureBoxAsync(pictureBox1, GraphicInWindow); if (_mci_timer != null) { _mci_timer.Tick -= new EventHandler(_mci_timer_Tick); _mci_timer.Dispose(); } _mci_timer = (Timer)null; _mci_timer = new Timer(); int num = 1; try { num = _mci.Length; } catch { } _mci_timer.Interval = num; _mci_timer.Tick += new EventHandler(_mci_timer_Tick); try { _mci.SetRectangle(0, 0, pictureBox1.Width, pictureBox1.Height); } catch (Exception ex) { ErrorLogger.addToLog(ex.StackTrace, ex.Message); } try { _mci.Volume = 0; } catch (Exception ex) { ErrorLogger.addToLog(ex.StackTrace, ex.Message); } try { _mci.Play(false); } catch (Exception ex) { ErrorLogger.addToLog(ex.StackTrace, ex.Message); } try { _mci_timer.Start(); } catch (Exception ex) { ErrorLogger.addToLog(ex.StackTrace, ex.Message); } _actual_picture = (Image)null; } catch (Exception ex) { ErrorLogger.addToLog(ex.StackTrace, ex.Message); } } }