问题 1
如何在不删除整个画布内容的情况下覆盖书面文本?我可以再做一遍C#
吗?没有在XAML
代码中添加元素?
问题 2
我集成了一个缩放功能,但只有当我指向画布上绘制的东西时它才会缩放。当我只是指向我的 时,如何才能缩放Canvas
?
XAML
<Canvas x:Name="coordinateSystemBackground" VerticalAlignment="Top" Cursor="Cross" MouseWheel="coordinateSystemBackground_MouseWheel" RenderTransformOrigin="0.688,0.559" Width="1200" Height="720">
<ScrollViewer Grid.Column="0" Grid.Row="0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Width="1200" Height="750">
<Canvas x:Name="coordinateSystem" HorizontalAlignment="Left" VerticalAlignment="Top" Cursor="Cross" UseLayoutRounding="False" Canvas.Left="0" Width="1200" Height="720">
<Canvas.RenderTransform>
<ScaleTransform x:Name="st"/>
</Canvas.RenderTransform>
</Canvas>
</ScrollViewer>
</Canvas>
My Zoom function
private void coordinateSystemBackground_MouseWheel(object sender, MouseWheelEventArgs e)
{
// Skalierungsfaktor
double ScaleRate = 1.1;
//Transformiert gesamte Canvas...
if (e.Delta > 0)
{
st.ScaleX *= ScaleRate;
st.ScaleY *= ScaleRate;
labZoomFaktor.Content = (int)((st.ScaleX * 100) - 100) + " %";
}
else
{
st.ScaleX /= ScaleRate;
st.ScaleY /= ScaleRate;
labZoomFaktor.Content = (int)((st.ScaleX * 100) - 100) + " %";
}
}