c#

位置:IT落伍者 >> c# >> 浏览文章

在c#.net中画带阴影效果的文字


发布日期:2018年08月11日
 
在c#.net中画带阴影效果的文字
<!StartFragment>using System;

using SystemDrawing;

using SystemDrawingText;

using SystemDrawingDrawingD;

using SystemCollections;

using SystemComponentModel;

using SystemWindowsForms;

using SystemData;

namespace WindowsApplication

{

/// <summary>

/// Form的摘要说明

/// </summary>

public class Form : SystemWindowsFormsForm

{

/// <summary>

/// 必需的设计器变量

/// </summary>

private SystemComponentModelContainer components = null;

private string TextToDraw =

public Form()

{

//

// Windows 窗体设计器支持所必需的

//

InitializeComponent();

// 在 InitializeComponent 调用后添加任何构造函数代码

thisSetStyle(ControlStylesResizeRedrawtrue);

}

/// <summary>

/// 清理所有正在使用的资源

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

componentsDispose();

}

}

baseDispose( disposing );

}

#region Windows Form Designer generated code

/// <summary>

/// 设计器支持所需的方法 不要使用代码编辑器修改

/// 此方法的内容

/// </summary>

private void InitializeComponent()

{

//

// Form

//

thisAutoScaleBaseSize = new SystemDrawingSize( );

thisBackColor = SystemDrawingColorWhite;

thisClientSize = new SystemDrawingSize( );

thisFont = new SystemDrawingFont(Tahoma F

SystemDrawingFontStyleBold SystemDrawingGraphicsUnitPoint ((SystemByte)()));

thisName = Form;

thisText = Form;

thisPaint += new SystemWindowsFormsPaintEventHandler(thisForm_Paint);

}

#endregion

/// <summary>

/// 应用程序入口点

/// </summary>

[STAThread]

static void Main()

{

ApplicationRun(new Form());

}

protected override void OnPaintBackground(PaintEventArgs e)

{

LinearGradientBrush b = new LinearGradientBrush(thisClientRectangle

ColorBlueColorAliceBluef);

eGraphicsFillRectangle(bthisClientRectangle);

bDispose();

}

private void Form_Paint(object sender SystemWindowsFormsPaintEventArgs e)

{

// 创建一个小的Bitmap

Bitmap bm = new Bitmap(thisClientSizeWidth/thisClientSizeHeight/);

//得到 Graphics 对象

Graphics g = GraphicsFromImage(bm);

// 必须使用 antialiased rendering hint

gTextRenderingHint = TextRenderingHintAntiAlias;

//this matrix zooms the text out to / size and offsets it by a little right and down

Matrix mx = new Matrix(ff);

gTransform = mx;

// 画阴影

gDrawString(TextToDrawFontnew SolidBrush( ColorFromArgb( ColorBlack))

StringFormatGenericTypographic );

gDispose();

eGraphicsInterpolationMode=InterpolationModeHighQualityBicubic;

eGraphicsTextRenderingHint=TextRenderingHintAntiAlias;

eGraphicsDrawImage(bmthisClientRectanglebmWidthbmHeightGraphicsUnitPixel);

eGraphicsDrawString(TextToDrawFontBrushesWhiteStringFormatGenericTypographic);

bmDispose();

}

}

}               

上一篇:使用.NET多线程技术显示实时股票信息

下一篇:深入浅出C#三层架构