Exemplo n.º 1
0
        private bool Search(List <InformationOrder> result, InformationOrder treated, ConfigurationSearch cfgSearch)
        {
            if (treated.OriginalSize == null)
            {
                Logger.Log("This texture wasn't included in search because there was an error getting its informations: {0}", treated.FileSource.FullName, TypeLog.Warning);
                return(false);
            }
            //
            bool isOk = true;

            //
            //
            if (cfgSearch.IsSearchFormatEnabled)
            {
                if (!string.Equals(treated.OriginalSize.Format, cfgSearch.Format, StringComparison.OrdinalIgnoreCase))
                {
                    isOk = false;
                }
            }
            //
            if (cfgSearch.IsSearchNameEnabled)
            {
                if (treated.FileSource.Name.IndexOf(cfgSearch.Name, StringComparison.OrdinalIgnoreCase) < 0)
                {
                    isOk = false;
                }
            }
            //
            if (cfgSearch.IsSearchMaxSizeEnabled)
            {
                if (treated.OriginalSize.Width > cfgSearch.MaxSize || treated.OriginalSize.Height > cfgSearch.MaxSize)
                {
                    isOk = false;
                }
            }
            //
            if (cfgSearch.IsSearchMinSizeEnabled)
            {
                if (treated.OriginalSize.Width < cfgSearch.MinSize || treated.OriginalSize.Height < cfgSearch.MinSize)
                {
                    isOk = false;
                }
            }
            //
            if (cfgSearch.IsSearchMipmapsEnabled)
            {
                if (cfgSearch.IsMipmaps)
                {
                    if (treated.OriginalSize.Mipmaps == 1)
                    {
                        isOk = false;
                    }
                }
                else
                {
                    if (treated.OriginalSize.Mipmaps > 1)
                    {
                        isOk = false;
                    }
                }
            }
            //
            if (cfgSearch.IsSearchPowerOf2)
            {
                if (cfgSearch.IsPowerOf2)
                {
                    if (!TablePowerOfTwo.ContainsKey(treated.OriginalSize.Width) || !TablePowerOfTwo.ContainsKey(treated.OriginalSize.Height))
                    {
                        isOk = false;
                    }
                }
                else
                {
                    if (TablePowerOfTwo.ContainsKey(treated.OriginalSize.Width) && TablePowerOfTwo.ContainsKey(treated.OriginalSize.Height))
                    {
                        isOk = false;
                    }
                }
            }
            //
            if (isOk)
            {
                lock (result)
                {
                    result.Add(treated);
                }
            }
            return(isOk);
        }
Exemplo n.º 2
0
 public ModelConfigurationSearch(ConfigurationSearch search)
 {
     Search = search;
 }