Merge pull request #550 from irihitech/pathpicker
Path Picker Semi Theme improvement
This commit is contained in:
@@ -1,112 +1,144 @@
|
||||
<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:u="https://irihi.tech/ursa"
|
||||
xmlns:vm="using:Ursa.Demo.ViewModels"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Ursa.Demo.Pages.PathPickerDemo"
|
||||
x:DataType="vm:PathPickerDemoViewModel">
|
||||
<Grid ColumnDefinitions="*,*"
|
||||
RowDefinitions="7*,3*">
|
||||
<ScrollViewer Grid.Column="0" Grid.Row="0">
|
||||
<UserControl
|
||||
x:Class="Ursa.Demo.Pages.PathPickerDemo"
|
||||
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:u="https://irihi.tech/ursa"
|
||||
xmlns:vm="using:Ursa.Demo.ViewModels"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
x:DataType="vm:PathPickerDemoViewModel"
|
||||
mc:Ignorable="d">
|
||||
<Grid ColumnDefinitions="*,*" RowDefinitions="7*,3*">
|
||||
<ScrollViewer Grid.Row="0" Grid.Column="0">
|
||||
<StackPanel>
|
||||
<HeaderedContentControl Theme="{DynamicResource GroupBox}"
|
||||
Header="Functionality and Usage"
|
||||
Content="PathPicker aggregates a file selector and provides a Command property. The Command is triggered solely after opening the file selector and selecting a file, whereupon the Command receives an IReadOnlyList<string> parameter.">
|
||||
</HeaderedContentControl>
|
||||
<u:Form LabelAlignment="Left" LabelPosition="Left" LabelWidth="*" HorizontalAlignment="Stretch">
|
||||
<TextBox Name="Title" u:FormItem.Label="Title"></TextBox>
|
||||
<TextBox Name="SuggestedFileName" u:FormItem.Label="SuggestedFileName"
|
||||
Watermark="filename(not have file extension)">
|
||||
</TextBox>
|
||||
<TextBox Name="SuggestedStartPath" u:FormItem.Label="SuggestedStartPath"
|
||||
Watermark="D:\Win7 Help\win-x64">
|
||||
</TextBox>
|
||||
<TextBox Name="FileFilter" u:FormItem.Label="FileFilter"
|
||||
Watermark="[Name,Pattern] like this [123,*.exe,*.pdb] or [All][ImageAll][11,*.txt]">
|
||||
</TextBox>
|
||||
<TextBox Name="DefaultFileExtension" u:FormItem.Label="DefaultFileExtension"
|
||||
Watermark="json">
|
||||
</TextBox>
|
||||
<ToggleButton Name="AllowMultiple" Content="AllowMultiple" u:FormItem.NoLabel="True"
|
||||
HorizontalAlignment="Stretch">
|
||||
</ToggleButton>
|
||||
<ToggleButton Name="IsOmitCommandOnCancel" Content="Do not trigger the command after unselecting."
|
||||
u:FormItem.NoLabel="True"
|
||||
HorizontalAlignment="Stretch">
|
||||
</ToggleButton>
|
||||
<ToggleButton Name="IsClearSelectionOnCancel" Content="Clear the selection when unselecting."
|
||||
u:FormItem.NoLabel="True"
|
||||
HorizontalAlignment="Stretch">
|
||||
</ToggleButton>
|
||||
<u:EnumSelector Name="UsePickerType" EnumType="u:UsePickerTypes" u:FormItem.Label="UsePickerType"></u:EnumSelector>
|
||||
<HeaderedContentControl
|
||||
Content="PathPicker aggregates a file selector and provides a Command property. The Command is triggered solely after opening the file selector and selecting a file, whereupon the Command receives an IReadOnlyList<string> parameter."
|
||||
Header="Functionality and Usage"
|
||||
Theme="{DynamicResource GroupBox}" />
|
||||
<u:Form
|
||||
HorizontalAlignment="Stretch"
|
||||
LabelAlignment="Left"
|
||||
LabelPosition="Left"
|
||||
LabelWidth="*">
|
||||
<TextBox
|
||||
Name="Title"
|
||||
u:FormItem.Label="Title"
|
||||
Text="选择文件" />
|
||||
<TextBox
|
||||
Name="SuggestedFileName"
|
||||
u:FormItem.Label="SuggestedFileName"
|
||||
Watermark="filename(not have file extension)" />
|
||||
<TextBox
|
||||
Name="SuggestedStartPath"
|
||||
u:FormItem.Label="SuggestedStartPath"
|
||||
Watermark="D:\Win7 Help\win-x64" />
|
||||
<TextBox
|
||||
Name="FileFilter"
|
||||
u:FormItem.Label="FileFilter"
|
||||
Watermark="[Name,Pattern] like this [123,*.exe,*.pdb] or [All][ImageAll][11,*.txt]" />
|
||||
<TextBox
|
||||
Name="DefaultFileExtension"
|
||||
u:FormItem.Label="DefaultFileExtension"
|
||||
Watermark="json" />
|
||||
<CheckBox
|
||||
Name="AllowMultiple"
|
||||
u:FormItem.NoLabel="True"
|
||||
Content="AllowMultiple" />
|
||||
<CheckBox
|
||||
Name="IsOmitCommandOnCancel"
|
||||
u:FormItem.NoLabel="True"
|
||||
Content="Do not trigger the command after unselecting." />
|
||||
<CheckBox
|
||||
Name="IsClearSelectionOnCancel"
|
||||
u:FormItem.NoLabel="True"
|
||||
Content="Clear the selection when unselecting." />
|
||||
<u:EnumSelector
|
||||
Name="UsePickerType"
|
||||
u:FormItem.Label="UsePickerType"
|
||||
EnumType="u:UsePickerTypes" />
|
||||
<u:ControlClassesInput
|
||||
Name="ClassInput"
|
||||
HorizontalAlignment="Left"
|
||||
u:FormItem.Label="Style Class" >
|
||||
<u:ControlClassesInput.Styles>
|
||||
<Style Selector="u|ControlClassesInput /template/ u|TagInput">
|
||||
<Setter Property="Watermark" Value="Available: Top"></Setter>
|
||||
</Style>
|
||||
</u:ControlClassesInput.Styles>
|
||||
</u:ControlClassesInput>
|
||||
|
||||
</u:Form>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
<ScrollViewer Grid.Column="0" Grid.Row="1">
|
||||
<ScrollViewer Grid.Row="1" Grid.Column="0">
|
||||
<StackPanel Spacing="2">
|
||||
<HeaderedContentControl Header="Default">
|
||||
<u:PathPicker Title="{Binding #Title.Text}"
|
||||
SuggestedFileName="{Binding #SuggestedFileName.Text}"
|
||||
SuggestedStartPath="{Binding #SuggestedStartPath.Text}"
|
||||
FileFilter="{Binding #FileFilter.Text}"
|
||||
DefaultFileExtension="{Binding #DefaultFileExtension.Text}"
|
||||
AllowMultiple="{Binding #AllowMultiple.IsChecked}"
|
||||
UsePickerType="{Binding #UsePickerType.Value}"
|
||||
SelectedPathsText="{Binding Path,Mode=OneWayToSource}"
|
||||
SelectedPaths="{Binding Paths,Mode=OneWayToSource}"
|
||||
Command="{Binding SelectedCommand}"
|
||||
IsOmitCommandOnCancel="{Binding #IsOmitCommandOnCancel.IsChecked}"
|
||||
IsClearSelectionOnCancel="{Binding #IsClearSelectionOnCancel.IsChecked}">
|
||||
</u:PathPicker>
|
||||
<u:PathPicker
|
||||
Title="{Binding #Title.Text}"
|
||||
u:ControlClassesInput.Source="{Binding #ClassInput}"
|
||||
AllowMultiple="{Binding #AllowMultiple.IsChecked, Mode=TwoWay}"
|
||||
Command="{Binding SelectedCommand}"
|
||||
DefaultFileExtension="{Binding #DefaultFileExtension.Text}"
|
||||
FileFilter="{Binding #FileFilter.Text}"
|
||||
IsClearSelectionOnCancel="{Binding #IsClearSelectionOnCancel.IsChecked}"
|
||||
IsOmitCommandOnCancel="{Binding #IsOmitCommandOnCancel.IsChecked}"
|
||||
SelectedPaths="{Binding Paths, Mode=OneWayToSource}"
|
||||
SelectedPathsText="{Binding Path, Mode=OneWayToSource}"
|
||||
SuggestedFileName="{Binding #SuggestedFileName.Text}"
|
||||
SuggestedStartPath="{Binding #SuggestedStartPath.Text}"
|
||||
UsePickerType="{Binding #UsePickerType.Value}" />
|
||||
</HeaderedContentControl>
|
||||
<HeaderedContentControl Header="PathPickerOnlyButton">
|
||||
<u:PathPicker Theme="{DynamicResource PathPickerOnlyButton}"
|
||||
Title="{Binding #Title.Text}"
|
||||
SuggestedFileName="{Binding #SuggestedFileName.Text}"
|
||||
SuggestedStartPath="{Binding #SuggestedStartPath.Text}"
|
||||
FileFilter="{Binding #FileFilter.Text}"
|
||||
DefaultFileExtension="{Binding #DefaultFileExtension.Text}"
|
||||
AllowMultiple="{Binding #AllowMultiple.IsChecked}"
|
||||
UsePickerType="{Binding #UsePickerType.Value}"
|
||||
SelectedPathsText="{Binding Path,Mode=OneWayToSource}"
|
||||
SelectedPaths="{Binding Paths,Mode=OneWayToSource}"
|
||||
Command="{Binding SelectedCommand}"
|
||||
IsOmitCommandOnCancel="{Binding #IsOmitCommandOnCancel.IsChecked}"
|
||||
IsClearSelectionOnCancel="{Binding #IsClearSelectionOnCancel.IsChecked}">
|
||||
</u:PathPicker>
|
||||
<HeaderedContentControl Header="ButtonPathPicker">
|
||||
<u:PathPicker
|
||||
Title="{Binding #Title.Text}"
|
||||
AllowMultiple="{Binding #AllowMultiple.IsChecked}"
|
||||
Command="{Binding SelectedCommand}"
|
||||
DefaultFileExtension="{Binding #DefaultFileExtension.Text}"
|
||||
FileFilter="{Binding #FileFilter.Text}"
|
||||
IsClearSelectionOnCancel="{Binding #IsClearSelectionOnCancel.IsChecked}"
|
||||
IsOmitCommandOnCancel="{Binding #IsOmitCommandOnCancel.IsChecked}"
|
||||
SelectedPaths="{Binding Paths, Mode=OneWayToSource}"
|
||||
SelectedPathsText="{Binding Path, Mode=OneWayToSource}"
|
||||
SuggestedFileName="{Binding #SuggestedFileName.Text}"
|
||||
SuggestedStartPath="{Binding #SuggestedStartPath.Text}"
|
||||
Theme="{DynamicResource ButtonPathPicker}"
|
||||
UsePickerType="{Binding #UsePickerType.Value}" />
|
||||
</HeaderedContentControl>
|
||||
<HeaderedContentControl Header="PathPickerForListView">
|
||||
<u:PathPicker Theme="{DynamicResource PathPickerForListView}"
|
||||
Title="{Binding #Title.Text}"
|
||||
SuggestedFileName="{Binding #SuggestedFileName.Text}"
|
||||
SuggestedStartPath="{Binding #SuggestedStartPath.Text}"
|
||||
FileFilter="{Binding #FileFilter.Text}"
|
||||
DefaultFileExtension="{Binding #DefaultFileExtension.Text}"
|
||||
AllowMultiple="{Binding #AllowMultiple.IsChecked}"
|
||||
UsePickerType="{Binding #UsePickerType.Value}"
|
||||
SelectedPathsText="{Binding Path,Mode=OneWayToSource}"
|
||||
SelectedPaths="{Binding Paths,Mode=OneWayToSource}"
|
||||
Command="{Binding SelectedCommand}"
|
||||
IsOmitCommandOnCancel="{Binding #IsOmitCommandOnCancel.IsChecked}"
|
||||
IsClearSelectionOnCancel="{Binding #IsClearSelectionOnCancel.IsChecked}">
|
||||
</u:PathPicker>
|
||||
<HeaderedContentControl Header="ListPathPicker">
|
||||
<u:PathPicker
|
||||
Title="{Binding #Title.Text}"
|
||||
AllowMultiple="{Binding #AllowMultiple.IsChecked}"
|
||||
Command="{Binding SelectedCommand}"
|
||||
DefaultFileExtension="{Binding #DefaultFileExtension.Text}"
|
||||
FileFilter="{Binding #FileFilter.Text}"
|
||||
IsClearSelectionOnCancel="{Binding #IsClearSelectionOnCancel.IsChecked}"
|
||||
IsOmitCommandOnCancel="{Binding #IsOmitCommandOnCancel.IsChecked}"
|
||||
SelectedPaths="{Binding Paths, Mode=OneWayToSource}"
|
||||
SelectedPathsText="{Binding Path, Mode=OneWayToSource}"
|
||||
SuggestedFileName="{Binding #SuggestedFileName.Text}"
|
||||
SuggestedStartPath="{Binding #SuggestedStartPath.Text}"
|
||||
Theme="{DynamicResource ListPathPicker}"
|
||||
UsePickerType="{Binding #UsePickerType.Value}" />
|
||||
</HeaderedContentControl>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
<ScrollViewer Grid.Column="1" Grid.Row="0" Grid.RowSpan="2">
|
||||
<ScrollViewer
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1">
|
||||
<StackPanel Spacing="1">
|
||||
<TextBlock Text="{Binding CommandTriggerCount,StringFormat='Command Trigger Count:{0}'}"></TextBlock>
|
||||
<TextBlock Text="{Binding CommandTriggerCount, StringFormat='Command Trigger Count:{0}'}" />
|
||||
<HeaderedContentControl Header="SelectedPathsText">
|
||||
<TextBox Name="SelectedPath" u:FormItem.Label="SelectedPath" IsReadOnly="True"
|
||||
Text="{Binding Path}">
|
||||
</TextBox>
|
||||
<TextBox
|
||||
Name="SelectedPath"
|
||||
u:FormItem.Label="SelectedPath"
|
||||
IsReadOnly="True"
|
||||
Text="{Binding Path}" />
|
||||
</HeaderedContentControl>
|
||||
<HeaderedContentControl Header="SelectedPaths">
|
||||
<ListBox Name="SelectedPaths"
|
||||
ItemsSource="{Binding Paths}">
|
||||
</ListBox>
|
||||
<ListBox Name="SelectedPaths" ItemsSource="{Binding Paths}" />
|
||||
</HeaderedContentControl>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
@@ -12,6 +12,7 @@ public class MenuViewModel : ViewModelBase
|
||||
{
|
||||
new() { MenuHeader = "Introduction", Key = MenuKeys.MenuKeyIntroduction, IsSeparator = false },
|
||||
new() { MenuHeader = "Controls", IsSeparator = true },
|
||||
new() { MenuHeader = "AspectRatioLayout", Key = MenuKeys.AspectRatioLayout, Status = "New" },
|
||||
new() { MenuHeader = "AutoCompleteBox", Key = MenuKeys.MenuKeyAutoCompleteBox, Status = "WIP" },
|
||||
new() { MenuHeader = "Avatar", Key = MenuKeys.MenuKeyAvatar, Status = "WIP" },
|
||||
new() { MenuHeader = "Badge", Key = MenuKeys.MenuKeyBadge },
|
||||
@@ -44,6 +45,7 @@ public class MenuViewModel : ViewModelBase
|
||||
new() { MenuHeader = "Numeric UpDown", Key = MenuKeys.MenuKeyNumericUpDown },
|
||||
new() { MenuHeader = "NumPad", Key = MenuKeys.MenuKeyNumPad },
|
||||
new() { MenuHeader = "Pagination", Key = MenuKeys.MenuKeyPagination },
|
||||
new() { MenuHeader = "PathPicker", Key = MenuKeys.PathPicker, Status = "WIP" },
|
||||
new() { MenuHeader = "PinCode", Key = MenuKeys.MenuKeyPinCode },
|
||||
new() { MenuHeader = "RangeSlider", Key = MenuKeys.MenuKeyRangeSlider },
|
||||
new() { MenuHeader = "Rating", Key = MenuKeys.MenuKeyRating },
|
||||
@@ -59,8 +61,7 @@ public class MenuViewModel : ViewModelBase
|
||||
new() { MenuHeader = "ToolBar", Key = MenuKeys.MenuKeyToolBar },
|
||||
new() { MenuHeader = "TreeComboBox", Key = MenuKeys.MenuKeyTreeComboBox },
|
||||
new() { MenuHeader = "TwoTonePathIcon", Key = MenuKeys.MenuKeyTwoTonePathIcon },
|
||||
new() { MenuHeader = "AspectRatioLayout", Key = MenuKeys.AspectRatioLayout, Status = "New" },
|
||||
new() { MenuHeader = "PathPicker", Key = MenuKeys.PathPicker, Status = "WIP" },
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,83 +1,162 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ursa="https://irihi.tech/ursa">
|
||||
<ControlTheme x:Key="{x:Type ursa:PathPicker}" TargetType="ursa:PathPicker">
|
||||
<ResourceDictionary
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:converters="clr-namespace:Ursa.Themes.Semi.Converters"
|
||||
xmlns:u="https://irihi.tech/ursa">
|
||||
<Design.PreviewWith>
|
||||
<StackPanel Margin="20">
|
||||
<u:PathPicker Title="Hello World" Width="300" />
|
||||
</StackPanel>
|
||||
</Design.PreviewWith>
|
||||
<ControlTheme x:Key="{x:Type u:PathPicker}" TargetType="u:PathPicker">
|
||||
<Setter Property="CornerRadius" Value="3" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<DockPanel HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalAlignment}">
|
||||
<Button Name="PART_Button"
|
||||
DockPanel.Dock="Right"
|
||||
Content="{TemplateBinding Title}"
|
||||
Margin="1,0,0,0">
|
||||
</Button>
|
||||
<TextBox Name="PART_TextBox"
|
||||
DockPanel.Dock="Left"
|
||||
AcceptsReturn="{TemplateBinding AllowMultiple}"
|
||||
Text="{TemplateBinding SelectedPathsText,Mode=TwoWay}">
|
||||
</TextBox>
|
||||
<DockPanel>
|
||||
<Button
|
||||
Name="{x:Static u:PathPicker.PART_Button}"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center"
|
||||
Content="{TemplateBinding Title}"
|
||||
DockPanel.Dock="Right" />
|
||||
<TextBox
|
||||
Name="PART_TextBox"
|
||||
AcceptsReturn="{TemplateBinding AllowMultiple}"
|
||||
DockPanel.Dock="Left"
|
||||
Text="{TemplateBinding SelectedPathsText,
|
||||
Mode=TwoWay}" />
|
||||
</DockPanel>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<Style Selector="^[AllowMultiple=False]">
|
||||
<Style Selector="^ /template/ Button#PART_Button">
|
||||
<Setter Property="DockPanel.Dock" Value="Right"></Setter>
|
||||
</Style>
|
||||
<Style Selector="^ /template/ TextBox#PART_TextBox">
|
||||
<Setter Property="DockPanel.Dock" Value="Left"></Setter>
|
||||
</Style>
|
||||
<Style Selector="^ /template/ Button#PART_Button:pressed">
|
||||
<Setter Property="RenderTransform" Value="{x:Null}" />
|
||||
</Style>
|
||||
<Style Selector="^[AllowMultiple=True]">
|
||||
|
||||
<Style Selector="^ /template/ Button#PART_Button">
|
||||
<Setter Property="DockPanel.Dock" Value="Right" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={x:Static converters:CornerRadiusTakeConverter.Right}}" />
|
||||
<Setter Property="Margin" Value="1 0 0 0" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ TextBox#PART_TextBox">
|
||||
<Setter Property="DockPanel.Dock" Value="Left" />
|
||||
<Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={x:Static converters:CornerRadiusTakeConverter.Left}}" />
|
||||
</Style>
|
||||
<Style Selector="^.Top">
|
||||
<Style Selector="^ /template/ Button#PART_Button">
|
||||
<Setter Property="DockPanel.Dock" Value="Top"></Setter>
|
||||
<Setter Property="DockPanel.Dock" Value="Top" />
|
||||
<Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={x:Static converters:CornerRadiusTakeConverter.Top}}" />
|
||||
<Setter Property="Margin" Value="0 0 0 1" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ TextBox#PART_TextBox">
|
||||
<Setter Property="DockPanel.Dock" Value="Bottom"></Setter>
|
||||
<Setter Property="DockPanel.Dock" Value="Bottom" />
|
||||
<Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={x:Static converters:CornerRadiusTakeConverter.Bottom}}" />
|
||||
</Style>
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
|
||||
<ControlTheme x:Key="PathPickerOnlyButton" TargetType="ursa:PathPicker">
|
||||
<ControlTheme x:Key="ButtonPathPicker" TargetType="u:PathPicker">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<Button Name="PART_Button"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalAlignment}"
|
||||
Content="{TemplateBinding Title}">
|
||||
</Button>
|
||||
<Button
|
||||
Name="{x:Static u:PathPicker.PART_Button}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalAlignment}"
|
||||
Content="{TemplateBinding Title}" />
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
<Style Selector="^ /template/ Button#PART_Button:pressed">
|
||||
<Setter Property="RenderTransform" Value="{x:Null}" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="PathPickerForListView" TargetType="ursa:PathPicker">
|
||||
<ControlTheme x:Key="ListPathPicker" TargetType="u:PathPicker">
|
||||
<Setter Property="CornerRadius" Value="3" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<Expander HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalAlignment}">
|
||||
<Expander
|
||||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalAlignment}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
Theme="{StaticResource INTERNAL_PathPickerExpander}">
|
||||
<Expander.Header>
|
||||
<Button Name="PART_Button"
|
||||
HorizontalAlignment="Stretch"
|
||||
Content="{TemplateBinding Title}">
|
||||
<Button.Theme>
|
||||
<ControlTheme TargetType="Button">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<TextPresenter Text="{TemplateBinding Content}"
|
||||
Background="Transparent"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch">
|
||||
</TextPresenter>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</ControlTheme>
|
||||
</Button.Theme>
|
||||
</Button>
|
||||
<Button
|
||||
Name="PART_Button"
|
||||
HorizontalAlignment="Stretch"
|
||||
Content="{TemplateBinding Title}"
|
||||
CornerRadius="{TemplateBinding CornerRadius,
|
||||
Converter={x:Static converters:CornerRadiusTakeConverter.Left}}" />
|
||||
</Expander.Header>
|
||||
<ListBox ItemsSource="{TemplateBinding SelectedPaths}"></ListBox>
|
||||
<ListBox ItemsSource="{TemplateBinding SelectedPaths}" />
|
||||
</Expander>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
<Style Selector="^ /template/ Button#PART_Button:pressed">
|
||||
<Setter Property="RenderTransform" Value="{x:Null}" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="INTERNAL_PathPickerExpander" TargetType="Expander">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<DockPanel>
|
||||
<DockPanel DockPanel.Dock="Top" LastChildFill="True">
|
||||
<ToggleButton
|
||||
Name="ExpanderHeader"
|
||||
Margin="1,0,0,0"
|
||||
Background="{DynamicResource ToggleButtonDefaultBackground}"
|
||||
CornerRadius="{TemplateBinding CornerRadius,
|
||||
Converter={x:Static converters:CornerRadiusTakeConverter.Right}}"
|
||||
DockPanel.Dock="Right"
|
||||
IsChecked="{TemplateBinding IsExpanded,
|
||||
Mode=TwoWay}"
|
||||
Theme="{DynamicResource INTERNAL_PathPickerExpanderHeaderToggleButtonTheme}">
|
||||
<PathIcon
|
||||
Name="PART_PathIcon"
|
||||
Data="{DynamicResource ExpanderIcon}"
|
||||
Theme="{DynamicResource InnerPathIcon}">
|
||||
<PathIcon.Transitions>
|
||||
<Transitions>
|
||||
<TransformOperationsTransition Property="RenderTransform" Duration="0.1" />
|
||||
</Transitions>
|
||||
</PathIcon.Transitions>
|
||||
</PathIcon>
|
||||
</ToggleButton>
|
||||
<ContentPresenter Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" />
|
||||
</DockPanel>
|
||||
<ContentPresenter
|
||||
Name="PART_ContentPresenter"
|
||||
Margin="{DynamicResource ExpanderContentMargin}"
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
Foreground="{DynamicResource ExpanderContentForeground}"
|
||||
IsVisible="{TemplateBinding IsExpanded,
|
||||
Mode=TwoWay}" />
|
||||
</DockPanel>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<Style Selector="^:expanded /template/ PathIcon#PART_PathIcon">
|
||||
<Setter Property="RenderTransform" Value="rotate(180deg)" />
|
||||
</Style>
|
||||
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="INTERNAL_PathPickerExpanderHeaderToggleButtonTheme" TargetType="ToggleButton">
|
||||
<Setter Property="Padding" Value="{DynamicResource ButtonDefaultPadding}" />
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<ContentPresenter
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Background="{TemplateBinding Background}"
|
||||
Content="{TemplateBinding Content}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}" />
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
@@ -5,19 +5,19 @@ using Avalonia.Controls;
|
||||
using Avalonia.Controls.Metadata;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Logging;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.Threading;
|
||||
using Irihi.Avalonia.Shared.Common;
|
||||
using Irihi.Avalonia.Shared.Helpers;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
[TemplatePart(Name = "PART_Button", Type = typeof(Button))]
|
||||
[TemplatePart(Name = PART_Button, Type = typeof(Button))]
|
||||
[PseudoClasses(PseudoClassName.PC_Empty)]
|
||||
public class PathPicker : TemplatedControl
|
||||
{
|
||||
public const string PART_Button = "PART_Button";
|
||||
public static readonly StyledProperty<string> SuggestedStartPathProperty =
|
||||
AvaloniaProperty.Register<PathPicker, string>(
|
||||
nameof(SuggestedStartPath), string.Empty);
|
||||
@@ -166,14 +166,6 @@ public class PathPicker : TemplatedControl
|
||||
{
|
||||
_twoConvertLock = true;
|
||||
string[] separatedStrings = ["\r", "\n", "\r\n"];
|
||||
// var list = SelectedPathsText?.Split(separatedStrings, StringSplitOptions.RemoveEmptyEntries)
|
||||
// .Select(RemoveNewLine).ToArray()
|
||||
// ?? [];
|
||||
// if (list.Length == SelectedPaths.Count)
|
||||
// {
|
||||
// if (SelectedPaths.Select(x => list.Any(y => x == y)).All(x => x is false))
|
||||
// }
|
||||
|
||||
SelectedPaths = SelectedPathsText?.Split(separatedStrings, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(RemoveNewLine).ToArray()
|
||||
?? [];
|
||||
@@ -185,7 +177,7 @@ public class PathPicker : TemplatedControl
|
||||
{
|
||||
base.OnApplyTemplate(e);
|
||||
Button.ClickEvent.RemoveHandler(LaunchPicker, _button);
|
||||
_button = e.NameScope.Find<Button>("PART_Button");
|
||||
_button = e.NameScope.Find<Button>(PART_Button);
|
||||
Button.ClickEvent.AddHandler(LaunchPicker, _button);
|
||||
}
|
||||
|
||||
@@ -243,7 +235,7 @@ public class PathPicker : TemplatedControl
|
||||
try
|
||||
{
|
||||
if (TopLevel.GetTopLevel(this)?.StorageProvider is not { } storageProvider) return;
|
||||
|
||||
_button?.SetValue(IsEnabledProperty, false);
|
||||
switch (UsePickerType)
|
||||
{
|
||||
case UsePickerTypes.OpenFile:
|
||||
@@ -273,7 +265,7 @@ public class PathPicker : TemplatedControl
|
||||
?.TryGetLocalPath();
|
||||
UpdateSelectedPaths(string.IsNullOrEmpty(path)
|
||||
? Array.Empty<string>()
|
||||
: [path!]);
|
||||
: [path]);
|
||||
break;
|
||||
case UsePickerTypes.OpenFolder:
|
||||
FolderPickerOpenOptions folderPickerOpenOptions = new()
|
||||
@@ -290,16 +282,20 @@ public class PathPicker : TemplatedControl
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
this.PseudoClasses.Set(PseudoClassName.PC_Empty, SelectedPaths.Count == 0);
|
||||
if (SelectedPaths.Count != 0 || IsOmitCommandOnCancel is false)
|
||||
{
|
||||
Command?.Execute(SelectedPaths);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Logger.TryGet(LogEventLevel.Error, LogArea.Control)?.Log(this, $"{exception}");
|
||||
}
|
||||
|
||||
return;
|
||||
finally
|
||||
{
|
||||
_button?.SetValue(IsEnabledProperty, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSelectedPaths(IReadOnlyList<string> newList)
|
||||
|
||||
Reference in New Issue
Block a user