本文整理汇总了C#中System.Windows.Media.DrawingContext.PushTransform方法的典型用法代码示例。如果您正苦于以下问题:C# DrawingContext.PushTransform方法的具体用法?C# DrawingContext.PushTransform怎么用?C# DrawingContext.PushTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.DrawingContext
的用法示例。
在下文中一共展示了DrawingContext.PushTransform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
drawingContext.PushTransform(new TranslateTransform(AdornedElement.RenderSize.Width - 14, (AdornedElement.RenderSize.Height - 18) / 2.0));
drawingContext.DrawGeometry(ArrowBrush, null, sda_render_geometry);
drawingContext.Pop();
}
示例2: OnRender
protected override void OnRender(DrawingContext dc)
{
Point pos, tangent;
double angleInRadians;
double angleInDegrees;
TransformGroup tg;
Pen pen = new Pen(Stroke, StrokeThickness);
//dc.DrawGeometry(null, pen, LinePath);
if (BeginCap != null)
{
LinePath.GetPointAtFractionLength(0.01d, out pos, out tangent);
angleInRadians = Math.Atan2(tangent.Y, tangent.X) + Math.PI;
angleInDegrees = angleInRadians * 180 / Math.PI + 180;
tg = new TransformGroup();
tg.Children.Add(new RotateTransform(angleInDegrees));
LinePath.GetPointAtFractionLength(0.0d, out pos, out tangent);
tg.Children.Add(new TranslateTransform(pos.X, pos.Y));
dc.PushTransform(tg);
dc.DrawGeometry(Brushes.DeepPink, pen, BeginCap);
dc.Pop();
}
if (EndCap != null)
{
LinePath.GetPointAtFractionLength(0.99, out pos, out tangent);
angleInRadians = Math.Atan2(tangent.Y, tangent.X) + Math.PI;
angleInDegrees = angleInRadians * 180 / Math.PI;
tg = new TransformGroup();
tg.Children.Add(new RotateTransform(angleInDegrees));
LinePath.GetPointAtFractionLength(1, out pos, out tangent);
tg.Children.Add(new TranslateTransform(pos.X, pos.Y));
dc.PushTransform(tg);
dc.DrawGeometry(Brushes.DeepPink, pen, EndCap);
}
}
示例3: drawLimb
public void drawLimb(DrawingContext dc, Point p1, Point p2, int margin)
{
dc.PushTransform(new TranslateTransform(p1.X, p1.Y));
Vector diff = p2 - p1;
diff.Normalize();
double angle = Math.Acos(diff.Y) * (180.0 / Math.PI);
if (Double.IsNaN(angle))
angle = 0;
if (Double.IsNaN(diff.X))
diff.X = 0;
dc.PushTransform(new RotateTransform(Math.Sign(diff.X) * (-1) * angle));
Vector diff2 = p2 - p1;
double scale = diff2.Length / (this.Height - 2 * margin);
dc.PushTransform(new ScaleTransform(1, scale));
dc.PushTransform(new TranslateTransform(-this.Width / 2.0, -margin));
dc.DrawImage(this.Image, new Rect(0, 0, this.Width, this.Height));
dc.Pop();
dc.Pop();
dc.Pop();
dc.Pop();
}
示例4: DrawPointElement
protected override void DrawPointElement(DrawingContext dc, int Zoom)
{
dc.DrawLine(new Pen(Brushes.Black, 2), new Point(), new Point(0, -BodyOffset));
dc.PushTransform(new TranslateTransform(0, - 0.5 * BodyHeight - BodyOffset));
dc.DrawRectangle(Brushes.Black, null,
new Rect(-0.5 * BodyWidth, -0.5 * BodyHeight, BodyWidth, BodyHeight));
for (int i = 0; i < Lights.Length; i++)
dc.DrawEllipse(Lights[i], null, new Point(0, (2 + LightRadius + 1) * (i - 1)), LightRadius, LightRadius);
dc.PushTransform(new TranslateTransform(0.5 * BodyWidth + 2, -0.5 * BodyHeight));
if (Zoom > 11)
{
PrintStack(dc,
new FormattedText(Target.Name, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 10, Brushes.Black),
new FormattedText(OrdinateString, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 8, Brushes.Blue));
}
dc.Pop();
dc.Pop();
}
示例5: InnerDraw
protected override void InnerDraw(DrawingContext drawingContext)
{
drawingContext.PushTransform(_translateTransform);
drawingContext.PushTransform(_rotateTransform);
base.InnerDraw(drawingContext);
drawingContext.Pop();
drawingContext.Pop();
}
示例6: DrawTriangle
private void DrawTriangle(DrawingContext drawingContext, Point origin, double rotation)
{
drawingContext.PushTransform(new TranslateTransform(origin.X, origin.Y));
drawingContext.PushTransform(new RotateTransform(rotation));
drawingContext.DrawGeometry(m_Pen.Brush, null, m_Triangle);
drawingContext.Pop();
drawingContext.Pop();
}
示例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: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
AnimationControl();
var width = Width < 1 ? 1 : Width;
drawingContext.PushTransform(new TranslateTransform(RenderSize.Width / 2, RenderSize.Height / 2));
for (int i = 0; i < c_Blobs; i++)
{
drawingContext.PushTransform(new RotateTransform((360 / c_Blobs) * i));
drawingContext.DrawRectangle(m_Brushes[i], null, new Rect(0, width / 4.25, width / 16.0, width / 4.0));
drawingContext.Pop();
}
drawingContext.Pop();
}
示例9: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (AdornedElement.RenderSize.Width < 20)
return;
TranslateTransform transform = new TranslateTransform
(
AdornedElement.RenderSize.Width - 15,
(AdornedElement.RenderSize.Height - 5) / 2
);
transform = new TranslateTransform
(
AdornedElement.RenderSize.Width / 2 - 3.5,
AdornedElement.RenderSize.Height / 2 - 10
);
drawingContext.PushTransform(transform);
Geometry geometry = ascGeometry;
if (this.Direction == ListSortDirection.Descending)
geometry = descGeometry;
drawingContext.DrawGeometry(Brushes.LightGray, null, geometry);
drawingContext.Pop();
}
示例10: RenderImportanceArrow
private void RenderImportanceArrow(DrawingContext dc, FrameworkElement mostImportant, FrameworkElement leastImportant)
{
var startPoint = FindPoint(mostImportant, new Point(mostImportant.ActualWidth/2, mostImportant.ActualHeight));
var endPoint = FindPoint(leastImportant, new Point(leastImportant.ActualWidth/2, 0));
var vector = Point.Subtract(endPoint, startPoint);
var midPoint = Point.Add(startPoint, Vector.Multiply(vector, 0.66));
Transform arrowTransform = Transform.Identity;
double angle;
if (Math.Abs((angle = Vector.AngleBetween(vector, new Vector(0, -1))) - 0) > double.Epsilon)
{
arrowTransform = new RotateTransform(angle, midPoint.X, midPoint.Y);
}
var line = BuildPath.From(startPoint).LineTo(endPoint.X, endPoint.Y).Build();
var arrow = BuildPath.From(midPoint.X - 3, midPoint.Y - 3).LineTo(midPoint.X, midPoint.Y)
.LineTo(midPoint.X + 3, midPoint.Y - 3).Build();
dc.DrawGeometry(null, _pen, line);
dc.PushTransform(arrowTransform);
dc.DrawGeometry(null, _pen, arrow);
dc.Pop();
}
示例11: RenderBackground
/// <summary>This method draws a rectangular background around a group of elements</summary>
/// <param name="dc">The drawing context.</param>
/// <param name="info">Render info</param>
/// <param name="scale">The scale.</param>
/// <param name="offset">The offset.</param>
public virtual void RenderBackground(DrawingContext dc, GroupBackgroundRenderInfo info, double scale, Point offset)
{
dc.PushTransform(new TranslateTransform(offset.X, offset.Y));
dc.PushTransform(new ScaleTransform(scale, scale));
dc.DrawRectangle(info.Background, null, info.RenderRect);
if (info.Border != null && info.BorderWidth > 0)
{
var rect2 = new Rect(info.RenderRect.X + (info.BorderWidth/2),
info.RenderRect.Y + (info.BorderWidth/2),
info.RenderRect.Width + info.BorderWidth,
info.RenderRect.Height + info.BorderWidth);
dc.DrawRectangle(null, new Pen(info.Border, info.BorderWidth), rect2);
}
dc.Pop();
dc.Pop();
}
示例12: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
PushButton pushButton = Visual as PushButton;
if (pushButton.Pushed && _pushedImage != null)
{
drawingContext.DrawImage(_pushedImage, _imageRect);
}
else if (_image != null)
{
drawingContext.DrawImage(_image, _imageRect);
}
if (pushButton.Pushed)
{
drawingContext.PushTransform(new TranslateTransform(pushButton.TextPushOffset.X, pushButton.TextPushOffset.Y));
}
if (pushButton.Glyph != PushButtonGlyph.None)
{
drawingContext.DrawGeometry(_glyphBrush, _glyphPen, _glyphPath);
}
pushButton.TextFormat.RenderText(drawingContext, _textBrush, pushButton.Text, _imageRect);
if (pushButton.Pushed)
{
drawingContext.Pop();
}
}
示例13: DrawPointElement
protected override void DrawPointElement(DrawingContext dc, int Zoom)
{
if (Zoom > 12 || IsMouseOver)
{
string postLabelText = string.Format("{0}км", (double)Post.Ordinate / 1000);
var postLabel = new FormattedText(postLabelText, CultureInfo.CurrentCulture,
FlowDirection.LeftToRight, new Typeface("Verdana"), 10, mainBrush);
const int flagHeight = 22;
dc.PushTransform(new TranslateTransform(0, -flagHeight));
dc.DrawRectangle(Brushes.White, new Pen(mainBrush, 1), new Rect(-0.5, -0.5, Math.Round(postLabel.Width) + 5, Math.Round(postLabel.Height) + 2));
dc.DrawText(postLabel, new Point(2, 0));
dc.DrawLine(new Pen(mainBrush, 2), new Point(0, 0), new Point(0, flagHeight));
dc.Pop();
}
if (Zoom > 8)
dc.DrawEllipse(SectionBrush, new Pen(mainBrush, 1.5), new Point(0, 0), 5, 5);
else
dc.DrawRectangle(SectionBrush, null, new Rect(-2, -2, 4, 4));
if (IsMouseOver)
{
dc.PushTransform(new TranslateTransform(3, 10));
PrintStack(dc,
new FormattedText(Post.Direction == OrdinateDirection.Increasing ? "Возрастает по неч." : "Убывает по неч.",
CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 10, Brushes.DarkBlue),
new FormattedText(String.Format("Пути: {0}", string.Join(", ", Post.Tracks.Select(TrackName))),
CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 10, Brushes.DarkOliveGreen));
dc.Pop();
}
}
示例14: InnerDraw
protected override void InnerDraw(DrawingContext drawingContext)
{
base.InnerDraw(drawingContext);
drawingContext.PushTransform(_scaleTransform);
drawingContext.DrawDrawing(_textDrawing);
drawingContext.Pop();
}
示例15: ApplyFilter
/// <summary>
/// Applies the <see cref="ShinyFloorFilter" /> to the specified <paramref name="source"/>.
/// </summary>
/// <param name="source">The source image.</param>
/// <param name="dc"></param>
/// <param name="width"></param>
/// <param name="height"></param>
protected override void ApplyFilter(FastBitmap source, DrawingContext dc, int width, int height)
{
// First, draw reflected image with an opacity mask.
int reflectionHeight = (int)(source.Height * (ReflectionPercentage / 100.0f));
dc.PushTransform(new TransformGroup
{
Children = new TransformCollection
{
new ScaleTransform {ScaleY = -1},
new TranslateTransform {Y = GetReflectionOffsetY(source) + reflectionHeight}
}
});
dc.PushOpacityMask(new LinearGradientBrush(
Colors.Transparent,
Color.FromArgb((byte)(255.0f * (ReflectionOpacity / 100.0f)), 0, 0, 0),
new Point(0, 0),
new Point(0, 1)));
dc.DrawImage(new CroppedBitmap(source.InnerBitmap, new Int32Rect(0, source.Height - reflectionHeight, source.Width, reflectionHeight)),
new Rect(0, 0, source.Width, reflectionHeight));
dc.Pop();
dc.Pop();
// Draw original image.
dc.DrawImage(source.InnerBitmap, new Rect(0, 0, source.Width, source.Height));
}