3
WPF에서 사각형 및 기타 도형을 그립니다. 그와 마찬가지로,wpf의 사각형/요소 삭제
private Rect DrawSquare(Rect bounds, InkCanvas canvas)
{
Rectangle recta = new Rectangle();
recta.Stroke = Brushes.Black;
//recta.Fill = Brushes.Blue;
recta.StrokeThickness = 4;
recta.Width = bounds.Width;
recta.Height = bounds.Height;
InkCanvas.SetLeft(recta, bounds.Left);
InkCanvas.SetRight(recta, bounds.Right);
InkCanvas.SetTop(recta, bounds.Top);
canvas.Children.Add(recta);
return bounds;
}
그리고 난 그
private void myInkCanvas_SelectionChanging(object sender, InkCanvasSelectionChangingEventArgs e)
{
else if (toolbarMode == ToolbarMode.Delete)
{
myInkCanvas.Strokes.Erase(e.GetSelectedStrokes().GetBounds()); //can delete random lines
ReadOnlyCollection<UIElement> elements = e.GetSelectedElements();
foreach (UIElement element in elements)
{
/*String ShapeName = ((System.Windows.Media.Visual)(element)).ToString();
if (ShapeName.Contains("Rectangle"))
{
Rectangle recta = (Rectangle)element;
recta.Fill = Brushes.Blue;
}*/
myInkCanvas.Children.Remove(element); //cant delete shapes!!?
}
}
}
으로 임의의 줄을 삭제할 수 있습니다 내가 임의의 줄을 삭제할 수 있습니다하지만 난 모양
어떻게 내가 할 수있는 삭제 캔트?
을 (루프의 길이 때문에 요소의 제거에 변경 될 수 있습니다주의)을가 루프를 사용하여이 문제를 해결할 수 (myInkCanvas.Strokes.Erase (예를 .GetSelectedStrokes(). GetBounds());) 및 정의 된 모양 (타원, 사각형) myInkCanvas.Children.Remove .. ?? – tayfun
나는 당신이 무엇을하려고하는지, 왜 그것이 효과가 없는지 이해하지 못합니다. 제거를 사용하여 캔버스에서 도형을 제거 할 수 있습니다. –