Пример #1
0
        public void Open(string filename, Control owner)
        {
            if (IsOpen)
            {
                Close();
            }
            alias = Guid.NewGuid().ToString("N");
            if (!File.Exists(filename))
            {
                throw new FileNotFoundException("Die Datei '" + filename + "' existiert nicht", filename);
            }
            StringBuilder lpszShortPath = new StringBuilder(261);

            if (Mci.GetShortPathName(filename, lpszShortPath, lpszShortPath.Capacity) == 0)
            {
                throw new MciException("Fehler beim Auslesen des kurzen Dateinamens für '" + filename + "': Windows-Fehler " + (object)Marshal.GetLastWin32Error());
            }
            string lpstrCommand = "open " + lpszShortPath.ToString() + " type mpegvideo alias " + alias;

            if (owner != null)
            {
                lpstrCommand = lpstrCommand + " parent " + (object)(int)owner.Handle + " style child";
            }
            Mci.mciSendString(lpstrCommand, (StringBuilder)null, 0, IntPtr.Zero);
            isOpen    = true;
            _filename = FileName;
            Mci.mciSendString("set " + alias + " time format ms", (StringBuilder)null, 0, IntPtr.Zero);
        }
Пример #2
0
        private void ShowReceivedGraphic(Bitmap BM)
        {
            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, _ext_graphic_in_window);
            if (_actual_picture == null)
            {
                _actual_picture = (Image) new Bitmap(pictureBox1.Width, pictureBox1.Height);
                Graphics.FromImage(_actual_picture).Clear(Color.Black);
            }
            _get_effect(_ext_effect_index);
            if (_my_effect == null)
            {
                return;
            }
            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)BM);
            _actual_picture = (Image)BM;
        }
Пример #3
0
        public bool AddAnimation(string FileName, bool DoPlayAcusticSignal, string ExtraSoundFilename)
        {
            bool flag = false;

            if (File.Exists(FileName))
            {
                try
                {
                    Mci mci2 = new Mci();
                    mci2.Open(FileName);
                    int length = mci2.Length;
                    if (mci2.IsOpen)
                    {
                        mci2.Close();
                    }
                    mci2.Dispose();
                    _parts.Add(new Sequence.SequencePart(FileName, (long)length, 0, DoPlayAcusticSignal, ExtraSoundFilename, false));
                    flag = true;
                }
                catch
                {
                    flag = false;
                }
            }
            return(flag);
        }
Пример #4
0
 public void Dispose()
 {
     _media_timer.Stop();
     if (_player != null)
     {
         _player.Stop();
         _player = (Mci)null;
     }
     _is_preview = false;
 }
Пример #5
0
        private string GetMciError(int errorCode)
        {
            StringBuilder lpstrBuffer = new StringBuilder((int)byte.MaxValue);

            if (Mci.mciGetErrorString(errorCode, lpstrBuffer, lpstrBuffer.Capacity) == 0)
            {
                return("MCI-Fehler " + (object)errorCode);
            }
            return(lpstrBuffer.ToString());
        }
Пример #6
0
        public void ShowGraphic(Image Img, bool GraphicInWindow, int EffectIndex)
        {
            do
            {
                Thread.Sleep(1);
            }while (_loading);
            if (!_my_effect_ready)
            {
                return;
            }
            Point point   = new Point(0, 0);
            Size  newSize = Size;

            if (GraphicInWindow)
            {
                newSize = _graphic_size;
            }
            Bitmap bitmap = new Bitmap(Img, newSize);

            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);
            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 = Img;
            }
            else
            {
                pictureBox1.Image = Img;
            }
        }
Пример #7
0
        public void Close()
        {
            if (!isOpen)
            {
                return;
            }
            int errorCode = Mci.mciSendString("close " + alias, (StringBuilder)null, 0, IntPtr.Zero);

            if (errorCode != 0)
            {
                Console.WriteLine("Fehler beim Aufruf von 'Close': " + GetMciError(errorCode).ToString());
            }
            isOpen = false;
        }
Пример #8
0
        public void Play(int from, int to, bool repeat)
        {
            string lpstrCommand = "play " + alias + " from " + (object)from + " to " + (object)to;

            if (repeat)
            {
                lpstrCommand += " repeat";
            }
            int errorCode = Mci.mciSendString(lpstrCommand, (StringBuilder)null, 0, IntPtr.Zero);

            if (errorCode != 0)
            {
                throw new MciException("Fehler beim Aufruf von 'Play': " + GetMciError(errorCode));
            }
        }
Пример #9
0
 public void HideGraphic()
 {
     if (_mci_timer != null)
     {
         _mci_timer.Stop();
         _mci_timer.Tick -= new EventHandler(_mci_timer_Tick);
     }
     if (_mci != null)
     {
         try
         {
             _mci.Stop();
         }
         catch
         {
         }
         if (_mci.IsOpen)
         {
             try
             {
                 _mci.Close();
             }
             catch
             {
             }
         }
         try
         {
             _mci.Dispose();
         }
         catch
         {
         }
         _mci = (Mci)null;
     }
     if (pictureBox1 == null)
     {
         return;
     }
     if (_my_effect != null)
     {
         while (_my_effect.ThreadActive)
         {
             Application.DoEvents();
         }
     }
     hidePictureBoxAsync(pictureBox1);
 }
