锐英源软件
第一信赖

精通

英语

开源

擅长

开发

培训

胸怀四海 

第一信赖

当前位置:锐英源 / 英语翻译 / C#语言不用代码实现显示不规则窗体
服务方向
人工智能数据处理
人工智能培训
kaldi数据准备
小语种语音识别
语音识别标注
语音识别系统
语音识别转文字
kaldi开发技术服务
软件开发
运动控制卡上位机
机械加工软件
软件开发培训
Java 安卓移动开发
VC++
C#软件
汇编和破解
驱动开发
联系方式
固话:0371-63888850
手机:138-0381-0136
Q Q:396806883
微信:ryysoft

锐英源精品开源心得,转载请注明:“锐英源www.wisestudy.cn,孙老师作品,电话13803810136。”需要全文内容也请联系孙老师。


C#语言不用代码实现显示不规则窗体


前言


规则窗体是有标题栏,长方形的窗体,不规则窗体是非长方形的。


Introduction

First of all, I am a newbie at C#. I started it from only two days ago so, sorry for the experts if they didn’t like my article or didn’t find anything useful here. But I think there is some one who may need it to improve his application's interface. The trick is same as the technique which is used at the movies to make the actors do the scene at a room the walls of which is painted with a illuminated color, then the graphic designers put another scene of a forest or a planet or any place else, this is how it works for us.

The first step is to make the required Form graphics by any graphics tool (I usually use the Photoshop). The form graphics must have the background color as illuminated green because this color can be easily grouped and deleted without deleting any edges of the shape you want. In other words, if we used non illuminated color, the dark edges of the shape will be deleted with the background color.

Any way the work will show how it is done, as I did in my sample. You can see what I was saying:

首先,我是C#的新手。我是从两天前开始的,所以如果不喜欢我的文章,或者在这里没有找到任何有用的东西,对不起。但我认为有些人可能需要它来改进他的应用程序的界面。诀窍与电影中使用的技术相同,使演员在一个房间里进行场景,房间的墙壁涂有发光的颜色,然后图形设计师将另一个场景放在森林,行星或任何地方,这就是它对我们有用的方式。

第一步是通过任何图形工具制作所需的Form 图形(我通常使用Photoshop)。该形态的图形必须有背景色为照明绿色,因为这种颜色可以很容易地分组和删除,但删除时不删除任何你想要的边缘形状。换句话说,如果我们使用非照明颜色,则形状的暗边将和背景颜色一起删除。

任何方式的工作都会显示它是如何完成的,就像我在样本中所做的那样。你可以看到我在说什么:

Sample screenshot

But the main problem is that Visual studio needs the same exact color as the background and if you mismatched this rule, the background color will stick to your form. If we take a closer view of our painted form, you can see a small difference at a point on the curved edges:但主要的问题是Visual Studio需要与背景相同的颜色,如果你不匹配这个规则,背景颜色将显示到窗体上。如果我们仔细观察我们的绘制形状,您可以看到弯曲边缘上的一个小点差异:

Sample screenshot

The Visual Studio considers it as a different color than the background, so it leaves it without deleting and it looks very awful at your form as:Visual Studio将其视为与背景不同的颜色,因此它不会删除它,并且它在您的表单中看起来非常糟糕:

Sample screenshot

So try to eliminate all different colors from your graphic before using it. Now another thing …. When you save your background color, try to make the background color take a little space from it because the VS considers it as a part of the form although it eliminates it.

Now save your work as .bmp file and open VS.NET. Make a project that contains a C# empty form and start modifying it as the following:因此,在使用之前,请尝试从图形中消除所有不同的颜色。现在另一件事...... 保存背景颜色时,请尝试使背景颜色占用一点空间,因为VS会将其视为表单的一部分,尽管它会消除它。

现在将您的工作保存为.bmp文件并打开VS.NET。创建一个包含C#空表单的项目,并开始按以下方式修改它:

Sample screenshot

Add the button and the label you want and adjust the form properties as the following:

  • BackgroundImage: your background with extension .bmp
  • FormBorderStyle: None
  • TransparencyKey: Web, then choose Lime

Adjust the Button properties as the following:

  • BackColor: Web, then choose White Smoke
  • Text: OK

Adjust the Label properties as the following:

  • BackColor: Web, then choose Transparent
  • FlatStyle: Popup

Add this code to the button1_Click function:

添加所需的按钮和标签,并调整表单属性,如下所示:

  • BackgroundImage:你的背景扩展名为.bmp
  • FormBorderStyle: 没有
  • TransparencyKey:Web,然后选择Lime

调整Button属性如下:

  • BackColor:Web,然后选择White Smoke
  • Text: 好

调整Label属性如下:

  • BackColor:Web,然后选择透明
  • FlatStyle: 弹出

将此代码添加到button1_Click函数中:

Application.Exit();

If you want your form moveable, you can use the code at Jibin's article (Interactive Shaped Forms). That is all.如果您希望表单可移动,可以使用Jibin文章中的代码(Interactive Shape d Form s)。就这些。

友情链接
版权所有 Copyright(c)2004-2021 锐英源软件
公司注册号:410105000449586 豫ICP备08007559号 最佳分辨率 1024*768
地址:郑州大学北校区院(文化路97号院)内