Ejemplo n.º 1
0
        public void AssignIcon()
        {
            if (icon != null)
            {
                icon.Dispose();
                icon = null;
            }

            string fileCustomIcon = FileImage.CustomFileIcon(FileOperations.ExtractFileNameFromShellLink(FullPath));

            if (string.IsNullOrEmpty(fileCustomIcon))
            {
                icon = (Bitmap)FileImage.FileNameImage(FullPath);

                if (icon == null)
                {
                    if (FileOperations.DirectoryExists(FullPath))
                    {
                        icon = NativeThemeManager.LoadBitmap("Folder.png");
                    }
                    else
                    {
                        icon = NativeThemeManager.LoadBitmap("UnknownFile.png");
                    }
                }
            }
            else
            {
                icon = FastBitmap.FromFile(fileCustomIcon);
            }
        }
Ejemplo n.º 2
0
        protected override void BuildItems()
        {
            FolderItem item;
            string     fullTarget;

            DisposeItems();
            string fullPath = FileOperations.StripFileName(path);

            string[] files = Directory.GetFileSystemEntries(fullPath);

            HeaderText = Path.GetFileNameWithoutExtension(fullPath);

            item      = new FolderItem(fullPath);
            item.Logo = BitmapPainter.ResizeBitmap(NativeThemeManager.LoadBitmap("Folder.png"), FileImage.ImageSize, FileImage.ImageSize, true);
            Items.Add(item);

            int totalItems = 0;

            for (int i = 0; i < files.Length; i++)
            {
                fullTarget = files[i];
                if ((File.GetAttributes(fullTarget) & FileAttributes.Hidden) == FileAttributes.Hidden)
                {
                    continue;
                }

                totalItems++;

                if (totalItems > Limit)
                {
                    totalItems = Limit;
                    break;
                }

                item = new FolderItem(fullTarget);

                if (TextHelper.SameText(Path.GetExtension(fullTarget), ".circle"))
                {
                    item.Logo = GetLogoFromRing(fullTarget);
                }

                if (item.Logo == null)
                {
                    item.Logo = (Bitmap)FileImage.FileNameImage(fullTarget);
                }

                if (item.Logo == null)
                {
                    if (FileOperations.DirectoryExists(fullTarget))
                    {
                        item.Logo = NativeThemeManager.LoadBitmap("Folder.png");
                    }
                    else
                    {
                        item.Logo = NativeThemeManager.LoadBitmap("UnknownFile.png");
                    }
                }

                Items.Add(item);
            }

            files = null;
        }
Ejemplo n.º 3
0
        private void UpdateLogoFile(string newTarget)
        {
            StopAnimation();
            if (Logo != null)
            {
                Logo.Dispose();
                Logo = null;
            }

            string fullTarget = FileOperations.StripFileName(newTarget);

            if (!FileOperations.IsValidPathName(fullTarget))
            {
                Logo = NativeThemeManager.LoadBitmap("UnknownFile.png");
            }
            else
            {
                if (!string.IsNullOrEmpty(fullTarget))
                {
                    if (NativeMethods.FileExtensionIs(fullTarget, ".circle"))
                    {
                        Logo = GetLogoFromRing(fullTarget);
                    }
                }

                if (Logo == null)
                {
                    try
                    {
                        Logo = (Bitmap)FileImage.FileNameImage(fullTarget);
                    }
                    catch
                    {
                        Logo = null;
                    }
                }

                if (Logo == null)
                {
                    if (FileOperations.DirectoryExists(fullTarget))
                    {
                        Logo = NativeThemeManager.LoadBitmap("Folder.png");
                    }
                    else
                    {
                        Logo = FileOperations.GetExtensionLogo(fullTarget);
                        if (Logo == null)
                        {
                            Logo = NativeThemeManager.LoadBitmap("UnknownFile.png");
                        }
                    }
                }
            }

            AnimatedLogo = ImageAnimator.CanAnimate(Logo);
            if (!AnimatedLogo)
            {
                Logo = BitmapPainter.ResizeBitmap(Logo, FileImage.ImageSize, FileImage.ImageSize, true);
            }

            SaveLogoToCache();
        }