9 Commits

Author SHA1 Message Date
b26cc0e984 added virtual parent to list 2023-08-08 04:35:53 +02:00
ba39661926 Merge remote-tracking branch 'origin/master' 2023-08-07 22:00:41 +02:00
59e9131fed Added container selection to support pods with multiple containers 2023-08-07 22:00:27 +02:00
d544f75c99 Create LICENSE 2023-08-07 20:10:46 +02:00
ec60e55c7f remove focus on cell 2023-08-07 19:50:52 +02:00
a4fb00010e Make double click working 2023-08-07 19:50:52 +02:00
Christian Schmitt
6ad58270a9 removed unsused tag 2023-08-07 19:50:46 +02:00
Christian Schmitt
e284e3f532 added DoubleTapped Event to InvokeCommandAction 2023-08-07 19:50:15 +02:00
7e3c4248e1 Show errors on main ui thread 2023-08-06 19:37:24 +02:00
8 changed files with 220 additions and 42 deletions

View File

@@ -9,7 +9,7 @@
<Configurations>Debug;Release</Configurations> <Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU</Platforms> <Platforms>AnyCPU</Platforms>
<ApplicationIcon>Assets/app.ico</ApplicationIcon> <ApplicationIcon>Assets/app.ico</ApplicationIcon>
<Version>0.0.3</Version> <Version>0.0.7</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
@@ -28,6 +28,8 @@
<!--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 Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.1" /> <PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.1" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.1" /> <PackageReference Include="Avalonia.ReactiveUI" Version="11.0.1" />
<PackageReference Include="Avalonia.Xaml.Interactions" Version="11.0.2" />
<PackageReference Include="Avalonia.Xaml.Interactivity" Version="11.0.2" />
<PackageReference Include="KubernetesClient" Version="11.0.44" /> <PackageReference Include="KubernetesClient" Version="11.0.44" />
<PackageReference Include="Serilog" Version="3.0.1" /> <PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" /> <PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />

View File

@@ -0,0 +1,23 @@
namespace K8sFileBrowser.Models;
public class Container
{
public string Name { get; set; } = string.Empty;
public override string ToString()
{
return Name;
}
public override bool Equals(object? obj)
{
if (obj is Container container)
{
return Name == container.Name;
}
return false;
}
public override int GetHashCode() => Name.GetHashCode();
}

View File

@@ -6,9 +6,18 @@ public class FileInformation
{ {
public string Parent { get; set; } = string.Empty; public string Parent { get; set; } = string.Empty;
public FileType Type { get; set; } = FileType.File; public FileType Type { get; set; } = FileType.File;
public string DisplayName
{
get
{
if (".." == Name) return "..";
return Parent.Length < 2 ? Name[Parent.Length..] : Name[(Parent.Length + 1)..];
}
}
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public string Size { get; set; } = string.Empty; public string Size { get; set; } = string.Empty;
public DateTimeOffset Date { get; set; } = DateTimeOffset.MinValue; public DateTimeOffset? Date { get; set; }
public bool IsFile => Type == FileType.File; public bool IsFile => Type == FileType.File;
public bool IsDirectory => Type == FileType.Directory; public bool IsDirectory => Type == FileType.Directory;

View File

@@ -15,9 +15,9 @@ public interface IKubernetesService
Task<IEnumerable<Namespace>> GetNamespacesAsync(); Task<IEnumerable<Namespace>> GetNamespacesAsync();
Task<IEnumerable<Pod>> GetPodsAsync(string namespaceName, CancellationToken cancellationToken = default); Task<IEnumerable<Pod>> GetPodsAsync(string namespaceName, CancellationToken cancellationToken = default);
IList<FileInformation> GetFiles(string namespaceName, string podName, string containerName, string path); IList<FileInformation> GetFiles(string namespaceName, string podName, string containerName, string path);
Task DownloadFile(Namespace? selectedNamespace, Pod? selectedPod, FileInformation selectedFile, Task DownloadFile(Namespace? selectedNamespace, Pod? selectedPod, Container? selectedContainer, FileInformation selectedFile,
string? saveFileName, CancellationToken cancellationToken = default); string? saveFileName, CancellationToken cancellationToken = default);
Task DownloadLog(Namespace? selectedNamespace, Pod? selectedPod, Task DownloadLog(Namespace? selectedNamespace, Pod? selectedPod, Container? selectedContainer,
string? saveFileName, CancellationToken cancellationToken = default); string? saveFileName, CancellationToken cancellationToken = default);
} }

