none
InkCanvas 如何绘制文本,绘制图形。并且是可擦出的 RRS feed

全部回复

  • Hello,

    请参考一下下面的代码, 不知道下面的效果是否能满足你的要求。

    xml:

     <Grid.RowDefinitions>
                <RowDefinition Height="9*" />
                <RowDefinition />
            </Grid.RowDefinitions>
    
            <InkCanvas x:Name="inkCanvas" Grid.Row="0" />
    
            <Grid Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
    
                <RadioButton Grid.Column="0" Click="RadioButton_Click">绘制墨迹</RadioButton>
                <RadioButton Grid.Column="1" Click="RadioButton_Click">按点擦除</RadioButton>
                <RadioButton Grid.Column="2" Click="RadioButton_Click">按线擦除</RadioButton>
                <RadioButton Grid.Column="3" Click="RadioButton_Click">选中墨迹</RadioButton>
                <RadioButton Grid.Column="4" Click="RadioButton_Click">停止操作</RadioButton>
            </Grid>

    .cs:

      public Window3()
            {
                InitializeComponent();
            }
    
            private void RadioButton_Click(object sender, RoutedEventArgs e)
            {
                if ((sender as RadioButton).Content.ToString() == "绘制墨迹")
                {
                    //绘制墨迹  
                    inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
                }
    
                else if ((sender as RadioButton).Content.ToString() == "按点擦除")
                {
                    //使用橡皮擦按点擦除墨迹  
                    inkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
                }
    
                else if ((sender as RadioButton).Content.ToString() == "按线擦除")
                {
                    //使用橡皮擦按绘制的墨迹将某一笔墨迹擦除掉,注意是某一笔,如果多次绘制但是有交叉也是不可以的  
                    inkCanvas.EditingMode = InkCanvasEditingMode.EraseByStroke;
                }
    
                else if ((sender as RadioButton).Content.ToString() == "选中墨迹")
                {
                    //选中某一笔墨迹,进行拖动和缩放以及按 Delete 键删除,注意是某一笔  
                    inkCanvas.EditingMode = InkCanvasEditingMode.Select;
                }
    
                else if ((sender as RadioButton).Content.ToString() == "停止操作")
                {
                    //不做任何  
                    inkCanvas.EditingMode = InkCanvasEditingMode.None;
                }
            }

    https://blog.csdn.net/yourng/article/details/79278338

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2018年7月26日 2:44
    版主
  • 你可能理解错了。,我指的文本是用键盘打进去的文本,矩形是标准的长方形,用鼠标拖出来的那种。这个显然没法满足我的要求!不过还是谢谢你的回答。
    2018年7月26日 3:04