Beispiel #1
0
        public void Next()
        {
            Children.Remove(fFormerPanel);
            fFormerPanel.BeginAnimation(Panel.OpacityProperty, null); // Remove animation (not required but this assists the garbage collector)
            fFormerPanel.Done();                                      // Notify former panel that it is no longer in use.

            // Memory leak checking

            /*
             * GC.Collect();
             * GC.WaitForPendingFinalizers();
             * GC.Collect(5, GCCollectionMode.Forced);
             */

            // Rotate the panels down
            fFormerPanel = fActivePanel;
            fActivePanel = fNextPanel;
            fNextPanel   = null;

            // Stop the former panel
            fFormerPanel.Stop();

            // Animate the next panel in and play it
            if (fFadeTime >= cMinFadeTime)
            {
                DoubleAnimation animation = new DoubleAnimation(0.0, 1.0, fFadeTime);
                fActivePanel.BeginAnimation(Panel.OpacityProperty, animation, HandoffBehavior.SnapshotAndReplace);
            }
            else
            {
                fActivePanel.Opacity = 1.0;
            }
            fActivePanel.IsMuted = fMuted;
            fActivePanel.Play();

            if (!fDirectionIsForward)
            {
                fEnumerator.MoveNext();
                fEnumerator.MoveNext();
                fDirectionIsForward = true;
            }

            // Prep the next panel
            fEnumerator.MoveNext(AdvanceFlags.Wrap);
            string filename = fEnumerator.Current;

            if (string.IsNullOrEmpty(filename))
            {
                fNextPanel = new TextPanel(cNoImagesFound);
            }
            else
            {
                fNextPanel = SlidePanel.Load(new Uri(filename));
                fNextPanel.ShowMetadata = fShowMetadata;
            }
            fNextPanel.Opacity = 0.0;
            Children.Add(fNextPanel);
        }
Beispiel #2
0
        public void Prev()
        {
            if (fFormerPanel == null || fFormerPanel is TextPanel)
            {
                Message("At beginning.");
                return;
            }

            // Make sure we're ready for a reversal
            if (fFormerPanel.PanelState == PanelState.Init)
            {
                Message("Waiting for previous media to load...");
                return;
            }

            // Remove the prepped next panel
            Children.Remove(fNextPanel);
            fNextPanel.Done();    // Notify next panel that it is no longer in use.

            // Reverse-rotate the panels
            fNextPanel   = fActivePanel;
            fActivePanel = fFormerPanel;
            fFormerPanel = null;

            // Stop the formerly active panel
            fNextPanel.Stop();

            // Make it transparent again (remove existing animation)
            fNextPanel.BeginAnimation(Panel.OpacityProperty, null, HandoffBehavior.SnapshotAndReplace);
            fNextPanel.Opacity = 0.0;
            Debug.Assert(fActivePanel.Opacity == 1.0); // Ensure that the new active panel is visible
            Debug.WriteLine("New Active Panel: " + fActivePanel.Uri);

            // Play the new active panel
            fActivePanel.IsMuted = fMuted;
            fActivePanel.Play();

            if (fDirectionIsForward)
            {
                fEnumerator.MovePrev();
                fEnumerator.MovePrev();
                fDirectionIsForward = false;
            }

            // Load up a replacement former panel
            if (!fEnumerator.MovePrev() || string.IsNullOrEmpty(fEnumerator.Current))
            {
                fFormerPanel = new TextPanel("At Beginning");
            }
            else
            {
                fFormerPanel = SlidePanel.Load(new Uri(fEnumerator.Current));
                fFormerPanel.ShowMetadata = fShowMetadata;
            }
            Debug.Assert(fFormerPanel.Opacity == 1.0);
            Children.Insert(0, fFormerPanel);
        }
Beispiel #3
0
        public SlideShow()
        {
            fEnumerator.IncludeExtensions = sIncludeExtensions;

            BeginInit();

            fFormerPanel       = new TextPanel();
            fActivePanel       = new TextPanel();
            fNextPanel         = new TextPanel();
            fNextPanel.Opacity = 0;
            Children.Add(fFormerPanel);
            Children.Add(fActivePanel);
            Children.Add(fNextPanel);

            fTickHandler = new TickHandler(Tick);
            fTimer       = new System.Threading.Timer(RawTick, null, 500, 500);

            EndInit();
        }
Beispiel #4
0
        public void PanelStateChanged(SlidePanel panel, PanelState oldState, PanelState newState)
        {
            Debug.WriteLine(string.Format("State changed from {0} to {1}", oldState, newState));
            // Must be the active panel to matter
            if (!Object.ReferenceEquals(panel, fActivePanel))
            {
                return;
            }

            switch (newState)
            {
            case PanelState.Still:
                if (oldState == PanelState.Paused)
                {
                    Next();
                }
                else
                {
                    AutoAdvanceIn(fAutoAdvanceNextPeriod == 0 ? fAdvanceTime : fAutoAdvanceNextPeriod);
                }
                break;

            case PanelState.Playing:
                if (fTruncateVideo && Duration.Compare(panel.Duration, sLongVideoThreshold) >= 0)
                {
                    AutoAdvanceIn(cLongVideoLimit);
                    Debug.WriteLine("Truncating {0} second video.", panel.Duration.TimeSpan.TotalSeconds);
                }
                else
                {
                    AutoAdvanceIn(-1);          // Clear auto-advance
                }
                break;

            case PanelState.Paused:
                AutoAdvanceIn(-1);                              // Clear auto-advance
                break;

            case PanelState.Completed:
                AutoAdvanceIn(fAdvanceTime);
                break;
            }
        }