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); }
static void TestDirectory(DirectoryInfo dir, FolderTreeEnumerator enumerator) { List <FileInfo> files = new List <FileInfo>(dir.GetFiles()); files.Sort(CompareFileInfo); foreach (FileInfo file in files) { if (0 == (file.Attributes & (FileAttributes.Hidden | FileAttributes.System)) && (file.Extension.Equals(".jpg", StringComparison.OrdinalIgnoreCase) || file.Extension.Equals(".doc", StringComparison.OrdinalIgnoreCase))) { Trace.WriteLine(enumerator.Current); if (file.FullName != enumerator.Current) { Trace.Fail(string.Format("{0} != {1}", file.FullName, enumerator.Current)); } enumerator.MoveNext(); enumerator.MovePrev(); if (file.FullName != enumerator.Current) { Trace.Fail(string.Format("{0} != {1} (fwd/bck)", file.FullName, enumerator.Current)); } enumerator.MoveNext(); } } foreach (DirectoryInfo subdir in dir.GetDirectories()) { if (0 == (subdir.Attributes & (FileAttributes.Hidden | FileAttributes.System))) { TestDirectory(subdir, enumerator); } } }