本文整理汇总了C#中System.Windows.Media.DrawingContext.PushGuidelineY1方法的典型用法代码示例。如果您正苦于以下问题:C# DrawingContext.PushGuidelineY1方法的具体用法?C# DrawingContext.PushGuidelineY1怎么用?C# DrawingContext.PushGuidelineY1使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.DrawingContext
的用法示例。
在下文中一共展示了DrawingContext.PushGuidelineY1方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawingState
private double _baseGuidelineY; // the Y guideline of the text line.
/// <summary>
/// Construct drawing state for full text
/// </summary>
internal DrawingState(
DrawingContext drawingContext,
Point lineOrigin,
MatrixTransform antiInversion,
TextMetrics.FullTextLine currentLine
)
{
_drawingContext = drawingContext;
_antiInversion = antiInversion;
_currentLine = currentLine;
if (antiInversion == null)
{
_lineOrigin = lineOrigin;
}
else
{
_vectorToLineOrigin = lineOrigin;
}
if (_drawingContext != null)
{
// LineServices draws GlyphRun and TextDecorations in multiple
// callbacks and GlyphRuns may have different baselines. Pushing guideline
// for each DrawGlyphRun are too costly. We optimize for the common case where
// GlyphRuns and TextDecorations in the TextLine share the same baseline.
_baseGuidelineY = lineOrigin.Y + currentLine.Baseline;
_drawingContext.PushGuidelineY1(_baseGuidelineY);
}
}
示例2: OnRender
/// <summary>
/// Renders GlyphRun into a drawing context
/// </summary>
/// <param name="context">Drawing context</param>
protected override void OnRender(DrawingContext context)
{
if (_glyphRunProperties == null || _measurementGlyphRun == null)
return;
context.PushGuidelineY1(_glyphRunOrigin.Y);
try
{
context.DrawGlyphRun(Fill, _measurementGlyphRun);
}
finally
{
context.Pop();
}
}
示例3: _UpdateHighlightForeground
private void _UpdateHighlightForeground(DrawingContext dc, ArrayList highlights)
{
foreach (FixedHighlight fh in highlights)
{
Brush fg = null;
if (fh.HighlightType == FixedHighlightType.None)
{
#if NEVER
// use this code if you want to see unrecognized highlights
bg = Brushes.Yellow;
#else
continue;
#endif
}
Glyphs g = fh.Glyphs;
if (g == null)
{
continue;
}
Rect clipRect = fh.ComputeDesignRect();
if (clipRect == Rect.Empty)
{
continue;
}
GeneralTransform transform = fh.Element.TransformToAncestor(_page);
Transform t = transform.AffineTransform;
if (t != null)
{
dc.PushTransform(t);
}
else
{
dc.PushTransform(Transform.Identity);
}
dc.PushClip(new RectangleGeometry(clipRect));
if (fh.HighlightType == FixedHighlightType.TextSelection)
{
fg = SelectionHighlightInfo.ForegroundBrush;
}
else if (fh.HighlightType == FixedHighlightType.AnnotationHighlight)
{
fg = fh.ForegroundBrush;
}
// can add cases for new types of highlights
GlyphRun gr = g.ToGlyphRun();
if (fg == null)
{
fg = g.Fill;
}
dc.PushGuidelineY1(gr.BaselineOrigin.Y);
dc.PushClip(g.Clip);
dc.DrawGlyphRun(fg, gr);
dc.Pop(); // Glyphs clip
dc.Pop(); // Guideline
dc.Pop(); // clip
dc.Pop(); // transform
}
}
示例4: Draw
/// <summary>
/// Draw all formatted glyphruns
/// </summary>
/// <returns>drawing bounding box</returns>
public Rect Draw(
DrawingContext drawingContext,
Point currentOrigin
)
{
Rect inkBoundingBox = Rect.Empty;
Debug.Assert(_glyphs != null);
foreach (Glyphs glyphs in _glyphs)
{
GlyphRun glyphRun = glyphs.CreateGlyphRun(currentOrigin, _rightToLeft);
Rect boundingBox;
if (glyphRun != null)
{
boundingBox = glyphRun.ComputeInkBoundingBox();
if (drawingContext != null)
{
// Emit glyph run background.
glyphRun.EmitBackground(drawingContext, glyphs.BackgroundBrush);
drawingContext.PushGuidelineY1(currentOrigin.Y);
try
{
drawingContext.DrawGlyphRun(glyphs.ForegroundBrush, glyphRun);
}
finally
{
drawingContext.Pop();
}
}
}
else
{
boundingBox = Rect.Empty;
}
if (!boundingBox.IsEmpty)
{
// glyph run's ink bounding box is relative to its origin
boundingBox.X += glyphRun.BaselineOrigin.X;
boundingBox.Y += glyphRun.BaselineOrigin.Y;
}
// accumulate overall ink bounding box
inkBoundingBox.Union(boundingBox);
if (_rightToLeft)
{
currentOrigin.X -= glyphs.Width;
}
else
{
currentOrigin.X += glyphs.Width;
}
}
return inkBoundingBox;
}
示例5: DrawTextLine
/// <summary>
/// Draw a simple text line
/// </summary>
/// <returns>a drawing bounding box</returns>
private void DrawTextLine(
DrawingContext drawingContext,
Point origin
)
{
if (_runs.Length <= 0)
{
_boundingBox = Rect.Empty;
_statusFlags |= StatusFlags.BoundingBoxComputed;
return;
}
int idealXRelativeToOrigin = _idealOffsetUnRounded;
double y = origin.Y + Baseline;
if (drawingContext != null)
{
drawingContext.PushGuidelineY1(y);
}
Rect boundingBox = Rect.Empty;
try
{
foreach (SimpleRun run in _runs)
{
boundingBox.Union(
run.Draw(
drawingContext,
_settings.Formatter.IdealToReal(idealXRelativeToOrigin) + origin.X,
y,
false
)
);
idealXRelativeToOrigin += run.IdealWidth;
}
}
finally
{
if (drawingContext != null)
{
drawingContext.Pop();
}
}
if(boundingBox.IsEmpty)
{
boundingBox = new Rect(Start, 0, 0, 0);
}
else
{
boundingBox.X -= origin.X;
boundingBox.Y -= origin.Y;
}
_boundingBox = boundingBox;
_statusFlags |= StatusFlags.BoundingBoxComputed;
}