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
        /// <summary>
        /// Updates the target.
        /// </summary>
        /// <param name="newTarget">The new target.</param>
        internal void UpdateTarget(string newTarget)
        {
            CustomIcon = null;
            if (FileOperations.IsURL(newTarget))
            {
                string urlCustomIcon = WebsiteImage.CustomSiteIcon(newTarget);
                if (string.IsNullOrEmpty(urlCustomIcon))
                {
                    UpdateLogoURL(newTarget);
                }
                else
                {
                    CustomIcon = urlCustomIcon;
                }
                targetName        = newTarget;
                TranslationId     = string.Empty;
                TargetDescription = FileOperations.GetPageTitle(newTarget);
                if (string.IsNullOrEmpty(TargetDescription))
                {
                    TargetDescription = newTarget;
                }
                Update(true);
                Manager.FlushCurrentCircle();
            }
            else
            {
                string fileCustomIcon = FileImage.CustomFileIcon(newTarget);
                if (string.IsNullOrEmpty(fileCustomIcon))
                {
                    UpdateLogoFile(newTarget);
                }
                else
                {
                    CustomIcon = fileCustomIcon;
                    DestroyLogoImage();
                    FixupLogoImage();
                }

                //if the image was dragged on the stone, the logo is updated
                if (!FileOperations.FileIsImage(newTarget))
                {
                    targetName        = newTarget;
                    TranslationId     = string.Empty;
                    TargetDescription = Path.GetFileNameWithoutExtension(targetName);
                    if (string.IsNullOrEmpty(TargetDescription))
                    {
                        string rootPath = Path.GetPathRoot(targetName);
                        if (TextHelper.SameText(rootPath, targetName))
                        {
                            string    volumeName;
                            string    volumeLabel;
                            DriveInfo di = new DriveInfo(rootPath);
                            volumeName  = di.Name;
                            volumeLabel = di.VolumeLabel;
                            if (!string.IsNullOrEmpty(volumeLabel))
                            {
                                TargetDescription = volumeLabel + "(" + volumeName + ")";
                            }
                            else
                            {
                                TargetDescription = "(" + volumeName + ")";
                            }
                        }
                        else
                        {
                            TargetDescription = targetName;
                        }
                    }
                }
                else
                {
                    CustomIcon = newTarget;
                }



                FixupConfiguration();
                Update(true);
            }
        }