Structuring, added file lists
- You can now open a directory - The current filenames and previews are now displayed in the listboxes - Added method pipeline for updating the lists (OpenDirectory -> Filter -> Preview)
This commit is contained in:
parent
90f8f86e81
commit
0bc82dc6b5
14
BFR/Helpers/Extensions.cs
Normal file
14
BFR/Helpers/Extensions.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace BFR.Helpers
|
||||||
|
{
|
||||||
|
public static class IListExtensions
|
||||||
|
{
|
||||||
|
public static void ReplaceAll<T>(this IList<T> list, IEnumerable<T> replacement)
|
||||||
|
{
|
||||||
|
list.Clear();
|
||||||
|
foreach (var t in replacement)
|
||||||
|
list.Add(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,8 +10,8 @@
|
||||||
<Border Grid.Row="0" Grid.ColumnSpan="3">
|
<Border Grid.Row="0" Grid.ColumnSpan="3">
|
||||||
<Grid RowDefinitions="*,auto" ColumnDefinitions="auto,*,auto">
|
<Grid RowDefinitions="*,auto" ColumnDefinitions="auto,*,auto">
|
||||||
<Expander Grid.Column="0" Name="FilterExpander" Header="Filter"/>
|
<Expander Grid.Column="0" Name="FilterExpander" Header="Filter"/>
|
||||||
<TextBox Grid.Column="1" IsEnabled="False" Text="C:/Example.File.png"/>
|
<TextBox Grid.Column="1" IsEnabled="False" Text="{Binding WorkingDirectory}"/>
|
||||||
<Button Grid.Column="2" Content=" ... "/>
|
<Button Grid.Column="2" Content=" ... " Command="{Binding OpenDirectoryButtonClick}"/>
|
||||||
|
|
||||||
<!-- Filters -->
|
<!-- Filters -->
|
||||||
<Grid Grid.Row="1" Grid.ColumnSpan="3" ColumnDefinitions="auto,*,auto,*,auto,auto,auto,auto" IsVisible="{Binding #FilterExpander.IsExpanded}">
|
<Grid Grid.Row="1" Grid.ColumnSpan="3" ColumnDefinitions="auto,*,auto,*,auto,auto,auto,auto" IsVisible="{Binding #FilterExpander.IsExpanded}">
|
||||||
|
@ -33,8 +33,20 @@
|
||||||
<TextBox Classes="HeaderTextBox" Grid.Row="1" Grid.Column="2" Text="After"/>
|
<TextBox Classes="HeaderTextBox" Grid.Row="1" Grid.Column="2" Text="After"/>
|
||||||
|
|
||||||
<!-- Current and Preview ListBoxes -->
|
<!-- Current and Preview ListBoxes -->
|
||||||
<ListBox Grid.Row="2" Grid.Column="0"/>
|
<ListBox Grid.Row="2" Grid.Column="0" Items="{Binding Files}" IsEnabled="False">
|
||||||
<ListBox Grid.Row="2" Grid.Column="2"/>
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<TextBlock Text="{Binding OldFullName}"/>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
<ListBox Grid.Row="2" Grid.Column="2" Items="{Binding Files}" IsEnabled="False">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<TextBlock Text="{Binding FullName}"/>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
|
||||||
<!-- Middle Section (Operations, Controls) -->
|
<!-- Middle Section (Operations, Controls) -->
|
||||||
<Grid Grid.Row="2" Grid.Column="1" RowDefinitions="*,auto,auto" Classes="StyleBorders">
|
<Grid Grid.Row="2" Grid.Column="1" RowDefinitions="*,auto,auto" Classes="StyleBorders">
|
||||||
|
|
|
@ -1,10 +1,50 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
using BFR.DataModels;
|
||||||
|
using BFR.Helpers;
|
||||||
|
|
||||||
namespace BFR
|
namespace BFR
|
||||||
{
|
{
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
|
public async Task OpenDirectoryButtonClick() =>
|
||||||
|
OpenDirectory(await new OpenFolderDialog() { Directory = WorkingDirectory }.ShowAsync(this));
|
||||||
|
|
||||||
|
public void OpenDirectory(string directory)
|
||||||
|
{
|
||||||
|
WorkingDirectory = directory;
|
||||||
|
AllFiles.ReplaceAll(Directory.GetFiles(WorkingDirectory).Select(x => new FileModel(x)));
|
||||||
|
Filter();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Filter()
|
||||||
|
{
|
||||||
|
Files.ReplaceAll(AllFiles);
|
||||||
|
|
||||||
|
// TODO: Apply filters
|
||||||
|
|
||||||
|
Preview();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Preview()
|
||||||
|
{
|
||||||
|
// Reset all files to how they currently exist
|
||||||
|
foreach (var file in Files)
|
||||||
|
file.Path = file.OldPath;
|
||||||
|
|
||||||
|
// TODO: Apply operations
|
||||||
|
|
||||||
|
// Refresh the file list to guarantee that changes are displayed. TODO: Find a better way to do this.
|
||||||
|
Files.ReplaceAll(new List<FileModel>(Files));
|
||||||
|
}
|
||||||
|
|
||||||
public MainWindow() =>
|
public MainWindow() =>
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
@ -12,6 +52,7 @@ namespace BFR
|
||||||
{
|
{
|
||||||
AvaloniaXamlLoader.Load(this);
|
AvaloniaXamlLoader.Load(this);
|
||||||
DataContext = this;
|
DataContext = this;
|
||||||
|
OpenDirectory(Environment.OSVersion.Platform == PlatformID.Win32NT ? @"C:\Users" : @"\home");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,20 @@
|
||||||
using Avalonia.Controls;
|
using System;
|
||||||
|
|
||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Collections;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
using BFR.DataModels;
|
||||||
|
|
||||||
namespace BFR
|
namespace BFR
|
||||||
{
|
{
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
|
private readonly AvaloniaProperty<string> workingDirectoryProperty =
|
||||||
|
AvaloniaProperty.Register<MainWindow, string>(nameof(WorkingDirectory));
|
||||||
|
public string WorkingDirectory { get => GetValue(workingDirectoryProperty); set => SetValue(workingDirectoryProperty, value); }
|
||||||
|
|
||||||
|
public AvaloniaList<FileModel> AllFiles { get; } = new AvaloniaList<FileModel>();
|
||||||
|
public AvaloniaList<FileModel> Files { get; } = new AvaloniaList<FileModel>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user