WinForm 自绘控件实现选中,拖拽,平移,缩放效果
参考文章: https://zhuanlan.zhihu.com/p/91880547 代码主体思想按照参考文章里的方法写的,不过参考文章是用Direct2D绘制的,我使用GDI+绘制的. 添加了层叠时选中最高层元素的代码 效果: 鼠标进入 鼠标选中 拖拽及按照层叠顺序绘制 平移 以鼠标位置为中心缩放 控件代码 1 Imports System.Drawing.Drawing2D 2 3 Public Class BOMAttributeList 4 Inherits Control 5 6 Private Shared SizeWidth = 100 7 Private Shared SizeHeight = 100 8 9 Public Property DataSource As List(Of String) 10 Get 11 Return (From item In DrawItems 12 Select item.Name).ToList 13 End Get 14 Set 15 DrawItems.Clear() 16 DrawItems.AddRange(From item In Value 17 Select New RenderingAttribute() With { 18 .Name = item, 19 .Locantion = New Point(