Skip to content

Commit e467d63

Browse files
author
ArthurHub
committed
wpf fix control not round location by transforming rendering location
1 parent ca2eb77 commit e467d63

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Source/HtmlRenderer.WPF/HtmlControl.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,18 @@ protected override void OnRender(DrawingContext context)
278278
var htmlHeight = HtmlHeight(RenderSize);
279279
if (_htmlContainer != null && htmlWidth > 0 && htmlHeight > 0)
280280
{
281-
context.PushClip(new RectangleGeometry(new Rect(Padding.Left + BorderThickness.Left, Padding.Top + BorderThickness.Top, htmlWidth, htmlHeight)));
281+
var windows = Window.GetWindow(this);
282+
if (windows != null)
283+
{
284+
// adjust render location to round point so we won't get anti-alias smugness
285+
var wPoint = TranslatePoint(new Point(0, 0), windows);
286+
wPoint.Offset(-(int)wPoint.X, -(int)wPoint.Y);
287+
var xTrans = wPoint.X < .5 ? -wPoint.X : 1 - wPoint.X;
288+
var yTrans = wPoint.Y < .5 ? -wPoint.Y : 1 - wPoint.Y;
289+
context.PushTransform(new TranslateTransform(xTrans, yTrans));
290+
}
291+
292+
context.PushClip(new RectangleGeometry(new Rect(Padding.Left + BorderThickness.Left, Padding.Top + BorderThickness.Top, htmlWidth, (int)htmlHeight)));
282293
_htmlContainer.Location = new Point(Padding.Left + BorderThickness.Left, Padding.Top + BorderThickness.Top);
283294
_htmlContainer.PerformPaint(context, new Rect(Padding.Left + BorderThickness.Left, Padding.Top + BorderThickness.Top, htmlWidth, htmlHeight));
284295
context.Pop();

0 commit comments

Comments
 (0)