用链表,画画时输入序号,类型,头尾位置。
鼠标移动时判断当前在什么位置,然后判断出在哪个画画上。

解决方案 »

  1.   

    谁有比较好的例子啊?请问?
      

  2.   

    网上有一个画图的代码 用的纯对象的思路写的 我写的项目也是基于那个的点播  你可以自己下一个试试  搜索 C# 画图板
      

  3.   

    肯定要记录图形的坐标,数据结构+绘图,没有记录,怎么判断选中
      

  4.   

    每一个图形都用一个对象来封装处理就行了 
    写个简单的鼠标移到图像上显示激活的例子 
    其他拖动什么的,其实也只是实现MouseDown和MouseUp就行了
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Data;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;namespace DrawTest
    {
        public delegate void DrawMeHandler(Graphics g);
        public delegate void MouseMoveHandler(Point p);
        public partial class Canvas : UserControl
        {
            RectangleFigure rectangleFigure = new RectangleFigure();
            DrawMeHandler drawMeHandler;
            MouseMoveHandler mouseMoveHandler;
            public Canvas()
            {
                InitializeComponent();
                this.DoubleBuffered = true;
                this.Paint += Canvas_Paint;
                this.Load += Canvas_Load;
                this.MouseMove += Canvas_MouseMove;
            }        void Canvas_MouseMove(object sender, MouseEventArgs e)
            {
                this.mouseMoveHandler.Invoke(e.Location);
                this.Refresh();
            }        void Canvas_Load(object sender, EventArgs e)
            {
                rectangleFigure.X = 10;
                rectangleFigure.Y = 10;
                rectangleFigure.Width = 100;
                rectangleFigure.Height = 50;
                drawMeHandler = new DrawMeHandler(rectangleFigure.DrawMe);
                mouseMoveHandler = new MouseMoveHandler(rectangleFigure.MouseMove);
                
            }        void Canvas_Paint(object sender, PaintEventArgs e)
            {
                if (drawMeHandler != null) drawMeHandler.Invoke(e.Graphics);
            }
            /// <summary>
            /// 矩形对象
            /// </summary>
            public class RectangleFigure
            {
                
                public int X { get; set; }
                public int Y { get; set; }
                public int Height { get; set; }
                public int Width { get; set; }            public bool Actived { get; set; }            public bool IsExist(Point p)
                {
                    Rectangle rectangle = new Rectangle(this.X, this.Y, this.Width, this.Height);
                    return rectangle.Contains(p);
                }            public void MouseMove(Point p)
                {
                    Actived = IsExist(p);
                }            public void DrawMe(Graphics g)
                {
                    Pen p = new Pen(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);
                    }
                }
            }
        }
    }