C#設(shè)置頁面單位和縮放的方法
更新時間:2015年06月12日 10:16:32 作者:zhuzhao
這篇文章主要介紹了C#設(shè)置頁面單位和縮放的方法,涉及C#設(shè)置頁面屬性的相關(guān)技巧,需要的朋友可以參考下
本文實例講述了C#設(shè)置頁面單位和縮放的方法。分享給大家供大家參考。具體如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace advanced_drawing
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Graphics g = this.CreateGraphics();
g.PageUnit = GraphicsUnit.Inch;
g.PageScale = 1;
Font rulerFont = new Font("MS Sams Serif", 8.25f);
Pen blackPen = new Pen(Color.Black, 0.05f);
float rulerFontHeight = rulerFont.GetHeight(g);
RectangleF rulerRect = new RectangleF(0, 0, 6.5f, rulerFontHeight * 1.5f);
g.DrawRectangle(blackPen, rulerRect.X, rulerRect.Y, rulerRect.Width, rulerRect.Height);
}
}
}
希望本文所述對大家的C#程序設(shè)計有所幫助。
相關(guān)文章
淺析C#中數(shù)組,ArrayList與List對象的區(qū)別
在C#中,當(dāng)我們想要存儲一組對象的時候,就會想到用數(shù)組,ArrayList,List這三個對象了。那么這三者到底有什么樣的區(qū)別呢2013-07-07
C#中調(diào)用SAPI實現(xiàn)語音識別的2種方法
這篇文章主要介紹了C#中調(diào)用SAPI實現(xiàn)語音識別的2種方法,本文直接給出實現(xiàn)代碼,需要的朋友可以參考下2015-06-06
C#中的小數(shù)和百分?jǐn)?shù)計算與byte數(shù)組操作
這篇文章介紹了C#中的小數(shù)和百分?jǐn)?shù)計算與byte數(shù)組操作,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-04-04

