本文整理汇总了C#中System.Windows.Media.DrawingContext.DrawGeometry方法的典型用法代码示例。如果您正苦于以下问题:C# DrawingContext.DrawGeometry方法的具体用法?C# DrawingContext.DrawGeometry怎么用?C# DrawingContext.DrawGeometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.DrawingContext
的用法示例。
在下文中一共展示了DrawingContext.DrawGeometry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawHelpText
/// <summary>
/// Draw some helpful text.
/// </summary>
/// <param name="dc"></param>
protected virtual void DrawHelpText(DrawingContext dc)
{
System.Windows.Media.Typeface backType =
new System.Windows.Media.Typeface(new System.Windows.Media.FontFamily("sans courier"),
FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
System.Windows.Media.FormattedText formatted = new System.Windows.Media.FormattedText(
"Click & move the mouse to select a capture area.\nENTER/F10: Capture\nBACKSPACE/DEL: Start over\nESC: Exit",
System.Globalization.CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
backType,
32.0f,
new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.White));
// Make sure the text shows at 0,0 on the primary screen
System.Drawing.Point primScreen = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Location;
Point clientBase = PointFromScreen(new Point(primScreen.X + 5, primScreen.Y + 5));
Geometry textGeo = formatted.BuildGeometry(clientBase);
dc.DrawGeometry(
System.Windows.Media.Brushes.White,
null,
textGeo);
dc.DrawGeometry(
null,
new System.Windows.Media.Pen(System.Windows.Media.Brushes.White, 1),
textGeo);
}
示例2: OnRender
/// <summary>
/// OnRender override draws the geometry of the text and optional highlight.
/// </summary>
/// <param name="drawingContext">Drawing context of the OutlineText control.</param>
protected override void OnRender(DrawingContext drawingContext)
{
CreateText();
// Draw the outline based on the properties that are set.
drawingContext.DrawGeometry(Fill, new Pen(Stroke, StrokeThickness), _textGeometry);
}
示例3: 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();
}
示例4: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder();
geoBuilder.CornerRadius = textArea.SelectionCornerRadius;
foreach (var segment in textArea.Selection.Segments) {
geoBuilder.AddSegment(textView, segment);
}
Geometry geometry = geoBuilder.CreateGeometry();
if (geometry != null)
{
if (textArea.Selection.IsFindOnPageSelection())
{
drawingContext.DrawGeometry(textArea.FindOnPageBrush, textArea.FindOnPageBorder, geometry);
textView.findOnPageSelectionGeometry = geometry;
}
else
{
drawingContext.DrawGeometry(textArea.SelectionBrush, textArea.SelectionBorder, geometry);
textView.findOnPageSelectionGeometry = null;
}
}
else
{
textView.findOnPageSelectionGeometry = null;
}
}
示例5: 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();
}
示例6: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (AdornedElement.RenderSize.Width < 20)
return;
drawingContext.PushTransform(
new TranslateTransform(
AdornedElement.RenderSize.Width - 15,
(AdornedElement.RenderSize.Height - 5) / 2));
if (IsSecondaryAdorner)
{
drawingContext.DrawGeometry(null, new Pen(Brushes.Black, 0.5),
Direction == ListSortDirection.Ascending ?
_AscGeometry : _DescGeometry);
}
else
{
drawingContext.DrawGeometry(Brushes.Black, null,
Direction == ListSortDirection.Ascending ?
_AscGeometry : _DescGeometry);
}
drawingContext.Pop();
}
示例7: 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);
}
}
示例8: OnRender
protected override void OnRender(DrawingContext dc)
{
base.OnRender(dc);
if (_childrenPositions.Count == 0)
return;
if (!IsSmoothOutline)
{
dc.DrawGeometry(AreaBrush, LinePen, CreateLineCurveGeometry());
}
else
{
dc.DrawGeometry(AreaBrush, LinePen, CreateAreaCurveGeometry());
}
}
示例9: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
Size renderSize = this.RenderSize;
TextView textView = this.TextView;
if (textView != null && textView.VisualLinesValid) {
foreach (VisualLine line in textView.VisualLines) {
Rect rect = new Rect(0, line.VisualTop - textView.ScrollOffset.Y, 5, line.Height);
LineChangeInfo info = changeWatcher.GetChange(line.FirstDocumentLine.LineNumber);
switch (info.Change) {
case ChangeType.None:
break;
case ChangeType.Added:
drawingContext.DrawRectangle(Brushes.LightGreen, null, rect);
break;
case ChangeType.Modified:
drawingContext.DrawRectangle(Brushes.LightBlue, null, rect);
break;
case ChangeType.Unsaved:
drawingContext.DrawRectangle(Brushes.Yellow, null, rect);
break;
default:
throw new Exception("Invalid value for ChangeType");
}
if (!string.IsNullOrEmpty(info.DeletedLinesAfterThisLine)) {
Point pt1 = new Point(5, line.VisualTop + line.Height - textView.ScrollOffset.Y - 4);
Point pt2 = new Point(10, line.VisualTop + line.Height - textView.ScrollOffset.Y);
Point pt3 = new Point(5, line.VisualTop + line.Height - textView.ScrollOffset.Y + 4);
drawingContext.DrawGeometry(Brushes.Red, null, new PathGeometry(new List<PathFigure>() { CreateNAngle(pt1, pt2, pt3) }));
}
// special case for line 0
if (line.FirstDocumentLine.LineNumber == 1) {
info = changeWatcher.GetChange(0);
if (!string.IsNullOrEmpty(info.DeletedLinesAfterThisLine)) {
Point pt1 = new Point(5, line.VisualTop - textView.ScrollOffset.Y - 4);
Point pt2 = new Point(10, line.VisualTop - textView.ScrollOffset.Y);
Point pt3 = new Point(5, line.VisualTop - textView.ScrollOffset.Y + 4);
drawingContext.DrawGeometry(Brushes.Red, null, new PathGeometry(new List<PathFigure>() { CreateNAngle(pt1, pt2, pt3) }));
}
}
}
}
}
示例10: DoRender
protected override void DoRender(DrawingContext dc)
{
foreach (var tuple in FindSuperTasks())
{
FrameworkElement parentTaskElement = tuple.Item1;
var startPoint = FindPoint(parentTaskElement, new Point(0, parentTaskElement.ActualHeight/2));
startPoint.Offset(0, tuple.Item2.IndentLevel * 3);
var endpoints = (from vm in tuple.Item2.ChildVMs()
let element = FindElement(vm)
let border = FindBorder(element)
select FindPoint(border, new Point(0, border.ActualHeight/2))).OrderBy(pt => pt.Y).ToArray();
var leftMost = endpoints.Concat(new[]{startPoint}).Min(point => point.X);
var bottomMost = endpoints.Last();
var builder = BuildPath.From(startPoint)
.LineTo(leftMost - 3, startPoint.Y)
.CurveTo(leftMost - 8, startPoint.Y + 5, SweepDirection.Counterclockwise)
.LineTo(leftMost - 8, bottomMost.Y - 5)
.CurveTo(leftMost - 3, bottomMost.Y, SweepDirection.Counterclockwise)
.LineTo(bottomMost.X, bottomMost.Y);
foreach (var endpoint in endpoints.Take(endpoints.Count() - 1))
{
builder.NewFigureFrom(leftMost - 8, endpoint.Y).LineTo(endpoint.X, endpoint.Y);
}
var path = builder.Build();
dc.DrawGeometry(null, _pen, path);
}
}
示例11: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
if (this.adornedBuilding.ShowSpawnShieldLayer)
{
Rect adornedBuildingRect = new Rect(this.AdornedElement.RenderSize);
double gridCellSize = (adornedBuildingRect.Width / (double)this.adornedBuilding.GridWidth);
Rect spawnShieldRect = new Rect(
adornedBuildingRect.X - gridCellSize,
adornedBuildingRect.Y - gridCellSize,
adornedBuildingRect.Width + (2 * gridCellSize),
adornedBuildingRect.Height + (2 * gridCellSize));
Geometry spawnShieldGeometry = Geometry.Combine(
new RectangleGeometry(spawnShieldRect),
new RectangleGeometry(adornedBuildingRect),
GeometryCombineMode.Exclude,
null);
drawingContext.DrawGeometry(
this.spawnShieldBrush,
null,
spawnShieldGeometry);
}
base.OnRender(drawingContext);
}
示例12: Render
public void Render(DrawingContext dc)
{
if (_datasource != null && _datasource.Count > 0)
{
dc.DrawGeometry(null, new Pen(Brushes.White, 2), _geo);
}
}
示例13: Draw
public void Draw(TextView textview, DrawingContext drawingContext)
{
if (_result != null)
{
var backgroundGeometryBuilder = new BackgroundGeometryBuilder
{
CornerRadius = 1.0,
AlignToMiddleOfPixels = true
};
backgroundGeometryBuilder.AddSegment(textview, new TextSegment
{
StartOffset = _result.OpeningBracketOffset,
Length = _result.OpeningBracketLength
});
backgroundGeometryBuilder.CloseFigure();
backgroundGeometryBuilder.AddSegment(textview, new TextSegment
{
StartOffset = _result.ClosingBracketOffset,
Length = _result.ClosingBracketLength
});
var geometry = backgroundGeometryBuilder.CreateGeometry();
if (_borderPen == null)
{
UpdateColors(DefaultBackground, DefaultBackground);
}
if (geometry != null)
{
drawingContext.DrawGeometry(_backgroundBrush, _borderPen, geometry);
}
}
}
示例14: Draw
public void Draw(TextView textView, DrawingContext drawingContext)
{
if (textView == null)
{
throw new ArgumentNullException("textView");
}
if (drawingContext == null)
{
throw new ArgumentNullException("drawingContext");
}
if (this.currentResults == null || !textView.VisualLinesValid)
{
return;
}
ReadOnlyCollection<VisualLine> visualLines = textView.VisualLines;
if (visualLines.Count == 0)
{
return;
}
int offset = visualLines.First<VisualLine>().FirstDocumentLine.Offset;
int endOffset = visualLines.Last<VisualLine>().LastDocumentLine.EndOffset;
foreach (var current in this.currentResults.FindOverlappingSegments(offset, endOffset - offset))
{
BackgroundGeometryBuilder backgroundGeometryBuilder = new BackgroundGeometryBuilder();
backgroundGeometryBuilder.AlignToMiddleOfPixels = true;
backgroundGeometryBuilder.CornerRadius = 3.0;
backgroundGeometryBuilder.AddSegment(textView, current);
Geometry geometry = backgroundGeometryBuilder.CreateGeometry();
if (geometry != null)
{
drawingContext.DrawGeometry(this.markerBrush, this.markerPen, geometry);
}
}
}
示例15: Render
public void Render(DrawingContext context, IElement element)
{
var pathElement = element as CurvedPathElement;
if (pathElement != null)
{
var pen = new Pen(new SolidColorBrush(pathElement.LineColor), pathElement.LineWidth);
var brush = new SolidColorBrush(pathElement.FillColor);
var topCurveRadius = pathElement.Radius +(pathElement.PathWidth/2);
var bottomCurveRadius = pathElement.Radius -(pathElement.PathWidth/2);
var geometry = new StreamGeometry();
using (var gc = geometry.Open())
{
gc.BeginFigure(pathElement.BottomLeft, false, true);
gc.LineTo(pathElement.TopLeft, true, true);
gc.ArcTo(pathElement.TopRight,
new Size(topCurveRadius, topCurveRadius),
1, false, SweepDirection.Clockwise, true, true);
gc.LineTo(pathElement.BottomRight, true, true);
gc.ArcTo(pathElement.BottomLeft,
new Size(bottomCurveRadius, bottomCurveRadius),
1, false, SweepDirection.Counterclockwise, true, true);
}
context.DrawGeometry(brush, pen, geometry);
//var topPen = new Pen(Brushes.Red, 1);
//var bottomPen = new Pen(Brushes.Blue, 1);
//context.DrawEllipse(brush, topPen, pathElement.Origin, topCurveRadius, topCurveRadius);
//context.DrawEllipse(brush, bottomPen, pathElement.Origin, bottomCurveRadius, bottomCurveRadius);
//context.DrawEllipse(brush, pen, pathElement.Origin, pathElement.Radius, pathElement.Radius);
}
}