本文整理汇总了C#中System.Windows.Ink.Stroke.GetBounds方法的典型用法代码示例。如果您正苦于以下问题:C# Stroke.GetBounds方法的具体用法?C# Stroke.GetBounds怎么用?C# Stroke.GetBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Ink.Stroke
的用法示例。
在下文中一共展示了Stroke.GetBounds方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Graph
public Graph(IDelegate _del, Stroke b)
{
del = _del;
box = b;
bounds = box.GetBounds();
box.StylusPoints = InkUtils.xkcd(InkUtils.box(bounds));
box.DrawingAttributes.Color = Colors.Blue;
analyzer = new InkAnalyzer();
analyzer.ContextNodeCreated += ContextNodeCreated;
}
示例2: Stroke_Default_Bounds
public void Stroke_Default_Bounds ()
{
Stroke s = new Stroke ();
Rect bounds = s.GetBounds ();
Assert.AreEqual (-1.5, bounds.Top, "Top");
Assert.AreEqual (-1.5, bounds.Left, "Left");
Assert.AreEqual (3, bounds.Height, "Height");
Assert.AreEqual (3, bounds.Width, "Width");
}
示例3: CheckRemoveGate
private bool CheckRemoveGate(Stroke stroke)
{
Rect strokeBound = stroke.GetBounds();
bool removeGate = false;
List<Gate> removedGates = new List<Gate>();
for(int i = 0; i < circuitInkCanvas.Children.Count; i++)
{
UIElement gate = circuitInkCanvas.Children[i];
if (gate is Gate)
{
Gate g = gate as Gate;
Rect grect = new Rect(g.Margin.Left + 40, g.Margin.Top + 40, g.Width - 40, g.Height - 40);
if (strokeBound.Contains(grect))
{
//this.RemoveGate(g);
removedGates.Add(g);
removeGate = true;
}
}else if(gate is ConnectedWire)
{
ConnectedWire wire = gate as ConnectedWire;
//Debug.WriteLine("Stroke Rect Bound: " + strokeBound.ToString());
//Debug.WriteLine("Wire Origin is " + wire.Origin.ToString());
//Debug.WriteLine("Wire Destination is " + wire.Destination.ToString());
//Debug.WriteLine("Wire Outer Margin is " + wire.Outer.Margin.ToString());
HitTestResult result = null;
int count = 0;
foreach(StylusPoint pt in stroke.StylusPoints)
{
result = VisualTreeHelper.HitTest(wire, pt.ToPoint());
if(result != null)
{
count++;
}
}
//Debug.WriteLine("Count is " + count.ToString());
if(count >= 3)
{
//trigger remove wire
//From connectedWire to get terminal
Gates.Terminal t = new Gates.Terminal(wire.DestTerminalID.ID, wire.DestinationGate);
c.Disconnect1(t);
circuitInkCanvas.Children.Remove(wire);
/*
for (int j = 0; j < wire.DestinationGate.NumberOfInputs; j++)
{
Gates.Terminal t = new Gates.Terminal(j, wire.DestinationGate);
//Gates.Terminal t = new Gates.Terminal(j, wire.OriginGate);
if (t != null)
{
c.Disconnect1(t);
circuitInkCanvas.Children.Remove(wire);
}
}
*/
removeGate = true;
}
}
}
if(removeGate)
{
foreach (Gate g in removedGates)
{
this.RemoveGate(g);
}
return true;
}
return false;
}
示例4: StrokeInfo
/// <summary>
/// StrokeInfo
/// </summary>
internal StrokeInfo(Stroke stroke)
{
System.Diagnostics.Debug.Assert(stroke != null);
_stroke = stroke;
_bounds = stroke.GetBounds();
// Start listening to the stroke events
_stroke.DrawingAttributesChanged += new PropertyDataChangedEventHandler(OnStrokeDrawingAttributesChanged);
_stroke.StylusPointsReplaced += new StylusPointsReplacedEventHandler(OnStylusPointsReplaced);
_stroke.StylusPoints.Changed += new EventHandler(OnStylusPointsChanged);
_stroke.DrawingAttributesReplaced += new DrawingAttributesReplacedEventHandler(OnDrawingAttributesReplaced);
}
示例5: CreatePenDrawing
/// <summary>
/// Custom Pen Drawing
/// </summary>
private static Drawing CreatePenDrawing(DrawingAttributes drawingAttributes, bool isHollow, bool isRightToLeft)
{
// Create a single point stroke.
StylusPointCollection stylusPoints = new StylusPointCollection();
stylusPoints.Add(new StylusPoint(0f, 0f));
DrawingAttributes da = new DrawingAttributes();
da.Color = drawingAttributes.Color;
da.Width = drawingAttributes.Width;
da.Height = drawingAttributes.Height;
da.StylusTipTransform = drawingAttributes.StylusTipTransform;
da.IsHighlighter = drawingAttributes.IsHighlighter;
da.StylusTip = drawingAttributes.StylusTip;
Stroke singleStroke = new Stroke(stylusPoints, da);
// NTRAID#WINDOWS-1326403-2005/10/03-waynezen,
// We should draw our cursor in the device unit since it's device dependent object.
singleStroke.DrawingAttributes.Width = ConvertToPixel(singleStroke.DrawingAttributes.Width);
singleStroke.DrawingAttributes.Height = ConvertToPixel(singleStroke.DrawingAttributes.Height);
double maxLength = Math.Min(SystemParameters.PrimaryScreenWidth / 2, SystemParameters.PrimaryScreenHeight / 2);
//
// NOTE: there are two ways to set the width / height of a stroke
// 1) using .Width and .Height
// 2) using StylusTipTransform and specifying a scale
// these two can multiply and we need to prevent the size from ever going
// over maxLength or under 1.0. The simplest way to check if we're too big
// is by checking the bounds of the stroke, which takes both into account
//
Rect strokeBounds = singleStroke.GetBounds();
bool outOfBounds = false;
// Make sure that the cursor won't exceed the minimum or the maximum boundary.
if ( DoubleUtil.LessThan(strokeBounds.Width, 1.0) )
{
singleStroke.DrawingAttributes.Width = 1.0;
outOfBounds = true;
}
else if ( DoubleUtil.GreaterThan(strokeBounds.Width, maxLength) )
{
singleStroke.DrawingAttributes.Width = maxLength;
outOfBounds = true;
}
if ( DoubleUtil.LessThan(strokeBounds.Height, 1.0) )
{
singleStroke.DrawingAttributes.Height = 1.0;
outOfBounds = true;
}
else if ( DoubleUtil.GreaterThan(strokeBounds.Height, maxLength) )
{
singleStroke.DrawingAttributes.Height = maxLength;
outOfBounds = true;
}
//drop the StylusTipTransform if we're out of bounds. we might
//consider trying to preserve any transform but this is such a rare
//case (scaling over or under with a STT) that we don't care.
if (outOfBounds)
{
singleStroke.DrawingAttributes.StylusTipTransform = Matrix.Identity;
}
if (isRightToLeft)
{
//reverse left to right to right to left
Matrix xf = singleStroke.DrawingAttributes.StylusTipTransform;
xf.Scale(-1, 1);
//only set the xf if it has an inverse or the STT will throw
if (xf.HasInverse)
{
singleStroke.DrawingAttributes.StylusTipTransform = xf;
}
}
DrawingGroup penDrawing = new DrawingGroup();
DrawingContext dc = null;
try
{
dc = penDrawing.Open();
// Call the internal drawing method on Stroke to draw as hollow if isHollow == true
if ( isHollow )
{
singleStroke.DrawInternal(dc, singleStroke.DrawingAttributes, isHollow);
}
else
{
// Invoke the public Draw method which will handle the Highlighter correctly.
singleStroke.Draw(dc, singleStroke.DrawingAttributes);
}
}
finally
{
//.........这里部分代码省略.........
示例6: doMyStrokeRemovedExceptHistory
private void doMyStrokeRemovedExceptHistory(Stroke stroke)
{
var sum = stroke.sum().checksum.ToString();
var bounds = stroke.GetBounds();
Commands.SendDirtyStroke.Execute(new MeTLLib.DataTypes.TargettedDirtyElement(Globals.location.currentSlide,Globals.me,target,stroke.tag().privacy,sum));
}
示例7: isStrokeContainedByPolygon
private bool isStrokeContainedByPolygon(Stroke stroke, Rect currentShapeBounds)
{
bool isContained = false;
bool strokeContainedinBounds = false;
var sBounds = stroke.GetBounds();
foreach (Point p in new[]{
new Point(sBounds.Left,sBounds.Top),
new Point(sBounds.Right,sBounds.Top),
new Point(sBounds.Left,sBounds.Bottom),
new Point(sBounds.Right,sBounds.Bottom)})
if (!strokeContainedinBounds && currentShapeBounds.Contains(p))
{
strokeContainedinBounds = true;
}
if (strokeContainedinBounds)
{
var hitPointCount = 0;
int speedFactor = 1;
int tempIndex = 0;
var hitPointThreshold = (stroke.StylusPoints.Count() / speedFactor) * .75;
foreach (StylusPoint sp in stroke.StylusPoints)
{
tempIndex++;
if (tempIndex == speedFactor)
{
tempIndex = 0;
var spPoint = new Point(sp.X, sp.Y);
if (polyHitTest(currentSelectionShape.Points.ToArray(), spPoint))
{
hitPointCount++;
}
}
}
if (hitPointCount > hitPointThreshold)
{
isContained = true;
}
}
return isContained;
}
示例8: Stroke_StylusPointCollection_Bounds
public void Stroke_StylusPointCollection_Bounds ()
{
StylusPointCollection spc = new StylusPointCollection ();
spc.Add (new StylusPoint (1, 2));
Stroke s = new Stroke (spc);
Rect bounds = s.GetBounds ();
Assert.AreEqual (-0.5, bounds.Left, "Left");
Assert.AreEqual (0.5, bounds.Top, "Top");
Assert.AreEqual (3, bounds.Height, "Height");
Assert.AreEqual (3, bounds.Width, "Width");
}