Example #1
0
        private void LoadFromThumbsDB()
        {
            FileStream   f  = File.Open(this.SourceDirectory + Path.DirectorySeparatorChar + "Thumbs.iw", FileMode.Open, FileAccess.Read);
            BinaryReader br = new BinaryReader(f);

            // clear old thumbnail images
            if (thumbNails != null)
            {
                foreach (Bitmap b in thumbNails)
                {
                    if (b != null)
                    {
                        b.Dispose();
                    }
                }

                thumbNails.Clear();
            }

            thumbNails = new ThumbnailList();

            // clear old thumbnail paths
            if (files != null)
            {
                files.Clear();
            }

            while (br.BaseStream.Position != br.BaseStream.Length)
            {
                byte[] image    = br.ReadBytes(10054);
                char[] pathC    = br.ReadChars(1024);
                char[] toolTipC = br.ReadChars(1024);
                string path     = new String(pathC).Trim();
                string toolTip  = new String(toolTipC).Trim();

                MemoryStream ms    = new MemoryStream(image);
                Bitmap       thumb = new Bitmap(ms);
                thumbNails.Add(thumb);
                files.Add(path);
                toolTips.Add(toolTip);

                image = null;
                pathC = null;
                path  = null;
            }

            br.Close();
        }
Example #2
0
        private bool IsThumbsDBOld()
        {
            string[] tfiles = null;
            string thumbsDB = this.sourceDirectory + Path.DirectorySeparatorChar + "thumbsDB";

            files.Clear();

            string[] exts = null;

            if (thumbnailFileType == ThumbnailFileType.CommonImages)
            {
                exts = standardExts;
            }
            else if (thumbnailFileType == ThumbnailFileType.DICOM)
            {
                exts = dicomExts;
            }
            else if (thumbnailFileType == ThumbnailFileType.AllImages)
            {
                exts = allExts;

            }

            foreach (string ext in exts)
            {
                tfiles = Directory.GetFiles(this.sourceDirectory, ext);

                foreach (string file in tfiles)
                {
                    files.Add(file);
                }

                tfiles = null;
            }

            thumbNails = new ThumbnailList(files.Count);

            DateTime lastestModTime = DateTime.MinValue;

            for (int j = 0; j < files.Count; j++)
            {
                string file = (string)files[j];
                if (lastestModTime < File.GetCreationTime(file))
                    lastestModTime = File.GetCreationTime(file);

                if (lastestModTime < File.GetLastWriteTime(file))
                    lastestModTime = File.GetLastWriteTime(file);
            }

            DateTime thumbsDBTime = File.GetLastWriteTime(this.SourceDirectory + Path.DirectorySeparatorChar + "Thumbs.iw");

            if (lastestModTime > thumbsDBTime)
                return true;
            else
                return false;

        }
Example #3
0
        private void LoadFromThumbsDB()
        {            
            FileStream f = File.Open(this.SourceDirectory + Path.DirectorySeparatorChar + "Thumbs.iw", FileMode.Open, FileAccess.Read);
            BinaryReader br = new BinaryReader(f);

            // clear old thumbnail images
            if (thumbNails != null)
            {
                foreach (Bitmap b in thumbNails)
                {
                    if (b != null)
                        b.Dispose();
                }

                thumbNails.Clear();
            }

            thumbNails = new ThumbnailList();

            // clear old thumbnail paths
            if (files != null)
                files.Clear();

            while (br.BaseStream.Position != br.BaseStream.Length)
            {
                byte[] image = br.ReadBytes(10054);
                char[] pathC = br.ReadChars(1024);
                char[] toolTipC = br.ReadChars(1024);
                string path = new String(pathC).Trim();
                string toolTip = new String(toolTipC).Trim();

                MemoryStream ms = new MemoryStream(image);
                Bitmap thumb = new Bitmap(ms);
                thumbNails.Add(thumb);
                files.Add(path);
                toolTips.Add(toolTip);

                image = null;
                pathC = null;
                path = null;
            }

            br.Close();
        }
Example #4
0
        private bool IsThumbsDBOld()
        {
            string[] tfiles   = null;
            string   thumbsDB = this.sourceDirectory + Path.DirectorySeparatorChar + "thumbsDB";

            files.Clear();

            string[] exts = null;

            if (thumbnailFileType == ThumbnailFileType.CommonImages)
            {
                exts = standardExts;
            }
            else if (thumbnailFileType == ThumbnailFileType.DICOM)
            {
                exts = dicomExts;
            }
            else if (thumbnailFileType == ThumbnailFileType.AllImages)
            {
                exts = allExts;
            }

            foreach (string ext in exts)
            {
                tfiles = Directory.GetFiles(this.sourceDirectory, ext);

                foreach (string file in tfiles)
                {
                    files.Add(file);
                }

                tfiles = null;
            }

            thumbNails = new ThumbnailList(files.Count);

            DateTime lastestModTime = DateTime.MinValue;

            for (int j = 0; j < files.Count; j++)
            {
                string file = (string)files[j];
                if (lastestModTime < File.GetCreationTime(file))
                {
                    lastestModTime = File.GetCreationTime(file);
                }

                if (lastestModTime < File.GetLastWriteTime(file))
                {
                    lastestModTime = File.GetLastWriteTime(file);
                }
            }

            DateTime thumbsDBTime = File.GetLastWriteTime(this.SourceDirectory + Path.DirectorySeparatorChar + "Thumbs.iw");

            if (lastestModTime > thumbsDBTime)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }