【发布时间】:2016-03-17 20:29:38
【问题描述】:
我正在将笔画保存到数据库中,我可以检索它们。现在我还想保存笔画的颜色、宽度和透明度。
这就是我的代码中的内容
private void AddFloorPlan()
{
MyCustomStrokes customStrokes = new MyCustomStrokes();
customStrokes.StrokeCollection = new Point[FloorPlanStrokes.Count][];
for (int i = 0; i < FloorPlanStrokes.Count; i++)
{
customStrokes.StrokeCollection[i] =
new Point[FloorPlanStrokes[i].StylusPoints.Count];
for (int j = 0; j < FloorPlanStrokes[i].StylusPoints.Count; j++)
{
customStrokes.StrokeCollection[i][j] = new Point();
customStrokes.StrokeCollection[i][j].X = FloorPlanStrokes[i].StylusPoints[j].X;
customStrokes.StrokeCollection[i][j].Y = FloorPlanStrokes[i].StylusPoints[j].Y;
}
}
MemoryStream ms = new MemoryStream();
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(ms, customStrokes);
byte[] bytes = ms.ToArray();
ms.Dispose();
}
[Serializable]
public sealed class MyCustomStrokes
{
public MyCustomStrokes() { }
/// <SUMMARY>
/// The first index is for the stroke no.
/// The second index is for the keep the 2D point of the Stroke.
/// </SUMMARY>
public Point[][] StrokeCollection;
}
【问题讨论】:
标签: c# wpf drawing stroke inkcanvas