如何单击绘图,然后在显示中绘图? [英] How do I click on draw and then draw in display?

查看:81
本文介绍了如何单击绘图,然后在显示中绘图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<Window

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    x:Class="FunctionDrawWPF_Try1_110103.MainWindow"

    x:Name="Window"

    Title="Draw a function of x."

    Width="640" Height="480" mc:Ignorable="d" Background="#FF1596EE">

    <Grid x:Name="LayoutRoot">
        <Rectangle x:Name="display" Stroke="Black" Margin="113,8,89,102" Width="400" Height="300">
            <Rectangle.Fill>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="Black" Offset="0"/>
                    <GradientStop Color="White" Offset="1"/>
                </LinearGradientBrush>
            </Rectangle.Fill>
        </Rectangle>
        <Label x:Name="fx" HorizontalAlignment="Left" VerticalAlignment="Bottom" Content="f(x)=" Margin="124,0,0,77.04"/>
        <TextBox x:Name="fx_string" HorizontalAlignment="Left" VerticalAlignment="Bottom" Text="sin(x)" TextWrapping="Wrap" Margin="164,0,0,77.04" Width="360"/>
        <Label HorizontalAlignment="Left" Margin="122.823,0,0,34.04" VerticalAlignment="Bottom" Content="xmin="/>
        <TextBox x:Name="xmin" HorizontalAlignment="Left" Margin="166.573,0,0,34.04" VerticalAlignment="Bottom" Width="98.427" Height="25.96" Text="-1" TextWrapping="Wrap"/>
        <Label HorizontalAlignment="Right" Margin="0,0,231.19,34.04" VerticalAlignment="Bottom" Content="xmax=" d:LayoutOverrides="HorizontalAlignment"/>
        <TextBox x:Name="xmax" HorizontalAlignment="Right" Margin="0,0,100,34.04" VerticalAlignment="Bottom" Width="127.19" Height="25.96" Text="+1" TextWrapping="Wrap"/>
        <Button x:Name="draw" HorizontalAlignment="Left" Margin="24,24,0,0" VerticalAlignment="Top" Width="75" Content="Draw" Height="66.96" Click="draw_Click" />
        <Button x:Name="fit" HorizontalAlignment="Left" Margin="24,94.96,0,0" VerticalAlignment="Top" Width="75" Content="Fit" Height="68.96"/>
        <Button x:Name="axes" HorizontalAlignment="Left" Margin="24,167.92,0,207.12" Width="75" Content="Axes" RenderTransformOrigin="0.547,0.046"/>
        <Button x:Name="about" HorizontalAlignment="Left" Margin="24,0,0,138.12" VerticalAlignment="Bottom" Width="75" Content="About" Height="65"/>
    </Grid>
</Window>



我在后面的代码中:



I have in the code behind:

private void draw_Click(object sender, RoutedEventArgs e)
{
    //DrawingVisual display = new DrawingVisual();
    //DrawingContext dc = display.RenderOpen();
    //Pen drawingPen = new Pen(Brushes.Red, 3);
    //dc.DrawLine(drawingPen, new Point(20, 20), new Point(280, 280));
    //dc.Close();

    MessageBox.Show("draw_Click");
}



我确实收到消息框,但我想在显示矩形中绘制.我该如何告诉draw_Click?

Ranger.



I do get the message box but I want to draw in display the rectangle. How do I tell draw_Click this?

Ranger.

推荐答案

看看这篇文章:
WPF中的动态矩形和静态矩形 [
Take a look at this article:
Dynamic and static Rectangle in WPF[^]

Regards
Espen Harlinn


这篇关于如何单击绘图,然后在显示中绘图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