本文整理汇总了C#中OxyColor.IsVisible方法的典型用法代码示例。如果您正苦于以下问题:C# OxyColor.IsVisible方法的具体用法?C# OxyColor.IsVisible怎么用?C# OxyColor.IsVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OxyColor
的用法示例。
在下文中一共展示了OxyColor.IsVisible方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportToString
/// <summary>
/// Export the specified plot model to an xaml string.
/// </summary>
/// <param name="model">The model.</param>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <param name="background">The background.</param>
/// <returns>A xaml string.</returns>
public static string ExportToString(IPlotModel model, double width, double height, OxyColor background)
{
var g = new Grid();
if (background.IsVisible())
{
g.Background = background.ToBrush();
}
var c = new Canvas();
g.Children.Add(c);
var size = new Size(width, height);
g.Measure(size);
g.Arrange(new Rect(0, 0, width, height));
g.UpdateLayout();
var rc = new ShapesRenderContext(c) { UseStreamGeometry = false };
model.Update(true);
model.Render(rc, width, height);
var sb = new StringBuilder();
using (var sw = new StringWriter(sb))
{
var xw = XmlWriter.Create(sw, new XmlWriterSettings { Indent = true });
XamlWriter.Save(c, xw);
}
return sb.ToString();
}
示例2: DrawEllipse
/// <summary>
/// Draws an ellipse.
/// </summary>
/// <param name="rect">The rectangle.</param>
/// <param name="fill">The fill color.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The thickness.</param>
public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
{
this.SetAlias(false);
var convertedRectangle = rect.Convert();
if (fill.IsVisible())
{
this.SetFill(fill);
using (var path = new CGPath())
{
path.AddEllipseInRect(convertedRectangle);
this.gctx.AddPath(path);
}
this.gctx.DrawPath(CGPathDrawingMode.Fill);
}
if (stroke.IsVisible() && thickness > 0)
{
this.SetStroke(stroke, thickness);
using (var path = new CGPath())
{
path.AddEllipseInRect(convertedRectangle);
this.gctx.AddPath(path);
}
this.gctx.DrawPath(CGPathDrawingMode.Stroke);
}
}
示例3: PdfRenderContext
/// <summary>
/// Initializes a new instance of the <see cref="PdfRenderContext" /> class.
/// </summary>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <param name="background">The background color.</param>
public PdfRenderContext(double width, double height, OxyColor background)
{
this.RendersToScreen = false;
this.doc = new PdfDocument();
var page = new PdfPage { Width = new XUnit(width), Height = new XUnit(height) };
this.doc.AddPage(page);
this.g = XGraphics.FromPdfPage(page);
if (background.IsVisible())
{
this.g.DrawRectangle(ToBrush(background), 0, 0, width, height);
}
}
示例4: SaveBitmap
/// <summary>
/// Saves the PlotView as a bitmap.
/// </summary>
/// <param name="fileName">Name of the file.</param>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <param name="background">The background.</param>
public void SaveBitmap(string fileName, int width, int height, OxyColor background)
{
if (width <= 0)
{
width = (int)this.ActualWidth;
}
if (height <= 0)
{
height = (int)this.ActualHeight;
}
if (!background.IsVisible())
{
background = this.Background.ToOxyColor();
}
PngExporter.Export(this.ActualModel, fileName, width, height, background);
}
示例5: DrawEllipse
/// <summary>
/// Draws an ellipse.
/// </summary>
/// <param name="rect">The rectangle.</param>
/// <param name="fill">The fill color.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The thickness.</param>
public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
{
// center of ellipse
var ex = rect.Left + (rect.Width / 2.0);
var ey = rect.Top + (rect.Height / 2.0);
// ellipse dimensions
var ew = rect.Width;
var eh = rect.Height;
if (fill.IsVisible())
{
this.g.Save();
this.g.Translate(ex, ey); // make (ex, ey) == (0, 0)
this.g.Scale(ew / 2.0, eh / 2.0); // for width: ew / 2.0 == 1.0, eh / 2.0 == 1.0
this.g.Arc(0.0, 0.0, 1.0, 0.0, 2.0 * Math.PI); // 'circle' centered at (0, 0)
this.g.ClosePath();
this.g.SetSourceColor(fill);
this.g.Fill();
this.g.Restore();
}
if (stroke.IsVisible() && thickness > 0)
{
this.g.Save();
// g.SmoothingMode = SmoothingMode.HighQuality; // TODO
this.g.Translate(ex, ey); // make (ex, ey) == (0, 0)
this.g.Scale(ew / 2.0, eh / 2.0); // for width: ew / 2.0 == 1.0
// for height: eh / 2.0 == 1.0
this.g.Arc(0.0, 0.0, 1.0, 0.0, 2.0 * Math.PI); // 'circle' centered at (0, 0)
this.g.SetSourceColor(stroke);
this.g.LineWidth = thickness * 2.0 / ew;
this.g.Stroke();
this.g.Restore();
}
}
示例6: Export
/// <summary>
/// Exports the specified plot model to a xml writer.
/// </summary>
/// <param name="model">The model.</param>
/// <param name="writer">The xml writer.</param>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <param name="background">The background.</param>
private static void Export(IPlotModel model, XmlWriter writer, double width, double height, OxyColor background)
{
var c = new Canvas();
if (background.IsVisible())
{
c.Background = background.ToBrush();
}
c.Measure(new Size(width, height));
c.Arrange(new Rect(0, 0, width, height));
var rc = new CanvasRenderContext(c) { UseStreamGeometry = false };
rc.TextFormattingMode = TextFormattingMode.Ideal;
model.Update(true);
model.Render(rc, width, height);
c.UpdateLayout();
XamlWriter.Save(c, writer);
}
示例7: DrawRectangle
/// <summary>
/// Draws a rectangle.
/// </summary>
/// <param name="rect">The rectangle.</param>
/// <param name="fill">The fill color.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The stroke thickness.</param>
public override void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
{
this.paint.Reset();
{
if (fill.IsVisible())
{
this.SetFill(fill);
this.canvas.DrawRect(this.ConvertAliased(rect.Left), this.ConvertAliased(rect.Top), this.ConvertAliased(rect.Right), this.ConvertAliased(rect.Bottom), this.paint);
}
if (stroke.IsVisible())
{
this.SetStroke(stroke, thickness, aliased: true);
this.canvas.DrawRect(this.ConvertAliased(rect.Left), this.ConvertAliased(rect.Top), this.ConvertAliased(rect.Right), this.ConvertAliased(rect.Bottom), this.paint);
}
}
}
示例8: DrawPolygon
/// <summary>
/// Draws a polygon. The polygon can have stroke and/or fill.
/// </summary>
/// <param name="points">The points.</param>
/// <param name="fill">The fill color.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The stroke thickness.</param>
/// <param name="dashArray">The dash array.</param>
/// <param name="lineJoin">The line join type.</param>
/// <param name="aliased">If set to <c>true</c> the shape will be aliased.</param>
public override void DrawPolygon(IList<ScreenPoint> points, OxyColor fill, OxyColor stroke, double thickness, double[] dashArray, OxyPenLineJoin lineJoin, bool aliased)
{
this.paint.Reset();
{
this.path.Reset();
{
this.SetPath(points, aliased);
this.path.Close();
if (fill.IsVisible())
{
this.SetFill(fill);
this.canvas.DrawPath(this.path, this.paint);
}
if (stroke.IsVisible())
{
this.SetStroke(stroke, thickness, dashArray, lineJoin, aliased);
this.canvas.DrawPath(this.path, this.paint);
}
}
}
}
示例9: DrawEllipses
/// <summary>
/// Draws the collection of ellipses, where all have the same stroke and fill.
/// This performs better than calling DrawEllipse multiple times.
/// </summary>
/// <param name="rectangles">The rectangles.</param>
/// <param name="fill">The fill color.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The stroke thickness.</param>
public override void DrawEllipses(IList<OxyRect> rectangles, OxyColor fill, OxyColor stroke, double thickness)
{
this.paint.Reset();
{
foreach (var rect in rectangles)
{
if (fill.IsVisible())
{
this.SetFill(fill);
this.canvas.DrawOval(this.Convert(rect), this.paint);
}
if (stroke.IsVisible())
{
this.SetStroke(stroke, thickness);
this.canvas.DrawOval(this.Convert(rect), this.paint);
}
}
}
}
示例10: DrawRectangle
/// <summary>
/// Draws a rectangle.
/// </summary>
/// <param name="rect">The rectangle.</param>
/// <param name="fill">The fill color.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The stroke thickness.</param>
public override void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
{
this.SetAlias(true);
var convertedRect = rect.ConvertAliased();
if (fill.IsVisible())
{
this.SetFill(fill);
var path = new CGPath();
path.AddRect(convertedRect);
this.gctx.AddPath(path);
this.gctx.DrawPath(CGPathDrawingMode.Fill);
}
if (stroke.IsVisible() && thickness > 0)
{
this.SetStroke(stroke, thickness);
var path = new CGPath();
path.AddRect(convertedRect);
this.gctx.AddPath(path);
this.gctx.DrawPath(CGPathDrawingMode.Stroke);
}
}
示例11: SetStroke
/// <summary>
/// Sets the stroke of the specified shape.
/// </summary>
/// <param name="shape">The shape.</param>
/// <param name="stroke">The stroke.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="lineJoin">The line join.</param>
/// <param name="dashArray">The dash array.</param>
/// <param name="aliased">aliased if set to <c>true</c>.</param>
private void SetStroke(
Shape shape,
OxyColor stroke,
double thickness,
OxyPenLineJoin lineJoin = OxyPenLineJoin.Miter,
IEnumerable<double> dashArray = null,
bool aliased = false)
{
if (stroke.IsVisible() && thickness > 0)
{
shape.Stroke = this.GetCachedBrush(stroke);
switch (lineJoin)
{
case OxyPenLineJoin.Round:
shape.StrokeLineJoin = PenLineJoin.Round;
break;
case OxyPenLineJoin.Bevel:
shape.StrokeLineJoin = PenLineJoin.Bevel;
break;
// The default StrokeLineJoin is Miter
}
shape.StrokeThickness = thickness;
if (dashArray != null)
{
shape.StrokeDashArray = CreateDashArrayCollection(dashArray);
}
if (aliased)
{
// shape.UseLayoutRounding = aliased;
}
}
}
示例12: DrawRectangle
/// <summary>
/// Draws the rectangle.
/// </summary>
/// <param name="rect">The rectangle.</param>
/// <param name="fill">The fill color.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The stroke thickness.</param>
public void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
{
var el = new Rectangle();
if (stroke.IsVisible())
{
el.Stroke = new SolidColorBrush(stroke.ToColor());
el.StrokeThickness = thickness;
}
if (fill.IsVisible())
{
el.Fill = new SolidColorBrush(fill.ToColor());
}
el.Width = rect.Width;
el.Height = rect.Height;
Canvas.SetLeft(el, rect.Left);
Canvas.SetTop(el, rect.Top);
this.Add(el, rect.Left, rect.Top);
}
示例13: DrawPolygon
/// <summary>
/// Draws the polygon from the specified points. The polygon can have stroke and/or fill.
/// </summary>
/// <param name="points">The points.</param>
/// <param name="fill">The fill color.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The stroke thickness.</param>
/// <param name="dashArray">The dash array.</param>
/// <param name="lineJoin">The line join type.</param>
/// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param>
public void DrawPolygon(
IList<ScreenPoint> points,
OxyColor fill,
OxyColor stroke,
double thickness,
double[] dashArray,
OxyPenLineJoin lineJoin,
bool aliased)
{
var po = new Polygon();
this.SetStroke(po, stroke, thickness, lineJoin, dashArray, aliased);
if (fill.IsVisible())
{
po.Fill = this.GetCachedBrush(fill);
}
var pc = new PointCollection();
foreach (var p in points)
{
pc.Add(p.ToPoint(aliased));
}
po.Points = pc;
this.Add(po);
}
示例14: 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 ();
}
}
示例15: ToBrush
/// <summary>
/// Converts an OxyColor to a brush.
/// </summary>
/// <param name="fill">The fill color.</param>
/// <returns>The brush.</returns>
private static XBrush ToBrush(OxyColor fill)
{
if (fill.IsVisible())
{
return new XSolidBrush(ToColor(fill));
}
return null;
}