Example #1
0
        /// <summary>
        /// Add filters to the current filter group.
        /// </summary>
        /// <param name="filters">
        /// The filters to add.
        /// </param>

        public void Add(FilterBuilder.Filters[] filters)
        {
            //Add filter to the list
            foreach (FilterBuilder.Filters item in filters)
            {
                sFilters.Add(Helpers.ReturnFilterAsString(item));
            }

        }
Example #2
0
 /// <summary>
 /// Checks if the specified filter is contained within the filter group.
 /// </summary>
 /// <param name="filter">
 /// The filter to check for.
 /// </param>
 /// <returns>
 /// Boolean as to whether the filter was found in the collection.
 /// </returns>
 private bool Contains(FilterBuilder.Filters filter) => sFilters.Contains(Helpers.ReturnFilterAsString(filter));
Example #3
0
        /// <summary>
        /// Add a filter to the current filter group.
        /// </summary>
        /// <param name="filter">
        /// The filter to add.
        /// </param>

        public void Add(FilterBuilder.Filters filter)
        {
            //Add filter to the list
            sFilters.Add(Helpers.ReturnFilterAsString(filter));

        }
Example #4
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 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);

        }