Пример #10
0
 public void HideGraphicPreviewAsync()
 {
     if (InvokeRequired)
     {
         Invoke((Delegate) new Preview.HideGraphicPreviewAsyncDelegate(HideGraphicPreviewAsync), new object[0]);
     }
     else
     {
         if (_mci_player != null && _mci_player.IsOpen)
         {
             _mci_player.Stop();
             _mci_player.Dispose();
             _mci_player = (Mci)null;
         }
         pictureBox1.Image = (Image)null;
     }
 }
Пример #11
0
 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;
 }
Пример #12
0
 public void ShowGraphicPreviewAsync(string filename)
 {
     if (InvokeRequired)
     {
         Invoke((Delegate) new Preview.ShowGraphicPreviewAsyncDelegate(ShowGraphicPreviewAsync), (object)filename);
     }
     else
     {
         if (_mci_player != null && _mci_player.IsOpen)
         {
             _mci_player.Stop();
             _mci_player.Dispose();
             _mci_player = (Mci)null;
         }
         pictureBox1.Size = Size;
         _mci_player      = new Mci();
         _mci_player.Open(filename, (Control)pictureBox1);
         try
         {
             _mci_player.SetRectangle(0, 0, pictureBox1.Width, pictureBox1.Height);
         }
         catch
         {
         }
         try
         {
             _mci_player.Volume = 0;
         }
         catch
         {
         }
         try
         {
             _mci_player.Play(false);
         }
         catch
         {
         }
     }
 }
Пример #13
0
 public void clearScoreboardAsync(Form target, PictureBox picturebox)
 {
     if (target.InvokeRequired)
     {
         target.Invoke((Delegate) new SecondScreen.clearScoreboardAsyncDelegate(clearScoreboardAsync), (object)target, (object)picturebox);
     }
     else
     {
         if (_mci != null)
         {
             _mci.Close();
             _mci.Dispose();
         }
         _mci = (Mci)null;
         if (_mci_timer != null)
         {
             _mci_timer.Stop();
             _mci_timer.Tick -= new EventHandler(_mci_timer_Tick);
             _mci_timer.Dispose();
         }
         _mci_timer = (Timer)null;
         try
         {
             picturebox.Location = new Point(0, 0);
             picturebox.Size     = Size;
             picturebox.CreateGraphics().Clear(Color.Black);
             picturebox.Update();
             _actual_picture = (Image) new Bitmap(Width, Height);
             Graphics.FromImage(_actual_picture).Clear(Color.Black);
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
         }
     }
 }
Пример #14
0
        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);
                }
            }
        }
Пример #15
0
 public void ShowGraphic(string FileName, bool GraphicInWindow)
 {
     if (FileName != null)
     {
         _filename = FileName;
     }
     if (!File.Exists(_filename))
     {
         return;
     }
     try
     {
         pictureBox1.Image = Image.FromFile(_filename);
         showPictureBoxAsync(pictureBox1, GraphicInWindow);
         Update();
     }
     catch
     {
         try
         {
             if (_mci != null)
             {
                 if (_mci.IsOpen)
                 {
                     try
                     {
                         _mci.Close();
                     }
                     catch
                     {
                     }
                 }
                 try
                 {
                     _mci.Dispose();
                 }
                 catch
                 {
                 }
                 _mci = (Mci)null;
             }
             _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);
         }
     }
 }
Пример #16
0
 private void _media_timer_Tick(object sender, EventArgs e)
 {
     if (_do_start)
     {
         if (_player == null)
         {
             try
             {
                 _invokes.SetPictureBoxImageAsync(_picturebox, Image.FromFile(_default_media_filename));
             }
             catch
             {
                 try
                 {
                     _player = new Mci();
                     _player.Open(_default_media_filename, (Control)_picturebox);
                     _player.SetRectangle(0, 0, _picturebox.Width, _picturebox.Height);
                     _player.Volume = 0;
                     if (!_initial_start)
                     {
                         _remaining_media_time = _player.Length / 50;
                     }
                     _initial_start = false;
                     _player.Play(true);
                 }
                 catch
                 {
                     _player = (Mci)null;
                 }
             }
         }
         _do_start   = false;
         _is_started = true;
     }
     if (_remaining_media_time > 0 && _player != null)
     {
         --_remaining_media_time;
     }
     if (_remaining_media_time == 0)
     {
         if (MediaEndTimeReached != null)
         {
             MediaEndTimeReached(this);
         }
         if (_player == null)
         {
             return;
         }
         _player.SetRectangle(0, 0, _picturebox.Width, _picturebox.Height);
         _player.Stop();
         _player.Dispose();
         _player     = (Mci)null;
         _is_started = false;
     }
     else
     {
         if (MediaTimeChanged == null)
         {
             return;
         }
         MediaTimeChanged(this, _remaining_media_time);
     }
 }
Пример #17
0
 public void SetRectangle(int x, int y, int width, int height)
 {
     Mci.mciSendString("put " + alias + " window at " + (object)x + " " + (object)y + " " + (object)width + " " + (object)height, (StringBuilder)null, 0, IntPtr.Zero);
 }
Пример #18
0
 public void Stop()
 {
     Mci.mciSendString("stop " + alias, (StringBuilder)null, 0, IntPtr.Zero);
 }