本文整理汇总了C#中OxyColor.ToXwtColor方法的典型用法代码示例。如果您正苦于以下问题:C# OxyColor.ToXwtColor方法的具体用法?C# OxyColor.ToXwtColor怎么用?C# OxyColor.ToXwtColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OxyColor
的用法示例。
在下文中一共展示了OxyColor.ToXwtColor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawEllipse
/// <summary>
/// Draws an ellipse.
/// </summary>
/// <param name="rect">The rectangle defining the extents of the ellipse.</param>
/// <param name="fill">The fill color. If set to <c>OxyColors.Undefined</c>, the extents will not be filled.</param>
/// <param name="stroke">The stroke color. If set to <c>OxyColors.Undefined</c>, the extents will not be stroked.</param>
/// <param name="thickness">The thickness (in device independent units, 1/96 inch).</param>
public override void DrawEllipse(OxyRect rect,
OxyColor fill,
OxyColor stroke,
double thickness)
{
var ex = rect.Left + (rect.Width / 2.0);
var ey = rect.Top + (rect.Height / 2.0);
if (fill.IsVisible ()) {
Context.Save ();
Context.SetColor (fill.ToXwtColor ());
Context.Translate (ex, ey);
Context.Scale (1.0, -rect.Height / rect.Width);
Context.Arc (0.0, 0.0, rect.Width / 2.0, 0, 360);
Context.ClosePath ();
Context.Fill ();
Context.Restore ();
}
if (stroke.IsVisible () && thickness > 0) {
Context.Save ();
Context.SetColor (stroke.ToXwtColor ());
Context.SetLineWidth (thickness);
Context.Translate (ex, ey);
Context.Scale (1.0, -rect.Height / rect.Width);
Context.Arc (0.0, 0.0, rect.Width / 2.0, 0, 360);
Context.ClosePath ();
Context.Stroke ();
Context.Restore ();
}
}
示例2: DrawRectangle
/// <summary>
/// Draws a rectangle.
/// </summary>
/// <param name="rect">The rectangle to draw.</param>
/// <param name="fill">The fill color. If set to <c>OxyColors.Undefined</c>, the rectangle will not be filled.</param>
/// <param name="stroke">The stroke color. If set to <c>OxyColors.Undefined</c>, the rectangle will not be stroked.</param>
/// <param name="thickness">The stroke thickness (in device independent units, 1/96 inch).</param>
public override void DrawRectangle(OxyRect rect,
OxyColor fill,
OxyColor stroke,
double thickness)
{
if (fill.IsVisible ()) {
Context.Save ();
Context.Rectangle (rect.ToXwtRect (false));
Context.SetColor (fill.ToXwtColor ());
Context.Fill ();
Context.Restore ();
}
if (stroke.IsVisible () && thickness > 0) {
Context.Save ();
Context.SetColor (stroke.ToXwtColor ());
Context.SetLineWidth (thickness);
Context.Rectangle (rect.ToXwtRect (false));
Context.Stroke ();
Context.Restore ();
}
}
示例3: DrawText
/// <summary>
/// Draws text.
/// </summary>
/// <param name="p">The position.</param>
/// <param name="text">The text.</param>
/// <param name="fill">The text color.</param>
/// <param name="fontFamily">The font family.</param>
/// <param name="fontSize">Size of the font (in device independent units, 1/96 inch).</param>
/// <param name="fontWeight">The font weight.</param>
/// <param name="rotate">The rotation angle.</param>
/// <param name="halign">The horizontal alignment.</param>
/// <param name="valign">The vertical alignment.</param>
/// <param name="maxSize">The maximum size of the text (in device independent units, 1/96 inch).</param>
public override void DrawText(ScreenPoint p,
string text,
OxyColor fill,
string fontFamily,
double fontSize,
double fontWeight,
double rotate,
HorizontalAlignment halign,
VerticalAlignment valign,
OxySize? maxSize)
{
Context.Save ();
var layout = new TextLayout ();
layout.Font = GetCachedFont (fontFamily, fontSize, fontWeight);
layout.Text = text;
var size = layout.GetSize ();
if (maxSize != null) {
size.Width = Math.Min (size.Width, maxSize.Value.Width);
size.Height = Math.Min (size.Height, maxSize.Value.Height);
}
double dx = 0;
if (halign == HorizontalAlignment.Center) {
dx = -size.Width / 2;
}
if (halign == HorizontalAlignment.Right) {
dx = -size.Width;
}
double dy = 0;
if (valign == VerticalAlignment.Middle) {
dy = -size.Height / 2;
}
if (valign == VerticalAlignment.Bottom) {
dy = -size.Height;
}
Context.Translate (p.X, p.Y);
if (Math.Abs (rotate) > double.Epsilon) {
Context.Rotate (rotate);
}
Context.Translate (dx, dy);
Context.SetColor (fill.ToXwtColor ());
Context.DrawTextLayout (layout, 0, 0);
Context.Restore ();
}
示例4: DrawPolygon
/// <summary>
/// Draws a polygon.
/// </summary>
/// <param name="points">The points defining the polygon.</param>
/// <param name="fill">The fill color. If set to <c>OxyColors.Undefined</c>, the polygon will not be filled.</param>
/// <param name="stroke">The stroke color. If set to <c>OxyColors.Undefined</c>, the polygon will not be stroked.</param>
/// <param name="thickness">The stroke thickness (in device independent units, 1/96 inch).</param>
/// <param name="dashArray">The dash array (in device independent units, 1/96 inch).</param>
/// <param name="lineJoin">The line join type.</param>
/// <param name="aliased">If set to <c>true</c> the polygon will be aliased.</param>
public override void DrawPolygon(IList<ScreenPoint> points,
OxyColor fill,
OxyColor stroke,
double thickness,
double[] dashArray,
LineJoin lineJoin,
bool aliased)
{
if (fill.IsVisible () && points.Count >= 2) {
// g.SmoothingMode = aliased ? SmoothingMode.None : SmoothingMode.HighQuality; // TODO: Smoothing modes
Context.Save ();
Context.SetColor (fill.ToXwtColor ());
//Context.LineJoin = lineJoin.ToLineJoin();
Context.SetLineWidth (thickness);
if (dashArray != null)
Context.SetLineDash (0, Array.ConvertAll (dashArray, x => x * thickness));
Context.MoveTo (points [0].ToXwtPoint (aliased));
foreach (var point in points.Skip(1)) {
Context.LineTo (point.ToXwtPoint (aliased));
}
// g.LineTo(points[0].ToPointD(aliased));
Context.ClosePath ();
Context.Fill ();
Context.Restore ();
}
if (stroke.IsVisible () && thickness > 0 && points.Count >= 2) {
// g.SmoothingMode = aliased ? SmoothingMode.None : SmoothingMode.HighQuality; // TODO: Smoothing modes
Context.Save ();
Context.SetColor (stroke.ToXwtColor ());
//Context.LineJoin = lineJoin.ToLineJoin();
Context.SetLineWidth (thickness);
if (dashArray != null)
Context.SetLineDash (0, Array.ConvertAll (dashArray, x => x * thickness));
Context.MoveTo (points [0].ToXwtPoint (aliased));
foreach (var point in points.Skip(1)) {
Context.LineTo (point.ToXwtPoint (aliased));
}
Context.ClosePath ();
Context.Stroke ();
Context.Restore ();
}
}