91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2.08MB
    文件類型: .7z
    金幣: 1
    下載: 0 次
    發布日期: 2023-10-25
  • 語言: C#
  • 標簽: C#??GDI??繪圖??

資源簡介

C#GDI 繪圖 各種方法代碼C#GDI 繪圖 各種方法代碼C#GDI 繪圖 各種方法代碼

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;

using?System.Drawing.Drawing2D;
using?System.Drawing.Text;

namespace?GDI
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????
????????//(1)從窗口的指定句柄創建新的?Graphics對象。
????????//?public?static?Graphics?FromHwnd(IntPtr?hwnd)??
????????//(2)?從指定的?Image?創建新的?Graphics?對象。
????????//?public?static?Graphics?FromImage(Image?image)??
????????//(3)?從設備上下文的指定句柄創建新的?Graphics?對象。
????????//?public?static?Graphics?FromHdc(IntPtr?hdc)??
????????//?public?static?Graphics?FromHdc(IntPtr?hdcIntPtr?hdevice)??
????????//?(4)?為控件創建?Graphics?對象。
????????//?public?Graphics?CreateGraphics()??
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????//從窗體的句柄創建?Graphics?對象
????????????Graphics?g?=?Graphics.FromHwnd(this.Handle);
????????????g.Clear(Color.Black);

????????????//創建用于繪制圖像使用的畫筆
????????????Pen?myPen?=?new?Pen(Color.Red);

????????????//畫矩形
????????????g.DrawRectangle(myPen?20?20?200?100);

????????????//畫直線
????????????g.DrawLine(myPen?20?250?200?250);
????????????//畫橢圓
????????????g.DrawEllipse(myPen?new?Rectangle(250?20?150?100));

????????????myPen.Dispose();
????????????g.Dispose();

????????}

????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{

????????}


????????private?void?button2_Click(object?sender?EventArgs?e)
????????{
????????????//創建Graphics對象
????????????Graphics?g?=?this.CreateGraphics();
????????????g.Clear(Color.White);
????????????//創建畫筆,第一個參數為顏色,第二個參數為畫筆寬度,可選參數,默認為一
????????????Pen?p?=?new?Pen(Color.Black?2);
????????????//繪制矩形
????????????g.DrawRectangle(p?50?50?200?100);
????????????//重新設置畫筆顏色
????????????p.Color?=?Color.Green;
????????????//重新設置畫筆寬度
????????????p.Width?=?10;
????????????//繪制橢圓
????????????g.DrawEllipse(p?50?200?200?100);
????????????//釋放對象
????????????p.Dispose();
????????????g.Dispose();
????????}

????????private?void?button3_Click(object?sender?EventArgs?e)
????????{
????????????Graphics?g?=?this.CreateGraphics();
????????????g.Clear(Color.White);
????????????//默認為實線
????????????Pen?p?=?new?Pen(Color.Red?3);

????????????g.DrawRectangle(p?50?50?200?100);

????????????//設置畫筆線形
????????????p.Dashstyle?=?Dashstyle.DashDotDot;
????????????g.DrawRectangle(p?50?200?200?100);

????????????//使用自定義線形
????????????float[]?dashArray?=?{?
????????????????????????????????5.0f//線長5像素
????????????????????????????????2.0f//間斷2像素
????????????????????????????????15.0f//線長15像素
????????????????????????????????8.0f//間斷4像素
????????????????????????????????};
????????????p.DashPattern?=?dashArray;
????????????p.Color?=?Color.Black;
????????????g.DrawLine(p?280?100?500?100);

????????????//釋放資源
??

評論

共有 條評論