Skip to content

Commit 9e3f3ec

Browse files
committed
Add font size properties and improve SVG alignment
Introduces FontSize and HeaderFontSize dependency properties to the grid, updates the view and view model to support them, and exposes them in the demo. Improves SVG icon vertical alignment in cells. Also adds XML documentation to ThemeColor, cleans up the readme, and removes unused GridControl and GridCustomDrawOperation files.
1 parent d015fc0 commit 9e3f3ec

11 files changed

Lines changed: 130 additions & 170 deletions

File tree

readme.md

Lines changed: 28 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
# HierarchyGrid
22

3-
4-
5-
This component aims to display data along two different hierarchical classifications, as if a datagrid had its rows and columns defined by treeviews.
6-
7-
3+
This component aims to display data along two different hierarchical classifications, as if a datagrid had its rows and
4+
columns defined by trees.
85

96
## Definitions
107

@@ -14,112 +11,89 @@ Rows and columns are defined by *HierarchyDefinition*. There are two kinds of th
1411

1512
- *ConsumerDefinition*: extracts information from the object received from the producer, by default on column level.
1613

17-
18-
1914
```csharp
20-
2115
public object Content { get; set; }
22-
2316
```
2417

2518
Defines the content of the grid header associated to the definition.
2619

27-
28-
2920
```csharp
30-
3121
public X Add<X>(X child) where X : HierarchyDefinition
32-
3322
```
3423

3524
Adds a properly set child element to the current hierarchy definition.
3625

37-
38-
3926
### ProducerDefinition
4027

4128
```csharp
42-
43-
public Func<object> Producer { get; set; }
44-
29+
public Func<object>? Producer { get; set; }
4530
```
4631

4732
Defines the function that will be used to retrieve data from the producer.
4833

49-
50-
5134
```csharp
35+
public Func<Qualification>? Qualify { get; set; }
36+
```
5237

53-
public Func<Qualification> Qualify { get; set; }
38+
Allows override of qualification for all elements produced by this definition, independently of the consumer
39+
definition.
5440

41+
```csharp
42+
public bool IsLocked { get; set; }
5543
```
5644

57-
Allows override of qualification for all elements produced by this definition, independently from the consumer definition.
58-
59-
45+
If set to true, all produced elements will be read-only, even if the consumer defines an editor.
6046

6147
### ConsumerDefinition
6248

6349
```csharp
64-
65-
public Func<object, object> Consumer { get; set; }
66-
50+
public Func<object, object>? Consumer { get; set; }
6751
```
6852

6953
Defines the function that will extract information from the provided data.
7054

71-
72-
7355
```csharp
74-
75-
public Func<object, string> Formatter { get; set; }
76-
56+
public Func<object, string>? Formatter { get; set; }
7757
```
7858

7959
Defines the function that will format the consumer result as it will be displayed in the grid.
8060

81-
82-
8361
```csharp
84-
85-
public Func<object, Qualification> Qualify { get; set; }
86-
62+
public Func<object, Qualification>? Qualify { get; set; }
8763
```
8864

8965
Defines the function that will set the cell qualification according to consumer result.
9066

91-
92-
9367
```csharp
94-
95-
public Func<object, (byte a, byte r, byte g, byte b)> Colorize { get; set; }
96-
68+
public Func<object, (ThemeColor, ThemeColor)>? Colorize { get; set; }
9769
```
9870

9971
Defines the function that will set the cell background if cell qualification is set to ***Custom***.
10072

101-
102-
10373
```csharp
74+
public Func<object, object, string, bool>? Editor { get; set; }
75+
```
10476

105-
public Func<object, object, string, bool> Editor { get; set; }
77+
Defines the function called when a cell edition is validated. The first parameter is the object provided by the
78+
producer, the second is the result from the consumer, and the third one is the string input from the editing textbox.
79+
The
80+
boolean returns whether data has been updated.
10681

82+
```csharp
83+
public Func<object, object, bool>? IsLocked { get; set; }
10784
```
10885

109-
Defines the function called when a cell edition is validated. The first parameter is the object provided by the producer, the second is the result from the consumer and the third one is the string input from the editing textbox. The boolean returns whether or not data has been updated.
110-
111-
86+
Indicates that the cell can't be edited. The first parameter is raw data from the producer, and the second is the result
87+
from the consumer.
11288

11389
## Resulting grid
11490

115-
116-
11791
### Qualifications
11892

119-
Cell rendering can be modified according to a qualification. Available values are: Unset, Empty, Normal, Error, Warning, Remark, Custom, ReadOnly.
120-
121-
93+
Cell rendering can be modified according to a qualification. Available values are: Unset, Empty, Normal, Error, Warning,
94+
Remark, Custom, ReadOnly.
12295

12396
## Known issues
12497

125-
Even if UI performance has always been a major focus, *bindings* do impact scrolling speed. The more cells are displayed, the more the component will slow down.
98+
Even if UI performance has always been a major focus, the more cells are displayed, the more the component will slow
99+
down.
Lines changed: 4 additions & 9 deletions
Loading

src/Demo.AvaloniaApplication/Views/MainView.axaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
DefaultRowHeight="60"
3333
StatusMessage="I'm a test message!"
3434
EnableCrosshair="True"
35+
HeaderFontSize="18"
36+
FontSize="12"
3537
DockPanel.Dock="Top"/>
3638
</DockPanel>
3739
</TabItem>

