CodeTV.PanelChannel.AdjustTVLogo C# (CSharp) Method

AdjustTVLogo() private method

private AdjustTVLogo ( Channel channel ) : void
channel Channel
return void
        internal void AdjustTVLogo(Channel channel)
        {
            if (channel.Tag != null)
            {
                TreeNode treeNode = channel.Tag as TreeNode;

                if (channel is ChannelFolder)
                {
                    treeNode.ImageKey = treeNode.SelectedImageKey = "FolderClosed";
                    return;
                }
                else if (channel is ChannelTV)
                {
                    string logo = (channel as ChannelTV).Logo;
                    if (logo != null && logo.Length > 0)
                    {
                        if (MainForm.imageListLogoTV.Images.ContainsKey(logo))
                        {
                            treeNode.ImageKey = treeNode.SelectedImageKey = logo;
                            return;
                        }
                        else
                        {
                            try
                            {
                                string path = FileUtils.GetAbsolutePath(logo);
                                if (File.Exists(path))
                                {
                                    Bitmap bitmap = new Bitmap(path);
                                    //if (!Bitmap.IsAlphaPixelFormat(bitmap.PixelFormat))
                                    //    bitmap.MakeTransparent(Color.White);
                                    //Image thumbnail = ResizeImage(bitmap, 16, 16, false);
                                    Image thumbnail = Utils.ResizeImage(bitmap, 16, 16, false);
                                    MainForm.imageListLogoTV.Images.Add(logo, thumbnail);
                                    treeNode.ImageKey = treeNode.SelectedImageKey = logo;
                                    thumbnail.Dispose();
                                    bitmap.Dispose();
                                    return;
                                }
                            }
                            catch (ArgumentException) { }
                        }
                    }
                }

                treeNode.ImageKey = treeNode.SelectedImageKey = "LogoTVDefault";
            }
        }