commit
f138ae457e
@ -1,5 +1,5 @@
|
||||
<UserControl
|
||||
x:Class="Semi.Avalonia.Demo.Pages.GridSplitter"
|
||||
x:Class="Semi.Avalonia.Demo.Pages.GridSplitterDemo"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
@ -14,13 +14,13 @@
|
||||
RowDefinitions="*, Auto, *">
|
||||
<Border
|
||||
HorizontalAlignment="Stretch"
|
||||
Background="#FEFBCB"
|
||||
Background="{DynamicResource SemiYellow3Color}"
|
||||
CornerRadius="10" />
|
||||
<GridSplitter Grid.Row="1" ShowsPreview="True" />
|
||||
<Border
|
||||
Grid.Row="2"
|
||||
HorizontalAlignment="Stretch"
|
||||
Background="#FEFBCB"
|
||||
Background="{DynamicResource SemiYellow3Color}"
|
||||
CornerRadius="10" />
|
||||
</Grid>
|
||||
<Grid
|
||||
@ -29,13 +29,13 @@
|
||||
ColumnDefinitions="*, Auto, *">
|
||||
<Border
|
||||
HorizontalAlignment="Stretch"
|
||||
Background="#FEFBCB"
|
||||
Background="{DynamicResource SemiYellow3Color}"
|
||||
CornerRadius="10" />
|
||||
<GridSplitter Grid.Column="1" ShowsPreview="True" />
|
||||
<Border
|
||||
Grid.Column="2"
|
||||
HorizontalAlignment="Stretch"
|
||||
Background="#FEFBCB"
|
||||
Background="{DynamicResource SemiYellow3Color}"
|
||||
CornerRadius="10" />
|
||||
</Grid>
|
||||
</StackPanel>
|
@ -1,12 +1,11 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Semi.Avalonia.Demo.Pages;
|
||||
|
||||
public partial class GridSplitter : UserControl
|
||||
public partial class GridSplitterDemo : UserControl
|
||||
{
|
||||
public GridSplitter()
|
||||
public GridSplitterDemo()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="../Themes/ToggleButton.axaml" />
|
||||
<ResourceInclude Source="../Themes/ToggleSwitch.axaml" />
|
||||
<ResourceInclude Source="../Controls/ColorItemControl.axaml" />
|
||||
<ResourceInclude Source="../Controls/ColorDetailControl.axaml" />
|
||||
<ResourceInclude Source="../Controls/FunctionalColorGroupControl.axaml" />
|
||||
@ -34,11 +34,11 @@
|
||||
PanePlacement="Right">
|
||||
<SplitView.Pane>
|
||||
<StackPanel>
|
||||
<ToggleButton
|
||||
<ToggleSwitch
|
||||
Name="toggle"
|
||||
HorizontalAlignment="Right"
|
||||
IsChecked="True"
|
||||
Theme="{DynamicResource SplitViewToggleButton}" />
|
||||
Theme="{DynamicResource SplitViewToggleSwitch}" />
|
||||
<Border IsVisible="{Binding #splitView.IsPaneOpen}" Theme="{DynamicResource CardBorder}">
|
||||
<Panel>
|
||||
<TextBlock
|
||||
|
@ -114,20 +114,9 @@
|
||||
ItemsSource="{Binding Songs}" />
|
||||
<ToggleSwitch
|
||||
Grid.Row="2"
|
||||
Theme="{DynamicResource ButtonToggleSwitch}"
|
||||
Theme="{DynamicResource SplitViewToggleSwitch}"
|
||||
HorizontalAlignment="Left"
|
||||
IsChecked="{Binding #SplitView.IsPaneOpen}">
|
||||
<ToggleSwitch.OnContent>
|
||||
<PathIcon
|
||||
Width="16"
|
||||
Height="16"
|
||||
Data="{StaticResource NavigationMenuExpandIconGlyph}" />
|
||||
</ToggleSwitch.OnContent>
|
||||
<ToggleSwitch.OffContent>
|
||||
<PathIcon
|
||||
Width="16"
|
||||
Height="16"
|
||||
Data="{StaticResource NavigationMenuExpandIconGlyph}" />
|
||||
</ToggleSwitch.OffContent>
|
||||
</ToggleSwitch>
|
||||
</Grid>
|
||||
</SplitView.Pane>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ControlTheme x:Key="NavigationTab" TargetType="TabControl">
|
||||
<Setter Property="TabControl.Template">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="TabControl">
|
||||
<Border
|
||||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||
@ -10,7 +10,10 @@
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}">
|
||||
<DockPanel>
|
||||
<ScrollViewer DockPanel.Dock="Left" VerticalScrollBarVisibility="Auto">
|
||||
<ScrollViewer
|
||||
DockPanel.Dock="Left"
|
||||
Name="PART_ScrollViewer"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<Panel DockPanel.Dock="{TemplateBinding TabStripPlacement}">
|
||||
<ItemsPresenter Name="PART_ItemsPresenter">
|
||||
<ItemsPresenter.ItemsPanel>
|
||||
@ -19,7 +22,8 @@
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsPresenter.ItemsPanel>
|
||||
</ItemsPresenter>
|
||||
<Border Name="PART_BorderSeparator" Background="{DynamicResource TabItemLinePipePressedBorderBrush}" />
|
||||
<Border Name="PART_BorderSeparator"
|
||||
Background="{DynamicResource TabItemLinePipePressedBorderBrush}" />
|
||||
</Panel>
|
||||
</ScrollViewer>
|
||||
<ContentPresenter
|
||||
@ -38,5 +42,8 @@
|
||||
<Setter Property="VerticalAlignment" Value="Stretch" />
|
||||
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||
</Style>
|
||||
<Style Selector="^.Dismiss /template/ ScrollViewer#PART_ScrollViewer">
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
@ -1,26 +0,0 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ControlTheme x:Key="SplitViewToggleButton" TargetType="ToggleButton">
|
||||
<Setter Property="ToggleButton.Template">
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<Border
|
||||
Name="Background"
|
||||
Padding="8"
|
||||
Background="{TemplateBinding Background}"
|
||||
CornerRadius="3">
|
||||
<PathIcon
|
||||
Name="Icon"
|
||||
Width="16"
|
||||
Height="16"
|
||||
Data="M5 2H19C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5C2 3.34315 3.34315 2 5 2ZM6 4C5.44772 4 5 4.44772 5 5V19C5 19.5523 5.44772 20 6 20H9C9.55229 20 10 19.5523 10 19V5C10 4.44772 9.55229 4 9 4H6Z"
|
||||
Foreground="{DynamicResource ButtonDefaultTertiaryForeground}" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
<Style Selector="^:pointerover">
|
||||
<Setter Property="Background" Value="{DynamicResource ButtonDefaultPointeroverBackground}" />
|
||||
</Style>
|
||||
<Style Selector="^:pressed">
|
||||
<Setter Property="Background" Value="{DynamicResource ButtonDefaultPressedBackground}" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
67
demo/Semi.Avalonia.Demo/Themes/ToggleSwitch.axaml
Normal file
67
demo/Semi.Avalonia.Demo/Themes/ToggleSwitch.axaml
Normal file
@ -0,0 +1,67 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ControlTheme x:Key="ThemeToggleSwitch" TargetType="ToggleSwitch">
|
||||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="Padding" Value="8" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ButtonDefaultBorderBrush}" />
|
||||
<Setter Property="BorderThickness" Value="{DynamicResource ButtonBorderThickness}" />
|
||||
<Setter Property="CornerRadius" Value="{DynamicResource ButtonCornerRadius}" />
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
<Setter Property="OnContentTemplate">
|
||||
<DataTemplate>
|
||||
<PathIcon Theme="{StaticResource InnerPathIcon}" Data="{Binding}" />
|
||||
</DataTemplate>
|
||||
</Setter>
|
||||
<Setter Property="OffContentTemplate">
|
||||
<DataTemplate>
|
||||
<PathIcon Theme="{StaticResource InnerPathIcon}" Data="{Binding}" />
|
||||
</DataTemplate>
|
||||
</Setter>
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="ToggleSwitch">
|
||||
<Border
|
||||
Name="Background"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}">
|
||||
<Panel>
|
||||
<Panel Name="PART_SwitchKnob" />
|
||||
<Panel Name="PART_MovingKnobs" />
|
||||
<ContentPresenter
|
||||
Name="PART_OnContentPresenter"
|
||||
IsVisible="{TemplateBinding IsChecked}"
|
||||
Content="{TemplateBinding OnContent}"
|
||||
ContentTemplate="{TemplateBinding OnContentTemplate}" />
|
||||
<ContentPresenter
|
||||
Name="PART_OffContentPresenter"
|
||||
IsVisible="{TemplateBinding IsChecked, Converter={x:Static BoolConverters.Not}}"
|
||||
Content="{TemplateBinding OffContent}"
|
||||
ContentTemplate="{TemplateBinding OffContentTemplate}" />
|
||||
</Panel>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<Style Selector="^:pointerover">
|
||||
<Setter Property="Background" Value="{DynamicResource ButtonDefaultPointeroverBackground}" />
|
||||
</Style>
|
||||
<Style Selector="^:pressed">
|
||||
<Setter Property="Background" Value="{DynamicResource ButtonDefaultPressedBackground}" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="SplitViewToggleSwitch"
|
||||
BasedOn="{StaticResource ThemeToggleSwitch}"
|
||||
TargetType="ToggleSwitch">
|
||||
<Setter Property="Width" Value="32" />
|
||||
<Setter Property="Height" Value="32" />
|
||||
<Setter Property="OnContent"
|
||||
Value="M5 2H19C20.6569 2 22 3.34315 22 5V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5C2 3.34315 3.34315 2 5 2ZM6 4C5.44772 4 5 4.44772 5 5V19C5 19.5523 5.44772 20 6 20H9C9.55229 20 10 19.5523 10 19V5C10 4.44772 9.55229 4 9 4H6Z" />
|
||||
<Setter Property="OffContent" Value="{Binding $self.OnContent}" />
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
@ -15,56 +15,87 @@
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="../Themes/TabMenu.axaml" />
|
||||
<ResourceInclude Source="../Themes/ToggleButton.axaml" />
|
||||
<ResourceInclude Source="../Themes/ToggleSwitch.axaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<StreamGeometry x:Key="DocIcon">M12 21.5C10.65 20.65 8.2 20 6.5 20C4.85 20 3.15 20.3 1.75 21.05C1.65 21.1 1.6 21.1 1.5 21.1C1.25 21.1 1 20.85 1 20.6V6C1.6 5.55 2.25 5.25 3 5C4.11 4.65 5.33 4.5 6.5 4.5C8.45 4.5 10.55 4.9 12 6C13.45 4.9 15.55 4.5 17.5 4.5C18.67 4.5 19.89 4.65 21 5C21.75 5.25 22.4 5.55 23 6V20.6C23 20.85 22.75 21.1 22.5 21.1C22.4 21.1 22.35 21.1 22.25 21.05C20.85 20.3 19.15 20 17.5 20C15.8 20 13.35 20.65 12 21.5M12 8V19.5C13.35 18.65 15.8 18 17.5 18C18.7 18 19.9 18.15 21 18.5V7C19.9 6.65 18.7 6.5 17.5 6.5C15.8 6.5 13.35 7.15 12 8M13 11.5C14.11 10.82 15.6 10.5 17.5 10.5C18.41 10.5 19.26 10.59 20 10.78V9.23C19.13 9.08 18.29 9 17.5 9C15.73 9 14.23 9.28 13 9.84V11.5M17.5 11.67C15.79 11.67 14.29 11.93 13 12.46V14.15C14.11 13.5 15.6 13.16 17.5 13.16C18.54 13.16 19.38 13.24 20 13.4V11.9C19.13 11.74 18.29 11.67 17.5 11.67M20 14.57C19.13 14.41 18.29 14.33 17.5 14.33C15.67 14.33 14.17 14.6 13 15.13V16.82C14.11 16.16 15.6 15.83 17.5 15.83C18.54 15.83 19.38 15.91 20 16.07V14.57Z</StreamGeometry>
|
||||
<StreamGeometry x:Key="RepoIcon">M12,2A10,10 0 0,0 2,12C2,16.42 4.87,20.17 8.84,21.5C9.34,21.58 9.5,21.27 9.5,21C9.5,20.77 9.5,20.14 9.5,19.31C6.73,19.91 6.14,17.97 6.14,17.97C5.68,16.81 5.03,16.5 5.03,16.5C4.12,15.88 5.1,15.9 5.1,15.9C6.1,15.97 6.63,16.93 6.63,16.93C7.5,18.45 8.97,18 9.54,17.76C9.63,17.11 9.89,16.67 10.17,16.42C7.95,16.17 5.62,15.31 5.62,11.5C5.62,10.39 6,9.5 6.65,8.79C6.55,8.54 6.2,7.5 6.75,6.15C6.75,6.15 7.59,5.88 9.5,7.17C10.29,6.95 11.15,6.84 12,6.84C12.85,6.84 13.71,6.95 14.5,7.17C16.41,5.88 17.25,6.15 17.25,6.15C17.8,7.5 17.45,8.54 17.35,8.79C18,9.5 18.38,10.39 18.38,11.5C18.38,15.32 16.04,16.16 13.81,16.41C14.17,16.72 14.5,17.33 14.5,18.26C14.5,19.6 14.5,20.68 14.5,21C14.5,21.27 14.66,21.59 15.17,21.5C19.14,20.16 22,16.42 22,12A10,10 0 0,0 12,2Z</StreamGeometry>
|
||||
<StreamGeometry x:Key="DarkThemeIcon">M12 23C18.0751 23 23 18.0751 23 12C23 5.92487 18.0751 1 12 1C5.92487 1 1 5.92487 1 12C1 18.0751 5.92487 23 12 23ZM17 15C17.476 15 17.9408 14.9525 18.3901 14.862C17.296 17.3011 14.8464 19 12 19C8.13401 19 5 15.866 5 12C5 8.60996 7.40983 5.78277 10.6099 5.13803C10.218 6.01173 10 6.98041 10 8C10 11.866 13.134 15 17 15Z</StreamGeometry>
|
||||
<StreamGeometry x:Key="LightThemeIcon">M3.55 19.09L4.96 20.5L6.76 18.71L5.34 17.29M12 6C8.69 6 6 8.69 6 12S8.69 18 12 18 18 15.31 18 12C18 8.68 15.31 6 12 6M20 13H23V11H20M17.24 18.71L19.04 20.5L20.45 19.09L18.66 17.29M20.45 5L19.04 3.6L17.24 5.39L18.66 6.81M13 1H11V4H13M6.76 5.39L4.96 3.6L3.55 5L5.34 6.81L6.76 5.39M1 13H4V11H1M13 20H11V23H13</StreamGeometry>
|
||||
<StreamGeometry x:Key="MenuIcon">M2 19.5C2 18.6716 2.67157 18 3.5 18H20.5C21.3284 18 22 18.6716 22 19.5C22 20.3284 21.3284 21 20.5 21H3.5C2.67157 21 2 20.3284 2 19.5ZM2 12C2 11.1716 2.67157 10.5 3.5 10.5H20.5C21.3284 10.5 22 11.1716 22 12C22 12.8284 21.3284 13.5 20.5 13.5H3.5C2.67157 13.5 2 12.8284 2 12ZM2 4.5C2 3.67157 2.67157 3 3.5 3H20.5C21.3284 3 22 3.67157 22 4.5C22 5.32843 21.3284 6 20.5 6H3.5C2.67157 6 2 5.32843 2 4.5Z</StreamGeometry>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid RowDefinitions="Auto, *">
|
||||
<Border
|
||||
Grid.Row="0"
|
||||
Margin="8"
|
||||
Padding="12,4"
|
||||
Theme="{DynamicResource CardBorder}">
|
||||
<Grid VerticalAlignment="Center" ColumnDefinitions="*, Auto">
|
||||
<StackPanel Grid.Column="0" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
<Panel>
|
||||
<StackPanel Orientation="Horizontal" Spacing="8">
|
||||
<ToggleSwitch
|
||||
Name="ExpandButton"
|
||||
Theme="{DynamicResource SplitViewToggleSwitch}" />
|
||||
<SelectableTextBlock
|
||||
VerticalAlignment="Center"
|
||||
Classes="H6"
|
||||
Text="Semi Avalonia"
|
||||
Theme="{DynamicResource TitleTextBlock}" />
|
||||
<TextBlock
|
||||
Margin="8,0"
|
||||
Theme="{DynamicResource TitleSelectableTextBlock}" />
|
||||
<SelectableTextBlock
|
||||
VerticalAlignment="Center"
|
||||
Text="/" />
|
||||
<TextBlock
|
||||
Margin="8,0"
|
||||
<SelectableTextBlock
|
||||
VerticalAlignment="Center"
|
||||
Classes="Secondary"
|
||||
Text="{ReflectionBinding #tab.SelectedItem.Header}" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
||||
<Button Click="OpenDocumentation" Theme="{DynamicResource BorderlessButton}">
|
||||
<PathIcon
|
||||
Width="16"
|
||||
Height="16"
|
||||
Data="M12 21.5C10.65 20.65 8.2 20 6.5 20C4.85 20 3.15 20.3 1.75 21.05C1.65 21.1 1.6 21.1 1.5 21.1C1.25 21.1 1 20.85 1 20.6V6C1.6 5.55 2.25 5.25 3 5C4.11 4.65 5.33 4.5 6.5 4.5C8.45 4.5 10.55 4.9 12 6C13.45 4.9 15.55 4.5 17.5 4.5C18.67 4.5 19.89 4.65 21 5C21.75 5.25 22.4 5.55 23 6V20.6C23 20.85 22.75 21.1 22.5 21.1C22.4 21.1 22.35 21.1 22.25 21.05C20.85 20.3 19.15 20 17.5 20C15.8 20 13.35 20.65 12 21.5M12 8V19.5C13.35 18.65 15.8 18 17.5 18C18.7 18 19.9 18.15 21 18.5V7C19.9 6.65 18.7 6.5 17.5 6.5C15.8 6.5 13.35 7.15 12 8M13 11.5C14.11 10.82 15.6 10.5 17.5 10.5C18.41 10.5 19.26 10.59 20 10.78V9.23C19.13 9.08 18.29 9 17.5 9C15.73 9 14.23 9.28 13 9.84V11.5M17.5 11.67C15.79 11.67 14.29 11.93 13 12.46V14.15C14.11 13.5 15.6 13.16 17.5 13.16C18.54 13.16 19.38 13.24 20 13.4V11.9C19.13 11.74 18.29 11.67 17.5 11.67M20 14.57C19.13 14.41 18.29 14.33 17.5 14.33C15.67 14.33 14.17 14.6 13 15.13V16.82C14.11 16.16 15.6 15.83 17.5 15.83C18.54 15.83 19.38 15.91 20 16.07V14.57Z"
|
||||
Foreground="{DynamicResource ButtonDefaultTertiaryForeground}" />
|
||||
</Button>
|
||||
<Button Click="OpenRepository" Theme="{DynamicResource BorderlessButton}">
|
||||
<PathIcon
|
||||
Width="16"
|
||||
Height="16"
|
||||
Data="M12,2A10,10 0 0,0 2,12C2,16.42 4.87,20.17 8.84,21.5C9.34,21.58 9.5,21.27 9.5,21C9.5,20.77 9.5,20.14 9.5,19.31C6.73,19.91 6.14,17.97 6.14,17.97C5.68,16.81 5.03,16.5 5.03,16.5C4.12,15.88 5.1,15.9 5.1,15.9C6.1,15.97 6.63,16.93 6.63,16.93C7.5,18.45 8.97,18 9.54,17.76C9.63,17.11 9.89,16.67 10.17,16.42C7.95,16.17 5.62,15.31 5.62,11.5C5.62,10.39 6,9.5 6.65,8.79C6.55,8.54 6.2,7.5 6.75,6.15C6.75,6.15 7.59,5.88 9.5,7.17C10.29,6.95 11.15,6.84 12,6.84C12.85,6.84 13.71,6.95 14.5,7.17C16.41,5.88 17.25,6.15 17.25,6.15C17.8,7.5 17.45,8.54 17.35,8.79C18,9.5 18.38,10.39 18.38,11.5C18.38,15.32 16.04,16.16 13.81,16.41C14.17,16.72 14.5,17.33 14.5,18.26C14.5,19.6 14.5,20.68 14.5,21C14.5,21.27 14.66,21.59 15.17,21.5C19.14,20.16 22,16.42 22,12A10,10 0 0,0 12,2Z"
|
||||
Foreground="{DynamicResource ButtonDefaultTertiaryForeground}" />
|
||||
</Button>
|
||||
<ComboBox
|
||||
MinWidth="100"
|
||||
PlaceholderText="Select a theme"
|
||||
DisplayMemberBinding="{Binding Name}"
|
||||
ItemsSource="{Binding Themes}"
|
||||
SelectedItem="{Binding SelectedTheme}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<StackPanel.Styles>
|
||||
<Style Selector="Button">
|
||||
<Setter Property="Theme" Value="{DynamicResource BorderlessButton}" />
|
||||
<Setter Property="Width" Value="32" />
|
||||
<Setter Property="Height" Value="32" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource ButtonDefaultTertiaryForeground}" />
|
||||
</Style>
|
||||
<Style Selector="ToggleSwitch">
|
||||
<Setter Property="Theme" Value="{DynamicResource ThemeToggleSwitch}" />
|
||||
<Setter Property="Width" Value="32" />
|
||||
<Setter Property="Height" Value="32" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource ButtonDefaultTertiaryForeground}" />
|
||||
</Style>
|
||||
<Style Selector="PathIcon">
|
||||
<Setter Property="Theme" Value="{DynamicResource InnerPathIcon}" />
|
||||
</Style>
|
||||
</StackPanel.Styles>
|
||||
|
||||
<Button Command="{Binding OpenUrlCommand}" CommandParameter="{Binding DocumentationUrl}">
|
||||
<PathIcon Data="{StaticResource DocIcon}" />
|
||||
</Button>
|
||||
|
||||
<Button Command="{Binding OpenUrlCommand}" CommandParameter="{Binding RepoUrl}">
|
||||
<PathIcon Data="{StaticResource RepoIcon}" />
|
||||
</Button>
|
||||
|
||||
<ToggleSwitch
|
||||
Command="{Binding ToggleThemeCommand}"
|
||||
OnContent="{StaticResource DarkThemeIcon}"
|
||||
OffContent="{StaticResource LightThemeIcon}" />
|
||||
|
||||
<Button>
|
||||
<PathIcon Data="{StaticResource MenuIcon}" />
|
||||
<Button.Flyout>
|
||||
<MenuFlyout Placement="Bottom" ItemsSource="{Binding MenuItems}" />
|
||||
</Button.Flyout>
|
||||
<Button.Styles>
|
||||
<Style Selector="MenuItem" x:DataType="views:MenuItemViewModel">
|
||||
<Setter Property="Header" Value="{Binding Header}" />
|
||||
<Setter Property="ItemsSource" Value="{Binding Items}" />
|
||||
<Setter Property="Command" Value="{Binding Command}" />
|
||||
<Setter Property="CommandParameter" Value="{Binding CommandParameter}" />
|
||||
</Style>
|
||||
</Button.Styles>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Panel>
|
||||
</Border>
|
||||
<TabControl
|
||||
Name="tab"
|
||||
@ -73,6 +104,7 @@
|
||||
Padding="20,0,0,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
TabStripPlacement="Left"
|
||||
Classes.Dismiss="{Binding #ExpandButton.IsChecked}"
|
||||
Theme="{DynamicResource NavigationTab}">
|
||||
<TabItem Header="Overview">
|
||||
<pages:Overview />
|
||||
@ -126,7 +158,7 @@
|
||||
<pages:FlyoutDemo />
|
||||
</TabItem>
|
||||
<TabItem Header="GridSplitter">
|
||||
<pages:GridSplitter />
|
||||
<pages:GridSplitterDemo />
|
||||
</TabItem>
|
||||
<TabItem Header="HeaderedContentControl">
|
||||
<pages:HeaderedContentControlDemo />
|
||||
|
@ -1,10 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Styling;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace Semi.Avalonia.Demo.Views;
|
||||
|
||||
@ -15,62 +18,96 @@ public partial class MainView : UserControl
|
||||
InitializeComponent();
|
||||
this.DataContext = new MainViewModel();
|
||||
}
|
||||
|
||||
private void ToggleButton_OnIsCheckedChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var app = Application.Current;
|
||||
if (app is not null)
|
||||
{
|
||||
var theme = app.ActualThemeVariant;
|
||||
app.RequestedThemeVariant = theme == ThemeVariant.Dark ? ThemeVariant.Light : ThemeVariant.Dark;
|
||||
}
|
||||
}
|
||||
|
||||
private async void OpenRepository(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var top = TopLevel.GetTopLevel(this);
|
||||
if (top is null) return;
|
||||
var launcher = top.Launcher;
|
||||
await launcher.LaunchUriAsync(new Uri("https://github.com/irihitech/Semi.Avalonia"));
|
||||
}
|
||||
|
||||
private async void OpenDocumentation(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var top = TopLevel.GetTopLevel(this);
|
||||
if (top is null) return;
|
||||
var launcher = top.Launcher;
|
||||
await launcher.LaunchUriAsync(new Uri("https://docs.irihi.tech/semi"));
|
||||
}
|
||||
}
|
||||
|
||||
public partial class MainViewModel : ObservableObject
|
||||
{
|
||||
public ObservableCollection<ThemeItem> Themes { get; } =
|
||||
[
|
||||
new("Default", ThemeVariant.Default),
|
||||
new("Light", ThemeVariant.Light),
|
||||
new("Dark", ThemeVariant.Dark),
|
||||
new("Aquatic", SemiTheme.Aquatic),
|
||||
new("Desert", SemiTheme.Desert),
|
||||
new("Dust", SemiTheme.Dust),
|
||||
new("NightSky", SemiTheme.NightSky)
|
||||
];
|
||||
public string DocumentationUrl => "https://docs.irihi.tech/semi";
|
||||
public string RepoUrl => "https://github.com/irihitech/Semi.Avalonia";
|
||||
public IReadOnlyList<MenuItemViewModel> MenuItems { get; }
|
||||
|
||||
[ObservableProperty] private ThemeItem? _selectedTheme;
|
||||
|
||||
partial void OnSelectedThemeChanged(ThemeItem? oldValue, ThemeItem? newValue)
|
||||
public MainViewModel()
|
||||
{
|
||||
MenuItems =
|
||||
[
|
||||
new MenuItemViewModel
|
||||
{
|
||||
Header = "High Contrast Theme",
|
||||
Items =
|
||||
[
|
||||
new MenuItemViewModel
|
||||
{
|
||||
Header = "Aquatic",
|
||||
Command = SelectThemeCommand,
|
||||
CommandParameter = SemiTheme.Aquatic
|
||||
},
|
||||
new MenuItemViewModel
|
||||
{
|
||||
Header = "Desert",
|
||||
Command = SelectThemeCommand,
|
||||
CommandParameter = SemiTheme.Desert
|
||||
},
|
||||
new MenuItemViewModel
|
||||
{
|
||||
Header = "Dust",
|
||||
Command = SelectThemeCommand,
|
||||
CommandParameter = SemiTheme.Dust
|
||||
},
|
||||
new MenuItemViewModel
|
||||
{
|
||||
Header = "NightSky",
|
||||
Command = SelectThemeCommand,
|
||||
CommandParameter = SemiTheme.NightSky
|
||||
},
|
||||
]
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void ToggleTheme()
|
||||
{
|
||||
var app = Application.Current;
|
||||
if (app is null) return;
|
||||
var theme = app.ActualThemeVariant;
|
||||
app.RequestedThemeVariant = theme == ThemeVariant.Dark ? ThemeVariant.Light : ThemeVariant.Dark;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void SelectTheme(object? obj)
|
||||
{
|
||||
if (newValue is null) return;
|
||||
var app = Application.Current;
|
||||
if (app is not null)
|
||||
{
|
||||
app.RequestedThemeVariant = newValue.Theme;
|
||||
app.RequestedThemeVariant = obj as ThemeVariant;
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private static async Task OpenUrl(string url)
|
||||
{
|
||||
var launcher = ResolveDefaultTopLevel()?.Launcher;
|
||||
if (launcher is not null)
|
||||
{
|
||||
await launcher.LaunchUriAsync(new Uri(url));
|
||||
}
|
||||
}
|
||||
|
||||
private static TopLevel? ResolveDefaultTopLevel()
|
||||
{
|
||||
return Application.Current?.ApplicationLifetime switch
|
||||
{
|
||||
IClassicDesktopStyleApplicationLifetime desktopLifetime => desktopLifetime.MainWindow,
|
||||
ISingleViewApplicationLifetime singleView => TopLevel.GetTopLevel(singleView.MainView),
|
||||
_ => null
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class ThemeItem(string name, ThemeVariant theme)
|
||||
public class MenuItemViewModel
|
||||
{
|
||||
public string Name { get; set; } = name;
|
||||
public ThemeVariant Theme { get; set; } = theme;
|
||||
public string? Header { get; set; }
|
||||
public ICommand? Command { get; set; }
|
||||
public object? CommandParameter { get; set; }
|
||||
public IList<MenuItemViewModel>? Items { get; set; }
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user