/// <summary>
        /// Performs the disposal.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                try
                {
                    // Tidy up old audio if necessary
                    foreach (Media audio in _options.Audio)
                    {
                        try
                        {
                            Debug.WriteLine("Removing audio on region dispose", "Region");

                            // Unbind any events and dispose
                            audio.DurationElapsedEvent -= audio_DurationElapsedEvent;
                            audio.Dispose();
                        }
                        catch
                        {
                            Trace.WriteLine(new LogMessage("Region - Dispose", "Unable to dispose of audio item"), LogType.Audit.ToString());
                        }
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(new LogMessage("Region - Dispose", "Unable to dispose audio for media. Ex = " + ex.Message), LogType.Audit.ToString());
                }

                try
                {
                    _options.Dictionary.Clear();
                    _options.Audio.Clear();

                    Debug.WriteLine("Removing media on region dispose", "Region");

                    // Remove media from Controls
                    Controls.Remove(_media);

                    // Unbind and dispose
                    _media.DurationElapsedEvent -= media_DurationElapsedEvent;
                    _media.Dispose();
                    _media = null;

                    Debug.WriteLine("Media Disposed by Region", "Region - Dispose");
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(new LogMessage("Region - Dispose", "Unable to dispose media. Ex = " + ex.Message), LogType.Audit.ToString());
                }
                finally
                {
                    if (_media != null)
                    {
                        _media = null;
                    }
                }
            }

            base.Dispose(disposing);
        }
Example #2
0
        /// <summary>
        /// Performs the disposal.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                try
                {
                    _media.DurationElapsedEvent -= media_DurationElapsedEvent;
                    _media.Dispose();
                    _media = null;

                    Debug.WriteLine("Media Disposed by Region", "Region - Dispose");
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(new LogMessage("Region - Dispose", "Unable to dispose media. Ex = " + ex.Message), LogType.Audit.ToString());
                }
                finally
                {
                    if (_media != null)
                    {
                        _media = null;
                    }
                }
            }

            base.Dispose(disposing);
        }
Example #3
0
        /// <summary>
        /// Stop the provided media
        /// </summary>
        private void StopMedia(Media media, bool audio)
        {
            Trace.WriteLine(new LogMessage("Region - Stop Media", "Stopping media"), LogType.Audit.ToString());

            // Hide the media
            media.Hide();

            // Remove the controls
            Controls.Remove(media);

            // Dispose of the current media
            try
            {
                // Dispose of the media
                media.Dispose();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(new LogMessage("Region - Stop Media", "Unable to dispose. Ex = " + ex.Message), LogType.Audit.ToString());
            }

            // Stop any associated audio
            if (!audio && _options.Audio.Count >= _audioSequence)
            {
                try
                {
                    StopMedia(_options.Audio[_audioSequence - 1], true);
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(new LogMessage("Region - Stop Media", "Audio -  Unable to dispose. Ex = " + ex.Message), LogType.Audit.ToString());
                }
            }
        }
Example #4
0
        /// <summary>
        /// Performs the disposal.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                try
                {
                    _media.Dispose();
                    _media = null;

                    Debug.WriteLine("Media Disposed by Region", "Region - Dispose");
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine("There was no media to dispose", "Region - Dispose");
                }
                finally
                {
                    if (_media != null)
                    {
                        _media = null;
                    }
                }
            }

            base.Dispose(disposing);
        }
        /// <summary>
        /// Stop normal media node
        /// </summary>
        /// <param name="media"></param>
        private void StopMedia(Media media)
        {
            Trace.WriteLine(new LogMessage("Region - Stop Media", "Stopping media"), LogType.Audit.ToString());

            // Hide the media
            media.Hide();

            // Remove the controls
            Controls.Remove(media);

            // Dispose of the current media
            try
            {
                // Dispose of the media
                media.Dispose();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(new LogMessage("Region - Stop Media", "Unable to dispose. Ex = " + ex.Message), LogType.Audit.ToString());
            }
        }
Example #6
0
        /// <summary>
        /// Stop the provided media
        /// </summary>
        private void StopMedia(Media media)
        {
            Trace.WriteLine(new LogMessage("Region - Stop Media", "Stopping media"), LogType.Audit.ToString());

            // Hide the media
            media.Hide();

            // Remove the controls
            Controls.Remove(media);

            // Dispose of the current media
            try
            {
                // Dispose of the media
                media.Dispose();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("No media to remove");
                Debug.WriteLine(ex.Message);
            }
        }