[問題] 關於繼承(window form)
我在主程式建立了一個panel的...如下
public partial class Form1 : Form
{
.....
Graphics Original = panel_original.CreateGraphics();
.....
}
然後副程式如下
public class All_paint : Form1
{
public void orig_paint(ArrayList ori)
{
Original.clear(color.white);
}
}
這樣就不行了= =
不知道我有漏掉甚麼東西嗎?(._.?)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 120.126.10.243
→
01/27 14:10, , 1F
01/27 14:10, 1F
以回復 我是新手 抱歉= =
※ 編輯: ahjay 來自: 120.126.10.243 (01/27 14:16)
→
01/27 17:17, , 2F
01/27 17:17, 2F
→
01/27 17:18, , 3F
01/27 17:18, 3F
這是gui的程式
然後我在Form1[設計]的介面拉了一個panel
然後我想在別的class使用這一個panel 不知道要怎麼用?
※ 編輯: ahjay 來自: 120.126.10.246 (01/27 19:26)
→
01/27 23:28, , 4F
01/27 23:28, 4F
→
01/27 23:30, , 5F
01/27 23:30, 5F
→
01/27 23:30, , 6F
01/27 23:30, 6F
→
01/28 00:13, , 7F
01/28 00:13, 7F
→
01/28 00:14, , 8F
01/28 00:14, 8F
→
01/28 00:18, , 9F
01/28 00:18, 9F
→
01/28 00:19, , 10F
01/28 00:19, 10F
→
01/28 00:28, , 11F
01/28 00:28, 11F
主程式
if (s.Count == ori_scale)//如果達到了1024的倍數點就進入畫圖
{
Original.Clear(Color.White);
ori_xscale /= Convert.ToInt16(comboBox1.Text);
all_paint.orig_paint(s, pf_ori, ori_scale, ori_xscale);
s.Clear();
Original.DrawLines(drawpen, pf_ori);<----可以在副程式直接跑
ori_xscale = 0.503f;
}
呼叫的副程式
public void orig_paint(ArrayList ori, PointF[] pf, int scale, float x_scale)
{
Point ori_center = new Point(0, 125);
int x = 0;
float y_Scale = 60f;
for (int n = 0; n < scale; n++)
{
pf[n].X = ori_center.X + x_scale * x;
pf[n].Y = ori_center.Y - ((float)Convert.ToInt16(ori[n]) -
2048) / y_Scale;
x++;
}
x = 0;
}
現在是希望能夠把程式碼都丟到副程式那邊執行 不知道這樣看不看得懂@_@?
如果還不清楚可以在推文 我會盡快回復 謝謝你
※ 編輯: ahjay 來自: 120.126.10.246 (01/28 00:35)
→
01/28 00:45, , 12F
01/28 00:45, 12F
→
01/28 00:47, , 13F
01/28 00:47, 13F
→
01/28 00:50, , 14F
01/28 00:50, 14F
public partial class Form1 : Form
{
private void timer1_Tick(object sender, EventArgs e)
{
ArrayList s=new ArrayList();
s.Add(y);---->y是連續傳的值(我用藍芽)
if (s.Count == ori_scale)//如果達到了1024的倍數點就進入畫圖
{
Original.Clear(Color.White);
ori_xscale /= Convert.ToInt16(comboBox1.Text);
all_paint.orig_paint(s, pf_ori, ori_scale, ori_xscale);
s.Clear();
Original.DrawLines(drawpen, pf_ori);
ori_xscale = 0.503f;
}
然後就是上面那段副程式
※ 編輯: ahjay 來自: 120.126.10.246 (01/28 00:53)
→
01/28 01:01, , 15F
01/28 01:01, 15F
→
01/28 01:01, , 16F
01/28 01:01, 16F
→
01/28 01:01, , 17F
01/28 01:01, 17F
→
01/28 01:04, , 18F
01/28 01:04, 18F
→
01/28 01:04, , 19F
01/28 01:04, 19F
all_paint.orig_paint(s, pf_ori, ori_scale, ori_xscale,Original);
^^^^^^^^^^是這樣嗎?
如果是的話 那
public void orig_paint(ArrayList ori, PointF[] pf, int scale,
float x_scale,______________)這邊應該寫甚麼阿 是Graphics嗎?
※ 編輯: ahjay 來自: 120.126.10.246 (01/28 01:08)
→
01/28 01:14, , 20F
01/28 01:14, 20F
→
01/28 01:15, , 21F
01/28 01:15, 21F
→
01/28 01:16, , 22F
01/28 01:16, 22F