PathPresenter, File type item

This commit is contained in:
2022-05-16 22:12:21 +02:00
parent 836c39c80c
commit becca2b62f
7 changed files with 73 additions and 9 deletions

View File

@@ -0,0 +1,18 @@
using System.Globalization;
using Avalonia.Data.Converters;
namespace FileTime.GuiApp.Converters;
public class StringReplaceConverter : IValueConverter
{
public string? OldValue { get; set; }
public string? NewValue { get; set; }
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
=> value is string s && OldValue != null && NewValue != null ? s.Replace(OldValue, NewValue) : value;
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}

View File

@@ -31,4 +31,5 @@
<converters:ExceptionToStringConverter x:Key="ExceptionToStringConverter" />
<converters:CommandToCommandNameConverter x:Key="CommandToCommandNameConverter" />
<converters:ItemToImageConverter x:Key="ItemToImageConverter" />
<converters:StringReplaceConverter x:Key="PathPreformatter" OldValue="://" NewValue="/"/>
</ResourceDictionary>

View File

@@ -47,7 +47,7 @@
<StackPanel
Margin="20,10"
Orientation="Horizontal">
<!-- local:PathPresenter DataContext="{Binding AppState.SelectedTab^.CurrentLocation^.FullName.Path,Converter={StaticResource PathPreformatter}}"/ -->
<local:PathPresenter DataContext="{Binding AppState.SelectedTab^.CurrentLocation^.FullName.Path,Converter={StaticResource PathPreformatter}}"/>
<TextBlock
Foreground="{StaticResource AccentBrush}"
Text="{Binding AppState.SelectedTab^.CurrentSelectedItem^.DisplayNameText}" />

View File

@@ -0,0 +1,23 @@
<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"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
xmlns:coremodels="using:FileTime.Core.Models"
x:Class="FileTime.GuiApp.Views.PathPresenter">
<ItemsControl Items="{Binding Converter={StaticResource SplitStringConverter}, ConverterParameter={x:Static coremodels:Constants.SeparatorChar}}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding}"/>
<TextBlock Text="/" Margin="5,0,5,0" Foreground="{DynamicResource LightForegroundBrush}"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</UserControl>

View File

@@ -0,0 +1,18 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace FileTime.GuiApp.Views;
public partial class PathPresenter : UserControl
{
public PathPresenter()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}