本文整理汇总了C#中TheArtOfDev.HtmlRenderer.Adapters.Entities.RRect类的典型用法代码示例。如果您正苦于以下问题:C# RRect类的具体用法?C# RRect怎么用?C# RRect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RRect类属于TheArtOfDev.HtmlRenderer.Adapters.Entities命名空间,在下文中一共展示了RRect类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RGraphics
/// <summary>
/// Init.
/// </summary>
protected RGraphics(RAdapter adapter, RRect initialClip)
{
ArgChecker.AssertArgNotNull(adapter, "global");
_adapter = adapter;
_clipStack.Push(initialClip);
}
开发者ID:CapitalCoder,项目名称:HTML-Renderer,代码行数:10,代码来源:RGraphics.cs
示例2: GetLocation
/// <summary>
/// Get top-left location to start drawing the image at depending on background-position value.
/// </summary>
/// <param name="backgroundPosition">the background-position value</param>
/// <param name="rectangle">the rectangle to position image in</param>
/// <param name="imgSize">the size of the image</param>
/// <returns>the top-left location</returns>
private static RPoint GetLocation(string backgroundPosition, RRect rectangle, RSize imgSize)
{
double left = rectangle.Left;
if (backgroundPosition.IndexOf("left", StringComparison.OrdinalIgnoreCase) > -1)
{
left = (rectangle.Left + .5f);
}
else if (backgroundPosition.IndexOf("right", StringComparison.OrdinalIgnoreCase) > -1)
{
left = rectangle.Right - imgSize.Width;
}
else if (backgroundPosition.IndexOf("0", StringComparison.OrdinalIgnoreCase) < 0)
{
left = (rectangle.Left + (rectangle.Width - imgSize.Width) / 2 + .5f);
}
double top = rectangle.Top;
if (backgroundPosition.IndexOf("top", StringComparison.OrdinalIgnoreCase) > -1)
{
top = rectangle.Top;
}
else if (backgroundPosition.IndexOf("bottom", StringComparison.OrdinalIgnoreCase) > -1)
{
top = rectangle.Bottom - imgSize.Height;
}
else if (backgroundPosition.IndexOf("0", StringComparison.OrdinalIgnoreCase) < 0)
{
top = (rectangle.Top + (rectangle.Height - imgSize.Height) / 2 + .5f);
}
return new RPoint(left, top);
}
开发者ID:CapitalCoder,项目名称:HTML-Renderer,代码行数:39,代码来源:BackgroundImageDrawHandler.cs
示例3: GraphicsAdapter
/// <summary>
/// Init.
/// </summary>
/// <param name="g">the Perspex graphics object to use</param>
/// <param name="initialClip">the initial clip of the graphics</param>
/// <param name="releaseGraphics">optional: if to release the graphics object on dispose (default - false)</param>
public GraphicsAdapter(IDrawingContext g, RRect initialClip, bool releaseGraphics = false)
: base(PerspexAdapter.Instance, initialClip)
{
ArgChecker.AssertArgNotNull(g, "g");
_g = g;
_releaseGraphics = releaseGraphics;
}
开发者ID:tshcherban,项目名称:Perspex,代码行数:14,代码来源:GraphicsAdapter.cs
示例4: CreateLinearGradientBrush
protected override RBrush CreateLinearGradientBrush(RRect rect, RColor color1, RColor color2, double angle)
{
var startColor = angle <= 180 ? Utils.Convert(color1) : Utils.Convert(color2);
var endColor = angle <= 180 ? Utils.Convert(color2) : Utils.Convert(color1);
angle = angle <= 180 ? angle : angle - 180;
double x = angle < 135 ? Math.Max((angle - 45) / 90, 0) : 1;
double y = angle <= 45 ? Math.Max(0.5 - angle / 90, 0) : angle > 135 ? Math.Abs(1.5 - angle / 90) : 0;
return new BrushAdapter(new LinearGradientBrush(startColor, endColor, new Point(x, y), new Point(1 - x, 1 - y)));
}
开发者ID:Aerizeon,项目名称:HTML-Renderer,代码行数:9,代码来源:WpfAdapter.cs
示例5: PushClipExclude
public override void PushClipExclude(RRect rect)
{
var geometry = new CombinedGeometry();
geometry.Geometry1 = new RectangleGeometry(Utils.Convert(_clipStack.Peek()));
geometry.Geometry2 = new RectangleGeometry(Utils.Convert(rect));
geometry.GeometryCombineMode = GeometryCombineMode.Exclude;
_clipStack.Push(_clipStack.Peek());
_g.PushClip(geometry);
}
开发者ID:CapitalCoder,项目名称:HTML-Renderer,代码行数:10,代码来源:GraphicsAdapter.cs
示例6: CreateLinearGradientBrush
protected override RBrush CreateLinearGradientBrush(RRect rect, RColor color1, RColor color2, double angle)
{
XLinearGradientMode mode;
if (angle < 45)
mode = XLinearGradientMode.ForwardDiagonal;
else if (angle < 90)
mode = XLinearGradientMode.Vertical;
else if (angle < 135)
mode = XLinearGradientMode.BackwardDiagonal;
else
mode = XLinearGradientMode.Horizontal;
return new BrushAdapter(new XLinearGradientBrush(Utils.Convert(rect), Utils.Convert(color1), Utils.Convert(color2), mode));
}
开发者ID:ajinkyakulkarni,项目名称:HTML-Renderer,代码行数:13,代码来源:PdfSharpAdapter.cs
示例7: CreateLinearGradientBrush
protected override RBrush CreateLinearGradientBrush(RRect rect, RColor color1, RColor color2, double angle)
{
var startColor = angle <= 180 ? Util.Convert(color1) : Util.Convert(color2);
var endColor = angle <= 180 ? Util.Convert(color2) : Util.Convert(color1);
angle = angle <= 180 ? angle : angle - 180;
double x = angle < 135 ? Math.Max((angle - 45) / 90, 0) : 1;
double y = angle <= 45 ? Math.Max(0.5 - angle / 90, 0) : angle > 135 ? Math.Abs(1.5 - angle / 90) : 0;
return new BrushAdapter(new LinearGradientBrush
{
StartPoint = new RelativePoint(x, y, RelativeUnit.Relative),
EndPoint = new RelativePoint(1 - x, 1 - y, RelativeUnit.Relative),
GradientStops =
{
new GradientStop(startColor, 0),
new GradientStop(endColor, 1)
}
});
}
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:19,代码来源:AvaloniaAdapter.cs
示例8: DrawBackgroundImage
/// <summary>
/// Draw the background image of the given box in the given rectangle.<br/>
/// Handle background-repeat and background-position values.
/// </summary>
/// <param name="g">the device to draw into</param>
/// <param name="box">the box to draw its background image</param>
/// <param name="imageLoadHandler">the handler that loads image to draw</param>
/// <param name="rectangle">the rectangle to draw image in</param>
public static void DrawBackgroundImage(RGraphics g, CssBox box, ImageLoadHandler imageLoadHandler, RRect rectangle)
{
// image size depends if specific rectangle given in image loader
var imgSize = new RSize(imageLoadHandler.Rectangle == RRect.Empty ? imageLoadHandler.Image.Width : imageLoadHandler.Rectangle.Width,
imageLoadHandler.Rectangle == RRect.Empty ? imageLoadHandler.Image.Height : imageLoadHandler.Rectangle.Height);
// get the location by BackgroundPosition value
var location = GetLocation(box.BackgroundPosition, rectangle, imgSize);
var srcRect = imageLoadHandler.Rectangle == RRect.Empty
? new RRect(0, 0, imgSize.Width, imgSize.Height)
: new RRect(imageLoadHandler.Rectangle.Left, imageLoadHandler.Rectangle.Top, imgSize.Width, imgSize.Height);
// initial image destination rectangle
var destRect = new RRect(location, imgSize);
// need to clip so repeated image will be cut on rectangle
var lRectangle = rectangle;
lRectangle.Intersect(g.GetClip());
g.PushClip(lRectangle);
switch (box.BackgroundRepeat)
{
case "no-repeat":
g.DrawImage(imageLoadHandler.Image, destRect, srcRect);
break;
case "repeat-x":
DrawRepeatX(g, imageLoadHandler, rectangle, srcRect, destRect, imgSize);
break;
case "repeat-y":
DrawRepeatY(g, imageLoadHandler, rectangle, srcRect, destRect, imgSize);
break;
default:
DrawRepeat(g, imageLoadHandler, rectangle, srcRect, destRect, imgSize);
break;
}
g.PopClip();
}
开发者ID:CapitalCoder,项目名称:HTML-Renderer,代码行数:47,代码来源:BackgroundImageDrawHandler.cs
示例9: DrawBoxBorders
/// <summary>
/// Draws all the border of the box with respect to style, width, etc.
/// </summary>
/// <param name="g">the device to draw into</param>
/// <param name="box">the box to draw borders for</param>
/// <param name="rect">the bounding rectangle to draw in</param>
/// <param name="isFirst">is it the first rectangle of the element</param>
/// <param name="isLast">is it the last rectangle of the element</param>
public static void DrawBoxBorders(RGraphics g, CssBox box, RRect rect, bool isFirst, bool isLast)
{
if (rect.Width > 0 && rect.Height > 0)
{
if (!(string.IsNullOrEmpty(box.BorderTopStyle) || box.BorderTopStyle == CssConstants.None || box.BorderTopStyle == CssConstants.Hidden) && box.ActualBorderTopWidth > 0)
{
DrawBorder(Border.Top, box, g, rect, isFirst, isLast);
}
if (isFirst && !(string.IsNullOrEmpty(box.BorderLeftStyle) || box.BorderLeftStyle == CssConstants.None || box.BorderLeftStyle == CssConstants.Hidden) && box.ActualBorderLeftWidth > 0)
{
DrawBorder(Border.Left, box, g, rect, true, isLast);
}
if (!(string.IsNullOrEmpty(box.BorderBottomStyle) || box.BorderBottomStyle == CssConstants.None || box.BorderBottomStyle == CssConstants.Hidden) && box.ActualBorderBottomWidth > 0)
{
DrawBorder(Border.Bottom, box, g, rect, isFirst, isLast);
}
if (isLast && !(string.IsNullOrEmpty(box.BorderRightStyle) || box.BorderRightStyle == CssConstants.None || box.BorderRightStyle == CssConstants.Hidden) && box.ActualBorderRightWidth > 0)
{
DrawBorder(Border.Right, box, g, rect, isFirst, true);
}
}
}
开发者ID:rohatsu,项目名称:HTML-Renderer,代码行数:30,代码来源:BordersDrawHandler.cs
示例10: OnLoadImageComplete
/// <summary>
/// On image load process is complete with image or without update the image box.
/// </summary>
/// <param name="image">the image loaded or null if failed</param>
/// <param name="rectangle">the source rectangle to draw in the image (empty - draw everything)</param>
/// <param name="async">is the callback was called async to load image call</param>
private void OnLoadImageComplete(RImage image, RRect rectangle, bool async)
{
_imageWord.Image = image;
_imageWord.ImageRectangle = rectangle;
_imageLoadingComplete = true;
_wordsSizeMeasured = false;
if (_imageLoadingComplete && image == null)
{
SetErrorBorder();
}
if (!HtmlContainer.AvoidImagesLateLoading || async)
{
var width = new CssLength(Width);
var height = new CssLength(Height);
var layout = (width.Number <= 0 || width.Unit != CssUnit.Pixels) || (height.Number <= 0 || height.Unit != CssUnit.Pixels);
HtmlContainer.RequestRefresh(layout);
}
}
开发者ID:CapitalCoder,项目名称:HTML-Renderer,代码行数:26,代码来源:CssBoxImage.cs
示例11: DrawImage
public override void DrawImage(RImage image, RRect destRect)
{
_g.DrawImage(((ImageAdapter) image).Image, 1, new Rect(0, 0, image.Width, image.Height),
Util.Convert(destRect));
}
开发者ID:tshcherban,项目名称:Perspex,代码行数:5,代码来源:GraphicsAdapter.cs
示例12: GetTextureBrush
public override RBrush GetTextureBrush(RImage image, RRect dstRect, RPoint translateTransformLocation)
{
//TODO: Implement texture brush
return PerspexAdapter.Instance.GetSolidBrush(Util.Convert(Colors.Magenta));
//var brush = new ImageBrush(((ImageAdapter)image).Image);
//brush.Stretch = Stretch.None;
//brush.TileMode = TileMode.Tile;
//brush.Viewport = Utils.Convert(dstRect);
//brush.ViewportUnits = BrushMappingMode.Absolute;
//brush.Transform = new TranslateTransform(translateTransformLocation.X, translateTransformLocation.Y);
//brush.Freeze();
//return new BrushAdapter(brush);
}
开发者ID:tshcherban,项目名称:Perspex,代码行数:14,代码来源:GraphicsAdapter.cs
示例13: DrawImageErrorIcon
/// <summary>
/// Draw image failed to load icon.
/// </summary>
/// <param name="g">the device to draw into</param>
/// <param name="htmlContainer"></param>
/// <param name="r">the rectangle to draw icon in</param>
public static void DrawImageErrorIcon(RGraphics g, HtmlContainerInt htmlContainer, RRect r)
{
g.DrawRectangle(g.GetPen(RColor.LightGray), r.Left + 2, r.Top + 2, 15, 15);
var image = htmlContainer.Adapter.GetLoadingFailedImage();
g.DrawImage(image, new RRect(r.Left + 3, r.Top + 3, image.Width, image.Height));
}
开发者ID:CapitalCoder,项目名称:HTML-Renderer,代码行数:12,代码来源:RenderUtils.cs
示例14: GetRoundRect
/// <summary>
/// Creates a rounded rectangle using the specified corner radius<br/>
/// NW-----NE
/// | |
/// | |
/// SW-----SE
/// </summary>
/// <param name="g">the device to draw into</param>
/// <param name="rect">Rectangle to round</param>
/// <param name="nwRadius">Radius of the north east corner</param>
/// <param name="neRadius">Radius of the north west corner</param>
/// <param name="seRadius">Radius of the south east corner</param>
/// <param name="swRadius">Radius of the south west corner</param>
/// <returns>GraphicsPath with the lines of the rounded rectangle ready to be painted</returns>
public static RGraphicsPath GetRoundRect(RGraphics g, RRect rect, double nwRadius, double neRadius, double seRadius, double swRadius)
{
var path = g.GetGraphicsPath();
path.Start(rect.Left + nwRadius, rect.Top);
path.LineTo(rect.Right - neRadius, rect.Y);
if (neRadius > 0f)
path.ArcTo(rect.Right, rect.Top + neRadius, neRadius, RGraphicsPath.Corner.TopRight);
path.LineTo(rect.Right, rect.Bottom - seRadius);
if (seRadius > 0f)
path.ArcTo(rect.Right - seRadius, rect.Bottom, seRadius, RGraphicsPath.Corner.BottomRight);
path.LineTo(rect.Left + swRadius, rect.Bottom);
if (swRadius > 0f)
path.ArcTo(rect.Left, rect.Bottom - swRadius, swRadius, RGraphicsPath.Corner.BottomLeft);
path.LineTo(rect.Left, rect.Top + nwRadius);
if (nwRadius > 0f)
path.ArcTo(rect.Left + nwRadius, rect.Top, nwRadius, RGraphicsPath.Corner.TopLeft);
return path;
}
开发者ID:CapitalCoder,项目名称:HTML-Renderer,代码行数:42,代码来源:RenderUtils.cs
示例15: PaintBackground
/// <summary>
/// Paints the background of the box
/// </summary>
/// <param name="g">the device to draw into</param>
/// <param name="rect">the bounding rectangle to draw in</param>
/// <param name="isFirst">is it the first rectangle of the element</param>
/// <param name="isLast">is it the last rectangle of the element</param>
protected void PaintBackground(RGraphics g, RRect rect, bool isFirst, bool isLast)
{
if (rect.Width > 0 && rect.Height > 0)
{
RBrush brush = null;
if (BackgroundGradient != CssConstants.None)
{
brush = g.GetLinearGradientBrush(rect, ActualBackgroundColor, ActualBackgroundGradient, ActualBackgroundGradientAngle);
}
else if (RenderUtils.IsColorVisible(ActualBackgroundColor))
{
brush = g.GetSolidBrush(ActualBackgroundColor);
}
if (brush != null)
{
// TODO:a handle it correctly (tables background)
// if (isLast)
// rectangle.Width -= ActualWordSpacing + CssUtils.GetWordEndWhitespace(ActualFont);
RGraphicsPath roundrect = null;
if (IsRounded)
{
roundrect = RenderUtils.GetRoundRect(g, rect, ActualCornerNw, ActualCornerNe, ActualCornerSe, ActualCornerSw);
}
Object prevMode = null;
if (HtmlContainer != null && !HtmlContainer.AvoidGeometryAntialias && IsRounded)
{
prevMode = g.SetAntiAliasSmoothingMode();
}
if (roundrect != null)
{
g.DrawPath(brush, roundrect);
}
else
{
g.DrawRectangle(brush, Math.Ceiling(rect.X), Math.Ceiling(rect.Y), rect.Width, rect.Height);
}
g.ReturnPreviousSmoothingMode(prevMode);
if (roundrect != null)
roundrect.Dispose();
brush.Dispose();
}
if (_imageLoadHandler != null && _imageLoadHandler.Image != null && isFirst)
{
BackgroundImageDrawHandler.DrawBackgroundImage(g, this, _imageLoadHandler, rect);
}
}
}
开发者ID:verdesgrobert,项目名称:HTML-Renderer,代码行数:62,代码来源:CssBox.cs
示例16: OffsetRectangle
/// <summary>
/// Offsets the rectangle of the specified linebox by the specified gap,
/// and goes deep for rectangles of children in that linebox.
/// </summary>
/// <param name="lineBox"></param>
/// <param name="gap"></param>
internal void OffsetRectangle(CssLineBox lineBox, double gap)
{
if (Rectangles.ContainsKey(lineBox))
{
var r = Rectangles[lineBox];
Rectangles[lineBox] = new RRect(r.X, r.Y + gap, r.Width, r.Height);
}
}
开发者ID:verdesgrobert,项目名称:HTML-Renderer,代码行数:14,代码来源:CssBox.cs
示例17: OnImageLoadComplete
/// <summary>
/// On image load process complete with image request refresh for it to be painted.
/// </summary>
/// <param name="image">the image loaded or null if failed</param>
/// <param name="rectangle">the source rectangle to draw in the image (empty - draw everything)</param>
/// <param name="async">is the callback was called async to load image call</param>
private void OnImageLoadComplete(RImage image, RRect rectangle, bool async)
{
if (image != null && async)
HtmlContainer.RequestRefresh(false);
}
开发者ID:verdesgrobert,项目名称:HTML-Renderer,代码行数:11,代码来源:CssBox.cs
示例18: PushClip
public override void PushClip(RRect rect)
{
_clipStack.Push(_g.PushClip(Util.Convert(rect)));
//_clipStack.Push(rect);
//_g.PushClip(new RectangleGeometry(Utils.Convert(rect)));
}
开发者ID:tshcherban,项目名称:Perspex,代码行数:6,代码来源:GraphicsAdapter.cs
示例19: GetLinearGradientBrush
/// <summary>
/// Get linear gradient color brush from <paramref name="color1"/> to <paramref name="color2"/>.
/// </summary>
/// <param name="rect">the rectangle to get the brush for</param>
/// <param name="color1">the start color of the gradient</param>
/// <param name="color2">the end color of the gradient</param>
/// <param name="angle">the angle to move the gradient from start color to end color in the rectangle</param>
/// <returns>linear gradient color brush instance</returns>
public RBrush GetLinearGradientBrush(RRect rect, RColor color1, RColor color2, double angle)
{
return _adapter.GetLinearGradientBrush(rect, color1, color2, angle);
}
开发者ID:CapitalCoder,项目名称:HTML-Renderer,代码行数:12,代码来源:RGraphics.cs
示例20: DrawImage
/// <summary>
/// Draws the specified Image at the specified location and with the specified size.
/// </summary>
/// <param name="image">Image to draw. </param>
/// <param name="destRect">Rectangle structure that specifies the location and size of the drawn image. </param>
public abstract void DrawImage(RImage image, RRect destRect);
开发者ID:CapitalCoder,项目名称:HTML-Renderer,代码行数:6,代码来源:RGraphics.cs
注:本文中的TheArtOfDev.HtmlRenderer.Adapters.Entities.RRect类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论