本文整理汇总了C#中System.Windows.Ink.Stroke.DrawInternal方法的典型用法代码示例。如果您正苦于以下问题:C# Stroke.DrawInternal方法的具体用法?C# Stroke.DrawInternal怎么用?C# Stroke.DrawInternal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Ink.Stroke
的用法示例。
在下文中一共展示了Stroke.DrawInternal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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
{
//.........这里部分代码省略.........