Ejemplo n.º 1
0
        /// <summary>
        /// Enters the Explore This Folder modality.
        /// </summary>
        private void EnterExploreFolderMode()
        {
            bool fDebugOutput = true;
            bool fDebugOutputTraceLevel = true;
            bool fDebugTrace = fDebugOutput && fDebugOutputTraceLevel;

            Logging.LogLineIf(fDebugTrace, "EnterExploreFolderMode(): entered.");

            if (fInETFMode)
            {
                Logging.LogLineIf(fDebugTrace, "    EnterExploreFolderMode(); Not Entering Explore This Folder mode, we're already in it.");
                Logging.LogLineIf(fDebugTrace, "EnterExploreFolderMode(): Exiting method.");
                return;
            }

            if (fShowingEmbeddedFileImage)
            {
                // do nothing, we're showing an embedded resource
                Logging.LogLineIf(fDebugOutput, "   EnterExploreFolderMode(): called while we were displaying an embedded image, not a file. How did that happen?");
                MessageBox.Show("Explore This Folder is not available right now.", ProductName + " - Nice Try",
                MessageBoxButtons.OK, MessageBoxIcon.Error);
                Logging.LogLineIf(fDebugTrace, "EnterExploreFolderMode(): Exiting method.");
                return;
            }

            if (String.IsNullOrEmpty(pbMain.ImageLocation) || String.IsNullOrWhiteSpace(pbMain.ImageLocation))
            {
                Logging.LogLineIf(fDebugOutput, "   * EnterExploreFolderMode(): Not entering Explore This Folder mode because one of these failed:" + Environment.NewLine +
                    "String.IsNullOrEmpty(pbMainPhoto.ImageLocation) || String.IsNullOrWhiteSpace(pbMainPhoto.ImageLocation)");

                System.Diagnostics.Debug.Assert((false), "   EnterExploreFolderMode():  Not entering Explore This Folder mode, as one of these failed:" + Environment.NewLine +
                    "String.IsNullOrEmpty(pbMainPhoto.ImageLocation) || String.IsNullOrWhiteSpace(pbMainPhoto.ImageLocation)",
                    "Safe to click Continue.");

                MessageBox.Show("There has been an error. Cannot explore this folder at this time." + Environment.NewLine + Environment.NewLine +
                "Filename: " + pbMain.ImageLocation + Environment.NewLine, ProductName + " - Error",
                MessageBoxButtons.OK, MessageBoxIcon.Error);
                Logging.LogLineIf(fDebugTrace, "EnterExploreFolderMode(): Exiting method.");
                return;
            }

            bool fWasInSlideshowMode = ourSlideshow.IsRunning;
            string fullFilename = pbMain.ImageLocation;

            Logging.LogLineIf(fDebugTrace, "   EnterExploreFolderMode(): Attempting to enter ETF mode for file: " + pbMain.ImageLocation);
            Logging.LogLineIf(fDebugTrace, "   EnterExploreFolderMode(): MainFiles CurrentIndex / Count: " + MainFiles.CurrentIndex + " / " + MainFiles.Count);

            Logging.LogLineIf(fDebugTrace, "   EnterExploreFolderMode(): About to call MainFiles.GetFileByFullName(CurrentFileName)...");
            FileInfo etfEntryFile = MainFiles.GetFileByFullName(fullFilename);
            if (etfEntryFile == null)
            {
                Logging.LogLineIf(fDebugOutput, "   * EnterExploreFolderMode(): etfEntryFile == null.");
            #if DEBUG
                System.Diagnostics.Debug.Assert((false), "   EnterExploreFolderMode(): etfEntryFile == null.", "Will throw exception when you click Continue.");
            #endif
                throw new InvalidOperationException("   EnterExploreFolderMode(): etfEntryFile == null.");
            }

            // Create a new FileInfoSource, and store it at the FormWide level
            Logging.LogLineIf(fDebugTrace, "   EnterExploreFolderMode(): About to create ETF object...");
            ETFFiles = new ExploreThisFolderFileInfoSource(MainFiles, etfEntryFile);

            if ((ETFFiles != null) && (ETFFiles.DirectoryInfo != null))   // if there was an error etf.DirectoryInfo will be null. Probably.
            {
                Logging.LogLineIf(fDebugTrace, "   EnterExploreFolderMode(): ETF object created successfully.");
                fInETFMode = true;
                fWasInSlideshowModeWhenETFStarted = fWasInSlideshowMode;
                if (fWasInSlideshowMode) ourSlideshow.Exit();

                // Update text for "You are in ETF mode" indicator
                SetExploreFolderData();

            }
            else
            {
                fInETFMode = false;
                ETFFiles = null;
                if (fWasInSlideshowMode) fWasInSlideshowModeWhenETFStarted = false;
                if (fWasInSlideshowMode) ourSlideshow.Start();

                Logging.LogLineIf(fDebugOutput, "   * EnterExploreFolderMode(): FAILED test: (ETFFiles != null) && (ETFFiles.DirectoryInfo != null)");
            #if DEBUG
                System.Diagnostics.Debug.Assert((false), "   EnterExploreFolderMode(): FAILED test: (ETFFiles != null) && (ETFFiles.DirectoryInfo != null).", "Will throw exception when you click Continue.");
                throw new InvalidOperationException("   EnterExploreFolderMode(): FAILED test: (ETFFiles != null) && (ETFFiles.DirectoryInfo != null).");
            #else

                MessageBox.Show("There has been an error. Cannot explore this folder at this time." + Environment.NewLine + Environment.NewLine +
                    "Filename: " + pbMainPhoto.ImageLocation + Environment.NewLine, ProductName + " - Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            #endif
            }

            Logging.LogLineIf(fDebugTrace, "   EnterExploreFolderMode(): Entered ETF mode for file: " + fullFilename);
            Logging.LogLineIf(fDebugTrace, "   EnterExploreFolderMode(): ETFFiles CurrentIndex / Count: " + ETFFiles.CurrentIndex + " / " + ETFFiles.Count);

            // Tell PictureBox to update so new text will be drawn
            pbMain.Invalidate();
            Logging.LogLineIf(fDebugTrace, "EnterExploreFolderMode(): Exiting method.");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Exits Explore This Folder mode, in the direction specified in fPrevious.
        /// </summary>
        /// <param name="fPrevious"></param>
        private void ExitExploreFolderMode(bool fPrevious, bool fExternallyCalled = false)
        {
            bool fDebugOutput = true;
            bool fDebugOutputTraceLevel = true;
            bool fDebugTrace = fDebugOutput && fDebugOutputTraceLevel;

            Logging.LogLineIf(fDebugTrace, "ExitExploreFolderMode(): Entering method, fExternallyCalled = " + fExternallyCalled);

            if (fInETFMode)
            {
                Logging.LogLineIf(fDebugTrace, "   ExitExploreFolderMode(): MainFile CurrentIndex / Count: " + MainFiles.CurrentIndex + " / " + MainFiles.Count);
                Logging.LogLineIf(fDebugTrace, "   ExitExploreFolderMode(): exiting mode by going " + ((fPrevious) ? "backwards." : "forwards."));

                // Kill off the ETF object
                ETFFiles = null;
                fInETFMode = false;

                // Get the file in the direction passed to us
                Logging.LogLineIf(fDebugTrace, "   ExitExploreFolderMode(): about to call DoPreviousOrNext(fPrevious)...");
                DoPreviousOrNext(fPrevious);
                Logging.LogLineIf(fDebugTrace, "   ExitExploreFolderMode(): After DoPreviousOrNext(), MainFiles CurrentIndex / Count: " + MainFiles.CurrentIndex + " / " + MainFiles.Count);

                // Restart the slideshow if necessary
                Logging.LogLineIf(fDebugTrace, "   ExitExploreFolderMode(): about to restart slideshow, if necessary.");
                if (fWasInSlideshowModeWhenETFStarted) ourSlideshow.Start();
            }
            else
            {
                Logging.LogLineIf(fDebugTrace, "ExitExploreFolderMode(): Not exiting mode, as we were not in ETF mode.");
            }
            Logging.LogLineIf(fDebugTrace, "ExitExploreFolderMode(): Exiting method.");
        }