mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-04-27 11:43:23 +08:00
misc: ready for 12.0.x.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<AvaloniaVersion>11.3.0</AvaloniaVersion>
|
<AvaloniaVersion>12.0.999-cibuild0058575-alpha</AvaloniaVersion>
|
||||||
<DataGridVersion>11.3.0</DataGridVersion>
|
<DataGridVersion>11.3.0</DataGridVersion>
|
||||||
<CommunityToolkitVersion>8.4.0</CommunityToolkitVersion>
|
<CommunityToolkitVersion>8.4.0</CommunityToolkitVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
<semi:SemiTheme Locale="zh-CN" />
|
<semi:SemiTheme Locale="zh-CN" />
|
||||||
<semi:SemiPopupAnimations />
|
<semi:SemiPopupAnimations />
|
||||||
<semi:ColorPickerSemiTheme />
|
<semi:ColorPickerSemiTheme />
|
||||||
<semi:DataGridSemiTheme />
|
<!-- <semi:DataGridSemiTheme /> -->
|
||||||
<semi:TreeDataGridSemiTheme />
|
<!-- <semi:TreeDataGridSemiTheme /> -->
|
||||||
</Application.Styles>
|
</Application.Styles>
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
|
|||||||
@@ -1,180 +0,0 @@
|
|||||||
<UserControl
|
|
||||||
x:Class="Semi.Avalonia.Demo.Pages.DataGridDemo"
|
|
||||||
xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:vm="clr-namespace:Semi.Avalonia.Demo.ViewModels;assembly=Semi.Avalonia.Demo"
|
|
||||||
d:DesignHeight="450"
|
|
||||||
d:DesignWidth="800"
|
|
||||||
x:CompileBindings="True"
|
|
||||||
x:DataType="vm:DataGridDemoViewModel"
|
|
||||||
mc:Ignorable="d">
|
|
||||||
<TabControl>
|
|
||||||
<TabItem Header="DataGrid">
|
|
||||||
<Grid RowDefinitions="Auto, *">
|
|
||||||
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
|
||||||
<ToggleSwitch Content="Enable" Name="enable" IsChecked="True" />
|
|
||||||
<ToggleSwitch Content="Inset Content" Name="inset" />
|
|
||||||
<ToggleSwitch Content="ScrollBar Auto Hide" Name="autohide" />
|
|
||||||
</StackPanel>
|
|
||||||
<DataGrid Grid.Row="1"
|
|
||||||
Margin="8"
|
|
||||||
CanUserReorderColumns="True"
|
|
||||||
CanUserResizeColumns="True"
|
|
||||||
CanUserSortColumns="True"
|
|
||||||
HeadersVisibility="All"
|
|
||||||
IsReadOnly="True"
|
|
||||||
Classes.InsetContent="{Binding #inset.IsChecked}"
|
|
||||||
ScrollViewer.AllowAutoHide="{Binding #autohide.IsChecked}"
|
|
||||||
IsEnabled="{Binding #enable.IsChecked}"
|
|
||||||
ItemsSource="{Binding GridData1}">
|
|
||||||
<DataGrid.Columns>
|
|
||||||
<DataGridTextColumn
|
|
||||||
Width="6*"
|
|
||||||
x:DataType="vm:Song"
|
|
||||||
Binding="{Binding Title}"
|
|
||||||
Header="Title" />
|
|
||||||
<DataGridTextColumn
|
|
||||||
Width="6*"
|
|
||||||
x:DataType="vm:Song"
|
|
||||||
Binding="{Binding Artist}"
|
|
||||||
Header="Artist" />
|
|
||||||
<DataGridTextColumn
|
|
||||||
Width="6*"
|
|
||||||
x:DataType="vm:Song"
|
|
||||||
Binding="{Binding Album}"
|
|
||||||
Header="Album" />
|
|
||||||
<DataGridTemplateColumn Header="Duration" SortMemberPath="Duration">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<TextBlock
|
|
||||||
Margin="8,0,0,0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding Duration}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
</DataGrid.Columns>
|
|
||||||
|
|
||||||
</DataGrid>
|
|
||||||
|
|
||||||
</Grid>
|
|
||||||
</TabItem>
|
|
||||||
<TabItem Header="Grouping">
|
|
||||||
<DataGrid
|
|
||||||
Margin="8"
|
|
||||||
CanUserReorderColumns="True"
|
|
||||||
CanUserResizeColumns="True"
|
|
||||||
CanUserSortColumns="True"
|
|
||||||
HeadersVisibility="All"
|
|
||||||
IsReadOnly="True"
|
|
||||||
ItemsSource="{Binding GridData2}">
|
|
||||||
<DataGrid.Columns>
|
|
||||||
<DataGridTextColumn
|
|
||||||
Width="6*"
|
|
||||||
x:DataType="vm:Song"
|
|
||||||
Binding="{Binding Title}"
|
|
||||||
Header="Title" />
|
|
||||||
<DataGridTextColumn
|
|
||||||
Width="6*"
|
|
||||||
x:DataType="vm:Song"
|
|
||||||
Binding="{Binding Artist}"
|
|
||||||
Header="Artist" />
|
|
||||||
<DataGridTextColumn
|
|
||||||
Width="6*"
|
|
||||||
x:DataType="vm:Song"
|
|
||||||
Binding="{Binding Album}"
|
|
||||||
Header="Album" />
|
|
||||||
<DataGridTemplateColumn
|
|
||||||
x:DataType="vm:Song"
|
|
||||||
Header="Duration"
|
|
||||||
SortMemberPath="Duration">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate x:DataType="vm:Song">
|
|
||||||
<TextBlock
|
|
||||||
Margin="8,0,0,0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding Duration}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
</DataGrid.Columns>
|
|
||||||
</DataGrid>
|
|
||||||
</TabItem>
|
|
||||||
<TabItem Name="EditableTab" Header="Editable">
|
|
||||||
<Grid Margin="8" RowDefinitions="Auto,*,Auto">
|
|
||||||
<StackPanel
|
|
||||||
Grid.Row="0"
|
|
||||||
Orientation="Horizontal"
|
|
||||||
Spacing="4">
|
|
||||||
<TextBlock VerticalAlignment="Center" Text="FontSize:" />
|
|
||||||
<Slider
|
|
||||||
Name="FontSizeSlider"
|
|
||||||
Width="100"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Maximum="30"
|
|
||||||
Minimum="5"
|
|
||||||
Value="14" />
|
|
||||||
<CheckBox
|
|
||||||
Name="IsThreeStateCheckBox"
|
|
||||||
Content="IsThreeState"
|
|
||||||
IsChecked="False" />
|
|
||||||
</StackPanel>
|
|
||||||
<DataGrid
|
|
||||||
Grid.Row="1"
|
|
||||||
Margin="8"
|
|
||||||
ItemsSource="{Binding GridData3}">
|
|
||||||
<DataGrid.Columns>
|
|
||||||
<DataGridCheckBoxColumn
|
|
||||||
Width="2*"
|
|
||||||
Binding="{Binding IsSelected}"
|
|
||||||
Header="Select"
|
|
||||||
IsThreeState="{Binding #IsThreeStateCheckBox.IsChecked, Mode=OneWay}" />
|
|
||||||
<DataGridTextColumn
|
|
||||||
Width="6*"
|
|
||||||
x:DataType="vm:SongViewModel"
|
|
||||||
Binding="{Binding Title}"
|
|
||||||
FontSize="{Binding #FontSizeSlider.Value, Mode=OneWay}"
|
|
||||||
Header="Title" />
|
|
||||||
<DataGridTextColumn
|
|
||||||
Width="6*"
|
|
||||||
x:DataType="vm:SongViewModel"
|
|
||||||
Binding="{Binding Artist}"
|
|
||||||
Header="Artist" />
|
|
||||||
<DataGridTextColumn
|
|
||||||
Width="6*"
|
|
||||||
x:DataType="vm:SongViewModel"
|
|
||||||
Binding="{Binding Album}"
|
|
||||||
Header="Album" />
|
|
||||||
<DataGridTemplateColumn Width="2*" Header="Comments">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<TextBlock
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding CountOfComment}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataGridTemplateColumn.CellEditingTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<NumericUpDown
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
FormatString="N0"
|
|
||||||
Minimum="0"
|
|
||||||
Value="{Binding CountOfComment}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellEditingTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
</DataGrid.Columns>
|
|
||||||
</DataGrid>
|
|
||||||
<Button
|
|
||||||
Grid.Row="2"
|
|
||||||
Margin="12,0,12,12"
|
|
||||||
HorizontalAlignment="Right"
|
|
||||||
Command="{Binding AddCommand}"
|
|
||||||
Content="Add" />
|
|
||||||
</Grid>
|
|
||||||
</TabItem>
|
|
||||||
</TabControl>
|
|
||||||
</UserControl>
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
using Avalonia.Controls;
|
|
||||||
using Semi.Avalonia.Demo.ViewModels;
|
|
||||||
|
|
||||||
namespace Semi.Avalonia.Demo.Pages;
|
|
||||||
|
|
||||||
public partial class DataGridDemo : UserControl
|
|
||||||
{
|
|
||||||
public DataGridDemo()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
DataContext = new DataGridDemoViewModel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,328 +0,0 @@
|
|||||||
<UserControl xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:vm="clr-namespace:Semi.Avalonia.Demo.ViewModels"
|
|
||||||
xmlns:controls="clr-namespace:Semi.Avalonia.Demo.Controls"
|
|
||||||
xmlns:cvt="clr-namespace:Semi.Avalonia.Demo.Converters"
|
|
||||||
xmlns:pages="clr-namespace:Semi.Avalonia.Demo.Pages"
|
|
||||||
mc:Ignorable="d" d:DesignWidth="1000" d:DesignHeight="1450"
|
|
||||||
x:DataType="vm:HighContrastDemoViewModel"
|
|
||||||
x:CompileBindings="True"
|
|
||||||
x:Class="Semi.Avalonia.Demo.Pages.HighContrastDemo">
|
|
||||||
<Design.DataContext>
|
|
||||||
<vm:HighContrastDemoViewModel />
|
|
||||||
</Design.DataContext>
|
|
||||||
<SplitView
|
|
||||||
Name="splitView"
|
|
||||||
CompactPaneLength="50"
|
|
||||||
DisplayMode="CompactInline"
|
|
||||||
IsPaneOpen="{Binding #toggle.IsChecked, Mode=TwoWay}"
|
|
||||||
OpenPaneLength="300"
|
|
||||||
PanePlacement="Right">
|
|
||||||
<SplitView.Pane>
|
|
||||||
<StackPanel>
|
|
||||||
<ToggleSwitch
|
|
||||||
Name="toggle"
|
|
||||||
HorizontalAlignment="Right"
|
|
||||||
IsChecked="True"
|
|
||||||
Theme="{DynamicResource IconBorderlessToggleSwitch}"
|
|
||||||
Content="{StaticResource SemiIconSidebar}" />
|
|
||||||
<Border IsVisible="{Binding #splitView.IsPaneOpen}" Theme="{DynamicResource CardBorder}">
|
|
||||||
<Panel>
|
|
||||||
<TextBlock
|
|
||||||
IsVisible="{Binding SelectedColorResource, Converter={x:Static ObjectConverters.IsNull}}"
|
|
||||||
Text="Click on Color to Check Details"
|
|
||||||
TextWrapping="Wrap" />
|
|
||||||
<controls:ColorDetailControl
|
|
||||||
Background="{Binding SelectedColorResource.Brush}"
|
|
||||||
IsVisible="{Binding SelectedColorResource, Converter={x:Static ObjectConverters.IsNotNull}}"
|
|
||||||
ResourceKey="{Binding SelectedColorResource.ResourceKey}"
|
|
||||||
ResourceName="{Binding SelectedColorResource.ResourceKey}" />
|
|
||||||
</Panel>
|
|
||||||
</Border>
|
|
||||||
</StackPanel>
|
|
||||||
</SplitView.Pane>
|
|
||||||
<SplitView.Content>
|
|
||||||
<ScrollViewer>
|
|
||||||
<StackPanel Spacing="10">
|
|
||||||
<TextBlock Text="Theme Preview" FontWeight="SemiBold" />
|
|
||||||
<ListBox
|
|
||||||
Theme="{StaticResource PureCardRadioGroupListBox}"
|
|
||||||
ItemsSource="{Binding ThemeVariants}"
|
|
||||||
SelectedItem="{Binding SelectedThemeVariant}">
|
|
||||||
<ListBox.ItemsPanel>
|
|
||||||
<ItemsPanelTemplate>
|
|
||||||
<WrapPanel Orientation="Horizontal" />
|
|
||||||
</ItemsPanelTemplate>
|
|
||||||
</ListBox.ItemsPanel>
|
|
||||||
<ListBox.ItemTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<StackPanel HorizontalAlignment="Left" Spacing="5" MinWidth="200">
|
|
||||||
<ThemeVariantScope RequestedThemeVariant="{Binding}">
|
|
||||||
<Border
|
|
||||||
Padding="5 25 5 5"
|
|
||||||
HorizontalAlignment="Left"
|
|
||||||
Background="{DynamicResource WindowColor}"
|
|
||||||
BorderBrush="{DynamicResource WindowTextColor}"
|
|
||||||
BorderThickness="1"
|
|
||||||
CornerRadius="3">
|
|
||||||
<StackPanel Spacing="10">
|
|
||||||
<StackPanel Orientation="Horizontal" Spacing="50">
|
|
||||||
<StackPanel Spacing="5">
|
|
||||||
<TextBlock
|
|
||||||
FontSize="50"
|
|
||||||
Text="Aa" />
|
|
||||||
<StackPanel Orientation="Horizontal" Spacing="3">
|
|
||||||
<StackPanel.Styles>
|
|
||||||
<Style Selector="Border">
|
|
||||||
<Setter Property="BorderThickness" Value="1" />
|
|
||||||
<Setter Property="BorderBrush" Value="{DynamicResource WindowTextColor}" />
|
|
||||||
<Setter Property="CornerRadius" Value="5" />
|
|
||||||
<Setter Property="Width" Value="10" />
|
|
||||||
<Setter Property="Height" Value="{Binding $self.Width}" />
|
|
||||||
</Style>
|
|
||||||
</StackPanel.Styles>
|
|
||||||
<Border Background="{DynamicResource WindowColor}" />
|
|
||||||
<Border Background="{DynamicResource HotlightColor}" />
|
|
||||||
<Border Background="{DynamicResource GrayTextColor}" />
|
|
||||||
<Border Background="{DynamicResource HighlightTextColor}" />
|
|
||||||
<Border Background="{DynamicResource HighlightColor}" />
|
|
||||||
</StackPanel>
|
|
||||||
</StackPanel>
|
|
||||||
<Border
|
|
||||||
BorderThickness="1"
|
|
||||||
BorderBrush="{DynamicResource WindowTextColor}"
|
|
||||||
CornerRadius="3"
|
|
||||||
Padding="8">
|
|
||||||
<Panel>
|
|
||||||
<StackPanel Spacing="5">
|
|
||||||
<Border
|
|
||||||
Width="50"
|
|
||||||
Height="1"
|
|
||||||
Background="{DynamicResource WindowTextColor}" />
|
|
||||||
<Border
|
|
||||||
Height="1"
|
|
||||||
Background="{DynamicResource WindowTextColor}" />
|
|
||||||
<Border
|
|
||||||
Height="1"
|
|
||||||
Background="{DynamicResource WindowTextColor}" />
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel
|
|
||||||
HorizontalAlignment="Right"
|
|
||||||
VerticalAlignment="Bottom"
|
|
||||||
Orientation="Horizontal"
|
|
||||||
Spacing="2">
|
|
||||||
<Border
|
|
||||||
Width="20"
|
|
||||||
Height="5"
|
|
||||||
Background="{DynamicResource HighlightColor}"
|
|
||||||
CornerRadius="1" />
|
|
||||||
<Border
|
|
||||||
Width="20"
|
|
||||||
Height="5"
|
|
||||||
BorderThickness="1"
|
|
||||||
BorderBrush="{DynamicResource ButtonTextColor}"
|
|
||||||
CornerRadius="1" />
|
|
||||||
</StackPanel>
|
|
||||||
</Panel>
|
|
||||||
</Border>
|
|
||||||
</StackPanel>
|
|
||||||
<Border
|
|
||||||
Height="1"
|
|
||||||
Background="{DynamicResource WindowTextColor}" />
|
|
||||||
</StackPanel>
|
|
||||||
</Border>
|
|
||||||
</ThemeVariantScope>
|
|
||||||
<TextBlock Text="{Binding}" FontWeight="SemiBold" />
|
|
||||||
</StackPanel>
|
|
||||||
</DataTemplate>
|
|
||||||
</ListBox.ItemTemplate>
|
|
||||||
</ListBox>
|
|
||||||
|
|
||||||
<ThemeVariantScope
|
|
||||||
MinWidth="400"
|
|
||||||
RequestedThemeVariant="{Binding SelectedThemeVariant}">
|
|
||||||
<Border Padding="10" Background="{DynamicResource WindowColor}">
|
|
||||||
<StackPanel Spacing="16">
|
|
||||||
<StackPanel.Styles>
|
|
||||||
<Style Selector="TextBlock">
|
|
||||||
<Setter Property="HorizontalAlignment" Value="Left" />
|
|
||||||
<Setter Property="VerticalAlignment" Value="Center" />
|
|
||||||
<Setter Property="FontWeight" Value="SemiBold" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="controls|ColorItemControl.ColorBlock">
|
|
||||||
<Setter Property="Width" Value="44" />
|
|
||||||
<Setter Property="Height" Value="{Binding $self.Width}" />
|
|
||||||
<Setter Property="HorizontalAlignment" Value="Right" />
|
|
||||||
<Setter Property="BorderThickness" Value="1" />
|
|
||||||
<Setter Property="BorderBrush" Value="{DynamicResource WindowTextColor}" />
|
|
||||||
<Setter Property="CornerRadius" Value="3" />
|
|
||||||
</Style>
|
|
||||||
</StackPanel.Styles>
|
|
||||||
<Panel>
|
|
||||||
<TextBlock
|
|
||||||
Foreground="{DynamicResource WindowTextColor}"
|
|
||||||
Text="Background" />
|
|
||||||
<controls:ColorItemControl
|
|
||||||
Classes="ColorBlock"
|
|
||||||
DataContext="{Binding ColorResources[0]}"
|
|
||||||
Background="{DynamicResource WindowColor}" />
|
|
||||||
</Panel>
|
|
||||||
<Panel>
|
|
||||||
<TextBlock
|
|
||||||
Foreground="{DynamicResource WindowTextColor}"
|
|
||||||
Text="Text" />
|
|
||||||
<controls:ColorItemControl
|
|
||||||
Classes="ColorBlock"
|
|
||||||
DataContext="{Binding ColorResources[1]}"
|
|
||||||
Background="{DynamicResource WindowTextColor}" />
|
|
||||||
</Panel>
|
|
||||||
<Panel>
|
|
||||||
<TextBlock
|
|
||||||
Foreground="{DynamicResource HotlightColor}"
|
|
||||||
TextDecorations="Underline"
|
|
||||||
Text="Hyperlink" />
|
|
||||||
<controls:ColorItemControl
|
|
||||||
Classes="ColorBlock"
|
|
||||||
DataContext="{Binding ColorResources[2]}"
|
|
||||||
Background="{DynamicResource HotlightColor}" />
|
|
||||||
</Panel>
|
|
||||||
<Panel>
|
|
||||||
<TextBlock
|
|
||||||
Foreground="{DynamicResource GrayTextColor}"
|
|
||||||
Text="Inactive Text" />
|
|
||||||
<controls:ColorItemControl
|
|
||||||
Classes="ColorBlock"
|
|
||||||
DataContext="{Binding ColorResources[3]}"
|
|
||||||
Background="{DynamicResource GrayTextColor}" />
|
|
||||||
</Panel>
|
|
||||||
<Panel>
|
|
||||||
<TextBlock
|
|
||||||
Foreground="{DynamicResource HighlightTextColor}"
|
|
||||||
Background="{DynamicResource HighlightColor}"
|
|
||||||
Text="Selected text" />
|
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="4">
|
|
||||||
<controls:ColorItemControl
|
|
||||||
Classes="ColorBlock"
|
|
||||||
DataContext="{Binding ColorResources[4]}"
|
|
||||||
Background="{DynamicResource HighlightTextColor}" />
|
|
||||||
<controls:ColorItemControl
|
|
||||||
Classes="ColorBlock"
|
|
||||||
DataContext="{Binding ColorResources[5]}"
|
|
||||||
Background="{DynamicResource HighlightColor}" />
|
|
||||||
</StackPanel>
|
|
||||||
</Panel>
|
|
||||||
<Panel>
|
|
||||||
<Border
|
|
||||||
HorizontalAlignment="Left"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
BorderBrush="{DynamicResource ButtonTextColor}"
|
|
||||||
Background="{DynamicResource ButtonFaceColor}"
|
|
||||||
BorderThickness="2"
|
|
||||||
CornerRadius="3">
|
|
||||||
<TextBlock
|
|
||||||
Foreground="{DynamicResource ButtonTextColor}"
|
|
||||||
Padding="16 6"
|
|
||||||
Text="Button text" />
|
|
||||||
</Border>
|
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="4">
|
|
||||||
<controls:ColorItemControl
|
|
||||||
Classes="ColorBlock"
|
|
||||||
DataContext="{Binding ColorResources[6]}"
|
|
||||||
Background="{DynamicResource ButtonTextColor}" />
|
|
||||||
<controls:ColorItemControl
|
|
||||||
Classes="ColorBlock"
|
|
||||||
DataContext="{Binding ColorResources[7]}"
|
|
||||||
Background="{DynamicResource ButtonFaceColor}" />
|
|
||||||
</StackPanel>
|
|
||||||
</Panel>
|
|
||||||
</StackPanel>
|
|
||||||
</Border>
|
|
||||||
</ThemeVariantScope>
|
|
||||||
|
|
||||||
<DataGrid
|
|
||||||
HorizontalAlignment="Left"
|
|
||||||
CanUserSortColumns="False"
|
|
||||||
AutoGenerateColumns="False"
|
|
||||||
ItemsSource="{Binding ColorResources}"
|
|
||||||
GridLinesVisibility="All"
|
|
||||||
BorderBrush="{DynamicResource SemiColorBorder}"
|
|
||||||
BorderThickness="1"
|
|
||||||
Padding="5">
|
|
||||||
<DataGrid.Columns>
|
|
||||||
<DataGridTemplateColumn Header="Color">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<controls:ColorItemControl
|
|
||||||
Width="40"
|
|
||||||
Height="20"
|
|
||||||
CornerRadius="3"
|
|
||||||
Background="{Binding Brush}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
|
|
||||||
<DataGridTemplateColumn Header="ResourceKey">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<SelectableTextBlock
|
|
||||||
Margin="12 0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding ResourceKey}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
|
|
||||||
<DataGridTemplateColumn Header="Hex">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<SelectableTextBlock
|
|
||||||
Margin="12 0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding Brush,
|
|
||||||
Converter={x:Static cvt:ColorConverter.ToHex},ConverterParameter={x:False}}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
|
|
||||||
<DataGridTemplateColumn Header="Description">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<SelectableTextBlock
|
|
||||||
Margin="12 0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding Description}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
|
|
||||||
<DataGridTemplateColumn Header="Pair With">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<SelectableTextBlock
|
|
||||||
Margin="12 0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding PairWith}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
|
|
||||||
<DataGridTemplateColumn Width="100" Header="CopyText">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="vm:ColorResource">
|
|
||||||
<Button
|
|
||||||
Command="{Binding $parent[pages:HighContrastDemo].Copy}"
|
|
||||||
CommandParameter="{Binding CopyText}"
|
|
||||||
Theme="{DynamicResource IconBorderlessButton}"
|
|
||||||
Content="{StaticResource SemiIconCopy}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
</DataGrid.Columns>
|
|
||||||
</DataGrid>
|
|
||||||
</StackPanel>
|
|
||||||
</ScrollViewer>
|
|
||||||
</SplitView.Content>
|
|
||||||
</SplitView>
|
|
||||||
</UserControl>
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
using System.Threading.Tasks;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Semi.Avalonia.Demo.ViewModels;
|
|
||||||
|
|
||||||
namespace Semi.Avalonia.Demo.Pages;
|
|
||||||
|
|
||||||
public partial class HighContrastDemo : UserControl
|
|
||||||
{
|
|
||||||
public HighContrastDemo()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.DataContext = new HighContrastDemoViewModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task Copy(object? o)
|
|
||||||
{
|
|
||||||
if (o is null) return;
|
|
||||||
var toplevel = TopLevel.GetTopLevel(this);
|
|
||||||
if (toplevel?.Clipboard is { } c)
|
|
||||||
{
|
|
||||||
await c.SetTextAsync(o.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -353,12 +353,12 @@
|
|||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock Text="Install via nuget: " />
|
<TextBlock Text="Install via nuget: " />
|
||||||
<Border Margin="0,16" Classes="CodeBlock">
|
<Border Margin="0,16" Classes="CodeBlock">
|
||||||
<SelectableTextBlock FontFamily="Consolas" Text="{Binding $parent[local:Overview].MainInstall}" />
|
<SelectableTextBlock Text="{Binding $parent[local:Overview].MainInstall}" />
|
||||||
</Border>
|
</Border>
|
||||||
<TextBlock Text="Reference styles: " />
|
<TextBlock Text="Reference styles: " />
|
||||||
<Border Margin="0,16" Classes="CodeBlock">
|
<Border Margin="0,16" Classes="CodeBlock">
|
||||||
<SelectableTextBlock
|
<SelectableTextBlock
|
||||||
FontFamily="Consolas"
|
|
||||||
Text="{Binding $parent[local:Overview].MainStyle}"
|
Text="{Binding $parent[local:Overview].MainStyle}"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
</Border>
|
</Border>
|
||||||
@@ -368,12 +368,12 @@
|
|||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock Text="Install via nuget: " />
|
<TextBlock Text="Install via nuget: " />
|
||||||
<Border Margin="0,16" Classes="CodeBlock">
|
<Border Margin="0,16" Classes="CodeBlock">
|
||||||
<SelectableTextBlock FontFamily="Consolas" Text="{Binding $parent[local:Overview].ColorPickerInstall}" />
|
<SelectableTextBlock Text="{Binding $parent[local:Overview].ColorPickerInstall}" />
|
||||||
</Border>
|
</Border>
|
||||||
<TextBlock Text="Reference styles: " />
|
<TextBlock Text="Reference styles: " />
|
||||||
<Border Margin="0,16" Classes="CodeBlock">
|
<Border Margin="0,16" Classes="CodeBlock">
|
||||||
<SelectableTextBlock
|
<SelectableTextBlock
|
||||||
FontFamily="Consolas"
|
|
||||||
Text="{Binding $parent[local:Overview].ColorPickerStyle}"
|
Text="{Binding $parent[local:Overview].ColorPickerStyle}"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
</Border>
|
</Border>
|
||||||
@@ -383,12 +383,12 @@
|
|||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock Text="Install via nuget: " />
|
<TextBlock Text="Install via nuget: " />
|
||||||
<Border Margin="0,16" Classes="CodeBlock">
|
<Border Margin="0,16" Classes="CodeBlock">
|
||||||
<SelectableTextBlock FontFamily="Consolas" Text="{Binding $parent[local:Overview].DataGridInstall}" />
|
<SelectableTextBlock Text="{Binding $parent[local:Overview].DataGridInstall}" />
|
||||||
</Border>
|
</Border>
|
||||||
<TextBlock Text="Reference styles: " />
|
<TextBlock Text="Reference styles: " />
|
||||||
<Border Margin="0,16" Classes="CodeBlock">
|
<Border Margin="0,16" Classes="CodeBlock">
|
||||||
<SelectableTextBlock
|
<SelectableTextBlock
|
||||||
FontFamily="Consolas"
|
|
||||||
Text="{Binding $parent[local:Overview].DataGridStyle}"
|
Text="{Binding $parent[local:Overview].DataGridStyle}"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
</Border>
|
</Border>
|
||||||
@@ -398,12 +398,12 @@
|
|||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock Text="Install via nuget: " />
|
<TextBlock Text="Install via nuget: " />
|
||||||
<Border Margin="0,16" Classes="CodeBlock">
|
<Border Margin="0,16" Classes="CodeBlock">
|
||||||
<SelectableTextBlock FontFamily="Consolas" Text="{Binding $parent[local:Overview].TreeDataGridInstall}" />
|
<SelectableTextBlock Text="{Binding $parent[local:Overview].TreeDataGridInstall}" />
|
||||||
</Border>
|
</Border>
|
||||||
<TextBlock Text="Reference styles: " />
|
<TextBlock Text="Reference styles: " />
|
||||||
<Border Margin="0,16" Classes="CodeBlock">
|
<Border Margin="0,16" Classes="CodeBlock">
|
||||||
<SelectableTextBlock
|
<SelectableTextBlock
|
||||||
FontFamily="Consolas"
|
|
||||||
Text="{Binding $parent[local:Overview].TreeDataGridStyle}"
|
Text="{Binding $parent[local:Overview].TreeDataGridStyle}"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
</Border>
|
</Border>
|
||||||
@@ -413,12 +413,12 @@
|
|||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock Text="Install via nuget: " />
|
<TextBlock Text="Install via nuget: " />
|
||||||
<Border Margin="0,16" Classes="CodeBlock">
|
<Border Margin="0,16" Classes="CodeBlock">
|
||||||
<SelectableTextBlock FontFamily="Consolas" Text="{Binding $parent[local:Overview].DockInstall}" />
|
<SelectableTextBlock Text="{Binding $parent[local:Overview].DockInstall}" />
|
||||||
</Border>
|
</Border>
|
||||||
<TextBlock Text="Reference styles: " />
|
<TextBlock Text="Reference styles: " />
|
||||||
<Border Margin="0,16" Classes="CodeBlock">
|
<Border Margin="0,16" Classes="CodeBlock">
|
||||||
<SelectableTextBlock
|
<SelectableTextBlock
|
||||||
FontFamily="Consolas"
|
|
||||||
Text="{Binding $parent[local:Overview].DockStyle}"
|
Text="{Binding $parent[local:Overview].DockStyle}"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
</Border>
|
</Border>
|
||||||
@@ -428,12 +428,12 @@
|
|||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock Text="Install via nuget: " />
|
<TextBlock Text="Install via nuget: " />
|
||||||
<Border Margin="0,16" Classes="CodeBlock">
|
<Border Margin="0,16" Classes="CodeBlock">
|
||||||
<SelectableTextBlock FontFamily="Consolas" Text="{Binding $parent[local:Overview].TabaloniaInstall}" />
|
<SelectableTextBlock Text="{Binding $parent[local:Overview].TabaloniaInstall}" />
|
||||||
</Border>
|
</Border>
|
||||||
<TextBlock Text="Reference styles: " />
|
<TextBlock Text="Reference styles: " />
|
||||||
<Border Margin="0,16" Classes="CodeBlock">
|
<Border Margin="0,16" Classes="CodeBlock">
|
||||||
<SelectableTextBlock
|
<SelectableTextBlock
|
||||||
FontFamily="Consolas"
|
|
||||||
Text="{Binding $parent[local:Overview].TabaloniaStyle}"
|
Text="{Binding $parent[local:Overview].TabaloniaStyle}"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
</Border>
|
</Border>
|
||||||
@@ -443,12 +443,12 @@
|
|||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock Text="Install via nuget: " />
|
<TextBlock Text="Install via nuget: " />
|
||||||
<Border Margin="0,16" Classes="CodeBlock">
|
<Border Margin="0,16" Classes="CodeBlock">
|
||||||
<SelectableTextBlock FontFamily="Consolas" Text="{Binding $parent[local:Overview].AvaloniaEditInstall}" />
|
<SelectableTextBlock Text="{Binding $parent[local:Overview].AvaloniaEditInstall}" />
|
||||||
</Border>
|
</Border>
|
||||||
<TextBlock Text="Reference styles: " />
|
<TextBlock Text="Reference styles: " />
|
||||||
<Border Margin="0,16" Classes="CodeBlock">
|
<Border Margin="0,16" Classes="CodeBlock">
|
||||||
<SelectableTextBlock
|
<SelectableTextBlock
|
||||||
FontFamily="Consolas"
|
|
||||||
Text="{Binding $parent[local:Overview].AvaloniaEditStyle}"
|
Text="{Binding $parent[local:Overview].AvaloniaEditStyle}"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
</Border>
|
</Border>
|
||||||
|
|||||||
@@ -1,127 +0,0 @@
|
|||||||
<UserControl xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:vm="clr-namespace:Semi.Avalonia.Demo.ViewModels"
|
|
||||||
xmlns:converters="clr-namespace:Semi.Avalonia.Demo.Converters"
|
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
|
||||||
x:Class="Semi.Avalonia.Demo.Pages.TreeDataGridDemo"
|
|
||||||
x:CompileBindings="True"
|
|
||||||
x:DataType="vm:TreeDataGridDemoViewModel">
|
|
||||||
<UserControl.Resources>
|
|
||||||
<converters:FileIconConverter x:Key="FileIconConverter">
|
|
||||||
<StaticResource x:Key="file" ResourceKey="SemiIconFile" />
|
|
||||||
<StaticResource x:Key="folderOpen" ResourceKey="SemiIconFolderOpen" />
|
|
||||||
<StaticResource x:Key="folderClosed" ResourceKey="SemiIconFolder" />
|
|
||||||
</converters:FileIconConverter>
|
|
||||||
</UserControl.Resources>
|
|
||||||
<TabControl>
|
|
||||||
<TabItem Header="Songs">
|
|
||||||
<TreeDataGrid
|
|
||||||
AutoDragDropRows="True"
|
|
||||||
DataContext="{Binding SongsContext}"
|
|
||||||
Source="{Binding Songs}">
|
|
||||||
<TreeDataGrid.Resources>
|
|
||||||
<DataTemplate x:Key="AlbumCell" DataType="vm:SongViewModel">
|
|
||||||
<TextBlock
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Background="Transparent"
|
|
||||||
Text="{Binding Album}" />
|
|
||||||
</DataTemplate>
|
|
||||||
<DataTemplate x:Key="AlbumEditCell" DataType="vm:SongViewModel">
|
|
||||||
<ComboBox
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Classes="Small"
|
|
||||||
ItemsSource="{x:Static vm:Song.Albums}"
|
|
||||||
SelectedItem="{Binding Album}" />
|
|
||||||
</DataTemplate>
|
|
||||||
<DataTemplate x:Key="CommentsCell" DataType="vm:SongViewModel">
|
|
||||||
<TextBlock VerticalAlignment="Center" Text="{Binding CountOfComment}" />
|
|
||||||
</DataTemplate>
|
|
||||||
<DataTemplate x:Key="CommentsEditCell" DataType="vm:SongViewModel">
|
|
||||||
<NumericUpDown
|
|
||||||
Width="100"
|
|
||||||
HorizontalAlignment="Left"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Classes="Small"
|
|
||||||
Value="{Binding CountOfComment}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</TreeDataGrid.Resources>
|
|
||||||
<TreeDataGrid.Styles>
|
|
||||||
<Style Selector="TreeDataGrid TreeDataGridRow:nth-last-child(2n)">
|
|
||||||
<Setter Property="Background" Value="{DynamicResource SemiColorFill0}" />
|
|
||||||
</Style>
|
|
||||||
</TreeDataGrid.Styles>
|
|
||||||
</TreeDataGrid>
|
|
||||||
</TabItem>
|
|
||||||
<TabItem Header="Files">
|
|
||||||
<Grid DataContext="{Binding FilesContext}" RowDefinitions="Auto, *">
|
|
||||||
<DockPanel Margin="0,4" DockPanel.Dock="Top">
|
|
||||||
<ComboBox
|
|
||||||
DockPanel.Dock="Left"
|
|
||||||
ItemsSource="{Binding Drives}"
|
|
||||||
SelectedItem="{Binding SelectedDrive}" />
|
|
||||||
<TextBox
|
|
||||||
Margin="4,0,0,0"
|
|
||||||
VerticalContentAlignment="Center"
|
|
||||||
KeyDown="SelectedPath_KeyDown"
|
|
||||||
Text="{Binding SelectedPath, Mode=OneWay}" />
|
|
||||||
</DockPanel>
|
|
||||||
<TreeDataGrid
|
|
||||||
Name="fileViewer"
|
|
||||||
Grid.Row="1"
|
|
||||||
Source="{Binding Source}">
|
|
||||||
<TreeDataGrid.Resources>
|
|
||||||
|
|
||||||
<!-- Template for Name column cells -->
|
|
||||||
<DataTemplate x:Key="FileNameCell" DataType="vm:FileNodeViewModel">
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<PathIcon
|
|
||||||
Theme="{StaticResource InnerPathIcon}"
|
|
||||||
Margin="8,0">
|
|
||||||
<PathIcon.Data>
|
|
||||||
<MultiBinding Converter="{StaticResource FileIconConverter}">
|
|
||||||
<Binding Path="IsDirectory" />
|
|
||||||
<Binding Path="IsExpanded" />
|
|
||||||
</MultiBinding>
|
|
||||||
</PathIcon.Data>
|
|
||||||
</PathIcon>
|
|
||||||
<TextBlock VerticalAlignment="Center" Text="{Binding Name}" />
|
|
||||||
</StackPanel>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
<!-- Edit template for Name column cells -->
|
|
||||||
<DataTemplate x:Key="FileNameEditCell" DataType="vm:FileNodeViewModel">
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<Image Margin="0,0,4,0" VerticalAlignment="Center">
|
|
||||||
<Image.Source>
|
|
||||||
<MultiBinding Converter="{StaticResource FileIconConverter}">
|
|
||||||
<Binding Path="IsDirectory" />
|
|
||||||
<Binding Path="IsExpanded" />
|
|
||||||
</MultiBinding>
|
|
||||||
</Image.Source>
|
|
||||||
</Image>
|
|
||||||
<TextBox
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Classes="Small"
|
|
||||||
Text="{Binding Name}">
|
|
||||||
<TextBox.Styles>
|
|
||||||
<Style Selector="DataValidationErrors">
|
|
||||||
<Setter Property="Theme" Value="{DynamicResource TooltipDataValidationErrors}" />
|
|
||||||
</Style>
|
|
||||||
</TextBox.Styles>
|
|
||||||
</TextBox>
|
|
||||||
</StackPanel>
|
|
||||||
</DataTemplate>
|
|
||||||
</TreeDataGrid.Resources>
|
|
||||||
<TreeDataGrid.Styles>
|
|
||||||
<Style Selector="TreeDataGrid TreeDataGridRow:nth-child(2n)">
|
|
||||||
<Setter Property="Background" Value="{DynamicResource SemiColorFill0}" />
|
|
||||||
</Style>
|
|
||||||
</TreeDataGrid.Styles>
|
|
||||||
</TreeDataGrid>
|
|
||||||
</Grid>
|
|
||||||
</TabItem>
|
|
||||||
</TabControl>
|
|
||||||
</UserControl>
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Input;
|
|
||||||
using Semi.Avalonia.Demo.ViewModels;
|
|
||||||
|
|
||||||
namespace Semi.Avalonia.Demo.Pages;
|
|
||||||
|
|
||||||
public partial class TreeDataGridDemo : UserControl
|
|
||||||
{
|
|
||||||
public TreeDataGridDemo()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.DataContext = new TreeDataGridDemoViewModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SelectedPath_KeyDown(object? sender, KeyEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Key == Key.Enter)
|
|
||||||
{
|
|
||||||
var vm = DataContext as TreeDataGridDemoViewModel;
|
|
||||||
vm.FilesContext.SelectedPath = (sender as TextBox)!.Text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
<UserControl xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:vm="clr-namespace:Semi.Avalonia.Demo.ViewModels"
|
|
||||||
xmlns:pages="clr-namespace:Semi.Avalonia.Demo.Pages"
|
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
|
||||||
x:Class="Semi.Avalonia.Demo.Pages.VariablesDemo"
|
|
||||||
x:DataType="vm:VariablesDemoViewModel"
|
|
||||||
x:CompileBindings="True">
|
|
||||||
<Design.DataContext>
|
|
||||||
<vm:VariablesDemoViewModel />
|
|
||||||
</Design.DataContext>
|
|
||||||
<DataGrid
|
|
||||||
Margin="8"
|
|
||||||
CanUserReorderColumns="True"
|
|
||||||
CanUserResizeColumns="True"
|
|
||||||
CanUserSortColumns="True"
|
|
||||||
HeadersVisibility="All"
|
|
||||||
IsReadOnly="True"
|
|
||||||
ItemsSource="{Binding GridData}">
|
|
||||||
<DataGrid.Columns>
|
|
||||||
<DataGridTemplateColumn
|
|
||||||
Width="300"
|
|
||||||
x:DataType="vm:VariableItem"
|
|
||||||
Header="ResourceKey">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="vm:VariableItem">
|
|
||||||
<SelectableTextBlock
|
|
||||||
Margin="12,0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding ResourceKey}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
<DataGridTemplateColumn
|
|
||||||
Width="200"
|
|
||||||
x:DataType="vm:VariableItem"
|
|
||||||
Header="Type">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="vm:VariableItem">
|
|
||||||
<SelectableTextBlock
|
|
||||||
Margin="12,0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding Type.Name}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
<DataGridTemplateColumn
|
|
||||||
Width="200"
|
|
||||||
x:DataType="vm:VariableItem"
|
|
||||||
Header="Value">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="vm:VariableItem">
|
|
||||||
<SelectableTextBlock
|
|
||||||
Margin="12,0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding Value}"
|
|
||||||
TextWrapping="Wrap" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
<DataGridTemplateColumn
|
|
||||||
Width="*"
|
|
||||||
x:DataType="vm:VariableItem"
|
|
||||||
Header="Description">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="vm:VariableItem">
|
|
||||||
<SelectableTextBlock
|
|
||||||
Margin="12,0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding Description}"
|
|
||||||
TextWrapping="Wrap" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
<DataGridTemplateColumn
|
|
||||||
Width="100"
|
|
||||||
x:DataType="vm:VariableItem"
|
|
||||||
Header="CopyText"
|
|
||||||
SortMemberPath="Duration">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="vm:VariableItem">
|
|
||||||
<Button
|
|
||||||
Command="{Binding $parent[pages:VariablesDemo].Copy}"
|
|
||||||
CommandParameter="{Binding CopyText}"
|
|
||||||
Theme="{DynamicResource IconBorderlessButton}"
|
|
||||||
Content="{StaticResource SemiIconCopy}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
</DataGrid.Columns>
|
|
||||||
</DataGrid>
|
|
||||||
</UserControl>
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
using System.Threading.Tasks;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Semi.Avalonia.Demo.ViewModels;
|
|
||||||
|
|
||||||
namespace Semi.Avalonia.Demo.Pages;
|
|
||||||
|
|
||||||
public partial class VariablesDemo : UserControl
|
|
||||||
{
|
|
||||||
public VariablesDemo()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.DataContext = new VariablesDemoViewModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task Copy(object? o)
|
|
||||||
{
|
|
||||||
if (o is null) return;
|
|
||||||
var toplevel = TopLevel.GetTopLevel(this);
|
|
||||||
if (toplevel?.Clipboard is { } c)
|
|
||||||
{
|
|
||||||
await c.SetTextAsync(o.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)"/>
|
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)"/>
|
||||||
<PackageReference Include="Avalonia.Controls.ColorPicker" Version="$(AvaloniaVersion)"/>
|
<PackageReference Include="Avalonia.Controls.ColorPicker" Version="$(AvaloniaVersion)"/>
|
||||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="$(DataGridVersion)"/>
|
<!-- <PackageReference Include="Avalonia.Controls.DataGrid" Version="$(DataGridVersion)"/>-->
|
||||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||||
<PackageReference Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)">
|
<PackageReference Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)">
|
||||||
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\Semi.Avalonia\Semi.Avalonia.csproj"/>
|
<ProjectReference Include="..\..\src\Semi.Avalonia\Semi.Avalonia.csproj"/>
|
||||||
<ProjectReference Include="..\..\src\Semi.Avalonia.ColorPicker\Semi.Avalonia.ColorPicker.csproj"/>
|
<ProjectReference Include="..\..\src\Semi.Avalonia.ColorPicker\Semi.Avalonia.ColorPicker.csproj"/>
|
||||||
<ProjectReference Include="..\..\src\Semi.Avalonia.DataGrid\Semi.Avalonia.DataGrid.csproj"/>
|
<!-- <ProjectReference Include="..\..\src\Semi.Avalonia.DataGrid\Semi.Avalonia.DataGrid.csproj"/>-->
|
||||||
<ProjectReference Include="..\..\src\Semi.Avalonia.TreeDataGrid\Semi.Avalonia.TreeDataGrid.csproj"/>
|
<!-- <ProjectReference Include="..\..\src\Semi.Avalonia.TreeDataGrid\Semi.Avalonia.TreeDataGrid.csproj"/>-->
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,153 +0,0 @@
|
|||||||
<ResourceDictionary
|
|
||||||
xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:controls="clr-namespace:Semi.Avalonia.Demo.Controls"
|
|
||||||
xmlns:viewModels="clr-namespace:Semi.Avalonia.Demo.ViewModels"
|
|
||||||
xmlns:pages="clr-namespace:Semi.Avalonia.Demo.Pages"
|
|
||||||
x:CompileBindings="True"
|
|
||||||
x:DataType="viewModels:FunctionalColorGroupViewModel">
|
|
||||||
<ControlTheme x:Key="{x:Type controls:FunctionalColorGroupControl}" TargetType="controls:FunctionalColorGroupControl">
|
|
||||||
<Setter Property="Template">
|
|
||||||
<ControlTemplate TargetType="controls:FunctionalColorGroupControl">
|
|
||||||
<Grid RowDefinitions="Auto, *">
|
|
||||||
<SelectableTextBlock
|
|
||||||
Grid.Row="0"
|
|
||||||
Margin="0,16,0,0"
|
|
||||||
Classes="H3"
|
|
||||||
Text="{TemplateBinding Title}"
|
|
||||||
Theme="{DynamicResource TitleSelectableTextBlock}" />
|
|
||||||
<TabControl Grid.Row="1">
|
|
||||||
<TabItem Header="Light">
|
|
||||||
<DataGrid IsReadOnly="True" ItemsSource="{TemplateBinding LightColors}">
|
|
||||||
<DataGrid.Columns>
|
|
||||||
<DataGridTemplateColumn Width="70" Header="Color">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="viewModels:ColorItemViewModel">
|
|
||||||
<controls:ColorItemControl
|
|
||||||
Width="40"
|
|
||||||
Height="20"
|
|
||||||
Background="{Binding Brush}"
|
|
||||||
CornerRadius="3" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
<DataGridTemplateColumn Width="300" Header="ResourceKey">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="viewModels:ColorItemViewModel">
|
|
||||||
<SelectableTextBlock
|
|
||||||
Margin="12,0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding ResourceKey}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
<DataGridTemplateColumn Width="100" Header="Hex">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="viewModels:ColorItemViewModel">
|
|
||||||
<SelectableTextBlock
|
|
||||||
Margin="12,0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding Hex}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
<DataGridTemplateColumn Width="80" Header="Opacity">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="viewModels:ColorItemViewModel">
|
|
||||||
<SelectableTextBlock
|
|
||||||
Margin="12,0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding Brush.Opacity}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
<DataGridTextColumn
|
|
||||||
Width="*"
|
|
||||||
x:DataType="viewModels:ColorItemViewModel"
|
|
||||||
Binding="{Binding ColorDisplayName}"
|
|
||||||
CanUserSort="False"
|
|
||||||
Header="Description" />
|
|
||||||
<DataGridTemplateColumn Width="100" Header="CopyText">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="viewModels:ColorItemViewModel">
|
|
||||||
<Button
|
|
||||||
Command="{Binding $parent[pages:PaletteDemo].Copy}"
|
|
||||||
CommandParameter="{Binding CopyText}"
|
|
||||||
Theme="{DynamicResource IconBorderlessButton}"
|
|
||||||
Content="{StaticResource SemiIconCopy}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
</DataGrid.Columns>
|
|
||||||
</DataGrid>
|
|
||||||
</TabItem>
|
|
||||||
<TabItem Header="Dark">
|
|
||||||
<DataGrid IsReadOnly="True" ItemsSource="{TemplateBinding DarkColors}">
|
|
||||||
<DataGrid.Columns>
|
|
||||||
<DataGridTemplateColumn Width="70" Header="Color">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="viewModels:ColorItemViewModel">
|
|
||||||
<controls:ColorItemControl
|
|
||||||
Width="40"
|
|
||||||
Height="20"
|
|
||||||
Background="{Binding Brush}"
|
|
||||||
CornerRadius="3" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
<DataGridTemplateColumn Width="300" Header="ResourceKey">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="viewModels:ColorItemViewModel">
|
|
||||||
<SelectableTextBlock
|
|
||||||
Margin="12,0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding ResourceKey}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
<DataGridTemplateColumn Width="100" Header="Hex">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="viewModels:ColorItemViewModel">
|
|
||||||
<SelectableTextBlock
|
|
||||||
Margin="12,0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding Hex}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
<DataGridTemplateColumn Width="80" Header="Opacity">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="viewModels:ColorItemViewModel">
|
|
||||||
<SelectableTextBlock
|
|
||||||
Margin="12,0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding Brush.Opacity}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
<DataGridTextColumn
|
|
||||||
Width="*"
|
|
||||||
x:DataType="viewModels:ColorItemViewModel"
|
|
||||||
Binding="{Binding ColorDisplayName}"
|
|
||||||
CanUserSort="False"
|
|
||||||
Header="Description" />
|
|
||||||
<DataGridTemplateColumn Width="100" Header="CopyText">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="viewModels:ColorItemViewModel">
|
|
||||||
<Button
|
|
||||||
Command="{Binding $parent[pages:PaletteDemo].Copy}"
|
|
||||||
CommandParameter="{Binding CopyText}"
|
|
||||||
Theme="{DynamicResource IconBorderlessButton}"
|
|
||||||
Content="{StaticResource SemiIconCopy}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
</DataGrid.Columns>
|
|
||||||
</DataGrid>
|
|
||||||
</TabItem>
|
|
||||||
</TabControl>
|
|
||||||
</Grid>
|
|
||||||
</ControlTemplate>
|
|
||||||
</Setter>
|
|
||||||
</ControlTheme>
|
|
||||||
</ResourceDictionary>
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
<ResourceDictionary
|
|
||||||
xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:controls="clr-namespace:Semi.Avalonia.Demo.Controls"
|
|
||||||
xmlns:viewModels="clr-namespace:Semi.Avalonia.Demo.ViewModels"
|
|
||||||
xmlns:pages="clr-namespace:Semi.Avalonia.Demo.Pages"
|
|
||||||
x:CompileBindings="True"
|
|
||||||
x:DataType="viewModels:ShadowGroupViewModel">
|
|
||||||
<ControlTheme x:Key="{x:Type controls:ShadowGroupControl}" TargetType="controls:ShadowGroupControl">
|
|
||||||
<Setter Property="Template">
|
|
||||||
<ControlTemplate TargetType="controls:ShadowGroupControl">
|
|
||||||
<Grid RowDefinitions="Auto, *">
|
|
||||||
<SelectableTextBlock
|
|
||||||
Grid.Row="0"
|
|
||||||
Margin="0,16,0,0"
|
|
||||||
Classes="H3"
|
|
||||||
Text="{TemplateBinding Title}"
|
|
||||||
Theme="{DynamicResource TitleSelectableTextBlock}" />
|
|
||||||
<TabControl Grid.Row="1">
|
|
||||||
<TabItem Header="Light">
|
|
||||||
<DataGrid IsReadOnly="True" ItemsSource="{TemplateBinding LightShadows}">
|
|
||||||
<DataGrid.Columns>
|
|
||||||
<DataGridTemplateColumn Width="300" Header="ResourceKey">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="viewModels:ShadowItemViewModel">
|
|
||||||
<SelectableTextBlock
|
|
||||||
Margin="12,0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding ResourceKey}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
<DataGridTemplateColumn Width="300" Header="BoxShadows">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="viewModels:ShadowItemViewModel">
|
|
||||||
<SelectableTextBlock
|
|
||||||
Margin="12,0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding BoxShadowValue}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
<DataGridTextColumn
|
|
||||||
Width="*"
|
|
||||||
x:DataType="viewModels:ShadowItemViewModel"
|
|
||||||
Binding="{Binding ShadowDisplayName}"
|
|
||||||
CanUserSort="False"
|
|
||||||
Header="Description" />
|
|
||||||
<DataGridTemplateColumn Width="100" Header="CopyText">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="viewModels:ShadowItemViewModel">
|
|
||||||
<Button
|
|
||||||
Command="{Binding $parent[pages:PaletteDemo].Copy}"
|
|
||||||
CommandParameter="{Binding CopyText}"
|
|
||||||
Theme="{DynamicResource IconBorderlessButton}"
|
|
||||||
Content="{StaticResource SemiIconCopy}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
</DataGrid.Columns>
|
|
||||||
</DataGrid>
|
|
||||||
</TabItem>
|
|
||||||
<TabItem Header="Dark">
|
|
||||||
<DataGrid IsReadOnly="True" ItemsSource="{TemplateBinding DarkShadows}">
|
|
||||||
<DataGrid.Columns>
|
|
||||||
<DataGridTemplateColumn Width="300" Header="ResourceKey">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="viewModels:ShadowItemViewModel">
|
|
||||||
<SelectableTextBlock
|
|
||||||
Margin="12,0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding ResourceKey}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
<DataGridTemplateColumn Width="300" Header="BoxShadows">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="viewModels:ShadowItemViewModel">
|
|
||||||
<SelectableTextBlock
|
|
||||||
Margin="12,0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{Binding BoxShadowValue}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
<DataGridTextColumn
|
|
||||||
Width="*"
|
|
||||||
x:DataType="viewModels:ShadowItemViewModel"
|
|
||||||
Binding="{Binding ShadowDisplayName}"
|
|
||||||
CanUserSort="False"
|
|
||||||
Header="Description" />
|
|
||||||
<DataGridTemplateColumn Width="100" Header="CopyText">
|
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
|
||||||
<DataTemplate DataType="viewModels:ShadowItemViewModel">
|
|
||||||
<Button
|
|
||||||
Command="{Binding $parent[pages:PaletteDemo].Copy}"
|
|
||||||
CommandParameter="{Binding CopyText}"
|
|
||||||
Theme="{DynamicResource IconBorderlessButton}"
|
|
||||||
Content="{StaticResource SemiIconCopy}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
</DataGrid.Columns>
|
|
||||||
</DataGrid>
|
|
||||||
</TabItem>
|
|
||||||
</TabControl>
|
|
||||||
</Grid>
|
|
||||||
</ControlTemplate>
|
|
||||||
</Setter>
|
|
||||||
</ControlTheme>
|
|
||||||
</ResourceDictionary>
|
|
||||||
@@ -2,8 +2,6 @@
|
|||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceInclude Source="ColorDetailControl.axaml" />
|
<ResourceInclude Source="ColorDetailControl.axaml" />
|
||||||
<ResourceInclude Source="ColorItemControl.axaml" />
|
<ResourceInclude Source="ColorItemControl.axaml" />
|
||||||
<ResourceInclude Source="FunctionalColorGroupControl.axaml" />
|
|
||||||
<ResourceInclude Source="ShadowGroupControl.axaml" />
|
|
||||||
<ResourceInclude Source="ToggleSwitch.axaml" />
|
<ResourceInclude Source="ToggleSwitch.axaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -1,154 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Linq;
|
|
||||||
using Avalonia.Collections;
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
using CommunityToolkit.Mvvm.Input;
|
|
||||||
|
|
||||||
namespace Semi.Avalonia.Demo.ViewModels;
|
|
||||||
|
|
||||||
public class DataGridDemoViewModel : ObservableObject
|
|
||||||
{
|
|
||||||
public ObservableCollection<Song> GridData1 { get; set; }
|
|
||||||
|
|
||||||
public DataGridCollectionView GridData2 { get; set; }
|
|
||||||
|
|
||||||
public ObservableCollection<SongViewModel> GridData3 { get; set; }
|
|
||||||
|
|
||||||
public RelayCommand AddCommand { get; set; }
|
|
||||||
|
|
||||||
public DataGridDemoViewModel()
|
|
||||||
{
|
|
||||||
GridData1 = new ObservableCollection<Song>(Song.Songs);
|
|
||||||
GridData2 = new DataGridCollectionView(Song.Songs);
|
|
||||||
GridData2.GroupDescriptions.Add(new DataGridPathGroupDescription("Album"));
|
|
||||||
GridData3 = new ObservableCollection<SongViewModel>(Song.Songs.Take(10).Select(a => new SongViewModel()
|
|
||||||
{
|
|
||||||
Title = a.Title,
|
|
||||||
Artist = a.Artist,
|
|
||||||
Album = a.Album,
|
|
||||||
CountOfComment = a.CountOfComment,
|
|
||||||
IsSelected = false
|
|
||||||
}));
|
|
||||||
AddCommand = new RelayCommand(Add);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Add()
|
|
||||||
{
|
|
||||||
GridData3.Add(new SongViewModel());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Song
|
|
||||||
{
|
|
||||||
public string? Title { get; set; }
|
|
||||||
public string? Artist { get; set; }
|
|
||||||
public TimeSpan? Duration { get; set; }
|
|
||||||
public string? Album { get; set; }
|
|
||||||
public int CountOfComment { get; set; }
|
|
||||||
public string Url { get; set; }
|
|
||||||
|
|
||||||
public Song(string title, string artist, int m, int s, string album, int countOfComment, int netEaseId)
|
|
||||||
{
|
|
||||||
Title = title;
|
|
||||||
Artist = artist;
|
|
||||||
Duration = new TimeSpan(0, m, s);
|
|
||||||
Album = album;
|
|
||||||
CountOfComment = countOfComment;
|
|
||||||
Url = $"https://music.163.com/song?id={netEaseId}";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<string> Albums =>
|
|
||||||
[
|
|
||||||
"A.S.I.A",
|
|
||||||
"饕餮人间",
|
|
||||||
"七步咙咚呛",
|
|
||||||
"大惊小怪",
|
|
||||||
"The ONE",
|
|
||||||
"以梦为马 (壮志骄阳版)",
|
|
||||||
"emo了",
|
|
||||||
"一眼万年",
|
|
||||||
"冲刺吧",
|
|
||||||
"爱的赏味期限",
|
|
||||||
"COSMIC ANTHEM / 手紙",
|
|
||||||
"世界晚安",
|
|
||||||
"明年也要好好长大",
|
|
||||||
"320万年前",
|
|
||||||
"W.O.R.L.D."
|
|
||||||
];
|
|
||||||
|
|
||||||
public static List<Song> Songs =>
|
|
||||||
[
|
|
||||||
new("好肚有肚(feat.李玲玉)", "熊猫堂ProducePandas", 2, 50, "A.S.I.A", 730, 1487039339),
|
|
||||||
new("荒诞秀", "熊猫堂ProducePandas", 3, 15, "A.S.I.A", 639, 1487037601),
|
|
||||||
new("长大", "熊猫堂ProducePandas", 4, 6, "A.S.I.A", 1114, 1487037690),
|
|
||||||
new("招财猫(feat.纪粹希(G-Tracy))", "熊猫堂ProducePandas", 3, 37, "A.S.I.A", 361, 1487039632),
|
|
||||||
new("千转", "熊猫堂ProducePandas", 4, 0, "A.S.I.A", 1115, 1477312398),
|
|
||||||
new("辣辣辣", "熊猫堂ProducePandas", 3, 24, "A.S.I.A", 1873, 1465043716),
|
|
||||||
new("碎碎念", "熊猫堂ProducePandas", 3, 25, "A.S.I.A", 676, 1474142064),
|
|
||||||
new("盘他", "熊猫堂ProducePandas", 2, 16, "A.S.I.A", 365, 1481652786),
|
|
||||||
new("Na Na Na", "熊猫堂ProducePandas", 3, 26, "A.S.I.A", 312, 1469022662),
|
|
||||||
new("Indigo", "熊猫堂ProducePandas", 3, 15, "A.S.I.A", 137, 1487039517),
|
|
||||||
new("饕餮人间", "熊猫堂ProducePandas", 3, 20, "饕餮人间", 1295, 1499584605),
|
|
||||||
new("七步咙咚呛", "熊猫堂ProducePandas", 3, 10, "七步咙咚呛", 175, 1809095152),
|
|
||||||
new("大惊小怪", "熊猫堂ProducePandas", 3, 32, "大惊小怪", 10420, 1847477425),
|
|
||||||
new("工具人", "熊猫堂ProducePandas", 2, 46, "大惊小怪", 1135, 1847476499),
|
|
||||||
new("以梦为马", "熊猫堂ProducePandas", 4, 19, "大惊小怪", 18361, 1836034373),
|
|
||||||
new("以梦为马(Piano Version)", "熊猫堂ProducePandas", 3, 4, "大惊小怪", 570, 1847477423),
|
|
||||||
new("The ONE", "熊猫堂ProducePandas", 2, 58, "The ONE", 1508, 1864329424),
|
|
||||||
new("The ONE(日文版)", "熊猫堂ProducePandas", 2, 57, "The ONE", 385, 1864329429),
|
|
||||||
new("以梦为马 (壮志骄阳版)", "熊猫堂ProducePandas", 4, 19, "以梦为马 (壮志骄阳版)", 161, 1865138896),
|
|
||||||
new("New Horse", "熊猫堂ProducePandas", 2, 30, "emo了", 643, 1887021307),
|
|
||||||
new("不例外", "熊猫堂ProducePandas", 3, 31, "emo了", 1818, 1887022665),
|
|
||||||
new("满意", "熊猫堂ProducePandas", 4, 32, "emo了", 1081, 1882433472),
|
|
||||||
new("就算与全世界为敌也要跟你在一起", "熊猫堂ProducePandas", 3, 32, "emo了", 2119, 1881759960),
|
|
||||||
new("The ONE", "熊猫堂ProducePandas", 2, 58, "emo了", 67, 1887022648),
|
|
||||||
new("口香糖", "熊猫堂ProducePandas", 3, 10, "emo了", 2181, 1885502254),
|
|
||||||
new("Suuuuuuper Mario", "熊猫堂ProducePandas", 3, 32, "emo了", 1010, 1887021318),
|
|
||||||
new("饕餮人间", "熊猫堂ProducePandas", 3, 22, "emo了", 109, 1887021320),
|
|
||||||
new("以梦为马 (壮志骄阳版)", "熊猫堂ProducePandas", 4, 21, "emo了", 34, 1887022666),
|
|
||||||
new("The ONE(日文版)", "熊猫堂ProducePandas", 2, 57, "emo了", 27, 1887022646),
|
|
||||||
new("满意(DJheap九天版)", "熊猫堂ProducePandas", 4, 31, "emo了", 31, 1901605941),
|
|
||||||
new("一眼万年", "熊猫堂ProducePandas", 3, 54, "一眼万年", 20, 1922599361),
|
|
||||||
new("冲刺", "熊猫堂ProducePandas", 3, 49, "冲刺吧", 1006, 1932878194),
|
|
||||||
new("滴答滴", "熊猫堂ProducePandas", 2, 30, "爱的赏味期限", 86, 1957515790),
|
|
||||||
new("热带季风", "熊猫堂ProducePandas", 2, 45, "爱的赏味期限", 212, 1957514964),
|
|
||||||
new("渣", "熊猫堂ProducePandas", 3, 28, "爱的赏味期限", 22, 1957514965),
|
|
||||||
new("独特", "熊猫堂ProducePandas", 3, 33, "爱的赏味期限", 62, 1957514966),
|
|
||||||
new("雨后", "熊猫堂ProducePandas", 4, 15, "爱的赏味期限", 23, 1957514967),
|
|
||||||
new("然后然后", "熊猫堂ProducePandas", 3, 50, "爱的赏味期限", 108, 1957514968),
|
|
||||||
new("丢", "熊猫堂ProducePandas", 3, 26, "爱的赏味期限", 30, 1957515792),
|
|
||||||
new("热带疾风(FACEVOID桃心连哥 Remix)", "熊猫堂ProducePandas", 3, 23, "爱的赏味期限", 55, 1957515793),
|
|
||||||
new("COSMIC ANTHEM -Japanese Ver.-", "熊猫堂ProducePandas", 3, 11, "COSMIC ANTHEM / 手紙", 0, 1977171493),
|
|
||||||
new("手紙 (「長大-You Raise Me Up-」-Japanese Ver.-)", "熊猫堂ProducePandas", 4, 11, "COSMIC ANTHEM / 手紙", 0,
|
|
||||||
1977171494),
|
|
||||||
new("COSMIC ANTHEM -Chinese Ver.-", "熊猫堂ProducePandas", 3, 31, "COSMIC ANTHEM / 手紙", 0, 1977172202),
|
|
||||||
new("世界晚安", "熊猫堂ProducePandas", 2, 59, "世界晚安", 652, 1985063377),
|
|
||||||
new("世界晚安(泰文版)", "熊猫堂ProducePandas", 2, 59, "世界晚安", 134, 1987842504),
|
|
||||||
new("世界晚安(钢琴版)", "熊猫堂ProducePandas", 3, 2, "世界晚安", 76, 1990475933),
|
|
||||||
new("世界晚安(泰文钢琴版)", "熊猫堂ProducePandas", 3, 2, "世界晚安", 29, 1990475934),
|
|
||||||
new("世界晚安(DJ沈念版)", "熊猫堂ProducePandas", 3, 9, "世界晚安", 34, 2014263184),
|
|
||||||
new("世界晚安(钢琴配乐)", "熊猫堂ProducePandas", 2, 59, "世界晚安", 11, 2014263185),
|
|
||||||
new("明年也要好好长大", "熊猫堂ProducePandas", 3, 12, "明年也要好好长大", 0, 2010515162),
|
|
||||||
new("320万年前(DJ沈念版)", "熊猫堂ProducePandas", 3, 21, "320万年前", 8, 2055888636),
|
|
||||||
new("320万年前", "熊猫堂ProducePandas", 3, 7, "W.O.R.L.D.", 329, 2049770469),
|
|
||||||
new("隐德来希", "熊猫堂ProducePandas", 3, 3, "W.O.R.L.D.", 594, 2061317924),
|
|
||||||
new("孔明", "熊猫堂ProducePandas", 3, 59, "W.O.R.L.D.", 91, 2063175274),
|
|
||||||
new("锦鲤卟噜噜", "熊猫堂ProducePandas", 3, 5, "W.O.R.L.D.", 67, 2059208262),
|
|
||||||
new("指鹿为马", "熊猫堂ProducePandas", 3, 12, "W.O.R.L.D.", 74, 2063175272),
|
|
||||||
new("热带季风Remix", "熊猫堂ProducePandas", 3, 22, "W.O.R.L.D.", 23, 2063173319),
|
|
||||||
new("加州梦境", "熊猫堂ProducePandas", 2, 56, "W.O.R.L.D.", 1662, 2063173324),
|
|
||||||
new("渐近自由", "熊猫堂ProducePandas", 4, 19, "W.O.R.L.D.", 124, 2063173321),
|
|
||||||
new("世界所有的烂漫", "熊猫堂ProducePandas", 3, 30, "W.O.R.L.D.", 335, 2053388775)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public partial class SongViewModel : ObservableObject
|
|
||||||
{
|
|
||||||
[ObservableProperty] private string? _title;
|
|
||||||
[ObservableProperty] private string? _artist;
|
|
||||||
[ObservableProperty] private string? _album;
|
|
||||||
[ObservableProperty] private int _countOfComment;
|
|
||||||
[ObservableProperty] private bool? _isSelected;
|
|
||||||
}
|
|
||||||
@@ -1,364 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Controls.Models.TreeDataGrid;
|
|
||||||
using Avalonia.Controls.Selection;
|
|
||||||
using Avalonia.Threading;
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
|
|
||||||
namespace Semi.Avalonia.Demo.ViewModels;
|
|
||||||
|
|
||||||
public partial class FilesPageViewModel : ObservableObject
|
|
||||||
{
|
|
||||||
public IList<string> Drives { get; }
|
|
||||||
public HierarchicalTreeDataGridSource<FileNodeViewModel> Source { get; }
|
|
||||||
[ObservableProperty] private string _selectedDrive;
|
|
||||||
[ObservableProperty] private string? _selectedPath;
|
|
||||||
[ObservableProperty] private FileNodeViewModel? _root;
|
|
||||||
|
|
||||||
partial void OnSelectedDriveChanged(string value)
|
|
||||||
{
|
|
||||||
Root = new FileNodeViewModel(value, true, true);
|
|
||||||
if (Source is not null)
|
|
||||||
{
|
|
||||||
Source.Items = [Root];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
partial void OnSelectedPathChanged(string? value)
|
|
||||||
{
|
|
||||||
SetSelectedPath(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FilesPageViewModel()
|
|
||||||
{
|
|
||||||
Drives = DriveInfo.GetDrives().Select(x => x.Name).ToList();
|
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
||||||
{
|
|
||||||
SelectedDrive = @"C:\";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SelectedDrive = Drives.FirstOrDefault() ?? "/";
|
|
||||||
}
|
|
||||||
|
|
||||||
Source = new HierarchicalTreeDataGridSource<FileNodeViewModel>(Array.Empty<FileNodeViewModel>())
|
|
||||||
{
|
|
||||||
Columns =
|
|
||||||
{
|
|
||||||
new CheckBoxColumn<FileNodeViewModel>(
|
|
||||||
null,
|
|
||||||
x => x.IsChecked,
|
|
||||||
(o, v) => o.IsChecked = v,
|
|
||||||
options: new CheckBoxColumnOptions<FileNodeViewModel>
|
|
||||||
{
|
|
||||||
CanUserResizeColumn = false,
|
|
||||||
}),
|
|
||||||
new HierarchicalExpanderColumn<FileNodeViewModel>(
|
|
||||||
new TemplateColumn<FileNodeViewModel>(
|
|
||||||
"Name",
|
|
||||||
"FileNameCell",
|
|
||||||
"FileNameEditCell",
|
|
||||||
new GridLength(1, GridUnitType.Star),
|
|
||||||
new TemplateColumnOptions<FileNodeViewModel>
|
|
||||||
{
|
|
||||||
CompareAscending = FileNodeViewModel.SortAscending(vm => vm.Name),
|
|
||||||
CompareDescending = FileNodeViewModel.SortDescending(vm => vm.Name),
|
|
||||||
IsTextSearchEnabled = true,
|
|
||||||
TextSearchValueSelector = vm => vm.Name
|
|
||||||
}),
|
|
||||||
vm => vm.Children,
|
|
||||||
vm => vm.HasChildren,
|
|
||||||
vm => vm.IsExpanded),
|
|
||||||
new TextColumn<FileNodeViewModel, long?>(
|
|
||||||
"Size",
|
|
||||||
vm => vm.Size,
|
|
||||||
options: new TextColumnOptions<FileNodeViewModel>
|
|
||||||
{
|
|
||||||
CompareAscending = FileNodeViewModel.SortAscending(x => x.Size),
|
|
||||||
CompareDescending = FileNodeViewModel.SortDescending(x => x.Size),
|
|
||||||
}),
|
|
||||||
new TextColumn<FileNodeViewModel, DateTimeOffset?>(
|
|
||||||
"Modified",
|
|
||||||
x => x.Modified,
|
|
||||||
options: new TextColumnOptions<FileNodeViewModel>
|
|
||||||
{
|
|
||||||
CompareAscending = FileNodeViewModel.SortAscending(x => x.Modified),
|
|
||||||
CompareDescending = FileNodeViewModel.SortDescending(x => x.Modified),
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Source.RowSelection!.SingleSelect = false;
|
|
||||||
Source.RowSelection.SelectionChanged += SelectionChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SelectionChanged(object? sender, TreeSelectionModelSelectionChangedEventArgs<FileNodeViewModel> e)
|
|
||||||
{
|
|
||||||
var selectedPath = Source.RowSelection?.SelectedItem?.Path;
|
|
||||||
this.SetProperty(ref _selectedPath, selectedPath, nameof(SelectedPath));
|
|
||||||
|
|
||||||
foreach (var i in e.DeselectedItems)
|
|
||||||
Trace.WriteLine($"Deselected '{i?.Path}'");
|
|
||||||
foreach (var i in e.SelectedItems)
|
|
||||||
Trace.WriteLine($"Selected '{i?.Path}'");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetSelectedPath(string? value)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(value))
|
|
||||||
{
|
|
||||||
Source.RowSelection!.Clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var path = value;
|
|
||||||
var components = new Stack<string>();
|
|
||||||
DirectoryInfo? d = null;
|
|
||||||
|
|
||||||
if (File.Exists(path))
|
|
||||||
{
|
|
||||||
var f = new FileInfo(path);
|
|
||||||
components.Push(f.Name);
|
|
||||||
d = f.Directory;
|
|
||||||
}
|
|
||||||
else if (Directory.Exists(path))
|
|
||||||
{
|
|
||||||
d = new DirectoryInfo(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (d is not null)
|
|
||||||
{
|
|
||||||
components.Push(d.Name);
|
|
||||||
d = d.Parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
var index = IndexPath.Unselected;
|
|
||||||
|
|
||||||
if (components.Count > 0)
|
|
||||||
{
|
|
||||||
var drive = components.Pop();
|
|
||||||
var driveIndex = Drives.FindIndex(x => string.Equals(x, drive, StringComparison.OrdinalIgnoreCase));
|
|
||||||
|
|
||||||
if (driveIndex >= 0)
|
|
||||||
SelectedDrive = Drives[driveIndex];
|
|
||||||
|
|
||||||
FileNodeViewModel? node = _root;
|
|
||||||
index = new IndexPath(0);
|
|
||||||
|
|
||||||
while (node is not null && components.Count > 0)
|
|
||||||
{
|
|
||||||
node.IsExpanded = true;
|
|
||||||
|
|
||||||
var component = components.Pop();
|
|
||||||
var i = node.Children.FindIndex(x => string.Equals(x.Name, component, StringComparison.OrdinalIgnoreCase));
|
|
||||||
node = i >= 0 ? node.Children[i] : null;
|
|
||||||
index = i >= 0 ? index.Append(i) : default;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Source.Items = [Root];
|
|
||||||
Source.RowSelection!.SelectedIndex = index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public partial class FileNodeViewModel : ObservableObject, IEditableObject
|
|
||||||
{
|
|
||||||
[ObservableProperty] private string _path;
|
|
||||||
[ObservableProperty] private string _name;
|
|
||||||
private string? _undoName;
|
|
||||||
[ObservableProperty] private long? _size;
|
|
||||||
[ObservableProperty] private DateTimeOffset? _modified;
|
|
||||||
private FileSystemWatcher? _watcher;
|
|
||||||
private ObservableCollection<FileNodeViewModel>? _children;
|
|
||||||
[ObservableProperty] private bool _hasChildren = true;
|
|
||||||
[ObservableProperty] private bool _isExpanded;
|
|
||||||
|
|
||||||
public FileNodeViewModel(string path, bool isDirectory, bool isRoot = false)
|
|
||||||
{
|
|
||||||
Path = path;
|
|
||||||
Name = isRoot ? path : System.IO.Path.GetFileName(Path);
|
|
||||||
IsExpanded = isRoot;
|
|
||||||
IsDirectory = isDirectory;
|
|
||||||
HasChildren = isDirectory;
|
|
||||||
|
|
||||||
if (!isDirectory)
|
|
||||||
{
|
|
||||||
var info = new FileInfo(path);
|
|
||||||
Size = info.Length;
|
|
||||||
Modified = info.LastWriteTimeUtc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsChecked { get; set; }
|
|
||||||
public bool IsDirectory { get; }
|
|
||||||
public IReadOnlyList<FileNodeViewModel> Children => _children ??= LoadChildren();
|
|
||||||
|
|
||||||
private ObservableCollection<FileNodeViewModel> LoadChildren()
|
|
||||||
{
|
|
||||||
if (!IsDirectory)
|
|
||||||
{
|
|
||||||
throw new NotSupportedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new EnumerationOptions { IgnoreInaccessible = true };
|
|
||||||
var result = new ObservableCollection<FileNodeViewModel>();
|
|
||||||
|
|
||||||
foreach (var d in Directory.EnumerateDirectories(Path, "*", options))
|
|
||||||
{
|
|
||||||
result.Add(new FileNodeViewModel(d, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var f in Directory.EnumerateFiles(Path, "*", options))
|
|
||||||
{
|
|
||||||
result.Add(new FileNodeViewModel(f, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
_watcher = new FileSystemWatcher
|
|
||||||
{
|
|
||||||
Path = Path,
|
|
||||||
NotifyFilter = NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite,
|
|
||||||
};
|
|
||||||
|
|
||||||
_watcher.Changed += OnChanged;
|
|
||||||
_watcher.Created += OnCreated;
|
|
||||||
_watcher.Deleted += OnDeleted;
|
|
||||||
_watcher.Renamed += OnRenamed;
|
|
||||||
_watcher.EnableRaisingEvents = true;
|
|
||||||
|
|
||||||
if (result.Count == 0)
|
|
||||||
HasChildren = false;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Comparison<FileNodeViewModel?> SortAscending<T>(Func<FileNodeViewModel, T> selector)
|
|
||||||
{
|
|
||||||
return (x, y) =>
|
|
||||||
{
|
|
||||||
if (x is null && y is null)
|
|
||||||
return 0;
|
|
||||||
else if (x is null)
|
|
||||||
return -1;
|
|
||||||
else if (y is null)
|
|
||||||
return 1;
|
|
||||||
if (x.IsDirectory == y.IsDirectory)
|
|
||||||
return Comparer<T>.Default.Compare(selector(x), selector(y));
|
|
||||||
else if (x.IsDirectory)
|
|
||||||
return -1;
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Comparison<FileNodeViewModel?> SortDescending<T>(Func<FileNodeViewModel, T> selector)
|
|
||||||
{
|
|
||||||
return (x, y) =>
|
|
||||||
{
|
|
||||||
if (x is null && y is null)
|
|
||||||
return 0;
|
|
||||||
else if (x is null)
|
|
||||||
return 1;
|
|
||||||
else if (y is null)
|
|
||||||
return -1;
|
|
||||||
if (x.IsDirectory == y.IsDirectory)
|
|
||||||
return Comparer<T>.Default.Compare(selector(y), selector(x));
|
|
||||||
else if (x.IsDirectory)
|
|
||||||
return -1;
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
void IEditableObject.BeginEdit() => _undoName = _name;
|
|
||||||
void IEditableObject.CancelEdit() => _name = _undoName!;
|
|
||||||
void IEditableObject.EndEdit() => _undoName = null;
|
|
||||||
|
|
||||||
private void OnChanged(object sender, FileSystemEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.ChangeType == WatcherChangeTypes.Changed && File.Exists(e.FullPath))
|
|
||||||
{
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
|
||||||
{
|
|
||||||
foreach (var child in _children!)
|
|
||||||
{
|
|
||||||
if (child.Path == e.FullPath)
|
|
||||||
{
|
|
||||||
if (!child.IsDirectory)
|
|
||||||
{
|
|
||||||
var info = new FileInfo(e.FullPath);
|
|
||||||
child.Size = info.Length;
|
|
||||||
child.Modified = info.LastWriteTimeUtc;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnCreated(object sender, FileSystemEventArgs e)
|
|
||||||
{
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
|
||||||
{
|
|
||||||
var node = new FileNodeViewModel(
|
|
||||||
e.FullPath,
|
|
||||||
File.GetAttributes(e.FullPath).HasFlag(FileAttributes.Directory));
|
|
||||||
_children!.Add(node);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnDeleted(object sender, FileSystemEventArgs e)
|
|
||||||
{
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
|
||||||
{
|
|
||||||
for (var i = 0; i < _children!.Count; ++i)
|
|
||||||
{
|
|
||||||
if (_children[i].Path == e.FullPath)
|
|
||||||
{
|
|
||||||
_children.RemoveAt(i);
|
|
||||||
Debug.WriteLine($"Removed {e.FullPath}");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnRenamed(object sender, RenamedEventArgs e)
|
|
||||||
{
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
|
||||||
{
|
|
||||||
foreach (var child in _children!)
|
|
||||||
{
|
|
||||||
if (child.Path == e.OldFullPath)
|
|
||||||
{
|
|
||||||
child.Path = e.FullPath;
|
|
||||||
child.Name = e.Name ?? string.Empty;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static class ListExtensions
|
|
||||||
{
|
|
||||||
public static int FindIndex<T>(this IEnumerable<T> source, Func<T, bool> predicate)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
foreach (var item in source)
|
|
||||||
{
|
|
||||||
if (predicate(item))
|
|
||||||
return i;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Linq;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Controls.Models.TreeDataGrid;
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
|
|
||||||
namespace Semi.Avalonia.Demo.ViewModels;
|
|
||||||
|
|
||||||
public class SongsPageViewModel : ObservableObject
|
|
||||||
{
|
|
||||||
public FlatTreeDataGridSource<SongViewModel> Songs { get; }
|
|
||||||
|
|
||||||
public SongsPageViewModel()
|
|
||||||
{
|
|
||||||
var songs = new ObservableCollection<SongViewModel>(Song.Songs.Select(a => new SongViewModel()
|
|
||||||
{
|
|
||||||
Title = a.Title,
|
|
||||||
Artist = a.Artist,
|
|
||||||
Album = a.Album,
|
|
||||||
CountOfComment = a.CountOfComment,
|
|
||||||
IsSelected = false
|
|
||||||
}));
|
|
||||||
|
|
||||||
Songs = new FlatTreeDataGridSource<SongViewModel>(songs)
|
|
||||||
{
|
|
||||||
Columns =
|
|
||||||
{
|
|
||||||
new CheckBoxColumn<SongViewModel>(
|
|
||||||
"IsSelected",
|
|
||||||
a => a.IsSelected,
|
|
||||||
(model, b) => { model.IsSelected = b; },
|
|
||||||
new GridLength(108, GridUnitType.Pixel)),
|
|
||||||
new TextColumn<SongViewModel, string>(
|
|
||||||
"Title",
|
|
||||||
a => a.Title,
|
|
||||||
(o, a) => o.Title = a,
|
|
||||||
new GridLength(6, GridUnitType.Star)),
|
|
||||||
new TextColumn<SongViewModel, string>("Artist",
|
|
||||||
a => a.Artist,
|
|
||||||
(o, a) => o.Artist = a,
|
|
||||||
new GridLength(6, GridUnitType.Star)),
|
|
||||||
new TemplateColumn<SongViewModel>("Album",
|
|
||||||
"AlbumCell",
|
|
||||||
"AlbumEditCell",
|
|
||||||
new GridLength(6, GridUnitType.Star)),
|
|
||||||
new TemplateColumn<SongViewModel>(
|
|
||||||
"Comments",
|
|
||||||
"CommentsCell",
|
|
||||||
"CommentsEditCell",
|
|
||||||
new GridLength(6, GridUnitType.Star)),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
|
|
||||||
namespace Semi.Avalonia.Demo.ViewModels;
|
|
||||||
|
|
||||||
public class TreeDataGridDemoViewModel : ObservableObject
|
|
||||||
{
|
|
||||||
public SongsPageViewModel SongsContext { get; } = new();
|
|
||||||
public FilesPageViewModel FilesContext { get; } = new();
|
|
||||||
}
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Collections;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Media;
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
using Semi.Avalonia.Tokens;
|
|
||||||
|
|
||||||
namespace Semi.Avalonia.Demo.ViewModels;
|
|
||||||
|
|
||||||
public class VariablesDemoViewModel : ObservableObject
|
|
||||||
{
|
|
||||||
public DataGridCollectionView GridData { get; set; }
|
|
||||||
|
|
||||||
public VariablesDemoViewModel()
|
|
||||||
{
|
|
||||||
IResourceDictionary dictionary = new Variables();
|
|
||||||
foreach (var token in Tokens)
|
|
||||||
{
|
|
||||||
if (token.ResourceKey is not null && dictionary.TryGetValue(token.ResourceKey, out var value))
|
|
||||||
{
|
|
||||||
token.Type = value?.GetType();
|
|
||||||
token.Value = GetValueString(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GridData = new DataGridCollectionView(Tokens);
|
|
||||||
GridData.GroupDescriptions.Add(new DataGridPathGroupDescription(nameof(VariableItem.Category)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string GetValueString(object? value)
|
|
||||||
{
|
|
||||||
if (value is null) return string.Empty;
|
|
||||||
|
|
||||||
return value switch
|
|
||||||
{
|
|
||||||
double d => d.ToString(CultureInfo.InvariantCulture),
|
|
||||||
CornerRadius c => c.IsUniform ? $"{c.TopLeft}" : c.ToString(),
|
|
||||||
Thickness t => t.IsUniform ? $"{t.Left}" : t.ToString(),
|
|
||||||
FontWeight fontWeight => Convert.ToInt32(fontWeight).ToString(),
|
|
||||||
FontFamily fontFamily => fontFamily.FamilyNames.ToString(),
|
|
||||||
_ => value.ToString()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<VariableItem> Tokens { get; set; } =
|
|
||||||
[
|
|
||||||
new("Height", "SemiHeightControlSmall"),
|
|
||||||
new("Height", "SemiHeightControlDefault"),
|
|
||||||
new("Height", "SemiHeightControlLarge"),
|
|
||||||
new("Icon Size", "SemiWidthIconExtraSmall"),
|
|
||||||
new("Icon Size", "SemiWidthIconSmall"),
|
|
||||||
new("Icon Size", "SemiWidthIconMedium"),
|
|
||||||
new("Icon Size", "SemiWidthIconLarge"),
|
|
||||||
new("Icon Size", "SemiWidthIconExtraLarge"),
|
|
||||||
new("Border CornerRadius", "SemiBorderRadiusExtraSmall"),
|
|
||||||
new("Border CornerRadius", "SemiBorderRadiusSmall"),
|
|
||||||
new("Border CornerRadius", "SemiBorderRadiusMedium"),
|
|
||||||
new("Border CornerRadius", "SemiBorderRadiusLarge"),
|
|
||||||
new("Border CornerRadius", "SemiBorderRadiusFull"),
|
|
||||||
new("Border Spacing", "SemiBorderSpacing"),
|
|
||||||
new("Border Spacing", "SemiBorderSpacingControl"),
|
|
||||||
new("Border Spacing", "SemiBorderSpacingControlFocus"),
|
|
||||||
new("Border Thickness", "SemiBorderThickness"),
|
|
||||||
new("Border Thickness", "SemiBorderThicknessControl"),
|
|
||||||
new("Border Thickness", "SemiBorderThicknessControlFocus"),
|
|
||||||
new("Spacing", "SemiSpacingNone"),
|
|
||||||
new("Spacing", "SemiSpacingSuperTight"),
|
|
||||||
new("Spacing", "SemiSpacingExtraTight"),
|
|
||||||
new("Spacing", "SemiSpacingTight"),
|
|
||||||
new("Spacing", "SemiSpacingBaseTight"),
|
|
||||||
new("Spacing", "SemiSpacingBase"),
|
|
||||||
new("Spacing", "SemiSpacingBaseLoose"),
|
|
||||||
new("Spacing", "SemiSpacingLoose"),
|
|
||||||
new("Spacing", "SemiSpacingExtraLoose"),
|
|
||||||
new("Spacing", "SemiSpacingSuperLoose"),
|
|
||||||
new("Thickness", "SemiThicknessNone"),
|
|
||||||
new("Thickness", "SemiThicknessSuperTight"),
|
|
||||||
new("Thickness", "SemiThicknessExtraTight"),
|
|
||||||
new("Thickness", "SemiThicknessTight"),
|
|
||||||
new("Thickness", "SemiThicknessBaseTight"),
|
|
||||||
new("Thickness", "SemiThicknessBase"),
|
|
||||||
new("Thickness", "SemiThicknessBaseLoose"),
|
|
||||||
new("Thickness", "SemiThicknessLoose"),
|
|
||||||
new("Thickness", "SemiThicknessExtraLoose"),
|
|
||||||
new("Thickness", "SemiThicknessSuperLoose"),
|
|
||||||
new("FontSize", "SemiFontSizeSmall"),
|
|
||||||
new("FontSize", "SemiFontSizeRegular"),
|
|
||||||
new("FontSize", "SemiFontSizeHeader6"),
|
|
||||||
new("FontSize", "SemiFontSizeHeader5"),
|
|
||||||
new("FontSize", "SemiFontSizeHeader4"),
|
|
||||||
new("FontSize", "SemiFontSizeHeader3"),
|
|
||||||
new("FontSize", "SemiFontSizeHeader2"),
|
|
||||||
new("FontSize", "SemiFontSizeHeader1"),
|
|
||||||
new("FontWeight", "SemiFontWeightLight"),
|
|
||||||
new("FontWeight", "SemiFontWeightRegular"),
|
|
||||||
new("FontWeight", "SemiFontWeightBold"),
|
|
||||||
new("FontFamily", "SemiFontFamilyRegular"),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public class VariableItem()
|
|
||||||
{
|
|
||||||
public string? Category { get; set; }
|
|
||||||
public string? ResourceKey { get; set; }
|
|
||||||
public Type? Type { get; set; }
|
|
||||||
public string? Value { get; set; }
|
|
||||||
public string? Description { get; set; }
|
|
||||||
|
|
||||||
public VariableItem(string category, string resourceKey, string description = "") : this()
|
|
||||||
{
|
|
||||||
Category = category;
|
|
||||||
ResourceKey = resourceKey;
|
|
||||||
Description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string CopyText =>
|
|
||||||
$"""
|
|
||||||
<StaticResource x:Key="" ResourceKey="{ResourceKey}" />
|
|
||||||
""";
|
|
||||||
}
|
|
||||||
@@ -117,15 +117,15 @@
|
|||||||
<TabItem
|
<TabItem
|
||||||
Theme="{DynamicResource CategoryTabItem}"
|
Theme="{DynamicResource CategoryTabItem}"
|
||||||
Header="Resource Browser" />
|
Header="Resource Browser" />
|
||||||
<TabItem Header="Palette">
|
<!-- <TabItem Header="Palette"> -->
|
||||||
<pages:PaletteDemo />
|
<!-- <pages:PaletteDemo /> -->
|
||||||
</TabItem>
|
<!-- </TabItem> -->
|
||||||
<TabItem Header="HighContrastTheme">
|
<!-- <TabItem Header="HighContrastTheme"> -->
|
||||||
<pages:HighContrastDemo />
|
<!-- <pages:HighContrastDemo /> -->
|
||||||
</TabItem>
|
<!-- </TabItem> -->
|
||||||
<TabItem Header="Variables">
|
<!-- <TabItem Header="Variables"> -->
|
||||||
<pages:VariablesDemo />
|
<!-- <pages:VariablesDemo /> -->
|
||||||
</TabItem>
|
<!-- </TabItem> -->
|
||||||
<TabItem Header="Icon">
|
<TabItem Header="Icon">
|
||||||
<pages:IconDemo />
|
<pages:IconDemo />
|
||||||
</TabItem>
|
</TabItem>
|
||||||
@@ -135,12 +135,12 @@
|
|||||||
<TabItem Header="ColorPicker">
|
<TabItem Header="ColorPicker">
|
||||||
<pages:ColorPickerDemo />
|
<pages:ColorPickerDemo />
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="DataGrid">
|
<!-- <TabItem Header="DataGrid"> -->
|
||||||
<pages:DataGridDemo />
|
<!-- <pages:DataGridDemo /> -->
|
||||||
</TabItem>
|
<!-- </TabItem> -->
|
||||||
<TabItem Header="TreeDataGrid">
|
<!-- <TabItem Header="TreeDataGrid"> -->
|
||||||
<pages:TreeDataGridDemo />
|
<!-- <pages:TreeDataGridDemo /> -->
|
||||||
</TabItem>
|
<!-- </TabItem> -->
|
||||||
<TabItem
|
<TabItem
|
||||||
Theme="{DynamicResource CategoryTabItem}"
|
Theme="{DynamicResource CategoryTabItem}"
|
||||||
Header="Basic" />
|
Header="Basic" />
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageIcon>irihi.png</PackageIcon>
|
<PackageIcon>irihi.png</PackageIcon>
|
||||||
<PackageProjectUrl>https://github.com/irihitech/Semi.Avalonia</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/irihitech/Semi.Avalonia</PackageProjectUrl>
|
||||||
<AvaloniaVersion>11.2.1</AvaloniaVersion>
|
<AvaloniaVersion>12.0.999-cibuild0058575-alpha</AvaloniaVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user