本文整理汇总了C#中TheArtOfDev.HtmlRenderer.Adapters.Entities.RPoint类的典型用法代码示例。如果您正苦于以下问题:C# RPoint类的具体用法?C# RPoint怎么用?C# RPoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RPoint类属于TheArtOfDev.HtmlRenderer.Adapters.Entities命名空间,在下文中一共展示了RPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArcTo
public override void ArcTo(double x, double y, double size, Corner corner)
{
float left = (float)(Math.Min(x, _lastPoint.X) - (corner == Corner.TopRight || corner == Corner.BottomRight ? size : 0));
float top = (float)(Math.Min(y, _lastPoint.Y) - (corner == Corner.BottomLeft || corner == Corner.BottomRight ? size : 0));
_graphicsPath.AddArc(left, top, (float)size * 2, (float)size * 2, GetStartAngle(corner), 90);
_lastPoint = new RPoint(x, y);
}
示例2: Convert
/// <summary>
/// Convert from WPF point to core point.
/// </summary>
public static Point[] Convert(RPoint[] points)
{
Point[] myPoints = new Point[points.Length];
for (int i = 0; i < points.Length; i++)
myPoints[i] = Convert(points[i]);
return myPoints;
}
示例3: RRect
/// <summary>
/// Initializes a new instance of the <see cref="RRect" /> class with the specified location and size.
/// </summary>
/// <param name="location">A <see cref="RPoint" /> that represents the upper-left corner of the rectangular region.</param>
/// <param name="size">A <see cref="RSize" /> that represents the width and height of the rectangular region.</param>
public RRect(RPoint location, RSize size)
{
_x = location.X;
_y = location.Y;
_width = size.Width;
_height = size.Height;
}
示例4: IsInBox
/// <summary>
/// Check if the given location is inside the given box deep.<br/>
/// Check inner boxes and all lines that the given box spans to.
/// </summary>
/// <param name="box">the box to check</param>
/// <param name="location">the location to check</param>
/// <returns>true - location inside the box, false - otherwise</returns>
public static bool IsInBox(CssBox box, RPoint location)
{
foreach (var line in box.Rectangles)
{
if (line.Value.Contains(location))
return true;
}
foreach (var childBox in box.Boxes)
{
if (IsInBox(childBox, location))
return true;
}
return false;
}
示例5: PerformLayoutImp
/// <summary>
/// Measures the bounds of box and children, recursively.<br/>
/// Performs layout of the DOM structure creating lines by set bounds restrictions.
/// </summary>
/// <param name="g">Device context to use</param>
protected override void PerformLayoutImp(RGraphics g)
{
if (Display == CssConstants.None)
return;
RectanglesReset();
var prevSibling = DomUtils.GetPreviousSibling(this);
double left = ContainingBlock.Location.X + ContainingBlock.ActualPaddingLeft + ActualMarginLeft + ContainingBlock.ActualBorderLeftWidth;
double top = (prevSibling == null && ParentBox != null ? ParentBox.ClientTop : ParentBox == null ? Location.Y : 0) + MarginTopCollapse(prevSibling) + (prevSibling != null ? prevSibling.ActualBottom + prevSibling.ActualBorderBottomWidth : 0);
Location = new RPoint(left, top);
ActualBottom = top;
//width at 100% (or auto)
double minwidth = GetMinimumWidth();
double width = ContainingBlock.Size.Width
- ContainingBlock.ActualPaddingLeft - ContainingBlock.ActualPaddingRight
- ContainingBlock.ActualBorderLeftWidth - ContainingBlock.ActualBorderRightWidth
- ActualMarginLeft - ActualMarginRight - ActualBorderLeftWidth - ActualBorderRightWidth;
//Check width if not auto
if (Width != CssConstants.Auto && !string.IsNullOrEmpty(Width))
{
width = CssValueParser.ParseLength(Width, width, this);
}
if (width < minwidth || width >= 9999)
width = minwidth;
double height = ActualHeight;
if (height < 1)
{
height = Size.Height + ActualBorderTopWidth + ActualBorderBottomWidth;
}
if (height < 1)
{
height = 2;
}
if (height <= 2 && ActualBorderTopWidth < 1 && ActualBorderBottomWidth < 1)
{
BorderTopStyle = BorderBottomStyle = CssConstants.Solid;
BorderTopWidth = "1px";
BorderBottomWidth = "1px";
}
Size = new RSize(width, height);
ActualBottom = Location.Y + ActualPaddingTop + ActualPaddingBottom + height;
}
示例6: PaintWords
/// <summary>
/// Paint all the words in the box.
/// </summary>
/// <param name="g">the device to draw into</param>
/// <param name="offset">the current scroll offset to offset the words</param>
private void PaintWords(RGraphics g, RPoint offset)
{
if (Width.Length > 0)
{
var isRtl = Direction == CssConstants.Rtl;
foreach (var word in Words)
{
if (!word.IsLineBreak)
{
var wordPoint = new RPoint(word.Left + offset.X, word.Top + offset.Y);
if (word.Selected)
{
// handle paint selected word background and with partial word selection
var wordLine = DomUtils.GetCssLineBoxByWord(word);
var left = word.SelectedStartOffset > -1 ? word.SelectedStartOffset : (wordLine.Words[0] != word && word.HasSpaceBefore ? -ActualWordSpacing : 0);
var padWordRight = word.HasSpaceAfter && !wordLine.IsLastSelectedWord(word);
var width = word.SelectedEndOffset > -1 ? word.SelectedEndOffset : word.Width + (padWordRight ? ActualWordSpacing : 0);
var rect = new RRect(word.Left + offset.X + left, word.Top + offset.Y, width - left, wordLine.LineHeight);
g.DrawRectangle(GetSelectionBackBrush(g, false), rect.X, rect.Y, rect.Width, rect.Height);
if (HtmlContainer.SelectionForeColor != RColor.Empty && (word.SelectedStartOffset > 0 || word.SelectedEndIndexOffset > -1))
{
g.PushClipExclude(rect);
g.DrawString(word.Text, ActualFont, ActualColor, wordPoint, new RSize(word.Width, word.Height), isRtl);
g.PopClip();
g.PushClip(rect);
g.DrawString(word.Text, ActualFont, GetSelectionForeBrush(), wordPoint, new RSize(word.Width, word.Height), isRtl);
g.PopClip();
}
else
{
g.DrawString(word.Text, ActualFont, GetSelectionForeBrush(), wordPoint, new RSize(word.Width, word.Height), isRtl);
}
}
else
{
// g.DrawRectangle(HtmlContainer.Adapter.GetPen(RColor.Black), wordPoint.X, wordPoint.Y, word.Width - 1, word.Height - 1);
g.DrawString(word.Text, ActualFont, ActualColor, wordPoint, new RSize(word.Width, word.Height), isRtl);
}
}
}
}
}
示例7: DrawPolygon
public override void DrawPolygon(RBrush brush, RPoint[] points)
{
if (points != null && points.Length > 0)
{
var g = new StreamGeometry();
using (var context = g.Open())
{
context.BeginFigure(Util.Convert(points[0]), true);
for (int i = 1; i < points.Length; i++)
context.LineTo(Util.Convert(points[i]));
context.EndFigure(false);
}
_g.DrawGeometry(((BrushAdapter)brush).Brush, null, g);
}
}
示例8: DrawString
public override void DrawString(string str, RFont font, RColor color, RPoint point, RSize size, bool rtl)
{
var text = GetText(str, font);
text.Constraint = Util.Convert(size);
_g.DrawText(new SolidColorBrush(Util.Convert(color)), Util.Convert(point), text);
}
示例9: CheckNonEmptySelection
/// <summary>
/// Check if the current selection is non empty, has some selection data.
/// </summary>
/// <param name="loc"></param>
/// <param name="allowPartialSelect">true - partial word selection allowed, false - only full words selection</param>
/// <returns>true - is non empty selection, false - empty selection</returns>
private bool CheckNonEmptySelection(RPoint loc, bool allowPartialSelect)
{
// full word selection is never empty
if (!allowPartialSelect)
return true;
// if end selection location is near starting location then the selection is empty
if (Math.Abs(_selectionStartPoint.X - loc.X) <= 1 && Math.Abs(_selectionStartPoint.Y - loc.Y) < 5)
return false;
// selection is empty if on same word and same index
return _selectionStart != _selectionEnd || _selectionStartIndex != _selectionEndIndex;
}
示例10: CalculateWordCharIndexAndOffset
/// <summary>
/// Calculate the character index and offset by characters for the given word and given offset.<br/>
/// If the location is below the word line then set the selection to the end.<br/>
/// If the location is to the right of the word then set the selection to the end.<br/>
/// If the offset is to the left of the word set the selection to the beginning.<br/>
/// Otherwise calculate the width of each substring to find the char the location is on.
/// </summary>
/// <param name="control">used to create graphics to measure string</param>
/// <param name="word">the word to calculate its index and offset</param>
/// <param name="loc">the location to calculate for</param>
/// <param name="inclusive">is to include the first character in the calculation</param>
/// <param name="selectionIndex">return the index of the char under the location</param>
/// <param name="selectionOffset">return the offset of the char under the location</param>
private static void CalculateWordCharIndexAndOffset(RControl control, CssRect word, RPoint loc, bool inclusive, out int selectionIndex, out double selectionOffset)
{
selectionIndex = 0;
selectionOffset = 0f;
var offset = loc.X - word.Left;
if (word.Text == null)
{
// not a text word - set full selection
selectionIndex = -1;
selectionOffset = -1;
}
else if (offset > word.Width - word.OwnerBox.ActualWordSpacing || loc.Y > DomUtils.GetCssLineBoxByWord(word).LineBottom)
{
// mouse under the line, to the right of the word - set to the end of the word
selectionIndex = word.Text.Length;
selectionOffset = word.Width;
}
else if (offset > 0)
{
// calculate partial word selection
int charFit;
double charFitWidth;
var maxWidth = offset + (inclusive ? 0 : 1.5f * word.LeftGlyphPadding);
control.MeasureString(word.Text, word.OwnerBox.ActualFont, maxWidth, out charFit, out charFitWidth);
selectionIndex = charFit;
selectionOffset = charFitWidth;
}
}
示例11: HandleMouseMove
/// <summary>
/// Handle mouse move to handle hover cursor and text selection.
/// </summary>
/// <param name="parent">the control hosting the html to set cursor and invalidate</param>
/// <param name="loc">the location of the mouse on the html</param>
public void HandleMouseMove(RControl parent, RPoint loc)
{
if (_root.HtmlContainer.IsSelectionEnabled && _mouseDownInControl && parent.LeftMouseButton)
{
if (_mouseDownOnSelectedWord)
{
// make sure not to start drag-drop on click but when it actually moves as it fucks mouse-up
if ((DateTime.Now - _lastMouseDown).TotalMilliseconds > 200)
StartDragDrop(parent);
}
else
{
HandleSelection(parent, loc, !_isDoubleClickSelect);
_inSelection = _selectionStart != null && _selectionEnd != null && (_selectionStart != _selectionEnd || _selectionStartIndex != _selectionEndIndex);
}
}
else
{
// Handle mouse hover over the html to change the cursor depending if hovering word, link of other.
var link = DomUtils.GetLinkBox(_root, loc);
if (link != null)
{
_cursorChanged = true;
parent.SetCursorHand();
if (link != _lastLink)
{
_root.HtmlContainer.HandleLinkHover(parent, loc, link);
_lastLink = link;
}
}
else if (_root.HtmlContainer.IsSelectionEnabled)
{
var word = DomUtils.GetCssBoxWord(_root, loc);
_cursorChanged = word != null && !word.IsImage && !(word.Selected && (word.SelectedStartIndex < 0 || word.Left + word.SelectedStartOffset <= loc.X) && (word.SelectedEndOffset < 0 || word.Left + word.SelectedEndOffset >= loc.X));
if (_cursorChanged)
parent.SetCursorIBeam();
else
parent.SetCursorDefault();
_lastLink = null;
}
else if (_cursorChanged)
{
parent.SetCursorDefault();
_lastLink = null;
}
}
}
示例12: OffsetByScroll
/// <summary>
/// Adjust the offset of the given location by the current scroll offset.
/// </summary>
/// <param name="location">the location to adjust</param>
/// <returns>the adjusted location</returns>
private RPoint OffsetByScroll(RPoint location)
{
return new RPoint(location.X - ScrollOffset.X, location.Y - ScrollOffset.Y);
}
示例13: DrawImage
/// <summary>
/// Draw video image over the iframe if found.
/// </summary>
private void DrawImage(RGraphics g, RPoint offset, RRect rect)
{
if (_imageWord.Image != null)
{
if (rect.Width > 0 && rect.Height > 0)
{
if (_imageWord.ImageRectangle == RRect.Empty)
g.DrawImage(_imageWord.Image, rect);
else
g.DrawImage(_imageWord.Image, rect, _imageWord.ImageRectangle);
if (_imageWord.Selected)
{
g.DrawRectangle(GetSelectionBackBrush(g, true), _imageWord.Left + offset.X, _imageWord.Top + offset.Y, _imageWord.Width + 2, DomUtils.GetCssLineBoxByWord(_imageWord).LineHeight);
}
}
}
else if (_isVideo && !_imageLoadingComplete)
{
RenderUtils.DrawImageLoadingIcon(g, HtmlContainer, rect);
if (rect.Width > 19 && rect.Height > 19)
{
g.DrawRectangle(g.GetPen(RColor.LightGray), rect.X, rect.Y, rect.Width, rect.Height);
}
}
}
示例14: DrawPolygon
/// <summary>
/// Fills the interior of a polygon defined by an array of points specified by Point structures.
/// </summary>
/// <param name="brush">Brush that determines the characteristics of the fill. </param>
/// <param name="points">Array of Point structures that represent the vertices of the polygon to fill. </param>
public abstract void DrawPolygon(RBrush brush, RPoint[] points);
示例15: DrawString
/// <summary>
/// Draw the given string using the given font and foreground color at given location.
/// </summary>
/// <param name="str">the string to draw</param>
/// <param name="font">the font to use to draw the string</param>
/// <param name="color">the text color to set</param>
/// <param name="point">the location to start string draw (top-left)</param>
/// <param name="size">used to know the size of the rendered text for transparent text support</param>
/// <param name="rtl">is to render the string right-to-left (true - RTL, false - LTR)</param>
public abstract void DrawString(String str, RFont font, RColor color, RPoint point, RSize size, bool rtl);