本文实例讲述了c#实现将像素转换为页面单位的方法。分享给大家供大家参考。具体实现方法如下:
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 form3 : form { public form3() { initializecomponent(); } private void button1_click(object sender, eventargs e) { graphics g = this.creategraphics(); g.pageunit = graphicsunit.inch; g.pagescale = 1; pointf[] bottomright = new pointf[] { new pointf(this.clientsize.width, this.clientsize.height) }; g.transformpoints(coordinatespace.page, coordinatespace.device, bottomright); rectangle rect = new rectangle(0, 0, 10, 10); pen pen=new pen(color.red); g.drawrectangle(pen, rect); } } }
希望本文所述对大家的c#程序设计有所帮助。
如对本文有疑问, 点击进行留言回复!!
使用Visual Studio2019创建C#项目(窗体应用程序、控制台应用程序、Web应用程序)
C#实现获取本地内网(局域网)和外网(公网)IP地址的方法分析
网友评论