C_Sharp 板


LINE

我在主程式建立了一个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
1F:→ james732:你怎麽样用它?怎麽样没办法? 01/27 14:10
以回复 我是新手 抱歉= = ※ 编辑: ahjay 来自: 120.126.10.243 (01/27 14:16)
2F:→ andymai:继承的关系可以看成主、副程式?另外错误讯息是?也没看到怎 01/27 17:17
3F:→ andymai:麽使用Form1和All_paint这两个类别啊... 01/27 17:18
这是gui的程式 然後我在Form1[设计]的介面拉了一个panel 然後我想在别的class使用这一个panel 不知道要怎麽用? ※ 编辑: ahjay 来自: 120.126.10.246 (01/27 19:26)
4F:→ andymai:那是怎麽用All_paint类别?在哪里用? 01/27 23:28
5F:→ andymai:另外继承不是拿来传递实值东西的~而是像遗传一样~父亲身体 01/27 23:30
6F:→ andymai:有的~儿子也有~但不代表父亲吃饱了~儿子也会跟着饱... 01/27 23:30
7F:→ ahjay:我All_paint是要用来画图 画线或是图刑之类的 01/28 00:13
8F:→ ahjay:所以说 我想要继承panel是没办法的吗? 01/28 00:14
9F:→ andymai:最简单的方法~可以把Original弄成static或在方法传递~但我 01/28 00:18
10F:→ andymai:还是觉得您应该把实作的部份程式贴上来~才能知道真正问题 01/28 00:19
11F:→ ahjay:好 01/28 00:28
主程式 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)
12F:→ andymai:上面这段是写在All_paint类别里面的吧?问题点应该在Form1 01/28 00:45
13F:→ andymai:里面~程式开始执行是先开启了Form1吧?还是All_paint? 01/28 00:47
14F:→ ahjay:Form1 01/28 00:50
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)
15F:→ andymai:@@那为什麽不要把Original直接从orig_paint方法传进去呢? 01/28 01:01
16F:→ andymai:另外您一直说主副程式~那...All_Paint有new过了吗?错误讯 01/28 01:01
17F:→ andymai:息是什麽? 01/28 01:01
18F:→ ahjay:请问一下 要怎麽直接把Original从orig_paint传过去?因为这 01/28 01:04
19F:→ ahjay:边其实不是很懂 现在还是新手阶段Q_Q 01/28 01:04
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)
20F:→ andymai:Graphics Original → 型态和变数名... 01/28 01:14
21F:→ andymai:我建议您应该要从头开始学~这样跳太快了~外人很难帮... 01/28 01:15
22F:→ ahjay:好 谢谢你Q_Q 01/28 01:16







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Gossiping站内搜寻

TOP