本文整理汇总了C#中System.Windows.Media.Pen类的典型用法代码示例。如果您正苦于以下问题:C# Pen类的具体用法?C# Pen怎么用?C# Pen使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Pen类属于System.Windows.Media命名空间,在下文中一共展示了Pen类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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);
}
开发者ID:JazzFisch,项目名称:AnotherCombatManager,代码行数:26,代码来源:MeshTextureCoordinateVisualizer.cs
示例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));
}
}
开发者ID:eolandezhang,项目名称:Diagram,代码行数:27,代码来源:FoldingMarginMarker.cs
示例3: DrawOrthogonal
/// <summary>Draws a snapped orthogonal line.</summary>
internal static void DrawOrthogonal(DrawingContext dc, Orientation orientation, Pen pen, double q, double p0, double p1) {
if (orientation == Orientation.Horizontal) {
DrawHorizontal(dc, pen, q, p0, p1);
} else {
DrawVertical(dc, pen, q, p0, p1);
}
}
开发者ID:borkaborka,项目名称:gmit,代码行数:8,代码来源:ChartUtil.cs
示例4: Draw
public override void Draw()
{
base.Draw();
if (Series != null && Series.Count >= 3) {
Size boxSize = new Size(10, 10);
double y = (this.Height - boxSize.Height) / 2;
Pen border = new Pen(Brushes.Gray, 1);
m_elementX.Text = Series[0].Label;
m_elementX.BoxSize = boxSize;
m_elementX.Offset = new Vector(this.Width - 186, y);
m_elementX.Background = new SolidColorBrush(Series[0].Color);
m_elementX.Border = border;
m_elementX.Draw();
m_elementY.Text = Series[1].Label;
m_elementY.BoxSize = boxSize;
m_elementY.Offset = new Vector(this.Width - 120, y);
m_elementY.Background = new SolidColorBrush(Series[1].Color);
m_elementY.Border = border;
m_elementY.Draw();
m_elementZ.Text = Series[2].Label;
m_elementZ.BoxSize = boxSize;
m_elementZ.Offset = new Vector(this.Width - 54, y);
m_elementZ.Background = new SolidColorBrush(Series[2].Color);
m_elementZ.Border = border;
m_elementZ.Draw();
}
}
开发者ID:sohong,项目名称:greenfleet-viewer,代码行数:31,代码来源:LegendElement.cs
示例5: DrawGeometry
/// <summary>
/// DrawGeometry -
/// Draw a Geometry with the provided Brush and/or Pen.
/// If both the Brush and Pen are null this call is a no-op.
/// </summary>
/// <param name="brush">
/// The Brush with which to fill the Geometry.
/// This is optional, and can be null, in which case no fill is performed.
/// </param>
/// <param name="pen">
/// The Pen with which to stroke the Geometry.
/// This is optional, and can be null, in which case no stroke is performed.
/// </param>
/// <param name="geometry"> The Geometry to fill and/or stroke. </param>
public override void DrawGeometry(
Brush brush,
Pen pen,
Geometry geometry)
{
if (IsCurrentLayerNoOp ||(geometry == null) || geometry.IsEmpty())
{
return;
}
if (brush != null)
{
_contains |= geometry.FillContains(_point);
}
// If we have a pen and we haven't yet hit, try the widened geometry.
if ((pen != null) && !_contains)
{
_contains |= geometry.StrokeContains(pen, _point);
}
// If we've hit, stop walking.
if (_contains)
{
StopWalking();
}
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:41,代码来源:HitTestWithPointDrawingContextWalker.cs
示例6: PairedCharacterRenderer
public PairedCharacterRenderer()
{
highlightBrush = new SolidColorBrush(Colors.LightBlue);
highlightPen = new Pen(highlightBrush, 1.0);
PairedCharacters = new TextSegmentCollection<TextSegment>();
}
开发者ID:BernardNotarianni,项目名称:DownmarkerWPF,代码行数:7,代码来源:PairedCharacterRenderer.cs
示例7: OnRender
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
{
base.OnRender(drawingContext);
double height = element.ActualHeight;
double width = element.ActualWidth;
double linesHorizontal = height / LINEFACTOR;
double linesVertical = width / LINEFACTOR;
var pen = new Pen(Brushes.Blue, 0.1) { StartLineCap = PenLineCap.Triangle, EndLineCap = PenLineCap.Triangle };
int offset = 0;
for (int i = 0; i <= linesVertical; ++i)
{
offset = offset + LINEFACTOR;
drawingContext.DrawLine(pen, new Point(offset, 0), new Point(offset, height));
}
offset = 0;
for (int i = 0; i <= linesHorizontal; ++i)
{
offset = offset + LINEFACTOR;
drawingContext.DrawLine(pen, new Point(0, offset), new Point(width, offset));
}
}
开发者ID:plantener,项目名称:02350,代码行数:28,代码来源:GridAdorner.cs
示例8: PathOutlineVisual
public PathOutlineVisual(IPathOutline outline)
{
var brush = new SolidColorBrush(outline.LineColor);
var pen = new Pen(brush, 1);
var geometry = new StreamGeometry();
using (var gc = geometry.Open())
{
gc.BeginFigure(outline.BottomLeft, false, false);
gc.LineTo(outline.TopLeft, true, true);
gc.ArcTo(outline.TopRight,
new Size(outline.Radius + (outline.Width / 2), outline.Radius + (outline.Width / 2)),
1,
false,
outline.Direction == PathType.Convex ? SweepDirection.Clockwise : SweepDirection.Counterclockwise,
true,
true);
gc.LineTo(outline.BottomRight, true, true);
gc.ArcTo(outline.BottomLeft,
new Size(outline.Radius - (outline.Width / 2), outline.Radius - (outline.Width / 2)),
1,
false,
outline.Direction == PathType.Convex ? SweepDirection.Counterclockwise : SweepDirection.Clockwise,
true,
true);
}
using (var context = RenderOpen())
{
context.DrawGeometry(brush, pen, geometry);
}
}
开发者ID:curtmantle,项目名称:Geometry,代码行数:35,代码来源:PathOutlineVisual.cs
示例9: CreateGuidelineSet
private static GuidelineSet CreateGuidelineSet(Pen pen, Rect rect)
{
var halfPenWidth = pen.Thickness / 2;
var guidelines = new GuidelineSet(new[] {rect.Left - halfPenWidth, rect.Right - halfPenWidth},
new [] {rect.Top - halfPenWidth, rect.Bottom - halfPenWidth});
return guidelines;
}
开发者ID:Mrding,项目名称:Ribbon,代码行数:7,代码来源:DrawingContextExt.cs
示例10: OnRender
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
{
Random r = new Random();
Rect adornedElementRect = new Rect(this.AdornedElement.DesiredSize);
Point stPt = new Point(adornedElementRect.X, adornedElementRect.Y);
for (int x = 0; x < Number; x++)
{
Ellipse e = new Ellipse();
e.Width = 4;
Brush b = new SolidColorBrush(new Color() { R =(byte) r.Next(0,255), G =(byte) r.Next(0,255),B =(byte) r.Next(0,255) });
Pen p = new Pen(Brushes.Black,1);
int Rad = 3 ;
drawingContext.DrawEllipse(b, p, stPt, Rad, Rad);
stPt.X += (Rad * 2) + 1;
if (stPt.X > adornedElementRect.Width)
{
stPt.X = 3;
stPt.Y += 3;
}
}
// Some arbitrary drawing implements.
}
开发者ID:sabarn01,项目名称:DrawSomeDots,代码行数:27,代码来源:AdornWithDots.cs
示例11: AchievementAdornments
public AchievementAdornments(IWpfTextView view)
{
this.view = view;
this.layer = view.GetAdornmentLayer("AchievementAdornments");
this.descriptionLayer = view.GetAdornmentLayer("AchievementAdornmentsDescription");
view.LayoutChanged += OnLayoutChanged;
Brush brush = new SolidColorBrush(Color.FromArgb(0x20, 0x00, 0x00, 0xff));
brush.Freeze();
Brush penBrush = new SolidColorBrush(Colors.Red);
penBrush.Freeze();
Pen pen = new Pen(penBrush, 0.5);
pen.Freeze();
this.brush = brush;
this.pen = pen;
AchievementUIContext.AchievementClicked += (sender, e) =>
{
Reset();
var filePath = GetFilePath(view);
if (e.AchievementDescriptor.CodeOrigin.FileName != filePath)
return;
codeOrigin = e.AchievementDescriptor.CodeOrigin;
achievementUiElement = (UIElement)e.UIElement;
CreateAdornment();
};
}
开发者ID:clausjoergensen,项目名称:strokes,代码行数:34,代码来源:AchievementAdornments.cs
示例12: YearRegionFieldWindow
public YearRegionFieldWindow(string parameterName, IParameter2DimensionalTypeless<double> parameterToDisplay)
{
InitializeComponent();
_parameter = parameterToDisplay;
_parameterName = parameterName;
plotterHeader.Content = parameterName;
var data2 = from p in parameterToDisplay.GetEnumerator()
where !Double.IsNaN(p.Value) && !Double.IsInfinity(p.Value)
group p by p.Dimension2;
foreach (var series in data2)
{
var data = from p in series
select new Point(p.Dimension1.Index + 1950, p.Value);
var dd = data.ToArray();
var d = dd.AsDataSource();
int remainder1 = series.Key.Index % 4;
var color = remainder1 == 0 ? Brushes.Blue : remainder1 == 1 ? Brushes.Red : remainder1 == 2 ? Brushes.Green : Brushes.Gold;
int tt = series.Key.Index / 4;
var dashline = tt == 0 ? DashStyles.Solid : tt == 1 ? DashStyles.Dash : tt == 2 ? DashStyles.Dot : DashStyles.DashDot;
var linedescr = tt == 0 ? "solid" : tt == 1 ? "dash" : tt == 2 ? "dot" : "dash-dot";
var pen = new Pen(color, 2);
pen.DashStyle = dashline;
plotter.AddLineGraph(d, pen, new PenDescription(String.Format("{0} ({1})", series.Key, linedescr)));
}
}
开发者ID:VWille,项目名称:fund,代码行数:33,代码来源:YearRegionFieldWindow.xaml.cs
示例13: 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));
}
}
开发者ID:pusp,项目名称:o2platform,代码行数:25,代码来源:FoldingMarginMarker.cs
示例14: InsertionAdorner
// Create the pen and triangle in a static constructor and freeze them to improve performance.
static InsertionAdorner()
{
pen = new Pen
{
Brush = Brushes.Gray,
Thickness = 2
};
pen.Freeze();
LineSegment firstLine = new LineSegment(new Point(0, -5), false);
firstLine.Freeze();
LineSegment secondLine = new LineSegment(new Point(0, 5), false);
secondLine.Freeze();
PathFigure figure = new PathFigure
{
StartPoint = new Point(5, 0)
};
figure.Segments.Add(firstLine);
figure.Segments.Add(secondLine);
figure.Freeze();
triangle = new PathGeometry();
triangle.Figures.Add(figure);
triangle.Freeze();
}
开发者ID:Boddlnagg,项目名称:WordsLive,代码行数:27,代码来源:InsertionAdorner.cs
示例15: _initializeResources
// initializes the edge resources
private void _initializeResources() {
_foreground = Brushes.Black;
Cursor = Cursors.Hand;
ToolTipService.SetInitialShowDelay(this, 250);
var sourceName = Source.Class.Name;
var targetName = Target.Class.Name;
var cardinality = ((Role & DiagramEdgeRole.ZeroToOne) != 0) ? "[0..1]" : "[0..n]";
var darkgray = (0x656565).ToBrush();
_lineStroke = new Pen(darkgray, 2);
_arrowFilled = darkgray;
if (Role.Has(DiagramEdgeRole.Inheritance)) {
ToolTip = "'{0}' inherits '{1}'".Substitute(targetName, sourceName);
} else if (Role.Has(DiagramEdgeRole.Containment)) {
ToolTip = "'{0}.{1}' contains '{2}{3}'".Substitute(sourceName, Label, targetName, cardinality);
} else if (Role.Has(DiagramEdgeRole.Association)) {
ToolTip = "'{0}.{1}' references '{2}{3}'".Substitute(sourceName, Label, targetName, cardinality);
} else if (Role.Has(DiagramEdgeRole.WeakAssociation)) {
_lineStroke.DashStyle = new DashStyle(new[] { 2.0, 2.0 }, 0);
ToolTip = "'{0}.{1}' references by Id '{2}{3}'".Substitute(sourceName, Label, targetName, cardinality);
}
_lineStroke.Freeze();
_arrowHollow = Brushes.White;
_arrowStroke = new Pen(_lineStroke.Brush, _lineStroke.Thickness);
_arrowStroke.Freeze();
}
开发者ID:borkaborka,项目名称:gmit,代码行数:31,代码来源:DiagramEdge.cs
示例16: 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));
}
}
开发者ID:kinectNao,项目名称:bluenao,代码行数:28,代码来源:MainWindow.xaml.cs
示例17: DrawCore
protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes)
{
if (drawingContext == null)
{
throw new ArgumentNullException("drawingContext");
}
if (null == drawingAttributes)
{
throw new ArgumentNullException("drawingAttributes");
}
Pen pen = new Pen
{
StartLineCap = PenLineCap.Round,
EndLineCap = PenLineCap.Round,
Brush = new SolidColorBrush(drawingAttributes.Color),
Thickness = drawingAttributes.Width
};
BrushConverter bc = new BrushConverter();
Brush BackGround = (Brush)bc.ConvertFromString(drawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor).ToString());
drawingContext.DrawRectangle(
BackGround,
pen,
new Rect(new Point(StylusPoints[0].X, StylusPoints[0].Y),
new Point(StylusPoints[1].X, StylusPoints[1].Y)));
}
开发者ID:sonicrang,项目名称:RangPaint,代码行数:27,代码来源:RectangleStroke.cs
示例18: PainterCache
static PainterCache()
{
UseTransparentImage = true;
try
{
TransparentBrush = new SolidColorBrush(Colors.Transparent);
TransparentBrush.Freeze();
BlackBrush = new SolidColorBrush(Colors.Black);
BlackBrush.Freeze();
WhiteBrush = new SolidColorBrush(Colors.White);
WhiteBrush.Freeze();
ZonePen = new Pen(BlackBrush, 1);
GridLineBrush = new SolidColorBrush(Colors.Orange);
GridLineBrush.Freeze();
GridLinePen = new Pen(GridLineBrush, 1);
GridLinePen.EndLineCap = PenLineCap.Square;
GridLinePen.StartLineCap = PenLineCap.Square;
GridLinePen.DashStyle = DashStyles.Dash;
PointGeometry = new RectangleGeometry(new Rect(-15, -15, 30, 30));
_transparentBackgroundBrush = CreateTransparentBackgroundBrush();
}
catch (Exception e)
{
Logger.Error(e, "PainterCache.PainterCache()");
}
}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:26,代码来源:PainterCache.cs
示例19: DrawEllipse
//public void DrawDrawing(Drawing drawing);
public void DrawEllipse(Brush brush, Pen pen, Point center, double radiusX, double radiusY)
{
Ellipse ellipse = new Ellipse();
SetupShape(ellipse, center.X - radiusX, center.Y - radiusY, radiusX * 2, radiusY * 2, brush, pen);
ellipse.Fill = brush;
_canvas.Children.Add(ellipse);
}
开发者ID:alexiej,项目名称:YATE,代码行数:9,代码来源:DrawingContext.cs
示例20: DrawLine
/// <summary>
/// DrawLine -
/// Draws a line with the specified pen.
/// Note that this API does not accept a Brush, as there is no area to fill.
/// </summary>
/// <param name="pen"> The Pen with which to stroke the line. </param>
/// <param name="point0"> The start Point for the line. </param>
/// <param name="point1"> The end Point for the line. </param>
public override void DrawLine(
Pen pen,
Point point0,
Point point1)
{
Debug.Assert(false);
}
开发者ID:JianwenSun,项目名称:cc,代码行数:15,代码来源:DrawingContextWalker.cs
注:本文中的System.Windows.Media.Pen类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论