Skip to content

Commit

Permalink
新增 情景插件和配置的列表拖拽
Browse files Browse the repository at this point in the history
优化 所有列表切换为虚拟
  • Loading branch information
MakesYT committed May 7, 2024
1 parent 7433b07 commit e636772
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 25 deletions.
11 changes: 5 additions & 6 deletions KitopiaAvalonia/Controls/ListShow.axaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:KitopiaAvalonia.Controls"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
xmlns:controls1="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia">
<Design.PreviewWith>
<controls:ListShow Width="200" Height="200">
Expand All @@ -16,9 +15,9 @@
<Setter Property="Template">
<ControlTemplate>
<ItemsControl>
<ListBox
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ItemsSource="{TemplateBinding ItemsSource}">
<ListBox Classes="draggableVirtualizing"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ItemsSource="{TemplateBinding ItemsSource}">
<ListBox.ItemContainerTheme>
<ControlTheme TargetType="ListBoxItem">
<Setter Property="Template">
Expand Down Expand Up @@ -84,9 +83,9 @@
CommandParameter="{TemplateBinding TextValue}"
Grid.Column="1" Height="36" Width="36">
<controls1:FontIcon FontFamily="{StaticResource FluentFont}" Foreground="GreenYellow"
Glyph="&#xf107;" />
Glyph="&#xf107;" />
</Button>
<DockPanel Grid.Column="0" Margin="0" >
<DockPanel Grid.Column="0" Margin="0">
<TextBox
Text="{Binding TextValue,Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" />
</DockPanel>
Expand Down
10 changes: 5 additions & 5 deletions KitopiaAvalonia/Pages/CustomScenariosManagerPage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<StackPanel Orientation="Horizontal">
<Button Content="新建情景" Command="{Binding NewCustomScenariosCommand}" />
</StackPanel>
<ListBox
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
MaxHeight="385"
ItemsSource="{Binding CustomScenarios,Mode=OneWay}"
Margin="0,10,0,0">
<ListBox Classes="draggableVirtualizing"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
MaxHeight="385"
ItemsSource="{Binding CustomScenarios,Mode=OneWay}"
Margin="0,10,0,0">

<ListBox.ItemContainerTheme>
<ControlTheme TargetType="ListBoxItem">
Expand Down
16 changes: 7 additions & 9 deletions KitopiaAvalonia/Pages/HotKeyManagerPage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
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:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
xmlns:converter="clr-namespace:Kitopia.Converter"
xmlns:pages="clr-namespace:Core.ViewModel.Pages;assembly=Core"
xmlns:controls1="clr-namespace:KitopiaAvalonia.Controls"
xmlns:customScenario="clr-namespace:Core.ViewModel.Pages.customScenario;assembly=Core"
xmlns:customScenario1="clr-namespace:Core.SDKs.CustomScenario;assembly=Core"
xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:hotkey="clr-namespace:Core.SDKs.HotKey;assembly=Core"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:DataType="pages:HotKeyManagerPageViewModel"
Expand All @@ -22,17 +18,19 @@
<SolidColorBrush Color="{DynamicResource TextFillColorPrimary}" />
</TextBlock.Foreground>
</TextBlock>

<ItemsControl ScrollViewer.HorizontalScrollBarVisibility="Disabled"
MaxHeight="385"
Margin="0,10,0,0" ItemsSource="{Binding Source={x:Static hotkey:HotKeyManager.HotKeys},Mode=OneWay}">

<ItemsControl
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
MaxHeight="385"
Margin="0,10,0,0" ItemsSource="{Binding Source={x:Static hotkey:HotKeyManager.HotKeys}}">
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="hotkey:HotKeyModel">
<Border BorderBrush="LightGray" BorderThickness="1" CornerRadius="4">
<StackPanel HorizontalAlignment="Center" Margin="5,0,5,5">
<TextBlock Margin="0,5,0,0" Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Text="{Binding SignName,Converter={StaticResource HotKeySignNameToStringCtr}}" />
<controls1:HotKeyShow Margin="0,5,0,0" HotKeyModel="{Binding RelativeSource={RelativeSource AncestorType=StackPanel},Path=DataContext}" />
<controls1:HotKeyShow Margin="0,5,0,0"
HotKeyModel="{Binding RelativeSource={RelativeSource AncestorType=StackPanel},Path=DataContext}" />
</StackPanel>

</Border>
Expand Down
31 changes: 26 additions & 5 deletions KitopiaAvalonia/Styles/Styles.axaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:windowing="clr-namespace:FluentAvalonia.UI.Windowing;assembly=FluentAvalonia"
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<Border Padding="20">
<!-- Add Controls for Previewer Here -->
</Border>
</Design.PreviewWith>
<Style Selector=":is(ListBox)">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>


</Styles>
</Style>
<Style Selector=":is(ListBox).draggableVirtualizing > :is(ListBoxItem)">
<Setter Property="ZIndex" Value="0" />
<Setter Property="(Interaction.Behaviors)">
<BehaviorCollectionTemplate>
<BehaviorCollection>
<ItemDragBehavior HorizontalDragThreshold="3" VerticalDragThreshold="3" Orientation="Vertical" />
</BehaviorCollection>
</BehaviorCollectionTemplate>
</Setter>
</Style>

<Style Selector=":is(ListBox).draggableVirtualizing > :is(ListBoxItem):pressed">
<Setter Property="ZIndex" Value="1" />
</Style>

</Styles>

0 comments on commit e636772

Please sign in to comment.