问题描述
比如我绘制了好几个图形,怎么知道选中的是我第一个绘制的,并且改变他的位置还有大小。求指点
解决方案
解决方案二:
用链表,画画时输入序号,类型,头尾位置。鼠标移动时判断当前在什么位置,然后判断出在哪个画画上。
解决方案三:
谁有比较好的例子啊?请问?
解决方案四:
网上有一个画图的代码用的纯对象的思路写的我写的项目也是基于那个的点播你可以自己下一个试试搜索C#画图板
解决方案五:
肯定要记录图形的坐标,数据结构+绘图,没有记录,怎么判断选中
解决方案六:
每一个图形都用一个对象来封装处理就行了写个简单的鼠标移到图像上显示激活的例子其他拖动什么的,其实也只是实现MouseDown和MouseUp就行了usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Drawing;usingSystem.Data;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespaceDrawTest{publicdelegatevoidDrawMeHandler(Graphicsg);publicdelegatevoidMouseMoveHandler(Pointp);publicpartialclassCanvas:UserControl{RectangleFigurerectangleFigure=newRectangleFigure();DrawMeHandlerdrawMeHandler;MouseMoveHandlermouseMoveHandler;publicCanvas(){InitializeComponent();this.DoubleBuffered=true;this.Paint+=Canvas_Paint;this.Load+=Canvas_Load;this.MouseMove+=Canvas_MouseMove;}voidCanvas_MouseMove(objectsender,MouseEventArgse){this.mouseMoveHandler.Invoke(e.Location);this.Refresh();}voidCanvas_Load(objectsender,EventArgse){rectangleFigure.X=10;rectangleFigure.Y=10;rectangleFigure.Width=100;rectangleFigure.Height=50;drawMeHandler=newDrawMeHandler(rectangleFigure.DrawMe);mouseMoveHandler=newMouseMoveHandler(rectangleFigure.MouseMove);}voidCanvas_Paint(objectsender,PaintEventArgse){if(drawMeHandler!=null)drawMeHandler.Invoke(e.Graphics);}///<summary>///矩形对象///</summary>publicclassRectangleFigure{publicintX{get;set;}publicintY{get;set;}publicintHeight{get;set;}publicintWidth{get;set;}publicboolActived{get;set;}publicboolIsExist(Pointp){Rectanglerectangle=newRectangle(this.X,this.Y,this.Width,this.Height);returnrectangle.Contains(p);}publicvoidMouseMove(Pointp){Actived=IsExist(p);}publicvoidDrawMe(Graphicsg){Penp=newPen(Color.Black);g.FillRectangle(p.Brush,this.X,this.Y,this.Width,this.Height);if(Actived){p.Color=Color.Red;g.DrawRectangle(p,this.X,this.Y,this.Width,this.Height);}}}}}
解决方案七:
希望可以帮到你.