本文整理汇总了C#中IGraphics.BeginEntity方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphics.BeginEntity方法的具体用法?C# IGraphics.BeginEntity怎么用?C# IGraphics.BeginEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraphics
的用法示例。
在下文中一共展示了IGraphics.BeginEntity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
protected virtual void Draw (IGraphics g, int startIndex, int length, float thickness)
{
g.BeginEntity (this);
if (length == 0) {
}
else if (length == 1) {
var p = _points [startIndex];
var r = thickness / 2;
g.FillOval (p.X - r, p.Y - r, thickness, thickness);
}
else {
g.BeginLines (true);
var end = startIndex + length;
for (var i = startIndex; i < end - 1; i++) {
g.DrawLine (
_points [i].X,
_points [i].Y,
_points [i + 1].X,
_points [i + 1].Y,
thickness);
}
g.EndLines ();
}
}
示例2: Draw
public void Draw(IGraphics g)
{
g.BeginEntity (this);
var now = DateTime.Now;
var r = Math.Min (Width / 2, Height / 2);
var center = new System.Drawing.PointF (Width / 2, Height / 2);
//
// Draw the face
//
g.SetColor (BackColor);
g.FillOval (center.X - r, center.Y - r, 2 * r, 2 * r);
g.SetColor (BorderColor);
g.DrawOval (center.X - r + 4, center.Y - r + 4, 2 * r - 8, 2 * r - 8, 8);
g.SetColor (FaceColor);
for (var i = 0; i < 12; i++) {
var angle = (i / 12.0) * 2 * Math.PI;
g.DrawLine (
center.X + 0.75f * r * (float)Math.Cos (angle),
center.Y + 0.75f * r * (float)Math.Sin (angle),
center.X + 0.9f * r * (float)Math.Cos (angle),
center.Y + 0.9f * r * (float)Math.Sin (angle),
7);
}
g.SetFont (LabelFont);
var textWidth = g.GetFontMetrics ().StringWidth ("Cross Graphics");
g.DrawString ("Cross Graphics", center.X - textWidth / 2, center.Y + 0.25f * r);
//
// Draw the hour hand
//
g.SetColor (Colors.DarkGray);
var h = now.Hour + now.Minute / 60.0;
var hAngle = h > 12 ?
((h - 12) / 12.0 * 2 * Math.PI - Math.PI /2) :
(h / 12.0 * 2 * Math.PI - Math.PI / 2);
g.DrawLine (
center.X + -0.1f * r * (float)Math.Cos (hAngle),
center.Y + -0.1f * r * (float)Math.Sin (hAngle),
center.X + 0.65f * r * (float)Math.Cos (hAngle),
center.Y + 0.65f * r * (float)Math.Sin (hAngle),
7);
//
// Draw the minute hand
//
g.SetColor (Colors.DarkGray);
var m = now.Minute + now.Second / 60.0;
var mAngle = (m / 60.0) * 2 * Math.PI - Math.PI / 2;
g.DrawLine (
center.X + -0.15f * r * (float)Math.Cos (mAngle),
center.Y + -0.15f * r * (float)Math.Sin (mAngle),
center.X + 0.85f * r * (float)Math.Cos (mAngle),
center.Y + 0.85f * r * (float)Math.Sin (mAngle),
5);
//
// Draw the second hand
//
g.SetColor (Colors.Red);
var sAngle = (now.Second / 60.0) * 2 * Math.PI - Math.PI / 2;
g.DrawLine (
center.X + -0.15f * r * (float)Math.Cos (sAngle),
center.Y + -0.15f * r * (float)Math.Sin (sAngle),
center.X + 0.85f * r * (float)Math.Cos (sAngle),
center.Y + 0.85f * r * (float)Math.Sin (sAngle),
1);
//
// Draw the pin
//
g.SetColor (Colors.Black);
g.FillOval (center.X - 5, center.Y - 5, 10, 10);
}