コード例 #1
0
        private List <FileInfo> setFileInfo(List <FileInfo> fi)
        {
            MyExtensions.Shuffle(fi, rng);
            pos = -1;

            return(fi);
        }
コード例 #2
0
        /// <summary>
        /// Returns x random images from the list (without randomizing it), no repeats.
        /// x cannot be greater than the number of existing images in the list.
        /// (TODO cleanup, probably ineffecient and verbose)
        /// </summary>
        /// <param name="x"></param>
        /// <returns></returns>
        public List <FileInfo> getRandomX(int x)
        {
            if (x >= fi.Count)
            {
                x = fi.Count - 1;
            }
            List <FileInfo> ret = new List <FileInfo>();

            FileInfo[] fi_ = new FileInfo[fi.Count];
            fi.CopyTo(fi_);
            MyExtensions.Shuffle(fi_, rng);
            ret = ret.ToList();
            if (x < fi.Count)
            {
                ret.RemoveRange(x, fi.Count - 1);
            }
            return(ret);
        }
コード例 #3
0
        /// <summary>
        /// Gets all files in a directory with the given extensions
        /// </summary>
        private List <FileInfo> setFileInfo(string folderpath)
        {
            List <FileInfo> fi = new List <FileInfo>();

            if (folderpath != "" && Directory.Exists(folderpath))
            {
                di = new DirectoryInfo(folderpath);
                fi = new List <FileInfo>();

                //if (useWhitelist || useBlacklist)
                //{
                //    foreach (var f in ext.Where(t => t == "*.jpg" || t == "*.jpeg").SelectMany(e => (di.EnumerateFiles(e, so))))
                //    {
                //        try
                //        {
                //            var v = new JpegMetadataAdapter(f.FullName).Metadata;
                //            if (!((!tagWhitelist.Any(t => v.Keywords.Contains(t)) && useWhitelist) || (tagBlacklist.Any(t => v.Keywords.Contains(t)) && useBlacklist)))
                //            //if (tagWhitelist.Any(t => v.Keywords.Contains(t)) && !tagBlacklist.Any(t => v.Keywords.Contains(t)))
                //                fi.Add(f);
                //        }
                //        catch { }
                //    }
                //    fi.AddRange(ext.Where(t => t != "*.jpg" && t != "*.jpeg").SelectMany(e => (di.EnumerateFiles(e, so))));
                //}
                //else
                //{
                fi.AddRange(ext.SelectMany(e => (di.EnumerateFiles(e, so))));
                //}

                MyExtensions.Shuffle(fi, rng);
                pos = -1;
            }
            else
            {
                di = null;
                fi = null;
            }

            return(fi);
        }
コード例 #4
0
 /// <summary>
 /// Shuffle the image list and reset the position.
 /// </summary>
 public void Randomize()
 {
     MyExtensions.Shuffle(fi, rng);
     pos = -1;
 }