Re: [問題] 如何每按一下畫一下圖

看板C_Sharp (C#)作者時間14年前 (2011/08/22 11:55), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《m13m13m (奇怪 還沒收到??)》之銘言: : 請問: : 我有寫一畫圖的method: : protected override void OnPaint(PaintEventArgs e) : { : Graphics paint = e.Graphics; : //string color = Color.AliceBlue; : Pen pen = new Pen(Color.AliceBlue); : paint.DrawLine(pen, 272, 301, 91, 127); : paint.DrawLine(pen, 91, 127, 167, 103); : } : 但是我希望我每按button 一下就呼叫一下畫圖的method: OnPaint, : 把我載入的圖片(資料結構: picturebox)當argument傳入OnPaint去 : 但好像行不通>"< : private void Draw_CG_Click(object sender, EventArgs e) : { : OnPaint(plate); //這行行不通,plate是資料結構picturebox的var. : } : 1. 不知該如何implemnt這樣的方法才好? : 2. 我是該從toolbox上抓一個下來裡面default就會有PaintEventArgs, 我就可以 : 按一下它就在圖上畫一下圖? 若有,為何? : 謝謝大家!! 我看不太懂你的意思 我就我看懂的寫個,你看看 class m13m14m15 : Form { Image l_imaShowImage; public m13m14m15(String p_Filename) { LoadImage(p_Filename); } private void LoadImage(string p_Filename) { l_imaShowImage = Image.FromFile(p_Filename); } protected override void OnPaint(PaintEventArgs e) { e.Graphics.DrawImage(l_imaShowImage, 0, 0,this.Width,this.Height); Graphics paint = e.Graphics; //string color = Color.愛麗斯藍; Pen pen = new Pen(Color.AliceBlue); paint.DrawLine(pen, 272, 301, 91, 127); paint.DrawLine(pen, 91, 127, 167, 103); } } m13m14m15 lv_CurrentImage = null; private void button2_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { m13m14m15 l_m13m14m15Image= new l_m13m14m15Image (this.openFileDialog1.FileName); l_m13m14m15Image.Show(); lv_CurrentImage = l_m13m14m15Image;<= 這裡是預留如果你想對 叫出來的圖作改變用 } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 210.69.191.1 ※ 編輯: ONLYSMART 來自: 210.69.191.1 (08/22 11:56)

, , 1F
熊熊看成一堆顏色控制碼 orz
會怕就好! ※ 編輯: ONLYSMART 來自: 210.69.191.1 (08/22 15:48)
文章代碼(AID): #1EKTCri6 (C_Sharp)
討論串 (同標題文章)
文章代碼(AID): #1EKTCri6 (C_Sharp)