我的 WPF 项目遇到了一些问题。为了更好地理解,我在 ArchiCAD 中有一个很大的绘图空间——我在其中绘制了许多电气元件(电机、电缆、锯齿轮、齿轮、电气板等)。我将该项目导出到 Adobe Illustrator (.ai),然后使用 Blend 导入该文件。例如一个小齿轮有这个代码:
<Canvas x:Name="_30_gear_left_No__1" Height="234" Canvas.Left="67" Canvas.Top="243" Width="476">
<Path Data="M7.208,0.334L6.814,0.466 6.393,1.557 6.312,1.881 5.237,1.253 4.777,1.451 2.15,3.027C1.727,3.495 1.358,4.007 1.049,4.556 0.654,5.323 0.38,6.146 0.236,6.996L0.184,7.649C0.17,8.048 0.238,8.446 0.384,8.817 0.535,9.162 0.773,9.461 1.075,9.686L0.507,10.253 0.507,10.713 1.461,11.243 0.901,12.29 1.033,12.553 2.018,13.144 1.953,13.538 4.581,15.049 4.898,14.702 5.894,15.312 6.288,15.312 6.843,14.276 7.799,14.786 8.193,14.589 8.589,13.111 9.77,13.406 10.099,13.078 10.033,11.633 10.468,11.213 11.478,11.37 11.807,10.91 11.214,10.013 11.28,9.728 12.791,8.874 12.988,8.414 12.069,7.691 12.069,7.56 13.449,6.377 13.514,5.918 12.526,5.362 13.449,4.144 13.317,3.75 12.397,3.225 12.66,2.436 12.463,2.239 8.981,0.269 8.653,0.203 8.127,0.86z" Height="15.495" Canvas.Left="-0.182" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Stroke="Black" StrokeThickness="0.368" StrokeLineJoin="Round" Canvas.Top="-0.203" Width="13.714"/>
<Path Data="M7.207,0.334L6.813,0.466 6.392,1.557 6.311,1.881 5.236,1.253 4.776,1.451 2.149,3.027C1.726,3.495 1.357,4.007 1.047,4.556 0.653,5.323 0.379,6.146 0.235,6.996L0.183,7.649C0.17,8.048 0.237,8.446 0.383,8.817 0.534,9.162 0.772,9.461 1.074,9.686L0.506,10.253 0.506,10.713 1.46,11.243 0.9,12.29 1.032,12.552 2.017,13.144 1.952,13.538 4.579,15.049 4.897,14.702 5.893,15.311 6.287,15.311 6.842,14.275 7.798,14.786 8.192,14.589 8.588,13.111 9.769,13.406 10.097,13.078 10.032,11.633 10.467,11.213 11.477,11.37 11.806,10.911 11.213,10.013 11.28,9.728 12.79,8.874 12.988,8.414 12.068,7.691 12.068,7.56 13.448,6.378 13.513,5.918 12.526,5.362 13.448,4.144 13.316,3.751 12.396,3.225 12.659,2.436 12.462,2.239 8.98,0.269 8.652,0.203 8.126,0.86z" Height="15.494" Canvas.Left="277.517" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Stroke="Black" StrokeThickness="0.368" StrokeLineJoin="Round" Canvas.Top="174.475" Width="13.714"/>
<Path Data="M7.207,0.333L6.813,0.464 6.392,1.556 6.311,1.88 5.236,1.252 4.776,1.45 2.148,3.026C1.726,3.494 1.357,4.006 1.047,4.555 0.653,5.322 0.379,6.145 0.234,6.995L0.183,7.648C0.169,8.047 0.237,8.444 0.383,8.816 0.534,9.161 0.772,9.46 1.074,9.685L0.506,10.252 0.506,10.712 1.46,11.242 0.9,12.289 1.032,12.551 2.017,13.143 1.952,13.537 4.579,15.048 4.897,14.701 5.893,15.31 6.287,15.31 6.842,14.274 7.798,14.785 8.192,14.588 8.588,13.11 9.769,13.405 10.097,13.077 10.032,11.632 10.467,11.212 11.477,11.369 11.806,10.91 11.213,10.012 11.279,9.727 12.79,8.873 12.987,8.413 12.068,7.69 12.068,7.559 13.448,6.376 13.513,5.917 12.525,5.361 13.448,4.143 13.316,3.75 12.396,3.224 12.659,2.435 12.462,2.238 8.98,0.268 8.652,0.202 8.126,0.859z" Height="15.494" Canvas.Left="462.933" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Stroke="Black" StrokeThickness="0.368" StrokeLineJoin="Round" Canvas.Top="218.677" Width="13.714"/>
</Canvas>
我所有的CANVAS项目都有超过 10000 行 xaml 代码。这会导致项目过载 - 并且应用程序变得无法控制。WindowsForm 在调整大小和拖动时变慢/发光。
请推荐一种更好的方法来为我的项目画线。最终产品必须能够对 MouseEnter 做出反应 - 对我项目中的特定部分执行一些操作,例如有关此元素的信息和 MouseLeftButtonDown - 将此元素添加到列表中。
感谢任何帮助。