本文整理汇总了C#中System.Windows.Ink.Stroke.HitTest方法的典型用法代码示例。如果您正苦于以下问题:C# Stroke.HitTest方法的具体用法?C# Stroke.HitTest怎么用?C# Stroke.HitTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Ink.Stroke
的用法示例。
在下文中一共展示了Stroke.HitTest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Stroke_Default
public void Stroke_Default ()
{
Stroke s = new Stroke ();
Assert.AreEqual (0, s.StylusPoints.Count, "StylusPoints");
Assert.Throws<ArgumentException> (delegate {
s.HitTest (null);
}, "HitTest-null");
Assert.IsFalse (s.HitTest (s.StylusPoints), "HitTest-StylusPoints");
}
示例2: Stroke_StylusPointCollection
public void Stroke_StylusPointCollection ()
{
StylusPointCollection spc = new StylusPointCollection ();
spc.Add (new StylusPoint (1, 2));
Stroke s = new Stroke (spc);
Assert.AreEqual (1, s.StylusPoints.Count, "StylusPoints-1");
spc.Add (new StylusPoint (3, 4));
Assert.AreEqual (2, s.StylusPoints.Count, "StylusPoints-2");
s.StylusPoints.Add (new StylusPoint (5, 6));
Assert.AreEqual (3, s.StylusPoints.Count, "StylusPoints-3a");
Assert.AreEqual (3, spc.Count, "StylusPoints-3b");
Assert.Throws<ArgumentException> (delegate {
s.HitTest (null);
}, "HitTest-null");
Assert.IsTrue (s.HitTest (s.StylusPoints), "HitTest-StylusPoints");
}
示例3: ProcessPointErase
void ProcessPointErase(Stroke stroke, StylusPointCollection pointErasePoints)
{
Stroke splitStroke1, splitStroke2, hitTestStroke;
// Determine first split stroke.
splitStroke1 = new Stroke();
hitTestStroke = new Stroke();
hitTestStroke.StylusPoints.Add(stroke.StylusPoints);
hitTestStroke.DrawingAttributes = stroke.DrawingAttributes;
//Iterate through the stroke from index 0 and add each stylus point to splitstroke1 until
//a stylus point that intersects with the input stylus point collection is reached.
while (true)
{
StylusPoint sp = hitTestStroke.StylusPoints[0];
hitTestStroke.StylusPoints.RemoveAt(0);
if (!hitTestStroke.HitTest(pointErasePoints)) break;
splitStroke1.StylusPoints.Add(sp);
}
//Determine second split stroke.
splitStroke2 = new Stroke();
hitTestStroke = new Stroke();
hitTestStroke.StylusPoints.Add(stroke.StylusPoints);
hitTestStroke.DrawingAttributes = stroke.DrawingAttributes;
while (true)
{
StylusPoint sp = hitTestStroke.StylusPoints[hitTestStroke.StylusPoints.Count - 1];
hitTestStroke.StylusPoints.RemoveAt(hitTestStroke.StylusPoints.Count - 1);
if (!hitTestStroke.HitTest(pointErasePoints)) break;
splitStroke2.StylusPoints.Insert(0, sp);
}
// Replace stroke with splitstroke1 and splitstroke2.
if (splitStroke1.StylusPoints.Count > 1)
{
splitStroke1.DrawingAttributes = stroke.DrawingAttributes;
_presenter.Strokes.Add(splitStroke1);
//App.inkStorage.Strokes.Add(splitStroke1);
}
if (splitStroke2.StylusPoints.Count > 1)
{
splitStroke2.DrawingAttributes = stroke.DrawingAttributes;
_presenter.Strokes.Add(splitStroke2);
//App.inkStorage.Strokes.Add(splitStroke2);
}
_presenter.Strokes.Remove(stroke);
// App.inkStorage.Strokes.Remove(stroke);
}
示例4: takeStroke
//.........这里部分代码省略.........
}
xAxis = s;
s.StylusPoints = InkUtils.xkcd(new StylusPointCollection(new Point[] { origin, xEnd }));
return true;
}
notX:
if (yAxis == null && Math.Abs(p2.Y - p1.Y) > 100 && Math.Abs((p2.X - p1.X) / (p2.Y - p1.Y)) < 0.3)
{
if (xAxis == null)
{
if (p1.Y > p2.Y)
{
origin = new Point(p1.X, p1.Y);
yEnd = new Point(p1.X, p2.Y);
}
else
{
origin = new Point(p2.X, p2.Y);
yEnd = new Point(p2.X, p1.Y);
}
}
else if (InkUtils.distSquared(p2, InkUtils.sp(origin)) < 20 * 20)
{
yEnd = new Point(origin.X, p1.Y);
}
else if (InkUtils.distSquared(p1, InkUtils.sp(origin)) < 20 * 20)
{
yEnd = new Point(origin.X, p2.Y);
}
else
{
goto notY;
}
yAxis = s;
s.StylusPoints = InkUtils.xkcd(new StylusPointCollection(new Point[] { origin, yEnd }));
return true;
}
notY: { }
}
}
else
{
StylusPoint spOrigin = InkUtils.sp(origin), spXEnd = InkUtils.sp(xEnd), spYEnd = InkUtils.sp(yEnd);
// Support bars
if (col.Count == 4
// Vertical bars
&& InkUtils.isVertical(col[0], col[1])
//&& InkUtils.isHorizontal(col[1], col[2])
&& InkUtils.isVertical(col[2], col[3])
&& InkUtils.similar(Math.Sqrt(InkUtils.distSquared(col[0], col[1])),
Math.Sqrt(InkUtils.distSquared(col[2], col[3])))
&& InkUtils.lineDistSquared(spOrigin, spXEnd, col[0]) < 400
&& InkUtils.lineDistSquared(spOrigin, spXEnd, col[3]) < 400)
{
double x1 = (col[0].X + col[1].X) / 2;
double x2 = (col[2].X + col[3].X) / 2;
double y = (col[1].Y + col[2].Y) / 2;
s.StylusPoints = InkUtils.xkcd(new StylusPointCollection(new Point[] {
new Point(x1, origin.Y),
new Point(x1, y),
new Point(x2, y),
new Point(x2, origin.Y)
}));
fillBar(x1, origin.Y, x2, y);
}
else if (col.Count == 4
// Horizontal bars
&& InkUtils.isHorizontal(col[0], col[1])
//&& InkUtils.isVertical(col[1], col[2])
&& InkUtils.isHorizontal(col[2], col[3])
&& InkUtils.similar(Math.Sqrt(InkUtils.distSquared(col[0], col[1])),
Math.Sqrt(InkUtils.distSquared(col[2], col[3])))
&& InkUtils.lineDistSquared(spOrigin, spYEnd, col[0]) < 400
&& InkUtils.lineDistSquared(spOrigin, spYEnd, col[3]) < 400)
{
double y1 = (col[0].Y + col[1].Y) / 2;
double y2 = (col[2].Y + col[3].Y) / 2;
double x = (col[1].X + col[2].X) / 2;
s.StylusPoints = InkUtils.xkcd(new StylusPointCollection(new Point[] {
new Point(origin.X, y1),
new Point(x, y1),
new Point(x, y2),
new Point(origin.X, y2)
}));
fillBar(origin.X, y1, x, y2);
}
// Maybe it's inside the graph itself?
else if (s.HitTest(new Rect(xEnd, yEnd), 80))
{
s.StylusPoints = InkUtils.xkcd(s.StylusPoints);
}
}
curves.Add(s);
// s.StylusPoints = InkUtils.xkcd(col);
//analyzer.AddStroke(s);
//analyzer.Analyze();
return true;
}
示例5: containsStroke
public bool containsStroke(Stroke s)
{
return s.HitTest(bounds, 80);
}