diff --git a/Semi.Avalonia.sln b/Semi.Avalonia.sln index 85b5a31..827c045 100644 --- a/Semi.Avalonia.sln +++ b/Semi.Avalonia.sln @@ -28,6 +28,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Semi.Avalonia.Demo.Android" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Semi.Avalonia.Demo.Drm", "demo\Semi.Avalonia.Demo.Drm\Semi.Avalonia.Demo.Drm.csproj", "{86D93406-412A-4429-93B2-92AAD0407784}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Semi.Avalonia.TreeDataGrid", "src\Semi.Avalonia.TreeDataGrid\Semi.Avalonia.TreeDataGrid.csproj", "{398D2998-0835-41F5-99A3-608CAB8051E2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Semi.Avalonia.TreeDataGrid.Demo", "demo\Semi.Avalonia.TreeDataGrid.Demo\Semi.Avalonia.TreeDataGrid.Demo.csproj", "{6178B545-4BB6-458C-A27C-EE11F3885D38}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -67,6 +71,14 @@ Global {86D93406-412A-4429-93B2-92AAD0407784}.Debug|Any CPU.Build.0 = Debug|Any CPU {86D93406-412A-4429-93B2-92AAD0407784}.Release|Any CPU.ActiveCfg = Release|Any CPU {86D93406-412A-4429-93B2-92AAD0407784}.Release|Any CPU.Build.0 = Release|Any CPU + {398D2998-0835-41F5-99A3-608CAB8051E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {398D2998-0835-41F5-99A3-608CAB8051E2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {398D2998-0835-41F5-99A3-608CAB8051E2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {398D2998-0835-41F5-99A3-608CAB8051E2}.Release|Any CPU.Build.0 = Release|Any CPU + {6178B545-4BB6-458C-A27C-EE11F3885D38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6178B545-4BB6-458C-A27C-EE11F3885D38}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6178B545-4BB6-458C-A27C-EE11F3885D38}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6178B545-4BB6-458C-A27C-EE11F3885D38}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -77,6 +89,7 @@ Global {D789AEDB-EBDF-4450-8E8E-B4A03FB257B0} = {43091528-9509-43CB-A003-9C5C11E96DD6} {0C81FC1C-5D2D-478A-9876-923A0C85EC2F} = {43091528-9509-43CB-A003-9C5C11E96DD6} {86D93406-412A-4429-93B2-92AAD0407784} = {43091528-9509-43CB-A003-9C5C11E96DD6} + {6178B545-4BB6-458C-A27C-EE11F3885D38} = {43091528-9509-43CB-A003-9C5C11E96DD6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7CA41ED3-2CED-40CC-AA21-28C3B42B1E86} diff --git a/demo/Semi.Avalonia.TreeDataGrid.Demo/App.axaml b/demo/Semi.Avalonia.TreeDataGrid.Demo/App.axaml new file mode 100644 index 0000000..3cd62a8 --- /dev/null +++ b/demo/Semi.Avalonia.TreeDataGrid.Demo/App.axaml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/demo/Semi.Avalonia.TreeDataGrid.Demo/App.axaml.cs b/demo/Semi.Avalonia.TreeDataGrid.Demo/App.axaml.cs new file mode 100644 index 0000000..c4d36b3 --- /dev/null +++ b/demo/Semi.Avalonia.TreeDataGrid.Demo/App.axaml.cs @@ -0,0 +1,23 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; + +namespace Semi.Avalonia.TreeDataGrid.Demo; + +public partial class App : Application +{ + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + desktop.MainWindow = new MainWindow(); + } + + base.OnFrameworkInitializationCompleted(); + } +} \ No newline at end of file diff --git a/demo/Semi.Avalonia.TreeDataGrid.Demo/Converters/FileIconConverter.cs b/demo/Semi.Avalonia.TreeDataGrid.Demo/Converters/FileIconConverter.cs new file mode 100644 index 0000000..0ed4943 --- /dev/null +++ b/demo/Semi.Avalonia.TreeDataGrid.Demo/Converters/FileIconConverter.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using Avalonia; +using Avalonia.Data.Converters; +using Avalonia.Media; +using Avalonia.Metadata; + +namespace Semi.Avalonia.TreeDataGrid.Demo.Converters; + +public class FileIconConverter: IMultiValueConverter +{ + [Content] + public Dictionary Items { get; set; } = new Dictionary(); + + public object? Convert(IList values, Type targetType, object? parameter, CultureInfo culture) + { + if (values[0] is bool isDirectory && values[1] is bool isOpen) + { + if (!isDirectory) + { + return Items["file"]; + } + return isOpen ? Items["folderOpen"] : Items["folderClosed"]; + } + return AvaloniaProperty.UnsetValue; + } +} \ No newline at end of file diff --git a/demo/Semi.Avalonia.TreeDataGrid.Demo/MainWindow.axaml b/demo/Semi.Avalonia.TreeDataGrid.Demo/MainWindow.axaml new file mode 100644 index 0000000..32c5e1d --- /dev/null +++ b/demo/Semi.Avalonia.TreeDataGrid.Demo/MainWindow.axaml @@ -0,0 +1,138 @@ + + + + M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z + M6.1,10L4,18V8H21A2,2 0 0,0 19,6H12L10,4H4A2,2 0 0,0 2,6V18A2,2 0 0,0 4,20H19C19.9,20 20.7,19.4 20.9,18.5L23.2,10H6.1M19,18H6L7.6,12H20.6L19,18Z + M20,18H4V8H20M20,6H12L10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6Z + + + +