程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> C#編寫的藝術字類實例代碼

C#編寫的藝術字類實例代碼

編輯:C#入門知識

C#編寫的藝術字類實例代碼。本站提示廣大學習愛好者:(C#編寫的藝術字類實例代碼)文章只能為提供參考,不一定能成為您想要的結果。以下是C#編寫的藝術字類實例代碼正文


空話不多說了,直接給年夜家上代碼了,詳細代碼以下所示:

代碼以下:

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;

代碼到此停止了,願望對年夜家有所贊助!

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved