File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
src/DotNetCampus.AvaloniaInkCanvas/Core Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -169,18 +169,31 @@ public void WritingCompleted()
169169 /// </summary>
170170 private readonly List < SkiaStroke > _staticStrokeList = [ ] ;
171171
172- internal void AddStaticStroke ( SkiaStroke skiaStroke )
172+ public void AddStaticStroke ( SkiaStroke skiaStroke )
173173 {
174174 skiaStroke . EnsureIsStaticStroke ( ) ;
175+ if ( skiaStroke . InkCanvas != null )
176+ {
177+ // 禁止一个笔迹被添加到多个画布中
178+ throw new InvalidOperationException ( "Stroke must not be added to multiple InkCanvas instances." ) ;
179+ }
180+
175181 _staticStrokeList . Add ( skiaStroke ) ;
176182 skiaStroke . InkCanvas = this ;
177183 InvalidateVisual ( ) ;
178184 }
179185
180- internal void RemoveStaticStroke ( SkiaStroke skiaStroke )
186+ public void RemoveStaticStroke ( SkiaStroke skiaStroke )
181187 {
182188 skiaStroke . EnsureIsStaticStroke ( ) ;
189+
190+ if ( ! ReferenceEquals ( skiaStroke . InkCanvas , this ) )
191+ {
192+ throw new InvalidOperationException ( "Stroke must be removed from this InkCanvas before removing." ) ;
193+ }
194+
183195 _staticStrokeList . Remove ( skiaStroke ) ;
196+ skiaStroke . InkCanvas = null ;
184197 InvalidateVisual ( ) ;
185198 }
186199
You can’t perform that action at this time.
0 commit comments