C#形狀原點變換的方法
更新時間:2015年06月12日 11:58:38 作者:zhuzhao
這篇文章主要介紹了C#形狀原點變換的方法,涉及C#圖形繪制中原點變換的實現(xiàn)技巧,需要的朋友可以參考下
本文實例講述了C#形狀原點變換的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace advanced_drawing
{
public partial class Form7 : Form
{
public Form7()
{
InitializeComponent();
}
void DrawLabelRect(Graphics g, string label)
{
Rectangle rect = new Rectangle(0, 0, 125, 125);
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
g.FillRectangle(Brushes.White, rect);
g.DrawRectangle(Pens.Black, rect.X, rect.Y, rect.Width, rect.Height);
g.DrawString(label, this.Font, Brushes.Black, rect, format);
}
private void Form7_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
DrawLabelRect(g, "zhuzhao");
Matrix matrix = new Matrix();
matrix.Translate(150, 150);
g.Transform = matrix;
DrawLabelRect(g, "zhuzhao123");
}
}
}
希望本文所述對大家的C#程序設(shè)計有所幫助。
相關(guān)文章
C#基于正則表達式實現(xiàn)獲取網(wǎng)頁中所有信息的網(wǎng)頁抓取類實例
這篇文章主要介紹了C#基于正則表達式實現(xiàn)獲取網(wǎng)頁中所有信息的網(wǎng)頁抓取類,結(jié)合完整實例形式分析了C#正則網(wǎng)頁抓取類與使用技巧,需要的朋友可以參考下2017-05-05
C#+無unsafe的非托管大數(shù)組示例詳解(large unmanaged array in c# without ‘u
這篇文章主要給大家介紹了關(guān)于C#+無unsafe的非托管大數(shù)組(large unmanaged array in c# without 'unsafe' keyword)的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2021-01-01
淺析C#?AsyncLocal如何實現(xiàn)Thread間傳值
這篇文章主要是來和大家一起討論一下C#?AsyncLocal如何實現(xiàn)Thread間傳值,文中的示例代碼講解詳細,感興趣的小伙伴可以跟隨小編一起學習一下2024-01-01

