FileSurfer 1.1.4
Modern Windows File Explorer
|
Welcome to the technical documentation of FileSurfer. This project was started back in July 2024 as my semestral programming project. Since then I have been working on polishing its features and managing its github page. It is a program I use every time I find myself on Windows (even though it is not much these days).
FileSurfer is built purely with C# and uses the Reactive UI framework from the AvaloniaUI ecosystem. By design of AvaloniaUI application, FileSurfer follows the MVVM (Model-View-ViewModel) architectural pattern.
The Models encapsulate functional logic such as file system operations, file system information retrieval, interaction with the system clipboard, etc...
Views represent the UI elements with minimal functional logic. They handle user input and serve it to the ViewModels while receiving data from the ViewModels to display.
ViewModels serve as a layer in between the Views and the Models. They transform data for the UI and routing user input to the appropriate Model functions.
Bellow is a list of classes and interfaces separated into namespaces.
Core namespace containing the entry point, global settings, and view resolution logic for the FileSurfer application.
Entry point for the FileSurfer application. This AvaloniaUI application uses the ReactiveUI framework.
A static class that manages the application configuration and user preferences using static properties. Loads and saves user settings using a json file at *"C:\Users\USER_NAME\AppData\Roaming\FileSurfer\settings.json"*.
Uses a simple record class SettingsRecord which holds the settings' as properties and also provides the default values. SettingsRecord is also used to parse the values from the json file and in SettingsWindowViewModel.
Entry point for the application. (generated by AvaloniaUI)
The code behind (.axaml.cs) handles command line arguments, application theme, and the creation of MainWindowViewModel.
The AXAML contains dynamic resources such as fonts and colors.
Instantiates views. (generated by AvaloniaUI)
Contains the graphic interfaces of FileSurfer. Defines Avalonia Windows and their layouts with minimal logic.
The main application window. Inherits from Window.
The AXAML handles the layout and overal look and feel of the application along with the style sheet in MainWindowStyle.axaml. It also defines simple keybindings which are not dependent on the state of the window and its elements.
The code behind handles interaction with MainWindowViewModel such as invoking commands in cases of more complex or context dependent user actions or key presses. Handles overall displaying logic such as disabling keyboard shortcuts while a text-box is focused. Invokes the OnClosing method before the program is closed. The OnClosing method saves the current settings and disposes the MainWindowViewModel.
Serves as a dialog for displaying error messages. Inherits from Window and does not have a ViewModel.
The AXAML handles the visual layout along with the style sheet in ErrorWindowStyle.axaml.
The code behind handles button actions, key presses, and holds the message displayed.
Window for configuring application settings. DataContext is SettingsWindowViewModel.
Inherits from MainWindow so it can be displayed as its dialog.
The AXAML handles the visual layout along with the style sheet in SettingsWindowStyle.axaml.
The code behind handles button actions and key presses.
Contains the ViewModels that connect the Views to the Models in FileSurfer.
View model that coordinates the SettingsWindow.
Communicates with FileSurferSettings via the SettingsRecord.
Handles the sanitization of input.
Primary view model that coordinates the application's main functionality. Inherits from ReactiveObject and implements IDisposable.
Holds all properties with data displayed in the MainWindow. Contains most of the basic logic present in the program.
Communicates with the MainWindow and serves its data to Models. Also contains searching logic which is tightly integrated with the MainWindow for performance reasons.
Directly holds most utility classes / interfaces from Models.
ViewModel representing displayable file system entries.
Holds data such as path, icon, size, etc. Contains an IFileSystemEntry.
Factory class for simplifying the creation of FileSystemEntryViewModels.
Contains an IFileInfoProvider and an IIconProvider.
Holds the fundamental data structures, interfaces, and logic related to the general behavior of FileSurfer.
Base interface for file system objects (files, directories, drives).
Created out of necessity to encapsulate more information about a file system object.
Implements IFileSystemEntry. Represents a file in the file system.
Non-essential properties are implemented lazily.
Implements IFileSystemEntry. Represents a directory in the file system.
Implements IFileSystemEntry. Represents a drive in the file system.
Instantiated with System.IO.DriveInfo.
Generic class managing undo and redo operations and history of visited directories in FileSurfer.
Implemented as a doubly linked list with empty head and tail nodes, which are especially useful when navigating undo/redo operations.
Simple interface representing the outcome of an operation in the FileSurfer app.
Replaced the former convention of bool SomeMethod(..., out string? errorMessage) while also allowing for multiple error messages.
A lightweight and immutable implementation of IResult.
Allows for a failed IResult without an error message.
Has a private constructor and can be retrieved only using static methods. An 'ok' and 'error' result without an errorMessage are static references.
A more flexible but also more memory intensive implementation of IResult.
Also has a private constructor.
Allows for adding more error messages and merging with other IResult objects after creation.
Provides abstractions and implementations for retrieving metadata about files, directories, and drives.
Interface for retrieving file metadata and properties as well as information about the environment.
Part of the lowest layer between the application and the file system.
Windows-specific implementation of IFileInfoProvider for retrieving file information.
Interface for retrieving icons for files, drives, and directories in the form of Avalonia.Media.Imaging.Bitmap.
Used by FileSystemEntryViewModel.
Implements IIconProvider and IDisposable.
Uses an IFileInfoProvider to retrieve icons.
Implements caching for icons of most file extensions, except for .exe, .dll. etc. which sometimes have unique icons.
Drive and directory icons are loaded from the assets directory.
Static class for creating unique filenames for new or copied files.
For example the user wants to create a new file (called New File by default) but a file with that name is already present In which case the FileNameGenerator will supply a new name such as New File (1).
Contains abstractions and implementations for version control integration, including command execution.
Enum representing the different states of files within a git repository in the context of FileSurfer's git integration.
Interface for integration with version control systems.
Implementing classes must also implement IDisposable.
Provides methods for downloading, uploading and staging changes in version controlled repositories.
Implementation of IVersionControl operations for Git repositories using the LibGit2Sharp NuGet package. Handles subdirectories of git repositories. Holds the data about the current git repository. That data is released (and potentially replaced) when InitIfVersionControlled is called on a directory outside of that repository.
Some commands from LibGit2Sharp require user authentication - these commands are implemented as shell commands for now.
Uses an IShellHandler for command invocation.
Caches state information about files and directories for the current repository.
Defines abstractions and implementations for interacting with the system shell.
Interface for interacting with the OS shell. Part of the lowest layer between the application and the file system.
Provides methods for opening programs and executing shell commands.
Windows-specific implementation of IShellHandler for shell interactions. Uses System.Runtime.InteropServices and IWshRuntimeLibrary to interop with the Windows shell.
Interface for restoring deleted files and directories from the system bin.
Implementation of IFileRestorer for restoration of deleted files and directories on Windows. Implemented using the Shell32 COM reference.
Static class that encapsulates showing of the native Windows properties window for a file, directory, or a drive.
Uses the ShellExecuteEx extern from shell32.dll.
Encapsulates file and directory operations.
Interface defining methods for file system operations such as creation, deleting, and moving of files and directories.
Part of the lowest layer between the application and the file system.
Windows-specific implementation of file operations. Most operations are implemented using Microsoft.VisualBasic.FileIO methods since they provide native Windows confirmation dialogs.
Internally uses an IFileInfoProvider and an IFileRestorer.
Interface for managing clipboard operations for files and directories.
Implements IClipboardManager.
Uses Windows Forms to interact with the system clipboard (subject to change), while still keeping track of clipboard operations using an internal 'clipboard'.
Supports pasting pictures from the system clipboard.
Uses an IFileIOHandler for file operations.
Static class that handles compression and extraction of archive files.
Implemented using the SharpCompress NuGet package.
Namespace containing undoable file operations and their supporting abstractions. Each operation is encapsulated in its own class.
Simple interface for operations that can be undone.
I decided to name the "redoing" function Invoke instead of Redo since the function is useful for when invoking these operations for the first time too.
Implements IUndoableFileOperation.
Abstract class for operations on multiple entries.
This class does not have a deeper conceptual meaning other than reducing boilerplate from IUndoableFileOperations that affect multiple files and directories.
Implements UndoableOperation.
Undoable operation for copying files to a destination.
Implements UndoableOperation.
Undoable operation for creating duplicates of files.
Implements UndoableOperation.
Undoable operation for moving files to a new location.
Implements UndoableOperation.
Undoable operation for moving files to the recycle bin/trash.
Implements IUndoableFileOperation.
Undoable operation for creating a new directory.
Implements IUndoableFileOperation.
Undoable operation for creating a new file.
Implements UndoableOperation.
Undoable operation for renaming files.
Assumes all entries have a common original parent directory.
Implements IUndoableFileOperation.
Undoable operation for renaming files.
Implements IUndoableFileOperation.
Undoable operation for moving all files from a subfolder to a parent folder.