本文整理汇总了C#中System.Windows.Media.DrawingContext类的典型用法代码示例。如果您正苦于以下问题:C# DrawingContext类的具体用法?C# DrawingContext怎么用?C# DrawingContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DrawingContext类属于System.Windows.Media命名空间,在下文中一共展示了DrawingContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
double segmentStart;
double segmentEnd;
if (Edge.Orientation == Orientation.Vertical)
{
segmentStart = Math.Min(Edge.Range.SegmentStart, CanvasItem.Top);
segmentEnd = Math.Max(Edge.Range.SegmentEnd, CanvasItem.Bottom);
}
else
{
segmentStart = Math.Min(Edge.Range.SegmentStart, CanvasItem.Left);
segmentEnd = Math.Max(Edge.Range.SegmentEnd, CanvasItem.Right);
}
var point1 = new Point(Edge.AxisDistance, segmentStart);
var point2 = new Point(Edge.AxisDistance, segmentEnd);
if (Edge.Orientation == Orientation.Horizontal)
{
point1 = point1.Swap();
point2 = point2.Swap();
}
drawingContext.DrawLine(Pen, point1, point2);
}
示例2: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
FoldingMargin margin = VisualParent as FoldingMargin;
Pen activePen = new Pen(margin.SelectedFoldingMarkerBrush, 1);
Pen inactivePen = new Pen(margin.FoldingMarkerBrush, 1);
activePen.StartLineCap = inactivePen.StartLineCap = PenLineCap.Square;
activePen.EndLineCap = inactivePen.EndLineCap = PenLineCap.Square;
Size pixelSize = PixelSnapHelpers.GetPixelSize(this);
Rect rect = new Rect(pixelSize.Width / 2,
pixelSize.Height / 2,
this.RenderSize.Width - pixelSize.Width,
this.RenderSize.Height - pixelSize.Height);
drawingContext.DrawRectangle(
IsMouseDirectlyOver ? margin.SelectedFoldingMarkerBackgroundBrush : margin.FoldingMarkerBackgroundBrush,
IsMouseDirectlyOver ? activePen : inactivePen, rect);
double middleX = rect.Left + rect.Width / 2;
double middleY = rect.Top + rect.Height / 2;
double space = PixelSnapHelpers.Round(rect.Width / 8, pixelSize.Width) + pixelSize.Width;
drawingContext.DrawLine(activePen,
new Point(rect.Left + space, middleY),
new Point(rect.Right - space, middleY));
if (!isExpanded) {
drawingContext.DrawLine(activePen,
new Point(middleX, rect.Top + space),
new Point(middleX, rect.Bottom - space));
}
}
示例3: DrawBone
/// <summary>
/// Draws a bone line between two joints
/// </summary>
/// <param name="skeleton">skeleton to draw bones from</param>
/// <param name="drawingContext">drawing context to draw to</param>
/// <param name="jointType0">joint to start drawing from</param>
/// <param name="jointType1">joint to end drawing at</param>
public static void DrawBone(TSkeleton skeleton, DrawingContext drawingContext, TJointType jointType0, TJointType jointType1)
{
TJoint joint0 = skeleton.Joints[(int)jointType0];
TJoint joint1 = skeleton.Joints[(int)jointType1];
// If we can't find either of these joints, exit
if (joint0.TrackingState == TJointTrackingState.NotTracked ||
joint1.TrackingState == TJointTrackingState.NotTracked)
{
return;
}
// Don't draw if both points are inferred
if (joint0.TrackingState == TJointTrackingState.Inferred &&
joint1.TrackingState == TJointTrackingState.Inferred)
{
return;
}
// We assume all drawn bones are inferred unless BOTH joints are tracked
Pen drawPen = inferredBonePen;
if (joint0.TrackingState == TJointTrackingState.Tracked && joint1.TrackingState == TJointTrackingState.Tracked)
{
drawPen = trackedBonePen;
}
drawingContext.DrawLine(drawPen, SkeletonPointToScreen(joint0.Position), SkeletonPointToScreen(joint1.Position));
}
示例4: Draw
public void Draw(TextView textView, DrawingContext drawingContext)
{
if (textView == null)
throw new ArgumentNullException("textView");
if (drawingContext == null)
throw new ArgumentNullException("drawingContext");
if (currentResults == null || !textView.VisualLinesValid)
return;
var visualLines = textView.VisualLines;
if (visualLines.Count == 0)
return;
int viewStart = visualLines.First().FirstDocumentLine.Offset;
int viewEnd = visualLines.Last().LastDocumentLine.EndOffset;
foreach (SearchResult result in currentResults.FindOverlappingSegments(viewStart, viewEnd - viewStart)) {
BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder();
geoBuilder.AlignToMiddleOfPixels = true;
geoBuilder.CornerRadius = 3;
geoBuilder.AddSegment(textView, result);
Geometry geometry = geoBuilder.CreateGeometry();
if (geometry != null) {
drawingContext.DrawGeometry(markerBrush, markerPen, geometry);
}
}
}
示例5: Draw
/// <summary>
/// Draw object
/// </summary>
public override void Draw(DrawingContext drawingContext)
{
if ( drawingContext == null )
{
throw new ArgumentNullException("drawingContext");
}
Rect r = Rectangle;
Point center = new Point(
(r.Left + r.Right) / 2.0,
(r.Top + r.Bottom) / 2.0);
double radiusX = (r.Right - r.Left) / 2.0;
double radiusY = (r.Bottom - r.Top) / 2.0;
drawingContext.DrawEllipse(
null,
new Pen(new SolidColorBrush(ObjectColor), ActualLineWidth),
center,
radiusX,
radiusY);
base.Draw(drawingContext);
}
示例6: RenderClippedEdges
private static void RenderClippedEdges(Skeleton skeleton, DrawingContext drawingContext)
{
if (skeleton.ClippedEdges.HasFlag(FrameEdges.Bottom))
{
drawingContext.DrawRectangle(
Brushes.Red,
null,
new Rect(0, RenderHeight - ClipBoundsThickness, RenderWidth, ClipBoundsThickness));
}
if (skeleton.ClippedEdges.HasFlag(FrameEdges.Top))
{
drawingContext.DrawRectangle(
Brushes.Red,
null,
new Rect(0, 0, RenderWidth, ClipBoundsThickness));
}
if (skeleton.ClippedEdges.HasFlag(FrameEdges.Left))
{
drawingContext.DrawRectangle(
Brushes.Red,
null,
new Rect(0, 0, ClipBoundsThickness, RenderHeight));
}
if (skeleton.ClippedEdges.HasFlag(FrameEdges.Right))
{
drawingContext.DrawRectangle(
Brushes.Red,
null,
new Rect(RenderWidth - ClipBoundsThickness, 0, ClipBoundsThickness, RenderHeight));
}
}
示例7: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
Rect rect = new Rect(startPoint, endPoint);
rect.Offset(-0.5d, -0.5d);
drawingContext.DrawRectangle(fill, stroke, rect);
}
示例8: OnRender
protected override void OnRender(DrawingContext dc)
{
if (background != null)
{
dc.DrawImage(background, new Rect(0, 0, background.PixelWidth, background.PixelHeight));
}
}
示例9: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
double width = RenderSize.Width;
double height = RenderSize.Height;
MeshGeometry3D mesh = Mesh;
if (mesh != null)
{
Pen pen = new Pen(Brushes.Black, 1.0);
int numTriangles = mesh.TriangleIndices.Count/3;
for(int i = 0; i < numTriangles; i++)
{
DrawTriangle(drawingContext,
pen,
mesh.TextureCoordinates[mesh.TriangleIndices[i * 3]],
mesh.TextureCoordinates[mesh.TriangleIndices[i * 3 + 1]],
mesh.TextureCoordinates[mesh.TriangleIndices[i * 3 + 2]],
width,
height);
}
}
base.OnRender(drawingContext);
}
示例10: DrawSearchHighlight
private void DrawSearchHighlight(DrawingContext dc, Block block)
{
foreach (var pair in _curSearchMatches)
{
int txtOffset = 0;
double y = block.Y;
for (int i = 0; i < block.Text.Length; i++)
{
int start = Math.Max(txtOffset, pair.Item1);
int end = Math.Min(txtOffset + block.Text[i].Length, pair.Item2);
if (end > start)
{
double x1 = block.Text[i].GetDistanceFromCharacterHit(new CharacterHit(start, 0)) + block.TextX;
double x2 = block.Text[i].GetDistanceFromCharacterHit(new CharacterHit(end, 0)) + block.TextX;
dc.DrawRectangle(_searchBrush.Value, null,
new Rect(new Point(x1, y), new Point(x2, y + _lineHeight)));
}
y += _lineHeight;
txtOffset += block.Text[i].Length;
}
}
}
示例11: DrawChanges
private void DrawChanges(DrawingContext drawingContext, NormalizedSnapshotSpanCollection changes, Brush brush)
{
if (changes.Count > 0)
{
double yTop = Math.Floor(_scrollBar.GetYCoordinateOfBufferPosition(changes[0].Start)) + markerStartOffset;
double yBottom = Math.Ceiling(_scrollBar.GetYCoordinateOfBufferPosition(changes[0].End)) + markerEndOffset;
for (int i = 1; i < changes.Count; ++i)
{
double y = _scrollBar.GetYCoordinateOfBufferPosition(changes[i].Start) + markerStartOffset;
if (yBottom < y)
{
drawingContext.DrawRectangle(
brush,
null,
new Rect(0, yTop, markerWidth, yBottom - yTop));
yTop = y;
}
yBottom = Math.Ceiling(_scrollBar.GetYCoordinateOfBufferPosition(changes[i].End)) + markerEndOffset;
}
drawingContext.DrawRectangle(
brush,
null,
new Rect(0, yTop, markerWidth, yBottom - yTop));
}
}
示例12: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
DrawGrid(drawingContext);
DrawChart(drawingContext);
UpdateParent();
}
示例13: 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.Deleted:
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");
}
}
}
}
示例14: Draw
public override void Draw(DrawingContext dc)
{
if (HasConnection())
CoreDraw.DrawLine(dc, StartConn.getPort().getCenter(), EndConn.getPort().getCenter(), LineWidth, Brushes.Blue, CoreDraw.LineStyle_StraightLine);
}
示例15: PaintCovexHull
protected virtual void PaintCovexHull(HandData cluster, DrawingContext drawingContext)
{
if (cluster.ConvexHull.Count > 3)
{
this.DrawLines(drawingContext, this.whitePen, cluster.ConvexHull.Points.Select(p => new System.Windows.Point(p.X, p.Y)).ToArray());
}
}