Esempio n. 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);
        }
Esempio n. 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);
        }