src/HierarchyGrid.Avalonia/Grid.DependencyProperties.cs

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,56 +5,82 @@ namespace HierarchyGrid.Avalonia;
55
public partial class Grid
66
{
77
public static readonly StyledProperty<string?> StatusMessageProperty =
8-
AvaloniaProperty.Register<Grid , string?>( nameof( StatusMessage ) , "No message" );
8+
AvaloniaProperty.Register<Grid, string?>(nameof(StatusMessage), "No message");
99

1010
public string? StatusMessage
1111
{
12-
get => GetValue( StatusMessageProperty );
13-
set => SetValue( StatusMessageProperty , value );
12+
get => GetValue(StatusMessageProperty);
13+
set => SetValue(StatusMessageProperty, value);
1414
}
1515

1616
public static readonly StyledProperty<int> DefaultColumnWidthProperty =
17-
AvaloniaProperty.Register<Grid , int>( nameof( DefaultColumnWidth ) , 120 );
17+
AvaloniaProperty.Register<Grid, int>(nameof(DefaultColumnWidth), 120);
1818

1919
public int DefaultColumnWidth
2020
{
21-
get => GetValue( DefaultColumnWidthProperty );
22-
set => SetValue( DefaultColumnWidthProperty , value );
21+
get => GetValue(DefaultColumnWidthProperty);
22+
set => SetValue(DefaultColumnWidthProperty, value);
2323
}
2424

25-
public static readonly StyledProperty<int> DefaultRowHeightProperty =
26-
AvaloniaProperty.Register<Grid , int>( nameof( DefaultRowHeight ) , 30 );
25+
public static readonly StyledProperty<int> DefaultRowHeightProperty = AvaloniaProperty.Register<
26+
Grid,
27+
int
28+
>(nameof(DefaultRowHeight), 30);
2729

2830
public int DefaultRowHeight
2931
{
30-
get => GetValue( DefaultRowHeightProperty );
31-
set => SetValue( DefaultRowHeightProperty , value );
32+
get => GetValue(DefaultRowHeightProperty);
33+
set => SetValue(DefaultRowHeightProperty, value);
3234
}
3335

3436
public static readonly StyledProperty<int> DefaultHeaderWidthProperty =
35-
AvaloniaProperty.Register<Grid , int>( nameof( DefaultHeaderWidth ) , 80 );
37+
AvaloniaProperty.Register<Grid, int>(nameof(DefaultHeaderWidth), 80);
3638

3739
public int DefaultHeaderWidth
3840
{
39-
get => GetValue( DefaultHeaderWidthProperty );
40-
set => SetValue( DefaultHeaderWidthProperty , value );
41+
get => GetValue(DefaultHeaderWidthProperty);
42+
set => SetValue(DefaultHeaderWidthProperty, value);
4143
}
4244

4345
public static readonly StyledProperty<int> DefaultHeaderHeightProperty =
44-
AvaloniaProperty.Register<Grid , int>( nameof( DefaultHeaderHeight ) , 30 );
46+
AvaloniaProperty.Register<Grid, int>(nameof(DefaultHeaderHeight), 30);
4547

4648
public int DefaultHeaderHeight
4749
{
48-
get => GetValue( DefaultHeaderHeightProperty );
49-
set => SetValue( DefaultHeaderHeightProperty , value );
50+
get => GetValue(DefaultHeaderHeightProperty);
51+
set => SetValue(DefaultHeaderHeightProperty, value);
5052
}
5153

52-
public static readonly StyledProperty<bool> EnableCrosshairProperty =
53-
AvaloniaProperty.Register<Grid , bool>( nameof( EnableCrosshair ) , false );
54+
public static readonly StyledProperty<bool> EnableCrosshairProperty = AvaloniaProperty.Register<
55+
Grid,
56+
bool
57+
>(nameof(EnableCrosshair), false);
5458

5559
public bool EnableCrosshair
5660
{
57-
get => GetValue( EnableCrosshairProperty );
58-
set => SetValue( EnableCrosshairProperty , value );
61+
get => GetValue(EnableCrosshairProperty);
62+
set => SetValue(EnableCrosshairProperty, value);
63+
}
64+
65+
public static readonly StyledProperty<float> FontSizeProperty = AvaloniaProperty.Register<
66+
Grid,
67+
float
68+
>(nameof(FontSize), 15);
69+
70+
public float FontSize
71+
{
72+
get => GetValue(FontSizeProperty);
73+
set => SetValue(FontSizeProperty, value);
74+
}
75+
76+
public static readonly StyledProperty<float> HeaderFontSizeProperty = AvaloniaProperty.Register<
77+
Grid,
78+
float
79+
>(nameof(HeaderFontSize), 15);
80+
81+
public float HeaderFontSize
82+
{
83+
get => GetValue(HeaderFontSizeProperty);
84+
set => SetValue(HeaderFontSizeProperty, value);
5985
}
6086
}

src/HierarchyGrid.Avalonia/Grid.axaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ private static void ApplyDependencyProperties(Grid view, HierarchyGridViewModel
204204
viewModel.DefaultHeaderWidth = view.DefaultHeaderWidth;
205205
viewModel.StatusMessage = view.StatusMessage ?? "No message";
206206
viewModel.EnableCrosshair = view.EnableCrosshair;
207+
viewModel.FontSize = view.FontSize;
208+
viewModel.HeaderFontSize = view.HeaderFontSize;
207209
}
208210

209211
private static async Task SkiaElement_PaintSurface(

src/HierarchyGrid.Avalonia/GridControl.cs

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/HierarchyGrid.Avalonia/GridCustomDrawOperation.cs

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)