- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我使用inkcanvas1.EditingMode 是InkCanvasEditingMode.EraseByPoint 它正在删除并且StrokeErased 事件触发。
但是当我通过inkcanvas1.Strokes.Erase()删除笔画时;函数然后 StrokeErased 事件不会触发。那么我如何识别哪些笔画被删除,哪些笔画是新创建的。考虑在我的墨水 Canvas 上数千笔画。所以我无法保持每一个添加和删除的笔画。
有没有其他事件或任何解决方案。
我有以下示例 WPF Inkcanvas 代码
XAML 代码
<Window x:Class="MyWhiteBoard.MainWindow"
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"
xmlns:local="clr-namespace:MyWhiteBoard"
mc:Ignorable="d"
WindowState="Maximized"
Title="MainWindow" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
</Grid.RowDefinitions>
<InkCanvas x:Name="inkcanvas1" Grid.Row="0" StrokeErased="inkcanvas1_StrokeErased" MouseMove="inkcanvas1_MouseMove"></InkCanvas>
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center">
<Button Width="100" Height="50" Background="WhiteSmoke" Content="Draw" Click="drawInkClick"></Button>
<Button Width="100" Height="50" Background="WhiteSmoke" Content="Erase by Point" Click="EraseByPointsClick"></Button>
<Button Width="100" Height="50" Background="WhiteSmoke" Content="Stroke Erase" Click="StrokeEraseClick"></Button>
<Button Width="100" Height="50" Background="WhiteSmoke" Content="clear all" Click="clearAllClick"></Button>
</StackPanel>
</Grid>
</Window>
public partial class MainWindow : Window
{
private bool IsStrokeEraseCalled = false;
public MainWindow()
{
InitializeComponent();
}
private void inkcanvas1_StrokeErased(object sender, RoutedEventArgs e)
{
// why this event is not calling when I use
//inkcanvas1.Strokes.Erase
}
private void EraseByPointsClick(object sender, RoutedEventArgs e)
{
inkcanvas1.EditingMode = InkCanvasEditingMode.EraseByPoint;
}
private void StrokeEraseClick(object sender, RoutedEventArgs e)
{
inkcanvas1.EditingMode = InkCanvasEditingMode.Select;
IsStrokeEraseCalled = !IsStrokeEraseCalled;
}
private void clearAllClick(object sender, RoutedEventArgs e)
{
inkcanvas1.Strokes.Clear();
}
private void inkcanvas1_MouseMove(object sender, MouseEventArgs e)
{
if (IsStrokeEraseCalled)
{
Point currentPoint = e.GetPosition((IInputElement)sender);
List<Point> enumrator = new List<Point>();
enumrator.Add(new Point(currentPoint.X, currentPoint.Y));
StylusShape EraseShape = (StylusShape)new RectangleStylusShape(100, 100, 0);
inkcanvas1.Strokes.Erase(enumrator, EraseShape);
}
}
private void drawInkClick(object sender, RoutedEventArgs e)
{
inkcanvas1.EditingMode = InkCanvasEditingMode.Ink;
}
}
最佳答案
尝试这个
public MainWindow()
{
InitializeComponent();
inkcanvas1.Strokes.StrokesChanged += Strokes_StrokesChanged;
}
private void Strokes_StrokesChanged(object sender, StrokeCollectionChangedEventArgs e)
{
StrokeCollection newlyAddedStroke = e.Added;
StrokeCollection oldRemovedStroke = e.Removed;
}
关于c# - 当我在 C# 中使用inkcanvas1.Strokes.Erase 语句时,WPF-InkCanvas StrokeErased 事件不会触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64486215/
我使用具有固定宽度和高度的 Canvas 。它有 500x500 大,我也想用这种方法保存它: private async void SaveasGIF(object sender, Rout
我希望能够在 InkCanvas 上绘制形状。到目前为止,我有以下 XAML:- 在页面构造函数中,我有以下内容:- inker.InkPresenter.Unprocesse
在我的申请中,我有一个 InkCanva s 在背景中有图像。当我在 InkCanvas 上画画时到底部或左侧边缘,InkCanvas更改大小以适合草图,这会扰乱背景中图像的渲染。如何停止 InkCa
所以我试图通过使用套接字创建一个类似同步绘画程序的东西。我有一个服务器端..和一个客户端,我试图将inkCollection从服务器发送到客户端。这适用于简单的文本,但我似乎无法发送inkCollec
我正在为触摸屏创建一个简单的绘画应用程序,我一直在与多点触控手势进行一些斗争,以便在 inkcanvas 中缩放和旋转,但我还没有找到解决方案。 有没有一种在 inkcanvas 中提供多点触控手势的
我正在为触摸屏创建一个简单的绘画应用程序,我一直在与多点触控手势进行一些斗争,以便在 inkcanvas 中缩放和旋转,但我还没有找到解决方案。 有没有一种在 inkcanvas 中提供多点触控手势的
我正在使用 InkCanvas 创建类似绘画的应用程序,我愿意实现撤消和我的应用程序中的重做功能。 哪一种是为 InkCanvas 实现撤消/重做的最佳方式? 最佳答案 我已经为 WPF 应用程序实现
使用以下 XAML: Te
我以前从未使用过InkCanvas 控件。我需要的是将文件加载到 InkCanvas 中,绘制一些涂鸦并获得生成的图像。我想对获取的图像进行一些额外的操作。 至于节省 如果我错了请纠正我。我找到了一个
在 WinForms 的 Microsoft.Ink 世界中,使用 InkCollector 对象,用户可以通过 this approach 获取笔画中某个点的时间戳. WPF 世界依赖于 InkCa
我正在开发一个程序,将 inkcanvas 笔画转换为字节数组进行加密,然后将其保存在 txt 文件中。本质上,我需要将字节数组转换为 inkcanvas 笔划。我已经完成了前半部分代码(将 inkc
我目前正在开发一个 UWP 应用程序,它应该允许用户在 InkCanvas 上绘制他想要的任何形状。这个形状的边缘是自动完成的,因此没有开放空间(到目前为止一切正常)。 现在我的问题是:如何使用单一颜
我将 WPF InkCanvas 用于绘图应用程序。 Canvas 位于图像上方。我可以在图像上涂鸦,但我需要它有发光效果——即实际绘制的线条必须有这种效果。有没有办法在 XAML 或 C# 代码中执
我正在使用 MVVMLight 创建问卷,并在呈现 InkCanvas 控件时遇到内存问题。这是我正在使用的一个淡化示例: 问题Vm public Question Question { get; s
在我的 UWP 应用程序中,我试图获取作为 InkCanvas 中墨迹笔画一部分的每个点的坐标,但官方文档似乎没有谈论它,有谁知道如何做到这一点? 最佳答案 只是猜测,但从文档来看它看起来像: for
我在一个窗口上有一个 InkCanvas,我允许用户在其中使用手写笔、触摸或鼠标进行绘图。我还允许用户添加文本。用户点击“添加文本”按钮,然后点击 Canvas 上他们想要文本的位置。那里会出现一个文
在我的 WPF 应用程序中,我有一些绘图功能。我已经使用 Canvas 解决了这个问题,并手动处理了鼠标手势,我还将绘制的 Strokes(包装在 InkPresenter 中)添加到了这个 Canv
您好,我不知道为什么它不起作用。看起来我不能在 InkCanvas 上使用这个事件。 XAML Clear 代码隐藏 private void MC_MouseLeftButt
我正在 UWP 中开发一个绘图程序,希望我的程序支持多个手写笔输入。当我在 WPF 中开发时,在进行了一些巧妙的鼠标和手写笔事件处理后,我能够从 WPF 版本的 InkCanvas 获得多个手写笔输入
是否可以将 InkCanvas 笔划集合保存为 svg 图像?我唯一能找到的是我可以将笔画保存为带有嵌入式 ISF(墨水序列化格式)的 GIF,或者将它们渲染为位图。我想以可以与其他平台(如网络)互操
我是一名优秀的程序员,十分优秀!