Ejemplo n.º 1
0
        /// <summary>
        /// Versucht einen Sender für die primäre Anzeige zu aktivieren.
        /// </summary>
        /// <param name="source">Der gewünschte Sender.</param>
        /// <param name="tx">Die aktuelle Änderungsumgebung.</param>
        /// <returns>Gesetzt, wenn die Aktivierung erfolgreich war.</returns>
        private Device EnsurePrimaryFeed(SourceSelection source, FeedTransaction tx)
        {
            // Make sure we can receive it
            var device = EnsureFeed(source);

            if (device != null)
            {
                return(device);
            }

            // See if there is any device we can free
            var availableDevice =
                m_devices
                .Where(cancidate => cancidate.ReusePossible)
                .Aggregate(default(Device), (best, test) => ((best != null) && (best.SecondaryFeeds.Count() <= test.SecondaryFeeds.Count())) ? best : test);

            // None
            if (availableDevice == null)
            {
                return(null);
            }

            // Stop all secondaries
            foreach (var secondaryFeed in availableDevice.SecondaryFeeds)
            {
                tx.DisableSecondaryView(secondaryFeed);
            }

            // Run test again - can not fail
            return(EnsureFeed(source));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Beendet alle Aufträge.
        /// </summary>
        public void Shutdown()
        {
            // Prepare the change
            using (var tx = new FeedTransaction(this))
            {
                // All feeds
                foreach (var feed in Feeds)
                {
                    // Primary
                    if (feed.IsPrimaryView)
                    {
                        tx.DisablePrimaryView(feed);
                    }

                    // Secondary
                    if (feed.IsSecondaryView)
                    {
                        tx.DisableSecondaryView(feed);
                    }

                    // Recording
                    foreach (var recording in feed.Recordings.ToArray())
                    {
                        tx.DisableRecording(feed, recording);
                    }
                }

                // Process all
                tx.Commit();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Verändert eine sekundäre Anzeige.
        /// </summary>
        /// <param name="sourceName">Der Name des Senders.</param>
        public void StopSecondaryFeed(string sourceName)
        {
            // Look it up
            var source = m_provider.Translate(sourceName);

            if (source == null)
            {
                throw new ArgumentException("unbekannter sender", "sourceName");
            }

            // Find the feed
            var feed = FindFeed(source);

            if (feed == null)
            {
                return;
            }
            else if (!feed.IsSecondaryView)
            {
                return;
            }

            // Prepare the change
            using (var tx = new FeedTransaction(this))
            {
                // Mark as active
                tx.DisableSecondaryView(feed);

                // Avoid cleanup
                tx.Commit();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Verändert die primäre Anzeige.
        /// </summary>
        /// <param name="sourceName">Die neue primäre Anzeige.</param>
        /// <returns>Gesetzt, wenn die Änderung erfolgreich war.</returns>
        public bool TryStartPrimaryFeed(string sourceName)
        {
            // Look it up
            var source = m_provider.Translate(sourceName);

            if (source == null)
            {
                throw new ArgumentException("unbekannter sender", "sourceName");
            }

            // Find the feed
            var feed = FindFeed(source);

            if (feed != null)
            {
                if (feed.IsPrimaryView)
                {
                    return(true);
                }
            }

            // Device we schedule on
            Device device;

            // Prepare the change
            using (var tx = new FeedTransaction(this))
            {
                // See if we are secondary
                if (feed != null)
                {
                    if (feed.IsSecondaryView)
                    {
                        tx.DisableSecondaryView(feed);
                    }
                }

                // Locate the current primary view
                var previous = PrimaryView;
                if (previous != null)
                {
                    tx.DisablePrimaryView(previous);
                }

                // Make sure we can receive it
                device = EnsurePrimaryFeed(source, tx);
                if (device == null)
                {
                    return(false);
                }

                // Avoid cleanup
                tx.Commit();
            }

            // Schedule for report
            device.FireWhenAvailable(source.Source, OnPrimaryViewChanged);

            // Report success
            return(true);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Versucht einen Sender für die primäre Anzeige zu aktivieren.
        /// </summary>
        /// <param name="source">Der gewünschte Sender.</param>
        /// <param name="tx">Die aktuelle Änderungsumgebung.</param>
        /// <returns>Gesetzt, wenn die Aktivierung erfolgreich war.</returns>
        private Device EnsurePrimaryFeed( SourceSelection source, FeedTransaction tx )
        {
            // Make sure we can receive it
            var device = EnsureFeed( source );
            if (device != null)
                return device;

            // See if there is any device we can free
            var availableDevice =
                m_devices
                    .Where( cancidate => cancidate.ReusePossible )
                    .Aggregate( default( Device ), ( best, test ) => ((best != null) && (best.SecondaryFeeds.Count() <= test.SecondaryFeeds.Count())) ? best : test );

            // None
            if (availableDevice == null)
                return null;

            // Stop all secondaries
            foreach (var secondaryFeed in availableDevice.SecondaryFeeds)
                tx.DisableSecondaryView( secondaryFeed );

            // Run test again - can not fail
            return EnsureFeed( source );
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Beendet alle Aufträge.
        /// </summary>
        public void Shutdown()
        {
            // Prepare the change
            using (var tx = new FeedTransaction( this ))
            {
                // All feeds
                foreach (var feed in Feeds)
                {
                    // Primary
                    if (feed.IsPrimaryView)
                        tx.DisablePrimaryView( feed );

                    // Secondary
                    if (feed.IsSecondaryView)
                        tx.DisableSecondaryView( feed );

                    // Recording
                    foreach (var recording in feed.Recordings.ToArray())
                        tx.DisableRecording( feed, recording );
                }

                // Process all
                tx.Commit();
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Verändert eine sekundäre Anzeige.
        /// </summary>
        /// <param name="sourceName">Der Name des Senders.</param>
        public void StopSecondaryFeed( string sourceName )
        {
            // Look it up
            var source = m_provider.Translate( sourceName );
            if (source == null)
                throw new ArgumentException( "unbekannter sender", "sourceName" );

            // Find the feed
            var feed = FindFeed( source );
            if (feed == null)
                return;
            else if (!feed.IsSecondaryView)
                return;

            // Prepare the change
            using (var tx = new FeedTransaction( this ))
            {
                // Mark as active
                tx.DisableSecondaryView( feed );

                // Avoid cleanup
                tx.Commit();
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Verändert die primäre Anzeige.
        /// </summary>
        /// <param name="sourceName">Die neue primäre Anzeige.</param>
        /// <returns>Gesetzt, wenn die Änderung erfolgreich war.</returns>
        public bool TryStartPrimaryFeed( string sourceName )
        {
            // Look it up
            var source = m_provider.Translate( sourceName );
            if (source == null)
                throw new ArgumentException( "unbekannter sender", "sourceName" );

            // Find the feed
            var feed = FindFeed( source );
            if (feed != null)
                if (feed.IsPrimaryView)
                    return true;

            // Device we schedule on
            Device device;

            // Prepare the change
            using (var tx = new FeedTransaction( this ))
            {
                // See if we are secondary
                if (feed != null)
                    if (feed.IsSecondaryView)
                        tx.DisableSecondaryView( feed );

                // Locate the current primary view
                var previous = PrimaryView;
                if (previous != null)
                    tx.DisablePrimaryView( previous );

                // Make sure we can receive it
                device = EnsurePrimaryFeed( source, tx );
                if (device == null)
                    return false;

                // Avoid cleanup
                tx.Commit();
            }

            // Schedule for report
            device.FireWhenAvailable( source.Source, OnPrimaryViewChanged );

            // Report success
            return true;
        }