0bc82dc6b5
- 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)
58 lines
1.5 KiB
C#
58 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
using Avalonia.Controls;
|
|
using Avalonia.Markup.Xaml;
|
|
|
|
using BFR.DataModels;
|
|
using BFR.Helpers;
|
|
|
|
namespace BFR
|
|
{
|
|
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() =>
|
|
InitializeComponent();
|
|
|
|
private void InitializeComponent()
|
|
{
|
|
AvaloniaXamlLoader.Load(this);
|
|
DataContext = this;
|
|
OpenDirectory(Environment.OSVersion.Platform == PlatformID.Win32NT ? @"C:\Users" : @"\home");
|
|
}
|
|
}
|
|
} |