Skip to content

Commit

Permalink
[add] BorderStrokeSelectionCloneToBoardOrNewPage_Click for elements
Browse files Browse the repository at this point in the history
  • Loading branch information
ChangSakura committed Aug 7, 2024
1 parent 18f407d commit 72b6cbb
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
31 changes: 30 additions & 1 deletion Ink Canvas/Helpers/InkCanvasElementsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,41 @@ public static List<UIElement> CloneSelectedElements(InkCanvas inkCanvas, ref Dic
SetTopData = InkCanvas.GetTop(element),
FrameworkElement = frameworkElement
};
LogHelper.WriteObjectLogToFile(frameworkElement);
}
}
return clonedElements;
}

public static List<UIElement> GetSelectedElementsCloned(InkCanvas inkCanvas)
{
List<UIElement> clonedElements = new List<UIElement>();
int key = 0;
foreach (UIElement element in inkCanvas.GetSelectedElements())
{
UIElement clonedElement = CloneUIElement(element);
if (clonedElement != null)
{
FrameworkElement frameworkElement = clonedElement as FrameworkElement;
string timestamp = "ele_" + DateTime.Now.ToString("ddHHmmssfff") + key.ToString();
frameworkElement.Name = timestamp;
++key;
InkCanvas.SetLeft(frameworkElement, InkCanvas.GetLeft(element));
InkCanvas.SetTop(frameworkElement, InkCanvas.GetTop(element));
clonedElements.Add(frameworkElement);
}
}
return clonedElements;
}

public static void AddElements(InkCanvas inkCanvas, List<UIElement> elements, TimeMachine timeMachine)
{
foreach (UIElement element in elements)
{
inkCanvas.Children.Add(element);
timeMachine.CommitElementInsertHistory(element);
}
}

private static UIElement CloneUIElement(UIElement element)
{
if (element == null) return null;
Expand Down
3 changes: 2 additions & 1 deletion Ink Canvas/MainWindow_cs/MW_PPT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private void PptApplication_SlideShowBegin(SlideShowWindow Wn)
{
ImageBlackboard_Click(null, null);
}

/*
//调整颜色
double screenRatio = SystemParameters.PrimaryScreenWidth / SystemParameters.PrimaryScreenHeight;
if (Math.Abs(screenRatio - 16.0 / 9) <= -0.01)
Expand All @@ -306,6 +306,7 @@ private void PptApplication_SlideShowBegin(SlideShowWindow Wn)
{
}
*/
lastDesktopInkColor = 1;


Expand Down
14 changes: 7 additions & 7 deletions Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,23 @@ private void BorderStrokeSelectionCloneToBoardOrNewPage_Click(object sender, Rou
{
if (currentMode == 0)
{
var strokes = inkCanvas.GetSelectedStrokes();
StrokeCollection strokes = inkCanvas.GetSelectedStrokes();
List<UIElement> elements = InkCanvasElementsHelper.GetSelectedElementsCloned(inkCanvas);
inkCanvas.Select(new StrokeCollection());
strokes = strokes.Clone();
ImageBlackboard_Click(null, null);
inkCanvas.Strokes.Add(strokes);
InkCanvasElementsHelper.AddElements(inkCanvas, elements, timeMachine);
}
else
{
var strokes = inkCanvas.GetSelectedStrokes();
StrokeCollection strokes = inkCanvas.GetSelectedStrokes();
List<UIElement> elements = InkCanvasElementsHelper.GetSelectedElementsCloned(inkCanvas);
inkCanvas.Select(new StrokeCollection());
strokes = strokes.Clone();
BtnWhiteBoardAdd_Click(null, null);
inkCanvas.Strokes.Add(strokes);
InkCanvasElementsHelper.AddElements(inkCanvas, elements, timeMachine);
}
}

Expand Down Expand Up @@ -432,11 +436,7 @@ private void BtnSelect_Click(object sender, RoutedEventArgs e)
selectedStrokes.Add(stroke);
}
}
List<UIElement> selectedElements = new List<UIElement>();
foreach (UIElement element in inkCanvas.Children)
{
selectedElements.Add(element);
}
List<UIElement> selectedElements = InkCanvasElementsHelper.GetAllElements(inkCanvas);
inkCanvas.Select(selectedStrokes, selectedElements);
}
}
Expand Down

0 comments on commit 72b6cbb

Please sign in to comment.