stroke.cs
来自「采用vc#.net和sqlce实现智能手机端和服务器数据交换」· CS 代码 · 共 71 行
CS
71 行
using System;
using System.Drawing;
using System.Collections;
namespace Microsoft.Sql.SqlCe.Samples.Cs.IBuySpyDelivery.IBuySpyDevice
{
internal class Stroke
{
ArrayList pointList;
public Stroke(int capacity)
{
pointList = new ArrayList(capacity);
}
public Point this[int index] {
get {
return (Point) pointList[index];
}
set {
pointList[index] = value;
}
}
public void Add(Point point) {
pointList.Add(point);
}
public int Count {
get {
return pointList.Count;
}
}
/// Stream representation. Format: [X][Y][X][Y]...[X][Y][0xFFFF][0xFFFF]
///
public short[] ToShortArray() {
short[] buf = new short[2 * pointList.Count + 2];
for (int i=0; i<pointList.Count; i++) {
buf[2*i] = (short) ((Point)pointList[i]).X;
buf[2*i + 1] = (short) ((Point)pointList[i]).Y;
}
buf[buf.Length - 2] = unchecked ((short) 0xFFFF);
buf[buf.Length - 1] = unchecked ((short) 0xFFFF);
return buf;
}
public Point[] ToPointArray() {
Point[] buf = new Point[pointList.Count];
for (int i=0; i<buf.Length; i++) {
buf[i] = (Point) pointList[i];
}
return buf;
}
public void Fill(short[] buf, int startIndx, int endIndx) {
short x,y;
if (null == buf || startIndx < 0 || endIndx <=0) return;
this.pointList.Clear();
for (int i=startIndx; i<endIndx; i += 2) {
x = buf[i];
y = buf[i+1];
this.pointList.Add(new Point(x, y));
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?