@@ -73,7 +73,7 @@ public abstract class HtmlControlBase : Control
7373 /// <summary>
7474 /// the current html text set in the control
7575 /// </summary>
76- protected string _html ;
76+ protected string _text ;
7777
7878 #endregion
7979
@@ -84,6 +84,7 @@ public abstract class HtmlControlBase : Control
8484 protected HtmlControlBase ( )
8585 {
8686 Background = SystemColors . WindowBrush ;
87+ SnapsToDevicePixels = true ;
8788
8889 _htmlContainer = new HtmlContainer ( ) ;
8990 _htmlContainer . LinkClicked += OnLinkClicked ;
@@ -183,7 +184,7 @@ public virtual string BaseStylesheet
183184 {
184185 _baseRawCssData = value ;
185186 _baseCssData = HtmlRender . ParseStyleSheet ( value ) ;
186- _htmlContainer . SetHtml ( _html , _baseCssData ) ;
187+ _htmlContainer . SetHtml ( _text , _baseCssData ) ;
187188 }
188189 }
189190
@@ -192,14 +193,14 @@ public virtual string BaseStylesheet
192193 /// </summary>
193194 [ Browsable ( true ) ]
194195 [ Description ( "Sets the html of this control." ) ]
195- public virtual string Html
196+ public virtual string Text
196197 {
197- get { return _html ; }
198+ get { return _text ; }
198199 set
199200 {
200- _html = value ;
201+ _text = value ;
201202 _htmlContainer . ScrollOffset = new Point ( 0 , 0 ) ;
202- _htmlContainer . SetHtml ( _html , _baseCssData ) ;
203+ _htmlContainer . SetHtml ( _text , _baseCssData ) ;
203204 InvalidateMeasure ( ) ;
204205 InvalidateVisual ( ) ;
205206 }
@@ -255,11 +256,25 @@ protected override void OnRender(DrawingContext context)
255256 if ( Background != null && Background . Opacity > 0 )
256257 context . DrawRectangle ( Background , null , new Rect ( RenderSize ) ) ;
257258
259+ if ( BorderThickness != new Thickness ( 0 ) )
260+ {
261+ var brush = BorderBrush ?? SystemColors . ControlDarkBrush ;
262+ if ( BorderThickness . Top > 0 )
263+ context . DrawRectangle ( brush , null , new Rect ( 0 , 0 , RenderSize . Width , BorderThickness . Top ) ) ;
264+ if ( BorderThickness . Bottom > 0 )
265+ context . DrawRectangle ( brush , null , new Rect ( 0 , RenderSize . Height - BorderThickness . Bottom , RenderSize . Width , BorderThickness . Bottom ) ) ;
266+ if ( BorderThickness . Left > 0 )
267+ context . DrawRectangle ( brush , null , new Rect ( 0 , 0 , BorderThickness . Left , RenderSize . Height ) ) ;
268+ if ( BorderThickness . Right > 0 )
269+ context . DrawRectangle ( brush , null , new Rect ( RenderSize . Width - BorderThickness . Right , 0 , BorderThickness . Right , RenderSize . Height ) ) ;
270+ }
271+
258272 var htmlWidth = HtmlWidth ( RenderSize ) ;
259273 var htmlHeight = HtmlHeight ( RenderSize ) ;
260274 if ( _htmlContainer != null && htmlWidth > 0 && htmlHeight > 0 )
261275 {
262- context . PushClip ( new RectangleGeometry ( new Rect ( new Size ( htmlWidth , htmlHeight ) ) ) ) ;
276+ context . PushClip ( new RectangleGeometry ( new Rect ( BorderThickness . Left , BorderThickness . Top , htmlWidth , htmlHeight ) ) ) ;
277+ _htmlContainer . Location = new Point ( BorderThickness . Left , BorderThickness . Top ) ;
263278 _htmlContainer . PerformPaint ( context , new Rect ( new Size ( htmlWidth , htmlHeight ) ) ) ;
264279 context . Pop ( ) ;
265280
@@ -395,15 +410,15 @@ protected override void OnVisualParentChanged(DependencyObject oldParent)
395410 /// </summary>
396411 protected virtual double HtmlWidth ( Size size )
397412 {
398- return size . Width ;
413+ return size . Width - BorderThickness . Left - BorderThickness . Right ;
399414 }
400415
401416 /// <summary>
402417 /// Get the width the HTML has to render in (not including vertical scroll iff it is visible)
403418 /// </summary>
404419 protected virtual double HtmlHeight ( Size size )
405420 {
406- return size . Height ;
421+ return size . Height - BorderThickness . Top - BorderThickness . Bottom ;
407422 }
408423
409424
0 commit comments