Example #1
0
        /*
         * function DirSearch
         * purpose: Iterate through the specified directory and add
         *  the files found to the listbox.
         * input:
         *  sDir - the name of the directory to be searched
         * output: none
         * properties modified: buttonList
         *
         * NOTE: This method adapted from method suggesed by John T,
         *  on May 30th 2009,
         *  http://stackoverflow.com/questions/929276/how-to-recursively-list-all-the-files-in-a-directory-in-c
         */
        /// <summary>
        /// Searches the current directory for files and adds them to the list as needed.
        /// Note: This method adapted from method suggested by John T,
        /// on May 30th, 2009,
        /// http://stackoverflow.com/questions/929276/how-to-recursively-list-all-the-files-in-a-directory-in-c
        /// </summary>
        /// <param name="sDir">The current directory</param>
        /// <param name="buttonListIn">The list of buttons to be amended</param>
        static void DirSearch(string sDir, List <IBoxButton> buttonListIn)
        {
            try
            {
                foreach (string f in Directory.GetFiles(sDir))
                {
                    //Debug.Log(f);
                    //if the file is an xml, add to list
                    if (f.EndsWith(".xml")) //XML HARDCODED
                    {
                        //delete the path from f
                        string g = f.Remove(0, sDir.Length + 1);

                        //create a new button with f as text
                        IBoxButton newButton = new IBoxButton();
                        newButton.text = g;

                        //add newButton to list
                        buttonListIn.Add(newButton);
                    }
                }
            }
            catch (System.Exception excpt)
            {
                Console.WriteLine(excpt.Message);
            }
        }
Example #2
0
        /// <summary>
        /// Method used to add a new element to the list
        /// </summary>
        /// <param name="textIn">The title of the element / text contained by the element</param>
        public void add(string textIn)
        {
            //define new item
            IBoxButton newButton = new IBoxButton();

            newButton.text = textIn;

            buttonList.Add(newButton); //add new button to list
        }
        /// <summary>
        /// Method used to add a new element to the list
        /// </summary>
        /// <param name="textIn">Text of the new element added</param>
        public void add(string textIn)
        {
            //define new item
            IBoxButton newButton = new IBoxButton();
            newButton.text = textIn;

            buttonList.Add(newButton); //add new button to list
        }
        /*
         * function DirSearch
         * purpose: Iterate through the specified directory and add
         *  the files found to the listbox.
         * input:
         *  sDir - the name of the directory to be searched
         * output: none
         * properties modified: buttonList
         *
         * NOTE: This method adapted from method suggesed by John T,
         *  on May 30th 2009,
         *  http://stackoverflow.com/questions/929276/how-to-recursively-list-all-the-files-in-a-directory-in-c
         */
        /// <summary>
        /// Searches the current directory for files and adds them to the list as needed.
        /// Note: This method adapted from method suggested by John T,
        /// on May 30th, 2009,
        /// http://stackoverflow.com/questions/929276/how-to-recursively-list-all-the-files-in-a-directory-in-c
        /// </summary>
        /// <param name="sDir">The current directory</param>
        /// <param name="buttonListIn">The list of buttons to be amended</param>
        static void DirSearch(string sDir, List<IBoxButton> buttonListIn)
        {
            try
            {

                foreach (string f in Directory.GetFiles(sDir))
                {
                    //Debug.Log(f);
                    //if the file is an xml, add to list
                    if (f.EndsWith(".xml")) //XML HARDCODED
                    {
                        //delete the path from f
                        string g = f.Remove(0, sDir.Length + 1);

                        //create a new button with f as text
                        IBoxButton newButton = new IBoxButton();
                        newButton.text = g;

                        //add newButton to list
                        buttonListIn.Add(newButton);
                    }
                }

            }
            catch (System.Exception excpt)
            {
                Console.WriteLine(excpt.Message);
            }
        }