fix:issue #209
This commit is contained in:
@@ -1334,6 +1334,90 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 克隆墨迹集合
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strokes">要克隆的墨迹集合</param>
|
||||||
|
/// <returns>克隆后的墨迹集合</returns>
|
||||||
|
private StrokeCollection CloneStrokes(StrokeCollection strokes)
|
||||||
|
{
|
||||||
|
if (strokes == null || strokes.Count == 0) return new StrokeCollection();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 创建墨迹集合的副本
|
||||||
|
var clonedStrokes = strokes.Clone();
|
||||||
|
|
||||||
|
// 为每个墨迹添加位置偏移以避免重叠
|
||||||
|
foreach (var stroke in clonedStrokes)
|
||||||
|
{
|
||||||
|
var offsetPoints = new StylusPointCollection();
|
||||||
|
foreach (var point in stroke.StylusPoints)
|
||||||
|
{
|
||||||
|
offsetPoints.Add(new StylusPoint(point.X + 20, point.Y + 20, point.PressureFactor));
|
||||||
|
}
|
||||||
|
stroke.StylusPoints = offsetPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加到画布
|
||||||
|
inkCanvas.Strokes.Add(clonedStrokes);
|
||||||
|
|
||||||
|
// 提交到时间机器以支持撤销
|
||||||
|
timeMachine.CommitStrokeUserInputHistory(clonedStrokes);
|
||||||
|
|
||||||
|
LogHelper.WriteLogToFile($"墨迹克隆完成: {clonedStrokes.Count} 个墨迹");
|
||||||
|
return clonedStrokes;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// 记录错误但不中断程序
|
||||||
|
LogHelper.WriteLogToFile($"克隆墨迹时发生错误: {ex.Message}", LogHelper.LogType.Error);
|
||||||
|
return new StrokeCollection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 克隆墨迹集合到新页面
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strokes">要克隆的墨迹集合</param>
|
||||||
|
private void CloneStrokesToNewBoard(StrokeCollection strokes)
|
||||||
|
{
|
||||||
|
if (strokes == null || strokes.Count == 0) return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 创建墨迹集合的副本
|
||||||
|
var clonedStrokes = strokes.Clone();
|
||||||
|
|
||||||
|
// 为每个墨迹添加位置偏移以避免重叠
|
||||||
|
foreach (var stroke in clonedStrokes)
|
||||||
|
{
|
||||||
|
var offsetPoints = new StylusPointCollection();
|
||||||
|
foreach (var point in stroke.StylusPoints)
|
||||||
|
{
|
||||||
|
offsetPoints.Add(new StylusPoint(point.X + 20, point.Y + 20, point.PressureFactor));
|
||||||
|
}
|
||||||
|
stroke.StylusPoints = offsetPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建新页面
|
||||||
|
BtnWhiteBoardAdd_Click(null, null);
|
||||||
|
|
||||||
|
// 添加到新页面的画布
|
||||||
|
inkCanvas.Strokes.Add(clonedStrokes);
|
||||||
|
|
||||||
|
// 提交到时间机器以支持撤销
|
||||||
|
timeMachine.CommitStrokeUserInputHistory(clonedStrokes);
|
||||||
|
|
||||||
|
LogHelper.WriteLogToFile($"墨迹克隆到新页面完成: {clonedStrokes.Count} 个墨迹");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// 记录错误但不中断程序
|
||||||
|
LogHelper.WriteLogToFile($"克隆墨迹到新页面时发生错误: {ex.Message}", LogHelper.LogType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,23 +34,24 @@ namespace Ink_Canvas
|
|||||||
lastBorderMouseDownObject = sender;
|
lastBorderMouseDownObject = sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool isStrokeSelectionCloneOn;
|
|
||||||
|
|
||||||
private void BorderStrokeSelectionClone_MouseUp(object sender, MouseButtonEventArgs e)
|
private void BorderStrokeSelectionClone_MouseUp(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (lastBorderMouseDownObject != sender) return;
|
if (lastBorderMouseDownObject != sender) return;
|
||||||
|
|
||||||
if (isStrokeSelectionCloneOn)
|
try
|
||||||
{
|
{
|
||||||
BorderStrokeSelectionClone.Background = Brushes.Transparent;
|
var strokes = inkCanvas.GetSelectedStrokes();
|
||||||
|
if (strokes.Count > 0)
|
||||||
isStrokeSelectionCloneOn = false;
|
{
|
||||||
|
// 直接执行克隆操作,与图片克隆保持一致
|
||||||
|
CloneStrokes(strokes);
|
||||||
|
LogHelper.WriteLogToFile($"墨迹克隆完成: {strokes.Count} 个墨迹");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
BorderStrokeSelectionClone.Background = new SolidColorBrush(StringToColor("#FF1ED760"));
|
LogHelper.WriteLogToFile($"墨迹克隆失败: {ex.Message}", LogHelper.LogType.Error);
|
||||||
|
|
||||||
isStrokeSelectionCloneOn = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,9 +61,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
var strokes = inkCanvas.GetSelectedStrokes();
|
var strokes = inkCanvas.GetSelectedStrokes();
|
||||||
inkCanvas.Select(new StrokeCollection());
|
inkCanvas.Select(new StrokeCollection());
|
||||||
strokes = strokes.Clone();
|
CloneStrokesToNewBoard(strokes);
|
||||||
BtnWhiteBoardAdd_Click(null, null);
|
|
||||||
inkCanvas.Strokes.Add(strokes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BorderStrokeSelectionDelete_MouseUp(object sender, MouseButtonEventArgs e)
|
private void BorderStrokeSelectionDelete_MouseUp(object sender, MouseButtonEventArgs e)
|
||||||
@@ -408,7 +407,6 @@ namespace Ink_Canvas
|
|||||||
// 显示墨迹选择栏和选择框
|
// 显示墨迹选择栏和选择框
|
||||||
GridInkCanvasSelectionCover.Visibility = Visibility.Visible;
|
GridInkCanvasSelectionCover.Visibility = Visibility.Visible;
|
||||||
BorderStrokeSelectionClone.Background = Brushes.Transparent;
|
BorderStrokeSelectionClone.Background = Brushes.Transparent;
|
||||||
isStrokeSelectionCloneOn = false;
|
|
||||||
updateBorderStrokeSelectionControlLocation();
|
updateBorderStrokeSelectionControlLocation();
|
||||||
UpdateSelectionDisplay();
|
UpdateSelectionDisplay();
|
||||||
return;
|
return;
|
||||||
@@ -657,23 +655,9 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isStrokeSelectionCloneOn)
|
|
||||||
{
|
SetCurrentToolMode(InkCanvasEditingMode.Select);
|
||||||
var strokes = inkCanvas.GetSelectedStrokes();
|
inkCanvas.Select(new StrokeCollection());
|
||||||
isProgramChangeStrokeSelection = true;
|
|
||||||
inkCanvas.Select(new StrokeCollection());
|
|
||||||
StrokesSelectionClone = strokes.Clone();
|
|
||||||
inkCanvas.Select(strokes);
|
|
||||||
isProgramChangeStrokeSelection = false;
|
|
||||||
inkCanvas.Strokes.Add(StrokesSelectionClone);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 新增:启动套索选择模式
|
|
||||||
// 使用集中化的工具模式切换方法
|
|
||||||
SetCurrentToolMode(InkCanvasEditingMode.Select);
|
|
||||||
inkCanvas.Select(new StrokeCollection());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user