本文整理汇总了C#中System.Windows.Media.DrawingContext.PushClip方法的典型用法代码示例。如果您正苦于以下问题:C# DrawingContext.PushClip方法的具体用法?C# DrawingContext.PushClip怎么用?C# DrawingContext.PushClip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.DrawingContext
的用法示例。
在下文中一共展示了DrawingContext.PushClip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (item != null)
{
var itemRect = new Rect(item.RenderSize);
Point startPoint;
Point endPoint;
if (!showMarkerAfterItem)
{
startPoint = itemRect.TopLeft;
endPoint = itemRect.TopRight;
}
else
{
startPoint = itemRect.BottomLeft;
endPoint = itemRect.BottomRight;
}
startPoint = item.TranslatePoint(startPoint, control);
endPoint = item.TranslatePoint(endPoint, control);
drawingContext.PushClip(new RectangleGeometry(adornerViewRect));
drawingContext.DrawLine(new Pen(Brushes.Green, 2), startPoint, endPoint);
}
}
示例2: Draw
public void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c)
{
if (applied?.Brush == null)
return;
const int scale = 4;
// Set up variables for this frame
var rect = props.Contain
? new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale)
: new Rect(props.X*scale, props.Y*scale, props.Width*scale, props.Height*scale);
var clip = new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale);
// Take an offset of 4 to allow layers to slightly leave their bounds
var progress = (6.0 - props.AnimationProgress)*10.0;
if (progress < 0)
{
// Can't meddle with the original brush because it's frozen.
var brush = applied.Brush.Clone();
brush.Opacity = 1 + 0.025*progress;
if (brush.Opacity < 0)
brush.Opacity = 0;
if (brush.Opacity > 1)
brush.Opacity = 1;
applied.Brush = brush;
}
rect.Inflate(-rect.Width/100.0*progress, -rect.Height/100.0*progress);
clip.Inflate(-clip.Width/100.0*progress, -clip.Height/100.0*progress);
c.PushClip(new RectangleGeometry(clip));
c.DrawRectangle(applied.Brush, null, rect);
c.Pop();
}
示例3: Draw
public void Draw(LayerModel layer, DrawingContext c)
{
// If an animation is present, let it handle the drawing
if (layer.LayerAnimation != null && !(layer.LayerAnimation is NoneAnimation))
{
layer.LayerAnimation.Draw(layer.Properties, layer.AppliedProperties, c);
return;
}
// Otherwise draw the rectangle with its layer.AppliedProperties dimensions and brush
var rect = layer.Properties.Contain
? new Rect(layer.AppliedProperties.X*4,
layer.AppliedProperties.Y*4,
layer.AppliedProperties.Width*4,
layer.AppliedProperties.Height*4)
: new Rect(layer.Properties.X*4,
layer.Properties.Y*4,
layer.Properties.Width*4,
layer.Properties.Height*4);
var clip = new Rect(layer.AppliedProperties.X*4, layer.AppliedProperties.Y*4,
layer.AppliedProperties.Width*4, layer.AppliedProperties.Height*4);
c.PushClip(new RectangleGeometry(clip));
c.DrawRectangle(layer.AppliedProperties.Brush, null, rect);
c.Pop();
}
示例4: Draw
public void Draw(DrawingContext context, DrawingArgs args)
{
context.PushClip(new RectangleGeometry(args.RenderBounds));
if (m_IsDirty || args.RequiresFullRedraw)
{
m_LonePoints.Clear();
System.Windows.Media.StreamGeometry geo = new StreamGeometry();
using (var c = geo.Open())
{
Point? figureStart = null;
int pointCount = 0; //point in the figure
if (Values.Count() == 1 && Values.First().HasValue)
{
m_LonePoints.Add(Values.First().Value);
}
else
{
foreach (var p in Values)
{
if (p.HasValue)
{
if (!figureStart.HasValue)
{
figureStart = p.Value;
c.BeginFigure(figureStart.Value, false, false);
pointCount = 1;
}
else
{
c.LineTo(p.Value, true, true);
pointCount++;
}
}
else
{
//detect lone points and draw a cross
if (pointCount == 1)
{
m_LonePoints.Add(figureStart.Value);
}
figureStart = null;
}
}
}
}
m_Geo = geo;
m_IsDirty = false;
}
m_Geo.Transform = args.Transform;
context.DrawGeometry(null, Pen, m_Geo);
var radius = Pen.Thickness;
foreach (var p in m_LonePoints)
{
context.DrawEllipse(m_Pen.Brush, null, args.Transform.Transform(p), radius, radius);
}
}
示例5: Render
public void Render(DrawingContext drawingContext)
{
if (IsVisible)
{
drawingContext.PushClip(_clipGeometry);
drawingContext.DrawGeometry(null, PainterCache.GridLinePen, _geometry);
drawingContext.Pop();
}
}
示例6: DrawCircle
public void DrawCircle(Point center, DrawingContext drawingContext, Size windowSize, bool drawCircle)
{
var rectangle = new Rect(center.X - Radius, center.Y - Radius, Radius * 2, Radius * 2);
var path = new PathGeometry();
path.AddGeometry(new EllipseGeometry(rectangle));
drawingContext.PushClip(path);
var windowRect = new Rect(windowSize);
drawingContext.DrawImage(Bitmap, windowRect);
if (drawCircle)
drawingContext.DrawEllipse(Brushes.Transparent, new Pen(Brushes.Red, 1.5), center, Radius, Radius);
}
示例7: RenderHeader
/// <summary>This method performs the actual render operation to show a text label</summary>
/// <param name="dc">Drawing context</param>
/// <param name="info">Render info</param>
/// <param name="scale">The scale.</param>
/// <param name="offset">The offset.</param>
public virtual void RenderHeader(DrawingContext dc, AutoHeaderTextRenderInfo info, double scale, Point offset)
{
dc.PushTransform(new TranslateTransform(offset.X, offset.Y));
dc.PushTransform(new ScaleTransform(scale, scale));
dc.PushClip(new RectangleGeometry(info.RenderRect));
info.FormattedText.SetMaxTextWidths(new[] { info.RenderRect.Width });
info.FormattedText.MaxLineCount = 1;
info.FormattedText.Trimming = TextTrimming.CharacterEllipsis;
dc.DrawText(info.FormattedText, info.RenderRect.TopLeft);
dc.Pop();
dc.Pop();
dc.Pop();
}
示例8: InnerDraw
//private const int Margin = 3;
protected override void InnerDraw(DrawingContext drawingContext)
{
base.InnerDraw(drawingContext);
if (_scaleTransform != null)
drawingContext.PushTransform(_scaleTransform);
if (_clipGeometry != null)
drawingContext.PushClip(_clipGeometry);
drawingContext.DrawDrawing(_textDrawing);
if (_clipGeometry != null)
drawingContext.Pop();
if (_scaleTransform != null)
drawingContext.Pop();
}
示例9: OnRender
protected override void OnRender(DrawingContext ctx)
{
ctx.PushClip(new RectangleGeometry(new Rect(0, 0, this.ActualWidth, this.ActualHeight)));//restrict drawing to textbox
ctx.DrawRectangle(LineNumberBackground, null, new Rect(0, 0, this.ActualWidth, this.ActualHeight));//Draw Background
int count = (int)(this.ActualHeight / CodeBox.GetLineHeight());
string lineText = string.Join(
Environment.NewLine,
Enumerable.Range(firstLine + 1, count).Select(l => l.ToString()).ToArray());
var text = CodeBox.GetFormatText(lineText, LineNumberForeground);
ctx.DrawText(text, new Point(0, 0));
}
示例10: Render
public void Render(DrawingContext drawingContext)
{
if (!_hidden)
{
if (_renderClip != null)
{
drawingContext.PushClip(_renderClip);
}
OnRender(drawingContext);
if (_renderClip != null)
{
drawingContext.Pop();
}
}
}
示例11: ApplyFilter
protected override void ApplyFilter(FastBitmap source, DrawingContext dc, int width, int height)
{
// Clip to rounded rectangle shape.
dc.PushClip(new RectangleGeometry(new Rect(new Size(width, height)), Roundness, Roundness));
// Draw image.
dc.PushTransform(new TranslateTransform(BorderWidth, BorderWidth));
dc.DrawImage(source.InnerBitmap, new Rect(0, 0, source.Width, source.Height));
dc.Pop();
dc.Pop();
// Draw border.
dc.DrawRoundedRectangle(null, new Pen(new SolidColorBrush(BorderColor.ToWpfColor()), BorderWidth),
new Rect(BorderWidth / 2.0, BorderWidth / 2.0, width - BorderWidth, height - BorderWidth),
Roundness, Roundness);
}
示例12: OnRender
protected override void OnRender(DrawingContext dc)
{
if ( this.ClipToBounds )
{
dc.PushClip( new RectangleGeometry( new Rect( 0, 0, this.ActualWidth, this.ActualHeight ) ) );
}
dc.DrawRectangle( Brushes.White, new Pen(), new Rect( 0, 0, this.ActualWidth, this.ActualHeight ) );
base.OnRender( dc );
if ( this.Text == String.Empty && this.HintTextImage != null )
{
dc.DrawText( this.HintTextImage, new Point( 4, ( this.ActualHeight - this.HintTextImage.Height ) / 2 ) );
}
if ( this.ClipToBounds )
{
// pop the clip that we added
dc.Pop();
}
}
示例13: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (_diffs != null)
{
var viewLeft = _editLeft.TextArea.TextView;
var viewRight = _editRight.TextArea.TextView;
viewLeft.EnsureVisualLines();
viewRight.EnsureVisualLines();
var leftFirst = viewLeft.VisualLines.First().FirstDocumentLine.LineNumber;
var leftLast = viewLeft.VisualLines.Last().LastDocumentLine.LineNumber;
var rightFirst = viewRight.VisualLines.First().FirstDocumentLine.LineNumber;
var rightLast = viewRight.VisualLines.Last().LastDocumentLine.LineNumber;
Func<ListCompare, bool> inRange = (c => Math.Abs(c.Base) >= leftFirst && Math.Abs(c.Base) <= leftLast
|| Math.Abs(c.Compare) >= rightFirst && Math.Abs(c.Compare) <= rightLast);
var start = 0;
while (start < _diffs.Count && !inRange(_diffs[start])) start++;
if (start >= _diffs.Count) start--;
var end = start;
while (start >= 0 && GetDiffType(_diffs[start]) != DiffType.Normal) start--;
while (end < _diffs.Count && inRange(_diffs[end])) end++;
end--;
while (end < _diffs.Count && GetDiffType(_diffs[end]) != DiffType.Normal) end++;
var lastType = GetDiffType(_diffs[start]);
DiffType currType;
Geometry geom;
drawingContext.PushClip(new RectangleGeometry(new Rect(new Point(0, 0), this.RenderSize)));
for (var i = start + 1; i <= end; i++)
{
currType = GetDiffType(_diffs[i]);
if (currType != lastType)
{
geom = GetPath(new Point(0, viewLeft.GetOrConstructVisualLine(viewLeft.Document.GetLineByNumber(Math.Abs(_diffs[i].Base))).VisualTop - viewLeft.VerticalOffset),
new Point(Width, viewRight.GetOrConstructVisualLine(viewRight.Document.GetLineByNumber(Math.Abs(_diffs[i].Compare))).VisualTop - viewRight.VerticalOffset));
drawingContext.DrawGeometry(null, new Pen() { Thickness = 2, Brush = Brushes.Black }, geom);
}
lastType = currType;
}
}
}
示例14: Draw
public void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c)
{
if (applied.Brush == null)
return;
const int scale = 4;
// Set up variables for this frame
var rect = props.Contain
? new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale)
: new Rect(props.X*scale, props.Y*scale, props.Width*scale, props.Height*scale);
var s1 = new Rect(new Point(rect.X, rect.Y + props.AnimationProgress), new Size(rect.Width, rect.Height));
var s2 = new Rect(new Point(s1.X, s1.Y - rect.Height), new Size(rect.Width, rect.Height + .5));
var clip = new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale);
c.PushClip(new RectangleGeometry(clip));
c.DrawRectangle(applied.Brush, null, s1);
c.DrawRectangle(applied.Brush, null, s2);
c.Pop();
}
示例15: Draw
public void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c)
{
if (applied.Brush == null)
return;
const int scale = 4;
// Set up variables for this frame
var rect = props.Contain
? new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale)
: new Rect(props.X*scale, props.Y*scale, props.Width*scale, props.Height*scale);
var clip = new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale);
// Can't meddle with the original brush because it's frozen.
var brush = applied.Brush.Clone();
brush.Opacity = (Math.Sin(props.AnimationProgress*Math.PI) + 1)*(props.Opacity/2);
applied.Brush = brush;
c.PushClip(new RectangleGeometry(clip));
c.DrawRectangle(applied.Brush, null, rect);
c.Pop();
}