Esempio n. 1
0
        public static ImageList FromFolder(IGUIContext ctx, string folderPath, string name = null, bool includeSubFolders = false, Size imageSize = default(Size))
        {
            try {
                folderPath = folderPath.BackSlash(false).FixedExpandedPath();
                if (String.IsNullOrEmpty(folderPath) || !Directory.Exists(folderPath))
                {
                    return(null);
                }
                if (String.IsNullOrEmpty(name))
                {
                    name = Path.GetDirectoryName(folderPath);
                }
                FileEnumerator enu = new FileEnumerator(folderPath, includeSubFolders);
                enu.FileMask = "*.png;*.jpg;*.jpeg;*.gif;*.tif;*.tiff";
                enu.ScanToList();
                if (enu.Count > 0)
                {
                    ImageList ret = new ImageList(ctx, name, imageSize, true);
                    foreach (var path in enu.FileList)
                    {
                        ret.AddImage(Path.GetFileName(path), path);
                    }
                    return(ret);
                }
            } catch (Exception ex) {
                ex.LogError();
            }

            return(null);
        }