工具栏项目中的图标问题. [英] Icon problem in tool bar item.

查看:91
本文介绍了工具栏项目中的图标问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我在标准工具栏中添加了两个新的工具栏项,这些项可以基于某些上下文启用和禁用.问题是,如果我使用VS软件包提供的图标并禁用工具栏项,则该按钮将被禁用,并且该图标将变为灰色,但是如果使用我的自定义图标,该按钮将被禁用,但该图标不会变为灰色. >
谁能告诉我应该使用哪种类型的图标/图像,以便在禁用工具栏项目时该图标/图像变灰以及应该从哪里获得?



,谢谢,

Ankesh.

Hi,

I have added two new tool bar item in standard tool bar, which gets enabled and disabled with based on some context. The problem is that if I use icon provided by the VS package and disable the tool bar item the button becomes disabled and icon is getting grayed but if I use my custom icon the button is disabled but the icon is not getting grayed.

Can any one tell me the what type of icon/image i should use so that it becoms grayed while disabling the tool bar item and from where I should get it?



Thanks,

Ankesh.

推荐答案

您好,安克什.

没有更好的方法,您需要先绘制一个灰色图像,在禁用工具栏时使用该灰色图像.

使用以下代码绘制灰度图像.

位图 toolBarIcon = 位图(toolStrip1.Items[0].Image);

            Bitmap toolBarIcon = new Bitmap(toolStrip1.Items[0].Image);

用于( int i = 0; i< toolBarIcon.Width; i ++)

            for (int i = 0; i < toolBarIcon.Width; i++)

            {

用于( int j = 0; j< toolBarIcon.Height; j ++)

                for (int j = 0; j < toolBarIcon.Height; j++)

                {

颜色 pixel = toolBarIcon.GetPixel(i,j);

                    Color pixel = toolBarIcon.GetPixel(i, j);

int val =(pixel.R + pixel.G + pixel.B)/3;

                    int val = (pixel.R + pixel.G + pixel.B) / 3;

颜色 .FromArgb(val,val,val));

                    toolBarIcon.SetPixel(i, j, Color.FromArgb(val, val, val));

                }

            }

并使用 已禁用.

谢谢

Chao


这篇关于工具栏项目中的图标问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