improve:清空墨迹
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
@@ -120,15 +121,29 @@ namespace Ink_Canvas
|
|||||||
_currentCommitType = CommitReason.ClearingCanvas;
|
_currentCommitType = CommitReason.ClearingCanvas;
|
||||||
if (isErasedByCode) _currentCommitType = CommitReason.CodeInput;
|
if (isErasedByCode) _currentCommitType = CommitReason.CodeInput;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 只清除笔画,不清除图片元素
|
|
||||||
// 图片元素的清除由调用方决定
|
|
||||||
inkCanvas.Strokes.Clear();
|
inkCanvas.Strokes.Clear();
|
||||||
|
|
||||||
|
// 执行内存清理
|
||||||
|
PerformLightweightMemoryCleanup();
|
||||||
|
|
||||||
_currentCommitType = CommitReason.UserInput;
|
_currentCommitType = CommitReason.UserInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行内存清理
|
||||||
|
/// </summary>
|
||||||
|
private void PerformLightweightMemoryCleanup()
|
||||||
|
{
|
||||||
|
|
||||||
|
// 异步执行垃圾回收,避免阻塞UI
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
// 延迟执行垃圾回收,避免立即阻塞
|
||||||
|
Thread.Sleep(100);
|
||||||
|
GC.Collect();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 恢复每页白板图片信息
|
// 恢复每页白板图片信息
|
||||||
private void RestoreStrokes(bool isBackupMain = false)
|
private void RestoreStrokes(bool isBackupMain = false)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user