/// <summary>
        /// Switches to the 'previous' page (whatever page this is!).
        /// </summary>
        public virtual void HandleActionBack() //TODO: The handleActionBack method has an edge case that I can't figure out quite yet -- when only two pages are visible and enabled, hitting the back button repeatedly cycles through the two pages..
        {                                      // :-/
            TLogging.Log("HandleActionBack (in TPetraShepherdFormLogic)");

            string             backPage      = ""; //temporary string to hold the key of the StartPage
            TPetraShepherdPage temporaryPage = CurrentPage;
            int counter = 0;

            if (CurrentPage.IsFirstPage)
            {
                backPage = CurrentPage.ID;
            }
            else
            {
                foreach (KeyValuePair <string, TPetraShepherdPage> pair in FShepherdPages.Pages)
                {
                    if ((pair.Value == CurrentPage) && pair.Value.Enabled && pair.Value.Visible)
                    {
                        backPage = temporaryPage.ID;

                        TLogging.Log("Set the backpage to the following: " + temporaryPage.ID);

                        break;
                    }

                    temporaryPage = pair.Value;
                    counter++;
                }
            }

            backPage = temporaryPage.ID;
            SwitchToPage(backPage);
        }
        /// <summary>
        /// Switches to the Start page (whatever page this is!).
        /// Iterates through FShepherdPages.Pages to find the first page that is both visible and enabled.
        /// </summary>
        public void SwitchToStartPage()
        {
            TLogging.Log("SwitchToStartPage (in TPetrashepherdFormLogic)");

            string startPage = "";             //temporary string to hold the key of the StartPage

            foreach (KeyValuePair <string, TPetraShepherdPage> pair in FShepherdPages.Pages)
            {
                if (pair.Value.Visible && pair.Value.Enabled)
                {
                    TLogging.Log("SwitchToStartPage foreach loop returned the following value that was both visible and enabled: " + pair.Key);
                    startPage = pair.Key;
                    pair.Value.IsFirstPage = true;
                    CurrentPage            = pair.Value;
                    break;
                }
            }

            TLogging.Log("temporary page was assigned to " + startPage + " in SwitchToStartPage.");

            try
            {
                SwitchToPage(startPage);
            }
            catch (KeyNotFoundException)
            {
                TLogging.Log("KeyNotFoundException Thrown in SwitchToStartPage when SwitchToPage(startPage) was called.");
            }
        }
        /// <summary>
        /// Constructor for TPetraShepherdPagesList. This function reads in a yaml file from the appropriate
        /// namespace, parses it into xmlNodes, and adds them to the list of pages so that they can be read
        /// by the individual ShepherdPage constructor, which it calls.
        /// </summary>
        /// <param name="AYamlFile">Full path to the Shepherd's YAML Definition file.</param>
        public TPetraShepherdPagesList(string AYamlFile)
        {
            TLogging.Log("Entering TPetraShepherdPagesList Constructor. AYamlFile = " + AYamlFile + "...");

            TYml2Xml    parser   = new TYml2Xml(AYamlFile);
            XmlDocument XmlPages = parser.ParseYML2XML();

            TLogging.Log("TPetraShepherdPagesList currently has this many nodes: " + XmlPages.LastChild.LastChild.LastChild.ChildNodes.Count);

            XmlNode temporaryXmlNode = XmlPages.LastChild.LastChild.LastChild.FirstChild;   //...LastChild.LastChild.LastChild.FirstChild is required because of the structure of the XML File after parsing.

            int counter = 0;

            XmlNodeList nodeList;
            XmlNode     root = XmlPages.DocumentElement;

            nodeList = XmlPages.LastChild.LastChild.LastChild.ChildNodes;
            TLogging.Log("The amount of nodes in the nodeList in the TPetraShepherdPagesList constructor is as follows: " + nodeList.Count);

            foreach (XmlNode node in nodeList)
            {
                if (node.Name.Contains("SubShepherd."))
                {
                    TLogging.Log("TPetraSHepherdPagesList Constructor loop: Found a sub shepherd.. Skipping.. ");
                }
                else
                {
                    TPetraShepherdPage temporaryPetraShepherdPage = new TPetraShepherdPage(node);   // Constructor call for each page built off an XML node.

                    TLogging.Log("TPetraShepherdPagesList Constructor loop: THE TITLE OF THE CURRENT PAGE IS: " + temporaryPetraShepherdPage.Title);

                    FPagesList.Add(temporaryPetraShepherdPage.ID, temporaryPetraShepherdPage);
                }

                counter++;
            }

            TPetraShepherdFinishPage shepherdFinishPage = new TPetraShepherdFinishPage(XmlPages);

            TLogging.Log("Adding a shepherd finish page: " + shepherdFinishPage.ID);
            FPagesList.Add(shepherdFinishPage.ID, shepherdFinishPage);

////            //Temporary Statement to add a subshepherd finish page in addition to the Finish page above
////            TPetraShepherdFinishPage shepherdSubFinishPage = new TPetraShepherdFinishPage(XmlPages, "SubShepherd");
////            TLogging.Log("Adding a shepherd sub-finish page: " + shepherdSubFinishPage.ID);
////            FPagesList.Add(shepherdSubFinishPage.ID, shepherdSubFinishPage);

            TLogging.Log("TPetraShepherdPagesList Constructor ran successfully.");
        }
        /// <summary>
        /// Switches to the 'next' page (whatever page this is!).
        /// </summary>
        public virtual void HandleActionNext()
        {
            TLogging.Log("HandleActionNext (in TPetraShepherdFormLogic)");

            string nextPage             = "";    //temporary string to hold the key of the StartPage
            bool   hasPassedCurrentPage = false; // used to tell if the iteration has already checked to see if you have passed the current page.
            bool   hasPassedItAgain     = false;

            foreach (KeyValuePair <string, TPetraShepherdPage> pair in FShepherdPages.Pages)
            {
                // TODO: there has to be a better way to handle iterating through the loop one more time; it works now, but is ugly.
                if (hasPassedCurrentPage)
                {
                    hasPassedItAgain = true;
                }

                if (pair.Key == CurrentPage.ID)
                {
                    TLogging.Log("Found the equivilance.");
                    hasPassedCurrentPage = true;
                    TLogging.Log("Set the hasPassedCurrentPage bool to true.");
                }

                if (pair.Value.Visible && pair.Value.Enabled && hasPassedItAgain)
                {
                    TLogging.Log("Switchtonextpage foreach loop returned the following value that was both visible and enabled: " + pair.Key);
                    nextPage    = pair.Key;
                    CurrentPage = pair.Value;
                    break;
                }
            }

            TLogging.Log("temporary next page was assigned to " + nextPage + " in HandleActionNext().");

            // TODO: rather than a try/catch statement, the next button should instead be greyed out
            try
            {
                SwitchToPage(nextPage);
            }
            catch (KeyNotFoundException)
            {
                TLogging.Log("KeyNotFoundException Thrown at HandleActionNext when SwitchToPage(nextPage) was called.");
            }
        }
        /// <summary>
        /// Switches the current page.
        /// </summary>
        protected void SwitchToPage(string APage)
        {
            TLogging.Log("SwitchToPage (in TPetraShepherdFormLogic) was called for Page '" + APage + "'");
            //// ....
            CurrentPage = FShepherdPages.Pages[APage];
            TLogging.Log("PetraShepherdConcreteForm: SwitchToPage -- Page number = " + CurrentPage.ID);
            TLogging.Log("The current Total number of pages is = " + EnumeratePages());
            TLogging.Log("The percentage of pages = " + GetProgressBarPercentage());

            try
            {
                FForm.ShowCurrentPage();
            }
            catch (Exception e)
            {
                //This line always throws an exception during the first run of the code;
                //I don't know if that's okay, but we should probably resolve it.
                TLogging.Log("The exception for ShowCurrentPage() in PetraShepherdConcreteForm was caught.");
                TLogging.Log(e.Message);
            }
        }
        /// <summary>
        /// Constructor for TPetraShepherdPagesList. This function reads in a yaml file from the appropriate
        /// namespace, parses it into xmlNodes, and adds them to the list of pages so that they can be read
        /// by the individual ShepherdPage constructor, which it calls.
        /// </summary>
        /// <param name="AYamlFile">Full path to the Shepherd's YAML Definition file.</param>
        public TPetraShepherdPagesList(string AYamlFile)
        {
            TLogging.Log("Entering TPetraShepherdPagesList Constructor. AYamlFile = " + AYamlFile + "...");

            TYml2Xml parser = new TYml2Xml(AYamlFile);
            XmlDocument XmlPages = parser.ParseYML2XML();

            TLogging.Log("TPetraShepherdPagesList currently has this many nodes: " + XmlPages.LastChild.LastChild.LastChild.ChildNodes.Count);

            XmlNode temporaryXmlNode = XmlPages.LastChild.LastChild.LastChild.FirstChild;   //...LastChild.LastChild.LastChild.FirstChild is required because of the structure of the XML File after parsing.

            int counter = 0;

            XmlNodeList nodeList;
            XmlNode root = XmlPages.DocumentElement;
            nodeList = XmlPages.LastChild.LastChild.LastChild.ChildNodes;
            TLogging.Log("The amount of nodes in the nodeList in the TPetraShepherdPagesList constructor is as follows: " + nodeList.Count);

            foreach (XmlNode node in nodeList)
            {
                if (node.Name.Contains("SubShepherd."))
                {
                    TLogging.Log("TPetraSHepherdPagesList Constructor loop: Found a sub shepherd.. Skipping.. ");
                }
                else
                {
                    TPetraShepherdPage temporaryPetraShepherdPage = new TPetraShepherdPage(node);   // Constructor call for each page built off an XML node.

                    TLogging.Log("TPetraShepherdPagesList Constructor loop: THE TITLE OF THE CURRENT PAGE IS: " + temporaryPetraShepherdPage.Title);

                    FPagesList.Add(temporaryPetraShepherdPage.ID, temporaryPetraShepherdPage);
                }

                counter++;
            }

            TPetraShepherdFinishPage shepherdFinishPage = new TPetraShepherdFinishPage(XmlPages);
            TLogging.Log("Adding a shepherd finish page: " + shepherdFinishPage.ID);
            FPagesList.Add(shepherdFinishPage.ID, shepherdFinishPage);

////            //Temporary Statement to add a subshepherd finish page in addition to the Finish page above
////            TPetraShepherdFinishPage shepherdSubFinishPage = new TPetraShepherdFinishPage(XmlPages, "SubShepherd");
////            TLogging.Log("Adding a shepherd sub-finish page: " + shepherdSubFinishPage.ID);
////            FPagesList.Add(shepherdSubFinishPage.ID, shepherdSubFinishPage);

            TLogging.Log("TPetraShepherdPagesList Constructor ran successfully.");
        }
        /// <summary>
        /// Switches to the 'next' page (whatever page this is!).
        /// </summary>
        public virtual void HandleActionNext()
        {
            TLogging.Log("HandleActionNext (in TPetraShepherdFormLogic)");

            string nextPage = "";     //temporary string to hold the key of the StartPage
            bool hasPassedCurrentPage = false;     // used to tell if the iteration has already checked to see if you have passed the current page.
            bool hasPassedItAgain = false;

            foreach (KeyValuePair <string, TPetraShepherdPage>pair in FShepherdPages.Pages)
            {
                // TODO: there has to be a better way to handle iterating through the loop one more time; it works now, but is ugly.
                if (hasPassedCurrentPage)
                {
                    hasPassedItAgain = true;
                }

                if (pair.Key == CurrentPage.ID)
                {
                    TLogging.Log("Found the equivilance.");
                    hasPassedCurrentPage = true;
                    TLogging.Log("Set the hasPassedCurrentPage bool to true.");
                }

                if (pair.Value.Visible && pair.Value.Enabled && hasPassedItAgain)
                {
                    TLogging.Log("Switchtonextpage foreach loop returned the following value that was both visible and enabled: " + pair.Key);
                    nextPage = pair.Key;
                    CurrentPage = pair.Value;
                    break;
                }
            }

            TLogging.Log("temporary next page was assigned to " + nextPage + " in HandleActionNext().");

            // TODO: rather than a try/catch statement, the next button should instead be greyed out
            try
            {
                SwitchToPage(nextPage);
            }
            catch (KeyNotFoundException)
            {
                TLogging.Log("KeyNotFoundException Thrown at HandleActionNext when SwitchToPage(nextPage) was called.");
            }
        }
        /// <summary>
        /// Switches to the Start page (whatever page this is!).
        /// Iterates through FShepherdPages.Pages to find the first page that is both visible and enabled.
        /// </summary>
        public void SwitchToStartPage()
        {
            TLogging.Log("SwitchToStartPage (in TPetrashepherdFormLogic)");

            string startPage = "";             //temporary string to hold the key of the StartPage

            foreach (KeyValuePair <string, TPetraShepherdPage>pair in FShepherdPages.Pages)
            {
                if (pair.Value.Visible && pair.Value.Enabled)
                {
                    TLogging.Log("SwitchToStartPage foreach loop returned the following value that was both visible and enabled: " + pair.Key);
                    startPage = pair.Key;
                    pair.Value.IsFirstPage = true;
                    CurrentPage = pair.Value;
                    break;
                }
            }

            TLogging.Log("temporary page was assigned to " + startPage + " in SwitchToStartPage.");

            try
            {
                SwitchToPage(startPage);
            }
            catch (KeyNotFoundException)
            {
                TLogging.Log("KeyNotFoundException Thrown in SwitchToStartPage when SwitchToPage(startPage) was called.");
            }
        }
        /// <summary>
        /// Switches the current page.
        /// </summary>
        protected void SwitchToPage(string APage)
        {
            TLogging.Log("SwitchToPage (in TPetraShepherdFormLogic) was called for Page '" + APage + "'");
            //// ....
            CurrentPage = FShepherdPages.Pages[APage];
            TLogging.Log("PetraShepherdConcreteForm: SwitchToPage -- Page number = " + CurrentPage.ID);
            TLogging.Log("The current Total number of pages is = " + EnumeratePages());
            TLogging.Log("The percentage of pages = " + GetProgressBarPercentage());

            try
            {
                FForm.ShowCurrentPage();
            }
            catch (Exception e)
            {
                //This line always throws an exception during the first run of the code;
                //I don't know if that's okay, but we should probably resolve it.
                TLogging.Log("The exception for ShowCurrentPage() in PetraShepherdConcreteForm was caught.");
                TLogging.Log(e.Message);
            }
        }