本文整理汇总了C#中System.Windows.Media.GeometryDrawing类的典型用法代码示例。如果您正苦于以下问题:C# GeometryDrawing类的具体用法?C# GeometryDrawing怎么用?C# GeometryDrawing使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GeometryDrawing类属于System.Windows.Media命名空间,在下文中一共展示了GeometryDrawing类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateAndAddAdornment
void CreateAndAddAdornment(ITextViewLine line, SnapshotSpan span, Brush brush, bool extendToRight)
{
var markerGeometry = _view.TextViewLines.GetMarkerGeometry(span);
double left = 0;
double width = _view.ViewportWidth + _view.MaxTextRightCoordinate;
if (markerGeometry != null)
{
left = markerGeometry.Bounds.Left;
if (!extendToRight) width = markerGeometry.Bounds.Width;
}
Rect rect = new Rect(left, line.Top, width, line.Height);
RectangleGeometry geometry = new RectangleGeometry(rect);
GeometryDrawing drawing = new GeometryDrawing(brush, new Pen(), geometry);
drawing.Freeze();
DrawingImage drawingImage = new DrawingImage(drawing);
drawingImage.Freeze();
Image image = new Image();
image.Source = drawingImage;
Canvas.SetLeft(image, geometry.Bounds.Left);
Canvas.SetTop(image, geometry.Bounds.Top);
_layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null);
}
开发者ID:ijprest,项目名称:BackgroundColorFix,代码行数:30,代码来源:BackgroundColorVisualManager.cs
示例2: 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());
GeometryConverter gc = new GeometryConverter();
Geometry geometry = (Geometry)gc.ConvertFromString(string.Format("M {0},{1} {2},{3} {4},{5} Z", StylusPoints[0].X, StylusPoints[1].Y, (Math.Abs(StylusPoints[1].X - StylusPoints[0].X))/2 + StylusPoints[0].X, StylusPoints[0].Y, StylusPoints[1].X, StylusPoints[1].Y));
GeometryDrawing gd = new GeometryDrawing(BackGround, pen, geometry);
drawingContext.DrawDrawing(gd);
}
开发者ID:sonicrang,项目名称:RangPaint,代码行数:25,代码来源:TriangleStroke.cs
示例3: CreateArcDrawing
/// <summary>
/// Create an Arc geometry drawing of an ellipse or circle
/// </summary>
/// <param name="rect">Box to hold the whole ellipse described by the arc</param>
/// <param name="startDegrees">Start angle of the arc degrees within the ellipse. 0 degrees is a line to the right.</param>
/// <param name="sweepDegrees">Sweep angle, -ve = Counterclockwise, +ve = Clockwise</param>
/// <returns>GeometryDrawing object</returns>
private static GeometryDrawing CreateArcDrawing(Rect rect, double startDegrees, double sweepDegrees)
{
// degrees to radians conversion
double startRadians = startDegrees * Math.PI / 180.0;
double sweepRadians = sweepDegrees * Math.PI / 180.0;
// x and y radius
double dx = rect.Width / 2;
double dy = rect.Height / 2;
// determine the start point
double xs = rect.X + dx + (Math.Cos(startRadians) * dx);
double ys = rect.Y + dy + (Math.Sin(startRadians) * dy);
// determine the end point
double xe = rect.X + dx + (Math.Cos(startRadians + sweepRadians) * dx);
double ye = rect.Y + dy + (Math.Sin(startRadians + sweepRadians) * dy);
// draw the arc into a stream geometry
StreamGeometry streamGeom = new StreamGeometry();
using (StreamGeometryContext ctx = streamGeom.Open())
{
bool isLargeArc = Math.Abs(sweepDegrees) > 180;
SweepDirection sweepDirection = sweepDegrees < 0 ? SweepDirection.Counterclockwise : SweepDirection.Clockwise;
ctx.BeginFigure(new Point(xs, ys), false, false);
ctx.ArcTo(new Point(xe, ye), new Size(dx, dy), 0, isLargeArc, sweepDirection, true, false);
}
// create the drawing
GeometryDrawing drawing = new GeometryDrawing();
drawing.Geometry = streamGeom;
return drawing;
}
开发者ID:Meddington,项目名称:xyzmidi,代码行数:41,代码来源:MappingFeedback.cs
示例4: CreateErrorPen
public static Pen CreateErrorPen(Color color)
{
var geometry = new StreamGeometry();
using (var context = geometry.Open())
{
context.BeginFigure(new Point(-1, 0), false, false);
context.PolyLineTo(new[] {
new Point(-0.5, 0.4),
new Point(0, 0),
new Point(0.5, -0.4),
new Point(1, 0),
}, true, true);
}
var brushPattern = new GeometryDrawing
{
Pen = new Pen(new SolidColorBrush(color), 0.4),
Geometry = geometry
};
var brush = new DrawingBrush(brushPattern)
{
TileMode = TileMode.Tile,
Viewport = new Rect(-1, -1, 2, 2),
ViewportUnits = BrushMappingMode.Absolute,
Viewbox = new Rect(-1, -1, 2, 2),
ViewboxUnits = BrushMappingMode.Absolute,
};
var pen = new Pen(brush, 3.0);
pen.Freeze();
return pen;
}
开发者ID:osmedile,项目名称:TypeCobol,代码行数:30,代码来源:Pen.cs
示例5: CreateARectangleWithDrawingBrush
private Brush CreateARectangleWithDrawingBrush()
{
// Create a DrawingBrush
DrawingBrush blackBrush = new DrawingBrush();
// Create a Geometry with white background
GeometryDrawing backgroundSquare =
new GeometryDrawing(
Brushes.DarkGray,
null,
new RectangleGeometry(new Rect(0, 0, 400, 400)));
// Create a GeometryGroup that will be added to Geometry
GeometryGroup gGroup = new GeometryGroup();
gGroup.Children.Add(new RectangleGeometry(new Rect(0, 0, 200, 200)));
gGroup.Children.Add(new RectangleGeometry(new Rect(200, 200, 200, 200)));
// Create a GeomertyDrawing
GeometryDrawing checkers = new GeometryDrawing(new SolidColorBrush(Colors.Gray), null, gGroup);
DrawingGroup checkersDrawingGroup = new DrawingGroup();
checkersDrawingGroup.Children.Add(backgroundSquare);
checkersDrawingGroup.Children.Add(checkers);
blackBrush.Drawing = checkersDrawingGroup;
// Set Viewport and TimeMode
blackBrush.Viewport = new Rect(0, 0, 0.1, 0.2);
blackBrush.TileMode = TileMode.Tile;
return blackBrush;
}
开发者ID:riezebosch,项目名称:Glitter,代码行数:30,代码来源:ColorConverter.cs
示例6: createDrawingWithFrameRectangleGeometry
private Drawing createDrawingWithFrameRectangleGeometry()
{
GeometryDrawing drawing = new GeometryDrawing();
drawing.Pen = new Pen(Brushes.Black, 1);
drawing.Geometry = buildFrameRectangle();
return drawing;
}
开发者ID:davidbedok,项目名称:oeprogvep,代码行数:7,代码来源:MainWindow.xaml.cs
示例7: MainWindow
public MainWindow()
{
InitializeComponent();
drawingGroup = new DrawingGroup();
// Создаем объект для описания геометрической фигуры
GeometryDrawing geometryDrawing = new GeometryDrawing();
// Описываем и сохраняем геометрию квадрата
RectangleGeometry rectGeometry = new RectangleGeometry();
rectGeometry.Rect = new Rect(0, 0, 10, 10);
geometryDrawing.Geometry = rectGeometry;
// Настраиваем перо и кисть
geometryDrawing.Pen = new Pen(Brushes.Red, 0.005);// Перо рамки
geometryDrawing.Brush = Brushes.LightBlue;// Кисть закраски
// Добавляем готовый слой в контейнер отображения
drawingGroup.Children.Add(geometryDrawing);
GeometryDrawing ellipsgeomy = new GeometryDrawing();
EllipseGeometry elgeometry = new EllipseGeometry(new Point(5, 5), 2, 2);
ellipsgeomy.Geometry = elgeometry;
ellipsgeomy.Brush = Brushes.White;
drawingGroup.Children.Add(ellipsgeomy);
}
开发者ID:EugeneMurashko,项目名称:git-test,代码行数:31,代码来源:MainWindow.xaml.cs
示例8: SetFillBrush
public void SetFillBrush()
{
DrawingGroup rootDrawingGroup = new DrawingGroup();
GeometryDrawing aDrawing = new GeometryDrawing();
aDrawing.Brush = Brushes.Gray.CloneCurrentValue();
aDrawing.Pen = new Pen(Brushes.Gray, 1);
aDrawing.Brush.Opacity = .5;
aDrawing.Geometry = Primitives.PolygonLine(WallElementDetails.StartPoint, WallElementDetails.EndPoint, 10, 10);
rootDrawingGroup.Children.Add(aDrawing);
//create a transition line
GeometryDrawing aCenterLine = new GeometryDrawing();
aCenterLine.Brush = Brushs.WallBoundaryStroke;
aCenterLine.Pen = Pens.WallBoundaryStroke;
aCenterLine.Geometry = Primitives.Line(WallElementDetails.StartPoint, WallElementDetails.EndPoint);
rootDrawingGroup.Children.Add(aCenterLine);
DrawingBrush brush = new DrawingBrush(rootDrawingGroup);
this.Fill = brush;
}
开发者ID:RookieOne,项目名称:Adorners,代码行数:26,代码来源:WallElement.cs
示例9: AreaSeries2D
public AreaSeries2D()
{
// 初始化保存数据点的变量
_points = new SeriesPointCollection();
_points.CollectionChanged += _points_CollectionChanged;
// 初始化绘制曲线的画板
gStream_Line = new StreamGeometry();
gStream_Area = new StreamGeometry();
gDrawing_Line = new GeometryDrawing();
gDrawing_Line.Brush = null;
gDrawing_Line.Pen = new Pen()
{
Thickness = 1,
Brush = Brushes.Black
};
gDrawing_Line.Geometry = gStream_Line;
/* 初始化绘制填充色的画板 */
gDrawing_Area = new GeometryDrawing();
gDrawing_Area.Brush = Brushes.Red;
gDrawing_Area.Pen = new Pen()
{
Thickness = 0,
Brush = null
};
gDrawing_Area.Geometry = gStream_Area;
/* 生成绘画组 */
drawingGroup = new DrawingGroup();
drawingGroup.Children.Add(gDrawing_Line);
drawingGroup.Children.Add(gDrawing_Area);
}
开发者ID:35408EF66CCE4377B1E3C2495CA1C18A,项目名称:XuanJiYi_PC,代码行数:34,代码来源:AreaSeries2D.cs
示例10: OnRender
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
{
base.OnRender(drawingContext);
// allows the points to be rendered as an image that can be further manipulated
PathGeometry geometry = new PathGeometry();
this.Siz
// Add all points to the geometry
foreach (Points pointXY in _points)
{
PathFigure figure = new PathFigure();
figure.StartPoint = pointXY.FromPoint;
figure.Segments.Add(new LineSegment(pointXY.ToPoint, true));
geometry.Figures.Add(figure);
}
// Add the first point to close the gap from the graph's end point
// to graph's start point
PathFigure lastFigure = new PathFigure();
lastFigure.StartPoint = _points[_points.Count - 1].FromPoint;
lastFigure.Segments.Add(new LineSegment(_firstPoint, true));
geometry.Figures.Add(lastFigure);
// Create a new drawing and drawing group in order to apply
// a custom drawing effect
GeometryDrawing drawing = new GeometryDrawing(this.Pen.Brush, this.Pen, geometry);
DrawingGroup drawingGroup = new DrawingGroup();
drawingGroup.Children.Add(drawing);
}
开发者ID:valentine-palazkov,项目名称:tictactoe-wpf,代码行数:32,代码来源:BoardCellView.xaml.cs
示例11: createDrawingWithGroupGemoetry
private Drawing createDrawingWithGroupGemoetry()
{
GeometryDrawing drawing = new GeometryDrawing();
drawing.Pen = new Pen(Brushes.Black, 1);
drawing.Geometry = buildGeometryGroup();
return drawing;
}
开发者ID:davidbedok,项目名称:oeprogvep,代码行数:7,代码来源:MainWindow.xaml.cs
示例12: Init
public void Init()
{
DrawingGroup dg = new DrawingGroup();
ImageDrawing id = new ImageDrawing(UnderlayImage, new Rect(0, 0, UnderlayImage.PixelWidth, UnderlayImage.PixelHeight));
dg.Children.Add(id);
pointsGeometryGroup = new GeometryGroup();
linesGeometryGroup = new GeometryGroup();
middlePointGeoGrp = new GeometryGroup();
if (points != null)
{
SetPointsGeometry();
}
GeometryDrawing gd = new GeometryDrawing(Brushes.Blue, null, pointsGeometryGroup);
dg.Children.Add(gd);
GeometryDrawing gd2 = new GeometryDrawing(null, new Pen(Brushes.LightGreen,3), linesGeometryGroup);
dg.Children.Add(gd2);
GeometryDrawing gd1 = new GeometryDrawing(Brushes.Red, null, middlePointGeoGrp);
dg.Children.Add(gd1);
Brush b = new SolidColorBrush(Colors.Red);
b.Opacity = 0.5;
mousePointGeometryDrwaing = new GeometryDrawing(b, null, null);
dg.Children.Add(mousePointGeometryDrwaing);
DrawingImage di = new DrawingImage(dg);
this.Source = di;
chosenPoint = -1;
}
开发者ID:gp1313,项目名称:morethantechnical,代码行数:33,代码来源:Window1.xaml.cs
示例13: PaintBackground
private void PaintBackground()
{
var backgroundSquare = new GeometryDrawing(Brushes.Black, null, new RectangleGeometry(new Rect(0, 0, 100, 100)));
var aGeometryGroup = new GeometryGroup();
aGeometryGroup.Children.Add(new RectangleGeometry(new Rect(0, 0, 50, 50)));
aGeometryGroup.Children.Add(new RectangleGeometry(new Rect(50, 50, 50, 50)));
var checkerBrush = new LinearGradientBrush();
checkerBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0));
checkerBrush.GradientStops.Add(new GradientStop(Color.FromRgb(0, 22, 0), 1.0));
var checkers = new GeometryDrawing(checkerBrush, null, aGeometryGroup);
var checkersDrawingGroup = new DrawingGroup();
checkersDrawingGroup.Children.Add(backgroundSquare);
checkersDrawingGroup.Children.Add(checkers);
var myBrush = new DrawingBrush
{
Drawing = checkersDrawingGroup,
Viewport = new Rect(0, 0, 0.02, 0.02),
TileMode = TileMode.Tile,
Opacity = 0.5
};
LayoutRoot.Background = myBrush;
}
开发者ID:estromsnes,项目名称:CodeNinjaSpy,代码行数:28,代码来源:CodeNinjaSpyShell.xaml.cs
示例14: AShape
/// <summary>
/// Create a new abstract shape.
/// </summary>
/// <param name="Id">The Id of the shape.</param>
/// <param name="Latitude">The latitude of the shape center.</param>
/// <param name="Longitude">The longitude of the shape center.</param>
/// <param name="Altitude">The altitude of the shape center.</param>
/// <param name="GeoWidth">The geographical width of the shape center.</param>
/// <param name="GeoHeight">The geographical height of the shape center.</param>
public AShape(String[] Geometries, Latitude Latitude, Longitude Longitude, Altitude Altitude, Latitude Latitude2, Longitude Longitude2, Color StrokeColor, Double StrokeThickness, Color FillColor)
{
this.Id = Id;
this.Latitude = Latitude;
this.Longitude = Longitude;
this.Altitude = Altitude;
this.Latitude2 = Latitude2;
this.Longitude2 = Longitude2;
var PathGeometry16 = PathGeometry.Parse(Geometries[8]);
var GD16 = new GeometryDrawing(new SolidColorBrush(FillColor), new Pen(new SolidColorBrush(StrokeColor), StrokeThickness), PathGeometry16);
var DrawingGroup = new DrawingGroup();
DrawingGroup.Children.Add(GD16);
this.Fill = new DrawingBrush()
{
Drawing = DrawingGroup,
//Viewport = new Rect(0, 0, 1, 1),
TileMode = TileMode.None,
Stretch = Stretch.UniformToFill
};
Bounds = DrawingGroup.Bounds;
var w = Bounds.Width;
var h = Bounds.Height;
}
开发者ID:subbuballa,项目名称:Aegir,代码行数:37,代码来源:AShape.cs
示例15: CreateVisuals
/// <summary>
/// Within the given line add the scarlet box behind the a
/// </summary>
private void CreateVisuals(ITextViewLine line)
{
//grab a reference to the lines in the current TextView
IWpfTextViewLineCollection textViewLines = _view.TextViewLines;
int start = line.Start;
int end = line.End;
//Loop through each character, and place a box around any a
for (int i = start; (i < end); ++i)
{
if (_view.TextSnapshot[i] == 'a')
{
SnapshotSpan span = new SnapshotSpan(_view.TextSnapshot, Span.FromBounds(i, i + 1));
Geometry g = textViewLines.GetMarkerGeometry(span);
if (g != null)
{
GeometryDrawing drawing = new GeometryDrawing(_brush, _pen, g);
drawing.Freeze();
DrawingImage drawingImage = new DrawingImage(drawing);
drawingImage.Freeze();
Image image = new Image();
image.Source = drawingImage;
//Align the image with the top of the bounds of the text geometry
Canvas.SetLeft(image, g.Bounds.Left);
Canvas.SetTop(image, g.Bounds.Top);
_layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null);
}
}
}
}
开发者ID:AlmatoolboxCE,项目名称:AlmaStyleFix,代码行数:37,代码来源:TextAdornment1.cs
示例16: AddDecorationError
public void AddDecorationError(BasePropertyDeclarationSyntax _property, string textFull, string toolTipText, FixErrorCallback errorCallback)
{
var lineSpan = tree.GetLineSpan(_property.Span, usePreprocessorDirectives: false);
int lineNumber = lineSpan.StartLinePosition.Line;
var line = _textView.TextSnapshot.GetLineFromLineNumber(lineNumber);
var textViewLine = _textView.GetTextViewLineContainingBufferPosition(line.Start);
int startSpace = textFull.Length - textFull.TrimStart().Length;
int endSpace = textFull.Length - textFull.TrimEnd().Length;
SnapshotSpan span = new SnapshotSpan(_textView.TextSnapshot, Span.FromBounds(line.Start.Position + startSpace, line.End.Position - endSpace));
Geometry g = _textView.TextViewLines.GetMarkerGeometry(span);
if (g != null)
{
rects.Add(g.Bounds);
GeometryDrawing drawing = new GeometryDrawing(_brush, _pen, g);
drawing.Freeze();
DrawingImage drawingImage = new DrawingImage(drawing);
drawingImage.Freeze();
Image image = new Image();
image.Source = drawingImage;
//image.Visibility = Visibility.Hidden;
Canvas.SetLeft(image, g.Bounds.Left);
Canvas.SetTop(image, g.Bounds.Top);
_layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, (t, ui) =>
{
rects.Remove(g.Bounds);
});
DrawIcon(span, g.Bounds.Left - 30, g.Bounds.Top, toolTipText, errorCallback);
}
}
开发者ID:jefflequeux,项目名称:DarkangeUtils,代码行数:35,代码来源:BaseMef.cs
示例17: CreateGeometryDrawing
GeometryDrawing CreateGeometryDrawing()
{
//http://msdn.microsoft.com/en-us/library/system.windows.media.geometrydrawing.aspx
GeometryGroup ellipses = new GeometryGroup();
ellipses.Children.Add(
new EllipseGeometry(new Point(200, 200), 45, 20)
);
ellipses.Children.Add(
new EllipseGeometry(new Point(200, 200), 20, 45)
);
GeometryDrawing aGeometryDrawing = new GeometryDrawing();
aGeometryDrawing.Geometry = ellipses;
// Paint the drawing with a gradient.
aGeometryDrawing.Brush =
new LinearGradientBrush(
Colors.Blue,
Color.FromRgb(204, 204, 255),
new Point(0, 0),
new Point(1, 1));
return aGeometryDrawing;
}
开发者ID:nanomouse,项目名称:stratasys,代码行数:25,代码来源:MainWindow.xaml.cs
示例18: TranslationAdornment
/// <summary>
/// Creates a square image and attaches an event handler to the layout changed event that
/// adds the the square in the upper right-hand corner of the TextView via the adornment layer
/// </summary>
/// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
public TranslationAdornment(IWpfTextView view)
{
_view = view;
Brush brush = new SolidColorBrush(Colors.BlueViolet);
brush.Freeze();
Brush penBrush = new SolidColorBrush(Colors.Red);
penBrush.Freeze();
Pen pen = new Pen(penBrush, 0.5);
pen.Freeze();
//draw a square with the created brush and pen
System.Windows.Rect r = new System.Windows.Rect(0, 0, 30, 30);
Geometry g = new RectangleGeometry(r);
GeometryDrawing drawing = new GeometryDrawing(brush, pen, g);
drawing.Freeze();
DrawingImage drawingImage = new DrawingImage(drawing);
drawingImage.Freeze();
_image = new Image();
_image.Source = drawingImage;
//Grab a reference to the adornment layer that this adornment should be added to
_adornmentLayer = view.GetAdornmentLayer("TranslationAdornment");
_view.ViewportHeightChanged += delegate { this.onSizeChange(); };
_view.ViewportWidthChanged += delegate { this.onSizeChange(); };
}
开发者ID:JeanAzzopardi,项目名称:TranslatorExtensionPackage,代码行数:34,代码来源:TranslationAdornment.cs
示例19: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
var ellipse = new EllipseGeometry(new Point(250, 50), 50, 50);
var drawing = new GeometryDrawing(Brushes.BlueViolet, new Pen(Brushes.Bisque, 2), ellipse);
drawingContext.DrawDrawing(drawing);
}
开发者ID:BerdyPango,项目名称:Researches,代码行数:8,代码来源:02_MyEllipseGeometry.cs
示例20: Process
public GeometryDrawing Process()
{
GeometryDrawing drawing = new GeometryDrawing();
drawing.Brush = Brushes.Transparent;
drawing.Geometry = new RectangleGeometry(this.Value);
return drawing;
}
开发者ID:jogibear9988,项目名称:svg2xaml,代码行数:8,代码来源:SvgViewbox.cs
注:本文中的System.Windows.Media.GeometryDrawing类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论