C#编写的艺术字类实例代码

C#编写的艺术字类实例代码,第1张

概述废话不多说了,直接给大家上代码了,具体代码如下所示:代码如下:usingSystem;

废话不多说了,直接给大家上代码了,具体代码如下所示:

代码如下:

using System;using System.Collections.Generic;using System.ComponentModel;using System.Drawing;using System.Drawing.Text;using System.Drawing.drawing2d;using System.Data;using System.Text;using System.windows.Forms;public partial class WordArt : UserControl//这是一个艺术字的控件{ //文本属性private string _text = "WordArt";public string Caption{get { return _text; }set { _text = value; }}//字体以及大小private Font _WordArtFont = new Font("宋体",15);public Font WordArtFont{get { return _WordArtFont; }set { _WordArtFont = value; }}//颜色private color _WordArtForecolor = color.BlueViolet;public color WordArtForecolor{get { return _WordArtForecolor; }set { _WordArtForecolor = value; }}//阴影的颜色private color _WordArtBackcolor = color.Gray;public color WordArtBackcolor{set { _WordArtBackcolor = value; }get { return _WordArtBackcolor; }}//文本输出质量:呈现模式和平滑效果private TextRenderingHint _TextRenderingHint = TextRenderingHint.ClearTypeGrIDFit;public TextRenderingHint WordArtTextRenderingHint{get { return _TextRenderingHint; }set { _TextRenderingHint = value; }}public SmoothingMode _SmoothingMode = SmoothingMode.AntiAlias;public SmoothingMode WordArtSmoothingMode{get { return _SmoothingMode; }set { _SmoothingMode = value; }}public WordArt(){InitializeComponent();}//艺术字的形式:阴影,浮雕……private WordArtEffectStyle _WordArtEffect=WordArtEffectStyle.projection;//投影为默认形式;public WordArtEffectStyle WordArtEffect{get { return _WordArtEffect; }set { _WordArtEffect = value; }}protected overrIDe voID OnPaint(PaintEventArgs e){base.OnPaint(e);Graphics g = this.CreateGraphics();Brush backBrush=new SolIDBrush(this.WordArtBackcolor);Brush foreBrush=new SolIDBrush(this.WordArtForecolor);Sizef size = g.MeasureString(this.Caption,this.WordArtFont);Single posX = (this.WIDth - Convert.ToInt16(size.WIDth)) / 2;Single posY = (this.Height - Convert.ToInt16(size.Height)) / 2;switch (this.WordArtEffect){case WordArtEffectStyle.projection://投影效果//设置文本输出质量g.TextRenderingHint = this.WordArtTextRenderingHint;g.SmoothingMode = this.WordArtSmoothingMode;Matrix matrix = new Matrix();//投射matrix.Shear(-1.5f,0.0f);//缩放matrix.Scale(1,0.5f);//平移matrix.Translate(120,75);//对绘图平面坐标实施变换g.transform = matrix;

代码到此结束了,希望对大家有所帮助!

总结

以上是内存溢出为你收集整理的C#编写的艺术字类实例代码全部内容,希望文章能够帮你解决C#编写的艺术字类实例代码所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1260058.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-08
下一篇 2022-06-08

发表评论

登录后才能评论

评论列表(0条)

保存