View File

@@ -98,7 +98,7 @@ public class KubernetesService : IKubernetesService
_kubernetesClient = kubernetesClient; _kubernetesClient = kubernetesClient;
} }
public async Task DownloadFile(Namespace? selectedNamespace, Pod? selectedPod, FileInformation selectedFile, public async Task DownloadFile(Namespace? selectedNamespace, Pod? selectedPod, Container? selectedContainer, FileInformation selectedFile,
string? saveFileName, CancellationToken cancellationToken = default) string? saveFileName, CancellationToken cancellationToken = default)
{ {
Log.Information("{SelectedNamespace} - {SelectedPod} - {@SelectedFile} - {SaveFileName}", Log.Information("{SelectedNamespace} - {SelectedPod} - {@SelectedFile} - {SaveFileName}",
@@ -139,14 +139,14 @@ public class KubernetesService : IKubernetesService
await _kubernetesClient.NamespacedPodExecAsync( await _kubernetesClient.NamespacedPodExecAsync(
selectedPod?.Name, selectedPod?.Name,
selectedNamespace?.Name, selectedNamespace?.Name,
selectedPod?.Containers.First(), selectedContainer?.Name,
new[] { "sh", "-c", $"tar cf - {selectedFile.Name}" }, new[] { "sh", "-c", $"tar cf - {selectedFile.Name}" },
false, false,
handler, handler,
cancellationToken); cancellationToken);
} }
public async Task DownloadLog(Namespace? selectedNamespace, Pod? selectedPod, public async Task DownloadLog(Namespace? selectedNamespace, Pod? selectedPod, Container? selectedContainer,
string? saveFileName, CancellationToken cancellationToken = default) string? saveFileName, CancellationToken cancellationToken = default)
{ {
Log.Information("{SelectedNamespace} - {SelectedPod} - {SaveFileName}", Log.Information("{SelectedNamespace} - {SelectedPod} - {SaveFileName}",
@@ -155,7 +155,7 @@ public class KubernetesService : IKubernetesService
var response = await _kubernetesClient.CoreV1.ReadNamespacedPodLogWithHttpMessagesAsync( var response = await _kubernetesClient.CoreV1.ReadNamespacedPodLogWithHttpMessagesAsync(
selectedPod?.Name, selectedPod?.Name,
selectedNamespace?.Name, selectedNamespace?.Name,
container: selectedPod?.Containers.First(), container: selectedContainer?.Name,
follow: false , cancellationToken: cancellationToken) follow: false , cancellationToken: cancellationToken)
.ConfigureAwait(false); .ConfigureAwait(false);

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reactive; using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Linq; using System.Reactive.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using K8sFileBrowser.Models; using K8sFileBrowser.Models;
@@ -12,7 +13,7 @@ namespace K8sFileBrowser.ViewModels;
public class MainWindowViewModel : ViewModelBase public class MainWindowViewModel : ViewModelBase
{ {
private ObservableAsPropertyHelper<IEnumerable<ClusterContext>> _clusterContexts; private ObservableAsPropertyHelper<IEnumerable<ClusterContext>> _clusterContexts = null!;
public IEnumerable<ClusterContext> ClusterContexts => _clusterContexts.Value; public IEnumerable<ClusterContext> ClusterContexts => _clusterContexts.Value;
private ClusterContext? _selectedClusterContext; private ClusterContext? _selectedClusterContext;
@@ -23,7 +24,7 @@ public class MainWindowViewModel : ViewModelBase
set => this.RaiseAndSetIfChanged(ref _selectedClusterContext, value); set => this.RaiseAndSetIfChanged(ref _selectedClusterContext, value);
} }
private IEnumerable<Namespace> _namespaces; private IEnumerable<Namespace> _namespaces = null!;
public IEnumerable<Namespace> Namespaces public IEnumerable<Namespace> Namespaces
{ {
get => _namespaces; get => _namespaces;
@@ -38,7 +39,7 @@ public class MainWindowViewModel : ViewModelBase
set => this.RaiseAndSetIfChanged(ref _selectedNamespace, value); set => this.RaiseAndSetIfChanged(ref _selectedNamespace, value);
} }
private ObservableAsPropertyHelper<IEnumerable<Pod>> _pods; private ObservableAsPropertyHelper<IEnumerable<Pod>> _pods = null!;
public IEnumerable<Pod> Pods => _pods.Value; public IEnumerable<Pod> Pods => _pods.Value;
private Pod? _selectedPod; private Pod? _selectedPod;
@@ -48,8 +49,23 @@ public class MainWindowViewModel : ViewModelBase
get => _selectedPod; get => _selectedPod;
set => this.RaiseAndSetIfChanged(ref _selectedPod, value); set => this.RaiseAndSetIfChanged(ref _selectedPod, value);
} }
private IEnumerable<Container>? _containers;
public IEnumerable<Container>? Containers
{
get => _containers;
set => this.RaiseAndSetIfChanged(ref _containers, value);
}
private ObservableAsPropertyHelper<IEnumerable<FileInformation>> _fileInformation; private Container? _selectedContainer;
public Container? SelectedContainer
{
get => _selectedContainer;
set => this.RaiseAndSetIfChanged(ref _selectedContainer, value);
}
private ObservableAsPropertyHelper<IEnumerable<FileInformation>> _fileInformation = null!;
public IEnumerable<FileInformation> FileInformation => _fileInformation.Value; public IEnumerable<FileInformation> FileInformation => _fileInformation.Value;
private FileInformation? _selectedFile; private FileInformation? _selectedFile;
@@ -68,19 +84,19 @@ public class MainWindowViewModel : ViewModelBase
set => this.RaiseAndSetIfChanged(ref _selectedPath, value); set => this.RaiseAndSetIfChanged(ref _selectedPath, value);
} }
private Message _message; private Message _message = null!;
public Message Message public Message Message
{ {
get => _message; get => _message;
set => this.RaiseAndSetIfChanged(ref _message, value); set => this.RaiseAndSetIfChanged(ref _message, value);
} }
public ReactiveCommand<Unit, Unit> DownloadCommand { get; private set; } public ReactiveCommand<Unit, Unit> DownloadCommand { get; private set; } = null!;
public ReactiveCommand<Unit, Unit> DownloadLogCommand { get; private set; } public ReactiveCommand<Unit, Unit> DownloadLogCommand { get; private set; } = null!;
public ReactiveCommand<Unit, Unit> ParentCommand { get; private set; } public ReactiveCommand<Unit, Unit> ParentCommand { get; private set; } = null!;
public ReactiveCommand<Unit, Unit> OpenCommand { get; private set; } public ReactiveCommand<Unit, Unit> OpenCommand { get; private set; } = null!;
private ReactiveCommand<Namespace, IEnumerable<Pod>> GetPodsForNamespace { get; set; } private ReactiveCommand<Namespace, IEnumerable<Pod>> GetPodsForNamespace { get; set; } = null!;
public MainWindowViewModel() public MainWindowViewModel()
@@ -98,6 +114,7 @@ public class MainWindowViewModel : ViewModelBase
// register the listeners // register the listeners
RegisterReadNamespaces(kubernetesService); RegisterReadNamespaces(kubernetesService);
RegisterReadPods(); RegisterReadPods();
RegisterReadContainers();
RegisterReadFiles(kubernetesService); RegisterReadFiles(kubernetesService);
RegisterResetPath(); RegisterResetPath();
@@ -123,19 +140,37 @@ public class MainWindowViewModel : ViewModelBase
// reset the path when the pod or namespace changes // reset the path when the pod or namespace changes
this.WhenAnyValue(c => c.SelectedPod, c => c.SelectedNamespace) this.WhenAnyValue(c => c.SelectedPod, c => c.SelectedNamespace)
.Throttle(new TimeSpan(10)) .Throttle(new TimeSpan(10))
.Subscribe(x => SelectedPath = "/"); .ObserveOn(RxApp.TaskpoolScheduler)
.Subscribe(_ => SelectedPath = "/");
} }
private void RegisterReadContainers()
{
// read the file information when the path changes
this
.WhenAnyValue(c => c.SelectedPod, c => c.SelectedNamespace)
.Throttle(new TimeSpan(10))
.Select(x => x.Item2 == null || x.Item1 == null
? new List<Container>()
: x.Item1.Containers.Select(c => new Container {Name = c}))
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe( x => Containers = x);
this.WhenAnyValue(x => x.Containers)
.Throttle(new TimeSpan(10))
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(x => SelectedContainer = x?.FirstOrDefault());
}
private void RegisterReadFiles(IKubernetesService kubernetesService) private void RegisterReadFiles(IKubernetesService kubernetesService)
{ {
// read the file information when the path changes // read the file information when the path changes
_fileInformation = this _fileInformation = this
.WhenAnyValue(c => c.SelectedPath, c => c.SelectedPod, c => c.SelectedNamespace) .WhenAnyValue(c => c.SelectedPath, c => c.SelectedPod, c => c.SelectedNamespace, c => c.SelectedContainer)
.Throttle(new TimeSpan(10)) .Throttle(new TimeSpan(10))
.Select(x => x.Item3 == null || x.Item2 == null .Select(x => x.Item3 == null || x.Item2 == null || x.Item1 == null || x.Item4 == null
? new List<FileInformation>() ? new List<FileInformation>()
: kubernetesService.GetFiles(x.Item3!.Name, x.Item2!.Name, x.Item2!.Containers.First(), : GetFileInformation(kubernetesService, x.Item1, x.Item2, x.Item3, x.Item4))
x.Item1))
.ObserveOn(RxApp.MainThreadScheduler) .ObserveOn(RxApp.MainThreadScheduler)
.ToProperty(this, x => x.FileInformation); .ToProperty(this, x => x.FileInformation);
} }
@@ -146,7 +181,7 @@ public class MainWindowViewModel : ViewModelBase
_pods = this _pods = this
.WhenAnyValue(c => c.SelectedNamespace) .WhenAnyValue(c => c.SelectedNamespace)
.Throttle(new TimeSpan(10)) .Throttle(new TimeSpan(10))
.SelectMany(ns => GetPodsForNamespace.Execute(ns)) .SelectMany(ns => GetPodsForNamespace.Execute(ns!))
.ObserveOn(RxApp.MainThreadScheduler) .ObserveOn(RxApp.MainThreadScheduler)
.ToProperty(this, x => x.Pods); .ToProperty(this, x => x.Pods);
} }
@@ -167,7 +202,7 @@ public class MainWindowViewModel : ViewModelBase
GetPodsForNamespace = ReactiveCommand.CreateFromObservable<Namespace, IEnumerable<Pod>>(ns => GetPodsForNamespace = ReactiveCommand.CreateFromObservable<Namespace, IEnumerable<Pod>>(ns =>
Observable.StartAsync(_ => PodsAsync(ns, kubernetesService), RxApp.TaskpoolScheduler)); Observable.StartAsync(_ => PodsAsync(ns, kubernetesService), RxApp.TaskpoolScheduler));
GetPodsForNamespace.ThrownExceptions GetPodsForNamespace.ThrownExceptions.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(ex => ShowErrorMessage(ex.Message).ConfigureAwait(false).GetAwaiter().GetResult()); .Subscribe(ex => ShowErrorMessage(ex.Message).ConfigureAwait(false).GetAwaiter().GetResult());
} }
@@ -186,7 +221,7 @@ public class MainWindowViewModel : ViewModelBase
} }
}, isNotRoot, RxApp.MainThreadScheduler); }, isNotRoot, RxApp.MainThreadScheduler);
ParentCommand.ThrownExceptions ParentCommand.ThrownExceptions.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(ex => ShowErrorMessage(ex.Message).ConfigureAwait(false).GetAwaiter().GetResult()); .Subscribe(ex => ShowErrorMessage(ex.Message).ConfigureAwait(false).GetAwaiter().GetResult());
} }
@@ -205,13 +240,13 @@ public class MainWindowViewModel : ViewModelBase
if (saveFileName != null) if (saveFileName != null)
{ {
ShowWorkingMessage("Downloading Log..."); ShowWorkingMessage("Downloading Log...");
await kubernetesService.DownloadLog(SelectedNamespace, SelectedPod, saveFileName); await kubernetesService.DownloadLog(SelectedNamespace, SelectedPod, SelectedContainer, saveFileName);
HideWorkingMessage(); HideWorkingMessage();
} }
}, RxApp.TaskpoolScheduler); }, RxApp.TaskpoolScheduler);
}, isSelectedPod, RxApp.MainThreadScheduler); }, isSelectedPod, RxApp.MainThreadScheduler);
DownloadLogCommand.ThrownExceptions DownloadLogCommand.ThrownExceptions.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(ex => ShowErrorMessage(ex.Message).ConfigureAwait(false).GetAwaiter().GetResult()); .Subscribe(ex => ShowErrorMessage(ex.Message).ConfigureAwait(false).GetAwaiter().GetResult());
} }
@@ -231,13 +266,13 @@ public class MainWindowViewModel : ViewModelBase
if (saveFileName != null) if (saveFileName != null)
{ {
ShowWorkingMessage("Downloading File..."); ShowWorkingMessage("Downloading File...");
await kubernetesService.DownloadFile(SelectedNamespace, SelectedPod, SelectedFile, saveFileName); await kubernetesService.DownloadFile(SelectedNamespace, SelectedPod, SelectedContainer, SelectedFile, saveFileName);
HideWorkingMessage(); HideWorkingMessage();
} }
}, RxApp.TaskpoolScheduler); }, RxApp.TaskpoolScheduler);
}, isFile, RxApp.MainThreadScheduler); }, isFile, RxApp.MainThreadScheduler);
DownloadCommand.ThrownExceptions DownloadCommand.ThrownExceptions.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(ex => ShowErrorMessage(ex.Message).ConfigureAwait(false).GetAwaiter().GetResult()); .Subscribe(ex => ShowErrorMessage(ex.Message).ConfigureAwait(false).GetAwaiter().GetResult());
} }
@@ -247,10 +282,16 @@ public class MainWindowViewModel : ViewModelBase
.WhenAnyValue(x => x.SelectedFile, x => x.Message.IsVisible) .WhenAnyValue(x => x.SelectedFile, x => x.Message.IsVisible)
.Select(x => x is { Item1.Type: FileType.Directory, Item2: false }); .Select(x => x is { Item1.Type: FileType.Directory, Item2: false });
OpenCommand = ReactiveCommand.Create(() => { SelectedPath = SelectedFile != null ? SelectedFile!.Name : "/"; }, OpenCommand = ReactiveCommand.Create(() =>
{
if (".." == SelectedFile?.Name)
SelectedPath = SelectedFile?.Parent;
else
SelectedPath = SelectedFile != null ? SelectedFile!.Name : "/";
},
isDirectory, RxApp.MainThreadScheduler); isDirectory, RxApp.MainThreadScheduler);
OpenCommand.ThrownExceptions OpenCommand.ThrownExceptions.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(ex => ShowErrorMessage(ex.Message).ConfigureAwait(false).GetAwaiter().GetResult()); .Subscribe(ex => ShowErrorMessage(ex.Message).ConfigureAwait(false).GetAwaiter().GetResult());
} }
@@ -270,17 +311,43 @@ public class MainWindowViewModel : ViewModelBase
{ {
ShowWorkingMessage("Switching context..."); ShowWorkingMessage("Switching context...");
Namespaces = new List<Namespace>(); Namespaces = new List<Namespace>();
kubernetesService.SwitchClusterContext(context!); kubernetesService.SwitchClusterContext(context);
var namespaces = await kubernetesService.GetNamespacesAsync(); var namespaces = await kubernetesService.GetNamespacesAsync();
HideWorkingMessage(); HideWorkingMessage();
return namespaces; return namespaces;
} }
catch (Exception e) catch (Exception e)
{ {
await ShowErrorMessage(e.Message); RxApp.MainThreadScheduler.Schedule(Action);
return new List<Namespace>(); return new List<Namespace>();
async void Action() => await ShowErrorMessage(e.Message);
} }
} }
private IList<FileInformation> GetFileInformation(IKubernetesService kubernetesService,
string path, Pod pod, Namespace nameSpace, Container container)
{
var kubernetesFileInformation = kubernetesService.GetFiles(
nameSpace.Name, pod.Name, container.Name, path);
// when the path is root, we don't want to show the parent directory
if (SelectedPath is not { Length: > 1 }) return kubernetesFileInformation;
// add the parent directory
var parent = SelectedPath[..SelectedPath.LastIndexOf('/')];
if (string.IsNullOrEmpty(parent))
{
parent = "/";
}
return kubernetesFileInformation.Prepend(new FileInformation
{
Name = "..",
Type = FileType.Directory,
Parent = parent
}).ToList();
}
private void ShowWorkingMessage(string message) private void ShowWorkingMessage(string message)
{ {

View File

@@ -72,12 +72,24 @@
</ListBox> </ListBox>
<GridSplitter Grid.Column="1" ResizeDirection="Columns" /> <GridSplitter Grid.Column="1" ResizeDirection="Columns" />
<Grid Grid.Column="2" RowDefinitions="Auto, *"> <Grid Grid.Column="2" RowDefinitions="Auto, *">
<Grid ColumnDefinitions="*, Auto"> <Grid ColumnDefinitions="*, Auto, Auto">
<StackPanel Grid.Column="0" Orientation="Horizontal"> <StackPanel Grid.Column="0" Orientation="Horizontal">
<TextBlock Text="Current Directory" VerticalAlignment="Center" Margin="10 0 0 0"></TextBlock> <TextBlock Text="Current Directory" VerticalAlignment="Center" Margin="10 0 0 0"></TextBlock>
<TextBlock Text="{Binding SelectedPath}" VerticalAlignment="Center" Margin="10 0 0 0"></TextBlock> <TextBlock Text="{Binding SelectedPath}" VerticalAlignment="Center" Margin="10 0 0 0"></TextBlock>
</StackPanel> </StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal" Spacing="4" Margin="10" HorizontalAlignment="Right"> <StackPanel Grid.Column="1" VerticalAlignment="Center" Orientation="Horizontal">
<Label VerticalAlignment="Center"
Margin="0 0 10 0">
Container:
</Label>
<ComboBox ItemsSource="{Binding Containers}"
SelectedItem="{Binding SelectedContainer}"
VerticalAlignment="Center"
MinWidth="200"
Margin="0 0 10 0">
</ComboBox>
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal" Spacing="4" Margin="10" HorizontalAlignment="Right">
<Button Command="{Binding ParentCommand}" VerticalAlignment="Center" ToolTip.Tip="Go To Parent Directory"> <Button Command="{Binding ParentCommand}" VerticalAlignment="Center" ToolTip.Tip="Go To Parent Directory">
<PathIcon Data="{StaticResource arrow_curve_up_left_regular}"></PathIcon> <PathIcon Data="{StaticResource arrow_curve_up_left_regular}"></PathIcon>
@@ -102,7 +114,7 @@
BorderThickness="1" BorderThickness="1"
SelectionMode="Single" SelectionMode="Single"
SelectedItem="{Binding SelectedFile}" SelectedItem="{Binding SelectedFile}"
> Focusable="False">
<DataGrid.Styles> <DataGrid.Styles>
<Style Selector="DataGridColumnHeader"> <Style Selector="DataGridColumnHeader">
<Setter Property="FontSize" Value="14"></Setter> <Setter Property="FontSize" Value="14"></Setter>
@@ -116,19 +128,63 @@
<DataGridTemplateColumn Header="Type"> <DataGridTemplateColumn Header="Type">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate DataType="models:FileInformation"> <DataTemplate DataType="models:FileInformation">
<Border ToolTip.Tip="{Binding Type}" VerticalAlignment="Center" HorizontalAlignment="Center"> <Border ToolTip.Tip="{Binding Type}" Background="Transparent">
<StackPanel> <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<PathIcon Data="{StaticResource folder_regular}" IsVisible="{Binding IsDirectory}"></PathIcon> <PathIcon Data="{StaticResource folder_regular}" IsVisible="{Binding IsDirectory}"></PathIcon>
<PathIcon Data="{StaticResource document_regular}" IsVisible="{Binding IsFile}"></PathIcon> <PathIcon Data="{StaticResource document_regular}" IsVisible="{Binding IsFile}"></PathIcon>
<PathIcon Data="{StaticResource document_unknown_regular}" IsVisible="{Binding IsUnknown}"></PathIcon> <PathIcon Data="{StaticResource document_unknown_regular}" IsVisible="{Binding IsUnknown}"></PathIcon>
</StackPanel> </StackPanel>
<Interaction.Behaviors>
<EventTriggerBehavior EventName="DoubleTapped">
<InvokeCommandAction Command="{Binding ((vm:MainWindowViewModel)DataContext).OpenCommand, RelativeSource={RelativeSource AncestorType=Window }}" />
</EventTriggerBehavior>
</Interaction.Behaviors>
</Border>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Name" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate DataType="models:FileInformation">
<Border Background="Transparent">
<TextBlock Text="{Binding DisplayName}" VerticalAlignment="Center"/>
<Interaction.Behaviors>
<EventTriggerBehavior EventName="DoubleTapped">
<InvokeCommandAction Command="{Binding ((vm:MainWindowViewModel)DataContext).OpenCommand, RelativeSource={RelativeSource AncestorType=Window }}" />
</EventTriggerBehavior>
</Interaction.Behaviors>
</Border>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Size" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate DataType="models:FileInformation">
<Border Background="Transparent">
<TextBlock Text="{Binding Size}" VerticalAlignment="Center"/>
<Interaction.Behaviors>
<EventTriggerBehavior EventName="DoubleTapped">
<InvokeCommandAction Command="{Binding ((vm:MainWindowViewModel)DataContext).OpenCommand, RelativeSource={RelativeSource AncestorType=Window }}" />
</EventTriggerBehavior>
</Interaction.Behaviors>
</Border>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Date" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate DataType="models:FileInformation">
<Border Background="Transparent">
<TextBlock Text="{Binding Date}" VerticalAlignment="Center"/>
<Interaction.Behaviors>
<EventTriggerBehavior EventName="DoubleTapped">
<InvokeCommandAction Command="{Binding ((vm:MainWindowViewModel)DataContext).OpenCommand, RelativeSource={RelativeSource AncestorType=Window }}" />
</EventTriggerBehavior>
</Interaction.Behaviors>
</Border> </Border>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn> </DataGridTemplateColumn>
<DataGridTextColumn Header="Name" Width="*" Binding="{Binding Name}" />
<DataGridTextColumn Header="Size" Binding="{Binding Size}" />
<DataGridTextColumn Header="Date" Binding="{Binding Date}" />
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
</Grid> </Grid>

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Andreas Billmann
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.