两点之间自定义的stroke的图形序列化为Xaml文件时就变成这两个点的一条直线,怎么解决啊??
比如:两点之间自定义stroke变成一个矩形:
StylusPointCollection pts = new StylusPointCollection();
topLeft = e.GetPosition(inkCanvas);
bottomRight = e.GetPosition(inkCanvas);
pts.Add(new StylusPoint(topLeft.X, topLeft.Y));
pts.Add(new StylusPoint(bottomRight.X, bottomRight.Y));
protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes)
{
if (drawingContext == null)
{
throw new ArgumentNullException("drawingContext");
}
if (null == drawingAttributes)
{
throw new ArgumentNullException("drawingAttributes");
}
Pen pen = new Pen
{
StartLineCap = PenLineCap.Round,
EndLineCap = PenLineCap.Round,
Brush = new SolidColorBrush(drawingAttributes.Color),
Thickness = drawingAttributes.Width
};
drawingContext.DrawRectangle(
BgColor,
pen,
new Rect(new Point(StylusPoints[0].X, StylusPoints[0].Y),
new Point(StylusPoints[1].X, StylusPoints[1].Y)));
}