本文整理汇总了C#中System.Windows.Media.DrawingContext.DrawLine方法的典型用法代码示例。如果您正苦于以下问题:C# DrawingContext.DrawLine方法的具体用法?C# DrawingContext.DrawLine怎么用?C# DrawingContext.DrawLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.DrawingContext
的用法示例。
在下文中一共展示了DrawingContext.DrawLine方法的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 dc)
{
var indent = NodeView.CalculateIndent(NodeView.Node);
var p = new Point(indent + 4.5, 0);
if (!NodeView.Node.IsRoot || NodeView.ParentTreeView.ShowRootExpander) {
dc.DrawLine(pen, new Point(p.X, ActualHeight / 2), new Point(p.X + 10, ActualHeight / 2));
}
if (NodeView.Node.IsRoot) return;
if (NodeView.Node.IsLast) {
dc.DrawLine(pen, p, new Point(p.X, ActualHeight / 2));
}
else {
dc.DrawLine(pen, p, new Point(p.X, ActualHeight));
}
var current = NodeView.Node;
while (true) {
p.X -= 19;
current = current.Parent;
if (p.X < 0) break;
if (!current.IsLast) {
dc.DrawLine(pen, p, new Point(p.X, ActualHeight));
}
}
}
示例3: OnRender
protected override void OnRender(DrawingContext dc)
{
var lightBrush = new SolidColorBrush(Colors.LightGray);
var darkBrush = new SolidColorBrush(Colors.Black);
lightBrush.Opacity = 0.4;
darkBrush.Opacity = 0.1;
double t1 = 6; // thickness of dark circle pen
double t2 = 2; // thickness of light pen (circle, arcs, segments)
double d = 0; // distance from light circle to segments
double l = 10; // length of segments
double r = 20.0; // radius of light circle
double r1 = r - (t1 + t2) / 2;
double r2 = r + l;
double r3 = r + t2 / 2 + d;
double r4 = (r + r2) / 2;
var darkPen = new Pen(darkBrush, t1);
var lightPen = new Pen(lightBrush, t2);
dc.DrawEllipse(null, lightPen, Position, r, r);
dc.DrawEllipse(null, darkPen, Position, r1, r1);
dc.DrawArc(null, lightPen, Position, 10, 80, r4, r4);
dc.DrawArc(null, lightPen, Position, 100, 170, r4, r4);
dc.DrawArc(null, lightPen, Position, 190, 260, r4, r4);
dc.DrawArc(null, lightPen, Position, 280, 350, r4, r4);
dc.DrawLine(lightPen, new Point(Position.X, Position.Y - r2), new Point(Position.X, Position.Y - r3));
dc.DrawLine(lightPen, new Point(Position.X, Position.Y + r2), new Point(Position.X, Position.Y + r3));
dc.DrawLine(lightPen, new Point(Position.X - r2, Position.Y), new Point(Position.X - r3, Position.Y));
dc.DrawLine(lightPen, new Point(Position.X + r2, Position.Y), new Point(Position.X + r3, Position.Y));
}
示例4: Init_DrawLT
public void Init_DrawLT(int running_train)
{
int i;
int temp;
int late_time_range;
late_time_range = 1000;
temp = 0;
x1 = 30;
y1 = 10;
x2 = 700;
y2 = 580;
narrow_x = (double)running_train / (x2 - x1);
narrow_y = (double)late_time_range / (y2 - y1);
drawingVisual = new DrawingVisual();
dc = drawingVisual.RenderOpen();
dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1, x1), new Point(x1, y2));
dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1, y2), new Point(x2, y2));
dc.DrawText(new FormattedText("N",
CultureInfo.GetCultureInfo("en-us"),
FlowDirection.LeftToRight,
new Typeface("Verdana"),
12, System.Windows.Media.Brushes.Black),
new System.Windows.Point(x2 - 30, y2 + 6));
dc.DrawText(new FormattedText("T",
CultureInfo.GetCultureInfo("en-us"),
FlowDirection.LeftToRight,
new Typeface("Verdana"),
12, System.Windows.Media.Brushes.Black),
new System.Windows.Point(x1 - 10, y1 - 8));
for (i = 0; i < (x2 - x1); i++)
{
if (i % ((x2 - x1) / 5) == 0)
{
dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1 + i, y2), new Point(x1 + i, y2 - 3));
dc.DrawText(new FormattedText((temp * running_train / 5).ToString(),
CultureInfo.GetCultureInfo("en-us"),
FlowDirection.LeftToRight,
new Typeface("Verdana"),
12, System.Windows.Media.Brushes.Black),
new System.Windows.Point(i + x1 - 5, y2 + 7));
temp++;
}
}
temp = 0;
for (i = 0; i < (y2 - y1); i++)
{
if (i % ((y2 - y1) / 5) == 0)
{
dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1, y2 - i), new Point(x1 + 3, y2 - i));
dc.DrawText(new FormattedText((temp * late_time_range / 5).ToString(),
CultureInfo.GetCultureInfo("en-us"),
FlowDirection.LeftToRight,
new Typeface("Verdana"),
12, System.Windows.Media.Brushes.Black),
new System.Windows.Point(x1 - 28, y2 - i - 9));
temp++;
}
}
}
示例5: 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));
}
}
示例6: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
Pen blackPen = new Pen(Brushes.Black, 1);
blackPen.StartLineCap = PenLineCap.Square;
blackPen.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(Brushes.White,
IsMouseDirectlyOver ? blackPen : new Pen(Brushes.Gray, 1),
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(blackPen,
new Point(rect.Left + space, middleY),
new Point(rect.Right - space, middleY));
if (!isExpanded) {
drawingContext.DrawLine(blackPen,
new Point(middleX, rect.Top + space),
new Point(middleX, rect.Bottom - space));
}
}
示例7: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
var dashPen = new Pen(Brushes.Red, 1) { DashStyle = new DashStyle(new double[] { 1, 6 }, 0) };
dashPen.Freeze();
if( _grid != null )
{
if (_grid.ColumnDefinitions != null)
{
double xPos = 0;
foreach (var column in _grid.ColumnDefinitions)
{
xPos += column.ActualWidth;
drawingContext.DrawLine(dashPen, new Point(xPos, 0), new Point(xPos,ActualHeight));
}
}
if (_grid.RowDefinitions != null)
{
double yPos = 0;
foreach (var column in _grid.RowDefinitions)
{
yPos += column.ActualHeight;
drawingContext.DrawLine(dashPen, new Point(0, yPos), new Point(ActualWidth, yPos));
}
}
}
base.OnRender(drawingContext);
}
示例8: Hor
public double Hor(DrawingContext dc, Target TargetA, Target TargetB ,bool show)
{
//3D
Vector3D vectorA = new Vector3D(TargetA.point3D().X - TargetB.point3D().X, TargetA.point3D().Y - TargetB.point3D().Y, TargetA.point3D().Z - TargetB.point3D().Z);
Vector3D vectorB = new Vector3D(0, 1, 0);
//2D
//Vector3D vectorA = new Vector3D(TargetA.point2D().X - TargetB.point2D().X, TargetA.point2D().Y - TargetB.point2D().Y, 0);
//Vector3D vectorB = new Vector3D(1, 0, 0);
double theta = Math.Abs(Vector3D.AngleBetween(vectorA, vectorB));
theta = 90 - theta;
//if (TargetA.point3D().Y < TargetB.point3D().Y) theta = -theta;
if (show) //show angle text
{
dc.DrawText(new FormattedText(theta.ToString("f0"),
CultureInfo.GetCultureInfo("en-us"),
FlowDirection.LeftToRight,
new Typeface("Verdana"),
25, brushDeepSkyBlue),
new Point(TargetB.point2D().X - 35, TargetB.point2D().Y - 35));
dc.DrawLine(PenDeepSkyBlue, TargetA.point2D(), TargetB.point2D()); //show angle line
dc.DrawLine(PenDeepSkyBlue, new Point(TargetA.point2D().X, TargetB.point2D().Y), TargetB.point2D());
}
return theta;
}
示例9: DrawBone
private void DrawBone(Joint jointFrom, Joint jointTo, Pen aPen, DrawingContext aContext)
{
if (jointFrom.TrackingState == JointTrackingState.NotTracked ||
jointTo.TrackingState == JointTrackingState.NotTracked)
{
return;
}
if (jointFrom.TrackingState == JointTrackingState.Inferred ||
jointTo.TrackingState == JointTrackingState.Inferred)
{
ColorImagePoint p1 = mySensor.CoordinateMapper.MapSkeletonPointToColorPoint(jointFrom.Position, ColorImageFormat.RgbResolution640x480Fps30);
ColorImagePoint p2 = mySensor.CoordinateMapper.MapSkeletonPointToColorPoint(jointTo.Position, ColorImageFormat.RgbResolution640x480Fps30);
//Thin line
aPen.DashStyle = DashStyles.Dash;
aContext.DrawLine(aPen, new Point(p1.X, p1.Y), new Point(p2.X, p2.Y));
}
if (jointFrom.TrackingState == JointTrackingState.Tracked ||
jointTo.TrackingState == JointTrackingState.Tracked)
{
ColorImagePoint p1 = mySensor.CoordinateMapper.MapSkeletonPointToColorPoint(jointFrom.Position, ColorImageFormat.RgbResolution640x480Fps30);
ColorImagePoint p2 = mySensor.CoordinateMapper.MapSkeletonPointToColorPoint(jointTo.Position, ColorImageFormat.RgbResolution640x480Fps30);
//Thick line
aPen.DashStyle = DashStyles.Solid;
aContext.DrawLine(aPen, new Point(p1.X, p1.Y), new Point(p2.X, p2.Y));
}
}
示例10: DrawLine
public static void DrawLine(DrawingContext dc, Point _Start, Point _End, double LineWidth, Brush LineColor, int LineStyle)
{
Pen lp = new Pen(LineColor, LineWidth);
switch (LineStyle)
{
case LineStyle_StraightLine :
dc.DrawLine(lp, _Start, _End);
break;
case LineStyle_MultipleSegment :
double dx = Math.Abs(_Start.X - _End.X);
double dy = Math.Abs(_Start.Y - _End.Y);
double d1 = Math.Pow(dx * dx + dy * dy, 0.5);
double d2 = Math.Pow(5 * 5 + 5 * 5, 0.5);
Vector v1 = new Vector(_End.X - _Start.X, _End.Y - _Start.Y);
Vector v2 = v1 / (d1 / d2);
int count = (int)(d1 / d2);
List<Point> S = new List<Point>();
List<Point> E = new List<Point>();
for (int i = 0; i < count; i += 2)
{
S.Add(_Start + v2 * i);
E.Add(_Start + v2 * i + v2);
}
for (int i = 0; i < S.Count; i++)
{
dc.DrawLine(lp, S.ElementAt(i), E.ElementAt(i));
}
break;
}
}
示例11: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
if (ParentMap != null)
{
var bounds = ParentMap.ViewportTransform.Inverse.TransformBounds(new Rect(ParentMap.RenderSize));
var start = ParentMap.MapTransform.Transform(new Point(bounds.X, bounds.Y));
var end = ParentMap.MapTransform.Transform(new Point(bounds.X + bounds.Width, bounds.Y + bounds.Height));
var minSpacing = MinLineSpacing * 360d / (Math.Pow(2d, ParentMap.ZoomLevel) * TileSource.TileSize);
var spacing = LineSpacings[LineSpacings.Length - 1];
if (spacing >= minSpacing)
{
spacing = LineSpacings.FirstOrDefault(s => s >= minSpacing);
}
var latLabelStart = Math.Ceiling(start.Latitude / spacing) * spacing;
var lonLabelStart = Math.Ceiling(start.Longitude / spacing) * spacing;
var latLabels = new List<Label>((int)((end.Latitude - latLabelStart) / spacing) + 1);
var lonLabels = new List<Label>((int)((end.Longitude - lonLabelStart) / spacing) + 1);
var labelFormat = spacing < 1d ? "{0} {1}°{2:00}'" : "{0} {1}°";
for (var lat = latLabelStart; lat <= end.Latitude; lat += spacing)
{
latLabels.Add(new Label(lat, new FormattedText(
CoordinateString(lat, labelFormat, "NS"),
CultureInfo.InvariantCulture, FlowDirection.LeftToRight, Typeface, FontSize, Foreground)));
drawingContext.DrawLine(Pen,
ParentMap.LocationToViewportPoint(new Location(lat, start.Longitude)),
ParentMap.LocationToViewportPoint(new Location(lat, end.Longitude)));
}
for (var lon = lonLabelStart; lon <= end.Longitude; lon += spacing)
{
lonLabels.Add(new Label(lon, new FormattedText(
CoordinateString(Location.NormalizeLongitude(lon), labelFormat, "EW"),
CultureInfo.InvariantCulture, FlowDirection.LeftToRight, Typeface, FontSize, Foreground)));
drawingContext.DrawLine(Pen,
ParentMap.LocationToViewportPoint(new Location(start.Latitude, lon)),
ParentMap.LocationToViewportPoint(new Location(end.Latitude, lon)));
}
foreach (var latLabel in latLabels)
{
foreach (var lonLabel in lonLabels)
{
var position = ParentMap.LocationToViewportPoint(new Location(latLabel.Position, lonLabel.Position));
drawingContext.PushTransform(new RotateTransform(ParentMap.Heading, position.X, position.Y));
drawingContext.DrawText(latLabel.Text,
new Point(position.X + StrokeThickness / 2d + 2d, position.Y - StrokeThickness / 2d - latLabel.Text.Height));
drawingContext.DrawText(lonLabel.Text,
new Point(position.X + StrokeThickness / 2d + 2d, position.Y + StrokeThickness / 2d));
drawingContext.Pop();
}
}
}
}
示例12: Init_DrawSP
public void Init_DrawSP(ArrayList sp, int track_len, int v_max)
{
int i;
int temp;
mysp = sp;
temp = 0;
x1 = 30;
y1 = 10;
x2 = 700;
y2 = 580;
narrow_x = (double)track_len / (x2-x1);
narrow_y = (double)v_max / ((y2 - y1) / 2);
drawingVisual = new DrawingVisual();
dc = drawingVisual.RenderOpen();
dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1, x1), new Point(x1, y2));
dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1, y2), new Point(x2, y2));
dc.DrawText(new FormattedText("T",
CultureInfo.GetCultureInfo("en-us"),
FlowDirection.LeftToRight,
new Typeface("Verdana"),
12, System.Windows.Media.Brushes.Black),
new System.Windows.Point(x2 - 30, y2 + 6));
dc.DrawText(new FormattedText("V",
CultureInfo.GetCultureInfo("en-us"),
FlowDirection.LeftToRight,
new Typeface("Verdana"),
12, System.Windows.Media.Brushes.Black),
new System.Windows.Point(x1 - 10, y1 - 8));
for (i = 0; i < (x2 - x1); i++)
{
if (i % ((x2 - x1) / 5) == 0)
{
dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1 + i, y2), new Point(x1 + i, y2 - 3));
dc.DrawText(new FormattedText((temp * track_len / 5).ToString(),
CultureInfo.GetCultureInfo("en-us"),
FlowDirection.LeftToRight,
new Typeface("Verdana"),
12, System.Windows.Media.Brushes.Black),
new System.Windows.Point(i + x1 - 5, y2 + 7));
temp++;
}
}
temp = 0;
for (i = 0; i < (y2 - y1)/2; i++)
{
if (i % ((y2 - y1) / 10) == 0)
{
dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1, y2 - i), new Point(x1 + 3, y2 - i));
dc.DrawText(new FormattedText((temp * v_max / 5).ToString(),
CultureInfo.GetCultureInfo("en-us"),
FlowDirection.LeftToRight,
new Typeface("Verdana"),
12, System.Windows.Media.Brushes.Black),
new System.Windows.Point(x1 - 28, y2 - i - 9));
temp++;
}
}
}
示例13: DrawBorder
protected void DrawBorder(DrawingContext drawingContext, Pen bdrPen)
{
int width = (int)Width;
int height = (int)Height;
// draw border
drawingContext.DrawLine(bdrPen, new Point(width - 0.5, 0.5), new Point(width - 0.5, height - 0.5));
drawingContext.DrawLine(bdrPen, new Point(0.5, height - 0.5), new Point(width - 0.5, height - 0.5));
}
示例14: DrawTriangle
private static void DrawTriangle(DrawingContext drawingContext, Pen pen, Point a, Point b, Point c, double width, double height)
{
Point ta = new Point(a.X * width, a.Y * height);
Point tb = new Point(b.X * width, b.Y * height);
Point tc = new Point(c.X * width, c.Y * height);
drawingContext.DrawLine(pen, ta, tb);
drawingContext.DrawLine(pen, tb, tc);
drawingContext.DrawLine(pen, tc, ta);
}
示例15: PaintBackground
public static void PaintBackground(this Altaxo.Worksheet.ColumnStyle thiss, DrawingContext dc, RectangleD2D cellRectangle, bool bSelected)
{
var cellRect = cellRectangle.ToWpf();
if (bSelected)
dc.DrawRectangle(thiss.DefaultSelectedBackgroundBrush.ToWpf(), null, cellRect);
else
dc.DrawRectangle(thiss.BackgroundBrush.ToWpf(), null, cellRect);
dc.DrawLine(thiss.CellBorder.ToWpf(), cellRect.BottomLeft, cellRect.BottomRight);
dc.DrawLine(thiss.CellBorder.ToWpf(), cellRect.BottomRight, cellRect.TopRight);
}