如何淡入/淡出的面板内容中使用C# [英] How to fade in/out a panel with content within using c#

查看:166
本文介绍了如何淡入/淡出的面板内容中使用C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小组作为容器这个面板上有一个画面上作为背景,容器板内,我有另外一个小组,我会放在标签的一些信息,这些信息会发生变化的时候,我要的是当一个新的信息是要告诉一个过渡,淡出信息面板与旧信息,然后消失在同一面板的新信息。在淡出信息面板的时候,我就能看到容器板的研究背景图像。这两个板有边框= FixedSingle,也是信息面板有一个背景色的颜色。

I have a Panel as a container this panel has a picture on it as a background, within the container panel, I have another panel where I gonna put some information in labels, that information will change in time, what I want is a transition when a new info is about to show, fade out the information panel with the old info and then fade in the same panel with the new info. At the time of the fade out the information panel I will be able to see the backgroud image of the container panel. Both panels have BorderStyle=FixedSingle, also the info panel has a backcolor color.

现在我的问题是:有没有什么办法来淡入/淡出信息面板,并在过多的全部内容

Now my question is: is there any way to fade in/out the information panel and the whole content within too?

我正在寻找在网上,我发现一种方法,这种效果与面板的背景色的工作,但它并没有在所有的工作,而且,内容仍然存在,因为他们只是试图淡化背景色属性:

I was searching in the web, and I found an approach to this effect working with the panel's backcolor but it doesn't work at all, and besides, the content still there, since they just try to fade the backcolor property:

Timer tm = new Timer();
    private void Form1_Shown(object sender, EventArgs e)
    {
        tm.Interval = 100;
        tm.Tick += new EventHandler(timer1_Tick);
        tm.Enabled = true;
    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        int aa = 0;
        panel2.BackColor = Color.FromArgb(aa, 255, 0, 0);

        aa += 10;
        if (aa > 255)
            tm.Enabled = false;
    }

任何帮助将AP preciated。

Any help will be appreciated.

推荐答案

我不相信你可以设置各个控件的不透明度。该形式本身有一个不透明的,但我不认为你想淡出整个控制。

I don't believe you can set the opacity of individual controls. The form itself has an opacity, but I don't think you want to fade out the whole control.

您可以创建支持透明度自定义控件......这里是一个例子: http://www.slimee.com/2009 /02/net-transparent-forms-and-controls-with.html

You can create custom controls that support opacity...here's an example: http://www.slimee.com/2009/02/net-transparent-forms-and-controls-with.html

相信这实现将应用到子控制面板内(因为它正在工作的矩形区域,该控制占用)。如果我错了,你就必须处理所有的子控件的为您凌驾行为的一部分。

I believe this implementation would apply to child controls within the panel (because it is working on the rectangular area that the control takes up). If I'm wrong, you'd have to handle all of the child control's as part of your over-ridden behavior.

正如其他人所说,得到这个看起来'顺利'可能是大量的工作。希望有人将有一个更好的答案。

As others have said, getting this to look 'smooth' might be a lot of work. Hopefully someone will have a better answer.

这篇关于如何淡入/淡出的面板内容中使用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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