0

問題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) + " %";
    }            
}
4

1 に答える 1