@@ -8,7 +8,7 @@ namespace HierarchyGrid.Skia
88{
99 internal static class CanvasExtensions
1010 {
11- private static Dictionary < string , Option < SKSvg > > _svgCache = new ( ) ;
11+ private static readonly Dictionary < string , Option < SKSvg > > _svgCache = [ ] ;
1212
1313 private static Option < SKSvg > GetSvg ( string path )
1414 {
@@ -292,10 +292,7 @@ double screenScale
292292 {
293293 double height = ComputeHeaderHeight ( viewModel , hdef ) ;
294294
295- var top = Enumerable
296- . Range ( 0 , hdef . Level )
297- . Select ( x => viewModel . ColumnsHeadersHeight [ x ] )
298- . Sum ( ) ;
295+ var top = Enumerable . Range ( 0 , hdef . Level ) . Sum ( x => viewModel . ColumnsHeadersHeight [ x ] ) ;
299296
300297 canvas . DrawHeader (
301298 viewModel ,
@@ -336,8 +333,7 @@ HierarchyDefinition hdef
336333 ? viewModel . ColumnsHeadersHeight [ hdef . Level ]
337334 : Enumerable
338335 . Range ( hdef . Level , viewModel . ColumnsHeadersHeight . Length - hdef . Level )
339- . Select ( x => viewModel . ColumnsHeadersHeight [ x ] )
340- . Sum ( ) ;
336+ . Sum ( x => viewModel . ColumnsHeadersHeight [ x ] ) ;
341337 return height ;
342338 }
343339
@@ -363,13 +359,9 @@ double screenScale
363359
364360 var width = Enumerable
365361 . Range ( column , hdef . Count ( ) - origin . RelativePositionFrom ( hdef ) )
366- . Select ( x => viewModel . ColumnsWidths . GetValueOrDefault ( x , 0 ) )
367- . Sum ( ) ;
362+ . Sum ( x => viewModel . ColumnsWidths . GetValueOrDefault ( x , 0 ) ) ;
368363
369- var top = Enumerable
370- . Range ( 0 , hdef . Level )
371- . Select ( x => viewModel . ColumnsHeadersHeight [ x ] )
372- . Sum ( ) ;
364+ var top = Enumerable . Range ( 0 , hdef . Level ) . Sum ( x => viewModel . ColumnsHeadersHeight [ x ] ) ;
373365 var height = viewModel . ColumnsHeadersHeight [ hdef . Level ] ;
374366
375367 canvas . DrawHeader (
@@ -474,14 +466,12 @@ double screenScale
474466 : Enumerable
475467 . Range ( hdef . Level , viewModel . RowsHeadersWidth . Length - hdef . Level )
476468 . Where ( x => x < viewModel . RowsHeadersWidth . Length )
477- . Select ( x => viewModel . RowsHeadersWidth [ x ] )
478- . Sum ( ) ;
469+ . Sum ( x => viewModel . RowsHeadersWidth [ x ] ) ;
479470
480471 var left = Enumerable
481472 . Range ( 0 , hdef . Level )
482473 . Where ( x => x < viewModel . RowsHeadersWidth . Length )
483- . Select ( x => viewModel . RowsHeadersWidth [ x ] )
484- . Sum ( ) ;
474+ . Sum ( x => viewModel . RowsHeadersWidth [ x ] ) ;
485475
486476 canvas . DrawHeader (
487477 viewModel ,
@@ -531,14 +521,12 @@ double screenScale
531521
532522 var height = Enumerable
533523 . Range ( row , hdef . Count ( ) - origin . RelativePositionFrom ( hdef ) )
534- . Select ( x => viewModel . RowsHeights . GetValueOrDefault ( x , 0 ) )
535- . Sum ( ) ;
524+ . Sum ( x => viewModel . RowsHeights . GetValueOrDefault ( x , 0 ) ) ;
536525
537526 var left = Enumerable
538527 . Range ( 0 , hdef . Level )
539528 . Where ( x => x < viewModel . RowsHeadersWidth . Length )
540- . Select ( x => viewModel . RowsHeadersWidth [ x ] )
541- . Sum ( ) ;
529+ . Sum ( x => viewModel . RowsHeadersWidth [ x ] ) ;
542530 var width = viewModel . RowsHeadersWidth [ hdef . Level ] ;
543531
544532 canvas . DrawHeader (
@@ -711,25 +699,24 @@ GlobalHeader globalHeader
711699
712700 private static SKPath BuildFoldAllPath ( float left , float top , float width , float height )
713701 {
714- float startX = left + ( width - 24 ) / 2 ;
715- float startY = top + ( height - 24 ) / 2 ;
702+ float startX = left + ( ( width - 24 ) / 2 ) ;
703+ float startY = top + ( ( height - 24 ) / 2 ) ;
716704
717705 const string data = """
718706 M19 9h-2.58l3.29-3.29a1 1 0 1 0-1.42-1.42L15 7.57V5a1 1 0 0 0-1-1 1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h5a1 1 0 0 0 0-2z
719707 M10 13H5a1 1 0 0 0 0 2h2.57l-3.28 3.29a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0L9 16.42V19a1 1 0 0 0 1 1 1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1z
720708 """ ;
721709
722710 var p = SKPath . ParseSvgPathData ( data ) ;
723- //p.Transform(SKMatrix.CreateScale(1.5f, 1.5f));
724711 p . Transform ( SKMatrix . CreateTranslation ( startX , startY ) ) ;
725712
726713 return p ;
727714 }
728715
729716 private static SKPath BuildExpandAllPath ( float left , float top , float width , float height )
730717 {
731- float startX = left + ( width - 24 ) / 2 ;
732- float startY = top + ( height - 24 ) / 2 ;
718+ float startX = left + ( ( width - 24 ) / 2 ) ;
719+ float startY = top + ( ( height - 24 ) / 2 ) ;
733720
734721 const string data = """
735722 M20 5a1 1 0 0 0-1-1h-5a1 1 0 0 0 0 2h2.57l-3.28 3.29a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0L18 7.42V10a1 1 0 0 0 1 1 1 1 0 0 0 1-1z
@@ -751,7 +738,7 @@ private static SKPath BuildFoldedPath(
751738 {
752739 var startPoint =
753740 width > 0f && height > 0f
754- ? new SKPoint ( left + ( width - 24 ) / 2 , top + ( height - 24 ) / 2 )
741+ ? new SKPoint ( left + ( ( width - 24 ) / 2 ) , top + ( ( height - 24 ) / 2 ) )
755742 : new SKPoint ( 3f + left , 5f + top ) ;
756743
757744 const string data = """
@@ -773,7 +760,7 @@ private static SKPath BuildExpandedPath(
773760 {
774761 var startPoint =
775762 width > 0f && height > 0f
776- ? new SKPoint ( left + ( width - 24f ) / 2 , top + ( height - 24f ) / 2 )
763+ ? new SKPoint ( left + ( ( width - 24f ) / 2 ) , top + ( ( height - 24f ) / 2 ) )
777764 : new SKPoint ( 3f + left , 5f + top ) ;
778765
779766 const string data = """
@@ -892,7 +879,7 @@ private static void RenderDecor(
892879 picture . CullRect . Height > cell . Height
893880 ? ( float ) ( cell . Top * screenScale )
894881 : ( float ) (
895- cell . Top + ( ( cell . Height - picture . CullRect . Height ) / 2 ) * screenScale
882+ cell . Top + ( screenScale * ( ( cell . Height - picture . CullRect . Height ) / 2 ) )
896883 ) ;
897884
898885 canvas . DrawPicture (
@@ -1032,10 +1019,6 @@ ref SKRect rect
10321019
10331020 private static TextBlock TextDrawer { get ; } = new ( ) ;
10341021 private static TextPaintOptions TextPaintOptions { get ; } =
1035- new TextPaintOptions
1036- {
1037- Edging = SKFontEdging . SubpixelAntialias ,
1038- SubpixelPositioning = true
1039- } ;
1022+ new TextPaintOptions { Edging = SKFontEdging . SubpixelAntialias } ;
10401023 }
10411024}
0 commit comments