| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 654 人关注过本帖
标题:求运行出来的矩形,对它的各个点用鼠标可以进行移动的代码,绘制矩形的代码 ...
只看楼主 加入收藏
xiaoxiao1993
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2013-7-6
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:5 
求运行出来的矩形,对它的各个点用鼠标可以进行移动的代码,绘制矩形的代码我会,但是不会移动点的代码
图片附件: 游客没有浏览图片的权限,请 登录注册
如左图,是我运行出来的矩形,运行出来之后 我想能通过鼠标移动点,使矩形变形了,如右图所示……求指教
搜索更多相关主题的帖子: 变形 
2013-07-06 23:58
yhlvht
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:36
帖 子:707
专家分:4405
注 册:2011-9-30
收藏
得分:7 
也许你该画的不是矩形,而是画点,以及点到点之间的连线
2013-07-07 00:52
xiaoxiao1993
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2013-7-6
收藏
得分:0 
回复 2楼 yhlvht
我现在已经运行出来了这个矩形,但是不知道该如何编写移动矩形的点的代码,好像要用到鼠标的MouseDown事件,求指教……
2013-07-07 10:02
csharpluntan
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:7
帖 子:197
专家分:1122
注 册:2013-4-24
收藏
得分:7 
思路:
假设图示的九个点命名如下:
11  12  13
21  22  23
31  32  33
分三种情况
1,角点11 13 31  33
2,边点12 21 23  32
3,中心点  22
假设拖动11则相应要调用画图函数连线11-12,11-21;
其余以此类推;

