Exemplo n.º 1
0
        private void lbxFiles_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (lbxFiles.SelectedIndex == -1)
                {
                    return;
                }

                lbxIcons.Items.Clear();
                lbxImages.Items.Clear();
                pbxXORImage.Image        = null;
                pbxANDImage.Image        = null;
                pbxIcon.Image            = null;
                lblWidthValue.Text       = null;
                lblHeightValue.Text      = null;
                lblColorDepthValue.Text  = null;
                lblCompressionValue.Text = null;
                mMultiIcon.SelectedIndex = -1;
                mMultiIcon.Load(Path.Combine(mFolder, (string)lbxFiles.SelectedItem));

                foreach (SingleIcon singleIcon in mMultiIcon)
                {
                    _ = lbxIcons.Items.Add(singleIcon.Name);
                }
            }
            catch (Exception ex)
            {
                _ = MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private void NextPic(string path)
        {
            if (GlobalSetting.ImageList.Length < 1)
            {
                return;
            }

            //The image data will load
            Image im = null;

            try
            {
                //Check if the image is a icon or not
                if (Path.GetExtension(path).ToLower() == ".ico")
                {
                    try
                    {
                        MultiIcon mIcon = new MultiIcon();
                        mIcon.Load(path);

                        //Try to get the largest image of it
                        SingleIcon sIcon  = mIcon[0];
                        IconImage  iImage = sIcon.OrderByDescending(ico => ico.Size.Width).ToList()[0];

                        //Convert to bitmap
                        im = iImage.Icon.ToBitmap();
                    }
                    catch //If a invalid icon
                    {
                        im = GlobalSetting.ImageList.GetImage(GlobalSetting.CurrentIndex);
                    }
                }
                else //If a normal image
                {
                    im = GlobalSetting.ImageList.GetImage(GlobalSetting.CurrentIndex);
                    var canPlay = ImageAnimator.CanAnimate(im);
                    var isAnime = System.Utility.Helper.File.GetExtension(path).ToLower() == "gif";
                    if (canPlay && !isAnime)
                    {
                        return;
                    }
                }
                GlobalSetting.IsImageError = GlobalSetting.ImageList.imgError;
                //Show image
                picturePanel.Zoom  = 100;
                picturePanel.Image = im;
            }
            catch//(Exception ex)
            {
                picturePanel.Image = null;
            }

            if (GlobalSetting.IsImageError)
            {
                picturePanel.Image = null;
            }

            //Collect system garbage
            System.GC.Collect();
        }
Exemplo n.º 3
0
        void PresentIconsFromFile(string filePath)
        {
            try
            {
                lbxIcons.Items.Clear();
                lbxImages.Items.Clear();
                //pbxXORImage.Image = null;
                //pbxANDImage.Image = null;
                pbxIcon.Image            = null;
                lblWidthValue.Text       = null;
                lblHeightValue.Text      = null;
                lblColorDepthValue.Text  = null;
                lblCompressionValue.Text = null;
                mMultiIcon.SelectedIndex = -1;
                mMultiIcon.Load(filePath);

                foreach (SingleIcon singleIcon in mMultiIcon)
                {
                    lbxIcons.Items.Add(singleIcon.Name);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 4
0
        public MultiIcon ToIconOverly(string iconAddress)
        {
            var multiIcon = new MultiIcon();
            var icon      = multiIcon.Add("Icon1");
            var mainIcon  = new MultiIcon();

            mainIcon.Load(iconAddress);

            foreach (var singleIcon in mainIcon[0].Where(image =>
                                                         image.PixelFormat == PixelFormat.Format16bppRgb565 ||
                                                         image.PixelFormat == PixelFormat.Format24bppRgb ||
                                                         image.PixelFormat == PixelFormat.Format32bppArgb)
                     .OrderByDescending(
                         image =>
                         image.PixelFormat == PixelFormat.Format16bppRgb565
                            ? 1
                            : image.PixelFormat == PixelFormat.Format24bppRgb
                                ? 2
                                : 3)
                     .ThenByDescending(image => image.Size.Width * image.Size.Height))
            {
                if (!icon.All(i => singleIcon.Size != i.Size || singleIcon.PixelFormat != i.PixelFormat))
                {
                    continue;
                }

                var bitmap = singleIcon.Icon.ToBitmap();

                if (bitmap.PixelFormat != singleIcon.PixelFormat)
                {
                    var clone = new Bitmap(bitmap.Width, bitmap.Height, singleIcon.PixelFormat);

                    using (var gr = Graphics.FromImage(clone))
                    {
                        gr.DrawImage(bitmap, new Rectangle(0, 0, clone.Width, clone.Height));
                    }

                    bitmap.Dispose();
                    bitmap = clone;
                }

                icon.Add(singleIcon.Size.Height * singleIcon.Size.Width < 24 * 24 ? bitmap : ToBitmapOverly(bitmap));

                if (singleIcon.Size.Width >= 256 && singleIcon.Size.Height >= 256)
                {
                    icon[icon.Count - 1].IconImageFormat = IconImageFormat.PNG;
                }

                bitmap.Dispose();
            }

            if (icon.Count == 0)
            {
                throw new ArgumentException();
            }

            multiIcon.SelectedIndex = 0;

            return(multiIcon);
        }
Exemplo n.º 5
0
 public static Bitmap ExtractHighResIconImage(string path, int? size = null)
 {
     var mi = new MultiIcon();
     mi.Load(path);
     var si = mi.FirstOrDefault();
     if (si != null)
     {
         IconImage icon;
         if (size != null)
         {
             if (size.Value <= 32)
             {
                 try
                 {
                     return Icon.ExtractAssociatedIcon(path).ToBitmap();
                 }
                 catch
                 {
                 }
             }
             icon = si.Where(x => x.Size.Height >= size.Value).OrderBy(x => x.Size.Height).FirstOrDefault();
             if (icon != null)
                 return icon.Icon.ToBitmap();
         }
         var max = si.Max(_i => _i.Size.Height);
         icon = si.FirstOrDefault(i => i.Size.Height == max);
         if(icon != null)
             return icon.Transparent;
     }
     return null;
 }
Exemplo n.º 6
0
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            EnableBlur();


            mMultiIcon.Load(@"C:\Users\erkan\AppData\Local\GitHubDesktop\GitHubDesktop.exe");
            mMultiIcon.Load(@"D:\Portable\Adobe\InDesign CC 2018\InDesign13\InDesignPortable.exe");
            mMultiIcon.Load(@"C:\Windows\System32\notepad.exe");


            List <IconImage> iconImageList = new List <IconImage>();


            foreach (var item in mMultiIcon[0])
            {
                iconImageList.Add(item); // Dosyay ya ait bütün boyutlardaki iconlar listeye eklenir
            }

            IconImage iconImage = iconImageList.OrderByDescending(x => x.Size.Height).First();

            //DP_Container.Children.Add(new System.Windows.Controls.Image()
            //{
            //    Source = ToImageSource(iconImage.Icon),
            //    Width = 50,
            //    Stretch = Stretch.Uniform
            //});


            Icon largeIcon = IconTools.GetIconForExtension(".html", ShellIconSize.LargeIcon);

            //DockPanel.SetDock(DP_Container, Dock.Left);
            //GetIcon(@"C:\Users\erkan\OneDrive\Masaüstü").ForEach(x =>
            //{
            //    DP_Container.Children.Add(new System.Windows.Controls.Image()
            //    {
            //        Source = ToImageSource(largeIcon),

            //        Height = 60,
            //        Stretch = Stretch.Uniform
            //    });
            //});
        }
Exemplo n.º 7
0
        public static Bitmap ReadIconFile(string path)
        {
            MultiIcon mIcon = new MultiIcon();
            mIcon.Load(path);

            //Try to get the largest image of it
            SingleIcon sIcon = mIcon[0];
            IconImage iImage = sIcon.OrderByDescending(ico => ico.Size.Width).ToList()[0];

            //Convert to bitmap
            return iImage.Icon.ToBitmap();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Returns a Bitmap of the icon associated with exe/dll or loads image file
        /// </summary>
        /// <param name="path">Full path to *.exe, *.dll or image file that will be used as the source for new icon</param>
        /// <returns></returns>
        public static SingleIcon GetIconFromFile(string path)
        {
            MultiIcon  mIco = new MultiIcon();
            SingleIcon ico  = mIco.Add("Icon1");

            // Load the image based on file extension
            switch (Path.GetExtension(path).ToLowerInvariant())
            {
            case ".jpg":
            case ".jpeg":
            case ".bmp":
            case ".png":
            case ".gif":
            case ".tiff":
                ico = ImageToIcon(path);
                break;

            case ".exe":
            case ".dll":
            case ".ico":
                try
                {
                    mIco.Load(path);
                }
                // Aseprite's exe produces an exception when trying to get its icon. I don't want to deal with it right now, just ignore it, file will use the default icon
                catch (System.Drawing.IconLib.Exceptions.InvalidFileException e)
                {
                    Console.Error.WriteLine(e.Message);
                }
                // Should never happen, just a failsafe
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show($"Unexpected error related to an icon, please report it on GitHub!\nLikely you can continue packing prosess despite this error.\n\nError message:\n\n\"{e.Message}\"", "Something went wrong!");
                }

                // If icon pack has multiple icons, take the first one
                if (mIco.Count > 0)
                {
                    ico = mIco[0];
                }
                // If exe doesn't have any icon it will not load the 'default' icon
                // But .NET Icon class can actually extract this 'default exe' icon
                else if (ico.Count == 0)
                {
                    ico.CreateFrom(Icon.ExtractAssociatedIcon(path).ToBitmap(), IconOutputFormat.Vista);
                }
                // Tip: you have to convert to Bitmap in order to get 16mil colors
                // if you load directly from icon it gets only 16 colors for some reason

                break;
            }
            return(ico);
        }
Exemplo n.º 9
0
        private MultiIcon GetMultiIcon()
        {
            if (ExePath == null)
            {
                return(null);
            }

            var multiIcon = new MultiIcon();

            multiIcon.Load(ExePath);
            return(multiIcon);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Read icon *.ICO file
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static Bitmap ReadIconFile(string path)
        {
            MultiIcon mIcon = new MultiIcon();

            mIcon.Load(path);

            //Try to get the largest image of it
            SingleIcon sIcon  = mIcon[0];
            IconImage  iImage = sIcon.OrderByDescending(ico => ico.Size.Width).ToList()[0];

            //Convert to bitmap
            return(iImage.Icon.ToBitmap());
        }
Exemplo n.º 11
0
    private System.Drawing.Image GetImageFromICO(MemoryStream ms)
    {
        System.Drawing.Image theIcon = null;

        //System.IO.MemoryStream ms = new System.IO.MemoryStream(LoadFile(path));
        MultiIcon multiIcon = new MultiIcon();

        try
        {
            multiIcon.Load(ms);

            foreach (IconImage iconImage in multiIcon[0])
            {
                MemoryStream msSrc = new MemoryStream();
                iconImage.Icon.ToBitmap().Save(msSrc, ImageFormat.Png);

                if (!iconImage.PixelFormat.ToString().Contains("Indexed"))
                {
                    System.Drawing.Image imgIco   = System.Drawing.Image.FromStream(msSrc);
                    System.Drawing.Image icoImage = new Bitmap(iconImage.Size.Width, iconImage.Size.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

                    Graphics g = Graphics.FromImage(icoImage);
                    g.CompositingQuality = CompositingQuality.HighQuality;
                    g.SmoothingMode      = SmoothingMode.HighQuality;
                    g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                    g.FillRectangle(System.Drawing.Brushes.White, -1, -1, iconImage.Size.Width + 1, iconImage.Size.Height + 1);
                    g.DrawImage(imgIco, iconImage.Size.Width, iconImage.Size.Height);

                    MemoryStream memStream = new MemoryStream();
                    imgIco.Save(memStream, System.Drawing.Imaging.ImageFormat.Png);  // can output different formats here
                    theIcon = System.Drawing.Image.FromStream(memStream);
                }
                else
                {
                    theIcon = System.Drawing.Image.FromStream(ms);
                }
                //break;
            }
        }
        catch
        {
            theIcon = System.Drawing.Image.FromStream(ms);
        }

        return(theIcon);
    }
Exemplo n.º 12
0
            public Builder LoadIcon()
            {
                if (_progId == null)
                {
                    return(this);
                }
                if (_exePath == null)
                {
                    return(this);
                }

                _multiIcon = new MultiIcon();
                _multiIcon.Load(_exePath);

                // Fallback
//                _icon = Icon.ExtractAssociatedIcon(_exePath);

                return(this);
            }
Exemplo n.º 13
0
        public static IconImage GetIconFromFile(string path)
        {
            MultiIcon multiIcon = new MultiIcon();

            multiIcon.Load(path);

            SingleIcon singleIcon = multiIcon[0];

            List <IconImage> iconImages = new List <IconImage>();

            foreach (var item in singleIcon)
            {
                iconImages.Add(item);
            }

            IconImage iconImage = iconImages.OrderByDescending(x => x.Size.Height).First();


            return(iconImage);
        }
        /// <summary>
        /// Does the preview.
        /// </summary>
        /// <param name="selectedFilePath">The selected file path.</param>
public void DoPreview(string selectedFilePath)
{
    //  Load the icons.
    try
    {
        var multiIcon = new MultiIcon();
        multiIcon.Load(selectedFilePath);

        //  Add the icon images.
        foreach (var iconImage in multiIcon.SelectMany(singleIcon => singleIcon))
            iconImages.Add(iconImage);

        //  Add the icons to the control.
        AddIconsToControl();
    }
    catch
    {
        //  Maybe we could show something to the user in the preview
        //  window, but for now we'll just ignore any exceptions.
    }
}
Exemplo n.º 15
0
        /// <summary>
        /// Returns a Bitmap of the icon associated with exe/dll or loads image file
        /// </summary>
        /// <param name="path">Full path to *.exe, *.dll or image file that will be used as the source for new icon</param>
        /// <returns></returns>
        public static SingleIcon GetIconFromFile(string path)
        {
            MultiIcon  mIco = new MultiIcon();
            SingleIcon ico  = mIco.Add("Icon1");

            // Load the image based on file extension
            switch (Path.GetExtension(path).ToLowerInvariant())
            {
            case ".jpg":
            case ".jpeg":
            case ".bmp":
            case ".png":
            case ".gif":
            case ".tiff":
                ico = ImageToIcon(path);
                break;

            case ".exe":
            case ".dll":
            case ".ico":
                mIco.Load(path);
                // If icon pack has multiple icons, take the first one
                if (mIco.Count > 0)
                {
                    ico = mIco[0];
                }
                // If exe doesn't have any icon it will not load the 'default' icon
                // But .NET Icon class can actually extract this 'default exe' icon
                else if (ico.Count == 0)
                {
                    ico.CreateFrom(Icon.ExtractAssociatedIcon(path).ToBitmap(), IconOutputFormat.Vista);
                }
                // Tip: you have to convert to Bitmap in order to get 16mil colors
                // if you load directly from icon it gets only 16 colors for some reason

                break;
            }
            return(ico);
        }
        /// <summary>
        /// Does the preview.
        /// </summary>
        /// <param name="selectedFilePath">The selected file path.</param>
        public void DoPreview(string selectedFilePath)
        {
            //  Load the icons.
            try
            {
                var multiIcon = new MultiIcon();
                multiIcon.Load(selectedFilePath);

                //  Add the icon images.
                foreach (var iconImage in multiIcon.SelectMany(singleIcon => singleIcon))
                {
                    iconImages.Add(iconImage);
                }

                //  Add the icons to the control.
                AddIconsToControl();
            }
            catch
            {
                //  Maybe we could show something to the user in the preview
                //  window, but for now we'll just ignore any exceptions.
            }
        }
Exemplo n.º 17
0
        public static Bitmap ExtractHighResIconImage(string path, int?size = null)
        {
            MultiIcon source1  = new MultiIcon();
            string    fileName = path;

            source1.Load(fileName);
            SingleIcon source2 = source1.FirstOrDefault <SingleIcon>();

            if (source2 != null)
            {
                if (size.HasValue)
                {
                    if (size.Value <= 32)
                    {
                        try
                        {
                            return(Icon.ExtractAssociatedIcon(path).ToBitmap());
                        }
                        catch
                        {
                        }
                    }
                    IconImage iconImage = source2.Where <IconImage>((Func <IconImage, bool>)(x => x.Size.Height >= size.Value)).OrderBy <IconImage, int>((Func <IconImage, int>)(x => x.Size.Height)).FirstOrDefault <IconImage>();
                    if (iconImage != null)
                    {
                        return(iconImage.Icon.ToBitmap());
                    }
                }
                int       max        = source2.Max <IconImage>((Func <IconImage, int>)(_i => _i.Size.Height));
                IconImage iconImage1 = source2.FirstOrDefault <IconImage>((Func <IconImage, bool>)(i => i.Size.Height == max));
                if (iconImage1 != null)
                {
                    return(iconImage1.Transparent);
                }
            }
            return((Bitmap)null);
        }
Exemplo n.º 18
0
        public static Bitmap ExtractHighResIconImage(string path, int?size = null)
        {
            var mi = new MultiIcon();

            mi.Load(path);
            var si = mi.FirstOrDefault();

            if (si != null)
            {
                IconImage icon;
                if (size != null)
                {
                    if (size.Value <= 32)
                    {
                        try
                        {
                            return(Icon.ExtractAssociatedIcon(path).ToBitmap());
                        }
                        catch
                        {
                        }
                    }
                    icon = si.Where(x => x.Size.Height >= size.Value).OrderBy(x => x.Size.Height).FirstOrDefault();
                    if (icon != null)
                    {
                        return(icon.Icon.ToBitmap());
                    }
                }
                var max = si.Max(_i => _i.Size.Height);
                icon = si.FirstOrDefault(i => i.Size.Height == max);
                if (icon != null)
                {
                    return(icon.Transparent);
                }
            }
            return(null);
        }
Exemplo n.º 19
0
            public Builder LoadIcon()
            {
                if (_progId == null) { return this; }
                if (_exePath == null) { return this; }

                _multiIcon = new MultiIcon();
                _multiIcon.Load(_exePath);

                // Fallback
                //                _icon = Icon.ExtractAssociatedIcon(_exePath);

                return this;
            }
Exemplo n.º 20
0
        Bitmap GetIcon(IconSize imageSize)
        {
            // Attempt to extract the icon from the file
            if (imageSize == IconSize.Medium)
                return Icon.ExtractAssociatedIcon(_imagePath).ToBitmap();

            MultiIcon multicon = new MultiIcon();
            try
            {
                multicon.Load(_imagePath);
            }
            catch (InvalidFileException ex)
            {
                if (Log.IsDebugEnabled)
                    Log.DebugFormat("Failed to get icons from {0}, using default application icon, got exception\n{1}", _imagePath, ex);

                return Icon.ExtractAssociatedIcon(_imagePath).ToBitmap();
            }

            IconImage largeImage = null;
            IconImage smallImage = null;

            if (multicon.Count > 0)
            {
                SingleIcon icon = multicon[0];
                foreach (IconImage iconImage in icon)
                {
                    // Ignore low quality icons (they look ugly), really big icons (don't need them that big, saves memory)
                    // or really small ones.
                    if (!IsLowQuality(iconImage) && iconImage.Size.Height <= Huge && iconImage.Size.Height >= Small)
                    {
                        if (largeImage == null)
                            largeImage = iconImage;
                        if (smallImage == null)
                            smallImage = iconImage;

                        if (iconImage.Size.Height > largeImage.Size.Height)
                            largeImage = iconImage;

                        if (iconImage.Size.Height < smallImage.Size.Height)
                            smallImage = iconImage;
                    }
                }
            }

            if (imageSize == IconSize.Small && smallImage != null)
                return smallImage.Transparent;

            if (imageSize == IconSize.Large && largeImage != null)
                return largeImage.Transparent;

            return Icon.ExtractAssociatedIcon(_imagePath).ToBitmap();
        }
Exemplo n.º 21
0
        Bitmap GetIcon(IconSize imageSize)
        {
            // Attempt to extract the icon from the file
            if (imageSize == IconSize.Medium)
            {
                return(Icon.ExtractAssociatedIcon(_imagePath).ToBitmap());
            }

            MultiIcon multicon = new MultiIcon();

            try
            {
                multicon.Load(_imagePath);
            }
            catch (InvalidFileException ex)
            {
                if (Log.IsDebugEnabled)
                {
                    Log.DebugFormat("Failed to get icons from {0}, using default application icon, got exception\n{1}", _imagePath, ex);
                }

                return(Icon.ExtractAssociatedIcon(_imagePath).ToBitmap());
            }

            IconImage largeImage = null;
            IconImage smallImage = null;

            if (multicon.Count > 0)
            {
                SingleIcon icon = multicon[0];
                foreach (IconImage iconImage in icon)
                {
                    // Ignore low quality icons (they look ugly), really big icons (don't need them that big, saves memory)
                    // or really small ones.
                    if (!IsLowQuality(iconImage) && iconImage.Size.Height <= Huge && iconImage.Size.Height >= Small)
                    {
                        if (largeImage == null)
                        {
                            largeImage = iconImage;
                        }
                        if (smallImage == null)
                        {
                            smallImage = iconImage;
                        }

                        if (iconImage.Size.Height > largeImage.Size.Height)
                        {
                            largeImage = iconImage;
                        }

                        if (iconImage.Size.Height < smallImage.Size.Height)
                        {
                            smallImage = iconImage;
                        }
                    }
                }
            }

            if (imageSize == IconSize.Small && smallImage != null)
            {
                return(smallImage.Transparent);
            }

            if (imageSize == IconSize.Large && largeImage != null)
            {
                return(largeImage.Transparent);
            }

            return(Icon.ExtractAssociatedIcon(_imagePath).ToBitmap());
        }
Exemplo n.º 22
0
        private MultiIcon GetMultiIcon()
        {
            if (ExePath == null)
            {
                return null;
            }

            var multiIcon = new MultiIcon();
            multiIcon.Load(ExePath);
            return multiIcon;
        }
Exemplo n.º 23
0
        /// <summary>
        /// ��ȡͼ����Ϣ
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        private static Image[] ReadIcon(String path)
        {
            // ����Ϊ���ж�
            if (String.IsNullOrEmpty(path))
            {
                return null;
            }
            // ȡͼ���ļ�·��
            int i = 0;
            int j = path.LastIndexOf(',');
            if (j > 0)
            {
                try
                {
                    i = int.Parse(path.Substring(j + 1));
                }
                catch (Exception)
                {
                    i = 0;
                }
                path = path.Substring(0, j).Trim(' ', '\'', '"');
            }
            // �ж�ͼ���ļ��Ƿ����
            if (!File.Exists(path))
            {
                return null;
            }
            // ȡ���ʵ�ͼ��
            if (i < 0)
            {
                i = 0;
            }

            try
            {
                // ��ȡͼ����Ϣ
                MultiIcon mi = new MultiIcon();
                mi.Load(path);
                if (i >= mi.Count)
                {
                    i = 0;
                }
                SingleIcon si = mi[i];

                // ȡ��������ߵ�ͼ��
                List<Image> img = new List<Image>();
                PixelFormat lpf = PixelFormat.Format1bppIndexed;
                j = si.Count;
                IconImage icon;
                while (j > 0)
                {
                    icon = si[--j];
                    if (icon.PixelFormat < lpf)
                    {
                        continue;
                    }
                    if (icon.PixelFormat > lpf)
                    {
                        img.Clear();
                        lpf = icon.PixelFormat;
                    }
                    img.Add(icon.Icon.ToBitmap());
                }
                return img.ToArray();
            }
            catch (Exception)
            {
                return null;
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Change image
        /// </summary>
        /// <param name="step">Image step to change. Zero is reload the current image.</param>
        private void NextPic(int step)
        {
            picMain.Text = "";

            if (GlobalSetting.ImageList.Length < 1)
            {
                this.Text = "ImageGlass";
                lblInfo.Text = string.Empty;

                GlobalSetting.IsImageError = true;
                picMain.Image = null;

                return;
            }

            //Update current index
            GlobalSetting.CurrentIndex += step;

            //Check if current index is greater than upper limit
            if (GlobalSetting.CurrentIndex >= GlobalSetting.ImageList.Length) GlobalSetting.CurrentIndex = 0;

            //Check if current index is less than lower limit
            if (GlobalSetting.CurrentIndex < 0) GlobalSetting.CurrentIndex = GlobalSetting.ImageList.Length - 1;

            //The image data will load
            Image im = null;

            try
            {
                //Check if the image is a icon or not
                if (Path.GetExtension(GlobalSetting.ImageList.GetFileName(GlobalSetting.CurrentIndex)).ToLower() == ".ico")
                {
                    try
                    {
                        MultiIcon mIcon = new MultiIcon();
                        mIcon.Load(GlobalSetting.ImageList.GetFileName(GlobalSetting.CurrentIndex));

                        //Try to get the largest image of it
                        SingleIcon sIcon = mIcon[0];
                        IconImage iImage = sIcon.OrderByDescending(ico => ico.Size.Width).ToList()[0];

                        //Convert to bitmap
                        im = iImage.Icon.ToBitmap();
                    }
                    catch //If a invalid icon
                    {
                        im = GlobalSetting.ImageList.GetImage(GlobalSetting.CurrentIndex);

                    }
                }
                else //If a normal image
                {
                    im = GlobalSetting.ImageList.GetImage(GlobalSetting.CurrentIndex);
                }

                GlobalSetting.IsImageError = GlobalSetting.ImageList.imgError;

                //Show image
                picMain.Image = im;

                //Zoom condition
                if(btnZoomLock.Checked)
                {
                    picMain.Zoom = GlobalSetting.ZoomLockValue;
                }
                else
                {
                    //Reset zoom
                    picMain.ZoomToFit();
                }

                //Get image file information
                this.UpdateStatusBar();

                //Release unused images
                if (GlobalSetting.CurrentIndex - 1 > -1 && GlobalSetting.CurrentIndex < GlobalSetting.ImageList.Length)
                {
                    GlobalSetting.ImageList.Unload(GlobalSetting.CurrentIndex - 1);
                }
            }
            catch//(Exception ex)
            {
                picMain.Image = null;

                Application.DoEvents();
                if (!File.Exists(GlobalSetting.ImageList.GetFileName(GlobalSetting.CurrentIndex)))
                {
                    GlobalSetting.ImageList.Unload(GlobalSetting.CurrentIndex);
                }
            }

            if(GlobalSetting.IsImageError)
            {
                picMain.Text = GlobalSetting.LangPack.Items["frmMain.picMain._ErrorText"];
                picMain.Image = null;
            }

            //Select thumbnail item
            if (GlobalSetting.IsShowThumbnail)
            {
                if (thumbBar.Controls.Count > 0)
                {
                    try
                    {
                        ThumbnailBox tb = (ThumbnailBox)thumbBar.Controls[GlobalSetting.CurrentIndex];
                        thumbBar.MoveToThumbnail(tb);
                    }
                    catch { }
                }
            }//end thumbnail

            //Collect system garbage
            System.GC.Collect();
        }