Ejemplo n.º 1
0
        /// <summary>
        /// Adds a system file type to the current filter
        /// group (gets description from computer).
        /// </summary>
        /// <param name="extension">
        /// The system file extension (e.g. "mp3").
        /// </param>
        /// <param name="plural">
        /// Optional. Specifies whether to try and make the system
        /// description plural ("Files" instead of "File") for
        /// consistency with other filters. Default is true.
        /// </param>

        public void Add(string extension, bool plural = true)
        {
            //Make sure extension starts with a dot
            extension = extension.StartsWith(".") == false ? "." + extension : extension;

            //Try to get the system file type desription
            string description = "";

            try
            {
                description = new Creek.IO.FilterBuilder.FilterBuilder().GetSystemFileTypeDescription(extension);
            }
            catch (Exception)
            {
                description = "";
            }


            //Return is description is nothing
            if (string.IsNullOrEmpty(description))
            {
                return;
            }

            //Check if needs to be plural
            if (plural)
            {
                //Add an 's' to the end if it doesn't have one
                description = description.EndsWith("s") == false ? description + "s" : description;
            }

            //Get the raw extension (without spaces, dots and stars)
            string ext = extension.Trim(' ', '.', '*');

            //Make the filter string by combining the description and extension
            //properly
            string s = (description.Trim() + " (*." + ext + ")|*." + ext);

            //Add filter to the list
            sFilters.Add(s);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a system file type to the current filter
        /// group (gets description from computer).
        /// </summary>
        /// <param name="extension">
        /// The system file extension (e.g. "mp3").
        /// </param>
        /// <param name="plural">
        /// Optional. Specifies whether to try and make the system
        /// description plural ("Files" instead of "File") for 
        /// consistency with other filters. Default is true.
        /// </param>

        public void Add(string extension, bool plural = true)
        {
            //Make sure extension starts with a dot
            extension = extension.StartsWith(".") == false ? "." + extension : extension;

            //Try to get the system file type desription
            string description = "";
            try
            {
                description = new Creek.IO.FilterBuilder.FilterBuilder().GetSystemFileTypeDescription(extension);
            }
            catch (Exception)
            {
                description = "";
            }


            //Return is description is nothing
            if (string.IsNullOrEmpty(description))
            {
                return;
            }

            //Check if needs to be plural
            if (plural)
            {
                //Add an 's' to the end if it doesn't have one
                description = description.EndsWith("s") == false ? description + "s" : description;
            }

            //Get the raw extension (without spaces, dots and stars)
            string ext = extension.Trim(' ', '.', '*');

            //Make the filter string by combining the description and extension
            //properly
            string s = (description.Trim() + " (*." + ext + ")|*." + ext);

            //Add filter to the list
            sFilters.Add(s);

        }