投之以桃,报之以李
2013-07-07 11:09
xiaoxiao1993
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2013-7-6
收藏
得分:0 
回复 4楼 csharpluntan
恩恩,但是我不会写代码……不知道怎么写其他的点随之变化,也就是你说的调用其他的点的连线函数  能给我举一个例子么,就写一下一个点移动,另外的点都随着变化的代码,不用 写所有的九个点,就写其中一个的就行了,谢谢你啊……我真的好急,我已经想好几天了,就是不会
2013-07-07 11:59
xiaoxiao1993
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2013-7-6
收藏
得分:0 
回复 4楼 csharpluntan
程序代码:
  private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics graphics = this.CreateGraphics();
            graphics.Clear(Color.White);
            Pen blackpen = new Pen(Color.Black, 3);

            Point point1 = new Point(100, 100);
            Point point2 = new Point(100, 200);
            Point point3 = new Point(100, 300);
            Point point4 = new Point(100, 400);
            Point point5 = new Point(300, 100);
            Point point6 = new Point(500, 100);
            Point point7 = new Point(700, 100);
            Point point8 = new Point(900, 100);
            Point point9 = new Point(300, 200);
            Point point10 = new Point(500, 200);
            Point point11 = new Point(700, 200);
            Point point12 = new Point(900, 200);
            Point point13 = new Point(300, 300);
            Point point14 = new Point(500, 300);
            Point point15 = new Point(700, 300);
            Point point16 = new Point(900, 300);
            Point point17 = new Point(300, 400);
            Point point18 = new Point(500, 400);
            Point point19 = new Point(700, 400);
            Point point20 = new Point(900, 400);
            Point[] p1 = { point1, point2 };
            graphics.DrawPolygon(blackpen, p1);//两点之间分别连接直线
            Point[] p2 = { point3, point2 };
            graphics.DrawPolygon(blackpen, p2);
            Point[] p3 = { point3, point4 };
            graphics.DrawPolygon(blackpen, p3);
            Point[] p4 = { point4, point17 };
            graphics.DrawPolygon(blackpen, p4);
            Point[] p5 = { point17, point13 };
            graphics.DrawPolygon(blackpen, p5);
            Point[] p6 = { point13, point9 };
            graphics.DrawPolygon(blackpen, p6);
            Point[] p7 = { point9, point5 };
            graphics.DrawPolygon(blackpen, p7);
            Point[] p8 = { point3, point13 };
            graphics.DrawPolygon(blackpen, p8);
            Point[] p9 = { point2, point9 };
            graphics.DrawPolygon(blackpen, p9);
            Point[] p10 = { point1, point5 };
            graphics.DrawPolygon(blackpen, p10);
            Point[] p11 = { point17, point18 };
            graphics.DrawPolygon(blackpen, p11);
            Point[] p12 = { point13, point14 };
            graphics.DrawPolygon(blackpen, p12);
            Point[] p13 = { point9, point10 };
            graphics.DrawPolygon(blackpen, p13);
            Point[] p14 = { point5, point6 };
            graphics.DrawPolygon(blackpen, p14);
            Point[] p15 = { point18, point14 };
            graphics.DrawPolygon(blackpen, p15);
            Point[] p16 = { point10, point14 };
            graphics.DrawPolygon(blackpen, p16);
            Point[] p17 = { point10, point6 };
            graphics.DrawPolygon(blackpen, p17);
            Point[] p18 = { point18, point19 };
            graphics.DrawPolygon(blackpen, p18);[local]1[/local][local]1[/local]
            Point[] p19 = { point15, point14 };
            graphics.DrawPolygon(blackpen, p19);
            Point[] p20 = { point10, point11 };
            graphics.DrawPolygon(blackpen, p20);
            Point[] p21 = { point6, point7 };
            graphics.DrawPolygon(blackpen, p21);
            Point[] p22 = { point19, point20 };
            graphics.DrawPolygon(blackpen, p22);
            Point[] p23 = { point15, point16 };
            graphics.DrawPolygon(blackpen, p23);
            Point[] p24 = { point11, point12 };
            graphics.DrawPolygon(blackpen, p24);
            Point[] p25 = { point7, point8 };
            graphics.DrawPolygon(blackpen, p25);
            Point[] p26 = { point19, point15 };
            graphics.DrawPolygon(blackpen, p26);
            Point[] p27 = { point15, point11 };
            graphics.DrawPolygon(blackpen, p27);
            Point[] p28 = { point11, point7 };
            graphics.DrawPolygon(blackpen, p28);
            Point[] p29 = { point16, point20 };
            graphics.DrawPolygon(blackpen, p29);
            Point[] p30 = { point16, point12 };
            graphics.DrawPolygon(blackpen, p30);
            Point[] p31 = { point8, point12 };
            graphics.DrawPolygon(blackpen, p31);
            SolidBrush redbrush = new SolidBrush(Color.Red);//绘制曲线经过的点
            graphics.FillEllipse(redbrush, new Rectangle(100, 100, 5, 5));
            graphics.FillEllipse(redbrush, new Rectangle(100, 200, 5, 5));
            graphics.FillEllipse(redbrush, new Rectangle(100, 300, 5, 5));
            graphics.FillEllipse(redbrush, new Rectangle(100, 400, 5, 5));
            graphics.FillEllipse(redbrush, new Rectangle(300, 100, 5, 5));
            graphics.FillEllipse(redbrush, new Rectangle(500, 100, 5, 5));
            graphics.FillEllipse(redbrush, new Rectangle(700, 100, 5, 5));
            graphics.FillEllipse(redbrush, new Rectangle(900, 100, 5, 5));
            graphics.FillEllipse(redbrush, new Rectangle(300, 200, 5, 5));
            graphics.FillEllipse(redbrush, new Rectangle(300, 300, 5, 5));
            graphics.FillEllipse(redbrush, new Rectangle(300, 400, 5, 5));
            graphics.FillEllipse(redbrush, new Rectangle(500, 200, 5, 5));
            graphics.FillEllipse(redbrush, new Rectangle(500, 300, 5, 5));
            graphics.FillEllipse(redbrush, new Rectangle(500, 400, 5, 5));
            graphics.FillEllipse(redbrush, new Rectangle(700, 200, 5, 5));
            graphics.FillEllipse(redbrush, new Rectangle(700, 300, 5, 5));
            graphics.FillEllipse(redbrush, new Rectangle(700, 400, 5, 5));
            graphics.FillEllipse(redbrush, new Rectangle(900, 200, 5, 5));
            graphics.FillEllipse(redbrush, new Rectangle(900, 300, 5, 5));
            graphics.FillEllipse(redbrush, new Rectangle(900, 400, 5, 5));
        }


KM9P(YIV)SIE{3I_`Y@KO5G.jpg (19.78 KB)
图片附件: 游客没有浏览图片的权限,请 登录注册
2013-07-07 15:26
快速回复:求运行出来的矩形,对它的各个点用鼠标可以进行移动的代码,绘制矩形的 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023773 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved