本文整理汇总了C#中System.Windows.Media.DrawingContext.DrawEllipse方法的典型用法代码示例。如果您正苦于以下问题:C# DrawingContext.DrawEllipse方法的具体用法?C# DrawingContext.DrawEllipse怎么用?C# DrawingContext.DrawEllipse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.DrawingContext
的用法示例。
在下文中一共展示了DrawingContext.DrawEllipse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
示例2: DrawEllipse
// assumptions for pixel snapping:
// - the drawing context itself is pixel snapped
// - all strokes have same thickness
// - the thickness is a whole number
#region ELLIPSES
/// <summary>See <c>WpfExtensions</c> for details.</summary>
public static void DrawEllipse(DrawingContext dc, Paint paint, Point center, double radiusX, double radiusY, bool snapToPixel) {
// get brush and stroke resources
if (paint == null) return;
var fill = paint.Fill;
var hasFill = (fill != null);
var strokes = paint.GetStrokePens().ToArray();
var numStrokes = strokes.Length;
if (!hasFill && numStrokes == 0) return;
var halfThickness = Math.Round(numStrokes > 0? strokes[0].Thickness : 0.0) / 2;
if (snapToPixel) {
center = new Point(center.X + halfThickness, center.Y + halfThickness);
}
if (numStrokes > 0) {
for (var i = 0; i < numStrokes - 1; i++) {
dc.DrawEllipse(null, strokes[i], center, radiusX, radiusY);
radiusX = (radiusX - 2 * halfThickness).Max(0);
radiusY = (radiusY - 2 * halfThickness).Max(0);
}
dc.DrawEllipse(fill, strokes[numStrokes - 1], center, radiusX, radiusY);
} else {
dc.DrawEllipse(fill, null, center, radiusX, radiusY);
}
}
示例3: DrawCenter
protected virtual void DrawCenter(HandData hand, DrawingContext drawingContext)
{
drawingContext.DrawEllipse(Brushes.Blue, null, new System.Windows.Point(hand.Location.X, hand.Location.Y), 5, 5);
if (hand.HasPalmPoint) {
drawingContext.DrawEllipse(Brushes.SpringGreen, null, new System.Windows.Point(hand.PalmPoint.Value.X, hand.PalmPoint.Value.Y), 5, 5);
var palmSize = hand.PalmDistance;
drawingContext.DrawEllipse(null, this.greenPen, new System.Windows.Point(hand.PalmPoint.Value.X, hand.PalmPoint.Value.Y), palmSize, palmSize);
}
}
示例4: OnRender
protected override void OnRender(DrawingContext dc)
{
base.OnRender(dc);
Size rectSize = new Size(RenderSize.Width + 6, RenderSize.Height + 6);
Rect rect = new Rect(new Point(-3, -3), rectSize);
dc.DrawRectangle(Brushes.Transparent, new Pen(Brushes.Blue, 1), rect);
dc.DrawEllipse(Brushes.Red, new Pen(Brushes.Blue, 1), new Point(0, 0), 6, 6);
dc.DrawEllipse(Brushes.Red, new Pen(Brushes.Blue, 1), new Point(0, this.ActualHeight), 6, 6);
dc.DrawEllipse(Brushes.Red, new Pen(Brushes.Blue, 1), new Point(this.ActualWidth, this.ActualHeight), 6, 6);
dc.DrawEllipse(Brushes.Red, new Pen(Brushes.Blue, 1), new Point(this.ActualWidth, 0), 6, 6);
}
示例5: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
Rect adornedElementRect = GetAdornedElementRect();
drawingContext.DrawRectangle(Brushes.Transparent, _pen, adornedElementRect);
drawingContext.DrawEllipse(_brush, null, adornedElementRect.TopLeft, HANDLE_SIZE, HANDLE_SIZE);
drawingContext.DrawEllipse(_brush, null, adornedElementRect.TopRight, HANDLE_SIZE, HANDLE_SIZE);
drawingContext.DrawEllipse(_brush, null, adornedElementRect.BottomRight, HANDLE_SIZE, HANDLE_SIZE);
drawingContext.DrawEllipse(_brush, null, adornedElementRect.BottomLeft, HANDLE_SIZE, HANDLE_SIZE);
}
示例6: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
Rect adornedElementRect = new Rect(this.AdornedElement.DesiredSize);
SolidColorBrush renderBrush = new SolidColorBrush(Colors.Red);
renderBrush.Opacity = 0.5;
Pen renderPen = new Pen(new SolidColorBrush(Colors.White), 1.5);
double renderRadius = 5.0;
// Draw a circle at each corner.
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.TopLeft, renderRadius, renderRadius);
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.TopRight, renderRadius, renderRadius);
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.BottomLeft, renderRadius, renderRadius);
drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.BottomRight, renderRadius, renderRadius);
}
示例7: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
drawingContext.DrawEllipse(Brushes.Blue, null, new Point(0,0), 1.0, 1.0);
}
示例8: CopyToFrameToDrawingContext
internal static void CopyToFrameToDrawingContext(this HighDefinitionFaceFrame highDefinitionFaceFrame, DrawingContext context, bool useDepthSpace = true, byte bodyIndex = 1, double pointRadius = 2F)
{
var faceAlignment = new FaceAlignment();
var coordinateMapper = highDefinitionFaceFrame.HighDefinitionFaceFrameSource.KinectSensor.CoordinateMapper;
var brush = BodyIndexColor.GetBrushFromBodyIndex(bodyIndex);
highDefinitionFaceFrame.GetAndRefreshFaceAlignmentResult(faceAlignment);
var faceModel = new FaceModel();
var vertices = faceModel.CalculateVerticesForAlignment(faceAlignment);
if (vertices.Count > 0)
{
for (int index = 0; index < vertices.Count; index++)
{
CameraSpacePoint vertice = vertices[index];
DepthSpacePoint point = coordinateMapper.MapCameraPointToDepthSpace(vertice);
if (float.IsInfinity(point.X) || float.IsInfinity(point.Y))
return;
context.DrawEllipse(brush, null, point.GetPoint(), pointRadius, pointRadius);
}
}
}
开发者ID:andreasassetti,项目名称:Kinect-v2-Visual-Studio-Visualizer,代码行数:25,代码来源:ExtensionMethodsHighDefinitionFaceFrame.cs
示例9: DrawPointElement
protected override void DrawPointElement(DrawingContext dc, int Zoom)
{
dc.DrawLine(new Pen(Brushes.Black, 2), new Point(), new Point(0, -BodyOffset));
dc.PushTransform(new TranslateTransform(0, - 0.5 * BodyHeight - BodyOffset));
dc.DrawRectangle(Brushes.Black, null,
new Rect(-0.5 * BodyWidth, -0.5 * BodyHeight, BodyWidth, BodyHeight));
for (int i = 0; i < Lights.Length; i++)
dc.DrawEllipse(Lights[i], null, new Point(0, (2 + LightRadius + 1) * (i - 1)), LightRadius, LightRadius);
dc.PushTransform(new TranslateTransform(0.5 * BodyWidth + 2, -0.5 * BodyHeight));
if (Zoom > 11)
{
PrintStack(dc,
new FormattedText(Target.Name, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 10, Brushes.Black),
new FormattedText(OrdinateString, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 8, Brushes.Blue));
}
dc.Pop();
dc.Pop();
}
示例10: Render
public override void Render(DrawingContext dc, CoordinateTransform transform)
{
var x = ViewportPanel.GetX(this);
var y = ViewportPanel.GetY(this);
dc.DrawEllipse(Brushes.Red, null, new Point(x, y).ViewportToScreen(transform), 3, 3);
}
示例11: OnRender
/// <summary>
/// When overridden in a derived class, participates in rendering operations that are directed by the layout system. The rendering instructions for this element are not used directly when this method is invoked, and are instead preserved for later asynchronous use by layout and drawing.
/// </summary>
/// <param name="drawingContext">The drawing instructions for a specific element. This context is provided to the layout system.</param>
protected override void OnRender(DrawingContext drawingContext)
{
// When no interfaces have been defined, there is nothing to draw.
if (this.interfaceNames.Count == 0)
{
return;
}
base.OnRender(drawingContext);
Pen pen = new Pen(Brushes.Gray, 0.5);
Point origin = new Point(30, 3);
double length = Constants.StartHeight + (this.interfaceNames.Count * Constants.LineHeight);
// draw path at top left
drawingContext.DrawLine(pen, origin, new Point(origin.X, origin.Y - length));
drawingContext.DrawEllipse(Brushes.Transparent, pen, new Point(origin.X, origin.Y - length - Constants.Radius), Constants.Radius, Constants.Radius);
// draw interface names
origin.Offset(5.0D, -length - Constants.Radius);
foreach (string name in this.interfaceNames)
{
drawingContext.DrawText(new FormattedText(name, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, new Typeface("Segoe UI"), 7, pen.Brush), origin);
origin.Offset(0, 7.0D);
}
}
示例12: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
c++;
Console.WriteLine("RENDER : " + c);
drawingContext.DrawEllipse(Brushes.Blue, new Pen(Brushes.Black, 1), new Point(_element.X2, _element.Y2), 3, 3);
base.OnRender(drawingContext);
}
示例13: DrawCore
//Переопределение базового метода, который позволяет рисовать круг, имея координаты центра и радиус
protected override void DrawCore(DrawingContext context, DrawingAttributes overrides)
{
StylusPointCollection points = this.GetBezierStylusPoints();
StylusPoint p1 = points[0];
context.DrawEllipse(new SolidColorBrush(fillColor), new Pen(new SolidColorBrush(strokeColor), thickness), new Point(p1.X, p1.Y), xRadius, yRaduis);
}
示例14: Draw
protected override void Draw(object sender, DrawingContext g)
{
// -> Preview circle if drawing
if (this.drawing)
{
g.DrawEllipse(null, new Pen(Brushes.Black,1), new Point(this.center.X, this.center.Y), this.radius, this.radius);
}
}
示例15: DrawHand
internal void DrawHand(HandData handData, DrawingContext drawingContext)
{
if (this.AnimationInProgress)
{
var brush = new SolidColorBrush(Color.FromArgb(this.Opacity, 255, 255, 255));
this.CreateText((int)this.Center.X + " | " + (int)this.Center.Y + "\n" + new Random().NextDouble(), brush);
this.CreateNumberText(handData.FingerCount.ToString(), brush);
drawingContext.DrawText(this.text, this.Center);
drawingContext.DrawText(this.number, new Point(this.Center.X, this.Center.Y - this.Radius - 40));
drawingContext.DrawEllipse(null, new Pen(brush, 4), this.Center, this.Radius - 20, this.Radius - 20);
drawingContext.DrawEllipse(null, new Pen(brush, 4), this.Center, this.Radius + 10, this.Radius + 10);
this.DrawFingerPoints(handData, drawingContext);
this.UpdateProgress(brush);
drawingContext.DrawGeometry(brush, null, path.Data);
}
}