@@ -359,8 +359,11 @@ private void UpdatePositionAndBorder()
359359 return ;
360360 }
361361
362- Canvas . SetLeft ( this , Position . X ) ;
363- Canvas . SetTop ( this , Position . Y ) ;
362+ var pos = this . Position ;
363+ var lineExtents = this . LineExtents ;
364+
365+ Canvas . SetLeft ( this , pos . X ) ;
366+ Canvas . SetTop ( this , pos . Y ) ;
364367 Control parent = this ;
365368 while ( ! ( parent is Canvas ) && parent != null )
366369 {
@@ -388,51 +391,51 @@ private void UpdatePositionAndBorder()
388391 var ha = HorizontalAlignment . Center ;
389392 if ( CanCenterHorizontally )
390393 {
391- if ( Position . X - ( contentWidth / 2 ) < MarginLimit )
394+ if ( pos . X - ( contentWidth / 2 ) < MarginLimit )
392395 {
393396 ha = HorizontalAlignment . Left ;
394397 }
395398
396- if ( Position . X + ( contentWidth / 2 ) > canvasWidth - MarginLimit )
399+ if ( pos . X + ( contentWidth / 2 ) > canvasWidth - MarginLimit )
397400 {
398401 ha = HorizontalAlignment . Right ;
399402 }
400403 }
401404 else
402405 {
403- ha = Position . X < canvasWidth / 2 ? HorizontalAlignment . Left : HorizontalAlignment . Right ;
406+ ha = pos . X < canvasWidth / 2 ? HorizontalAlignment . Left : HorizontalAlignment . Right ;
404407 }
405408
406409 var va = VerticalAlignment . Center ;
407410 if ( CanCenterVertically )
408411 {
409- if ( Position . Y - ( contentHeight / 2 ) < MarginLimit )
412+ if ( pos . Y - ( contentHeight / 2 ) < MarginLimit )
410413 {
411414 va = VerticalAlignment . Top ;
412415 }
413416
414417 if ( ha == HorizontalAlignment . Center )
415418 {
416419 va = VerticalAlignment . Bottom ;
417- if ( Position . Y - contentHeight < MarginLimit )
420+ if ( pos . Y - contentHeight < MarginLimit )
418421 {
419422 va = VerticalAlignment . Top ;
420423 }
421424 }
422425
423- if ( va == VerticalAlignment . Center && Position . Y + ( contentHeight / 2 ) > canvasHeight - MarginLimit )
426+ if ( va == VerticalAlignment . Center && pos . Y + ( contentHeight / 2 ) > canvasHeight - MarginLimit )
424427 {
425428 va = VerticalAlignment . Bottom ;
426429 }
427430
428- if ( va == VerticalAlignment . Top && Position . Y + contentHeight > canvasHeight - MarginLimit )
431+ if ( va == VerticalAlignment . Top && pos . Y + contentHeight > canvasHeight - MarginLimit )
429432 {
430433 va = VerticalAlignment . Bottom ;
431434 }
432435 }
433436 else
434437 {
435- va = Position . Y < canvasHeight / 2 ? VerticalAlignment . Top : VerticalAlignment . Bottom ;
438+ va = pos . Y < canvasHeight / 2 ? VerticalAlignment . Top : VerticalAlignment . Bottom ;
436439 }
437440
438441 var dx = ha == HorizontalAlignment . Center ? - 0.5 : ha == HorizontalAlignment . Left ? 0 : - 1 ;
@@ -454,40 +457,16 @@ private void UpdatePositionAndBorder()
454457 Y = dy * contentSize . Height
455458 } ;
456459
457- var pos = Position ;
458-
459460 if ( horizontalLine != null )
460461 {
461- if ( LineExtents . Width > 0 )
462- {
463- horizontalLine . StartPoint = horizontalLine . StartPoint . WithX ( LineExtents . Left ) ;
464- horizontalLine . EndPoint = horizontalLine . StartPoint . WithX ( LineExtents . Right ) ;
465- }
466- else
467- {
468- horizontalLine . StartPoint = horizontalLine . StartPoint . WithX ( 0 ) ;
469- horizontalLine . EndPoint = horizontalLine . StartPoint . WithX ( canvasWidth ) ;
470- }
471-
472- horizontalLine . StartPoint = horizontalLine . StartPoint . WithY ( pos . Y ) ;
473- horizontalLine . EndPoint = horizontalLine . EndPoint . WithY ( pos . Y ) ;
462+ horizontalLine . StartPoint = new Point ( lineExtents . Left - pos . X , 0 ) ;
463+ horizontalLine . EndPoint = new Point ( lineExtents . Right - pos . X , 0 ) ;
474464 }
475465
476466 if ( verticalLine != null )
477467 {
478- if ( LineExtents . Width > 0 )
479- {
480- horizontalLine . StartPoint = horizontalLine . StartPoint . WithY ( LineExtents . Top ) ;
481- horizontalLine . EndPoint = horizontalLine . StartPoint . WithY ( LineExtents . Bottom ) ;
482- }
483- else
484- {
485- horizontalLine . StartPoint = horizontalLine . StartPoint . WithY ( 0 ) ;
486- horizontalLine . EndPoint = horizontalLine . StartPoint . WithY ( canvasHeight ) ;
487- }
488-
489- horizontalLine . StartPoint = horizontalLine . StartPoint . WithY ( pos . X ) ;
490- horizontalLine . EndPoint = horizontalLine . EndPoint . WithY ( pos . X ) ;
468+ verticalLine . StartPoint = new Point ( 0 , lineExtents . Top - pos . Y ) ;
469+ verticalLine . EndPoint = new Point ( 0 , lineExtents . Bottom - pos . Y ) ;
491470 }
492471 }
493472
0 commit comments