Initial commit: FluidExplorer:从零实现的 WinUI 3 文件资源管理器替代品(Mica、命令栏、面包屑)

This commit is contained in:
WpyQwq
2026-09-19 11:54:03 +08:00
commit 5780fde61a
60 changed files with 15035 additions and 0 deletions
+140
View File
@@ -0,0 +1,140 @@
using FluidExplorer.Services;
using FluidExplorer.ViewModels;
using Microsoft.UI.Xaml.Controls;
namespace FluidExplorer.Views;
/// <summary>设置对话框:改动即时生效并写入 settings.json。</summary>
public sealed partial class SettingsDialog : ContentDialog
{
private readonly MainViewModel _main;
private bool _initializing = true;
public SettingsDialog(MainViewModel main)
{
_main = main;
InitializeComponent();
ThemeBox.SelectedIndex = main.ThemeMode switch
{
AppThemeMode.Light => 1,
AppThemeMode.Dark => 2,
_ => 0
};
AnimationSwitch.IsOn = main.AnimationsEnabled;
HiddenSwitch.IsOn = main.ShowHiddenFiles;
SystemSwitch.IsOn = main.ShowSystemFiles;
ExtensionSwitch.IsOn = main.ShowFileExtensions;
CheckBoxSwitch.IsOn = main.AlwaysShowCheckBoxes;
NewTabSwitch.IsOn = main.Settings.OpenFoldersInNewTab;
ScopeSwitch.IsOn = main.SearchInCurrentFolderOnly;
AsYouTypeSwitch.IsOn = main.Settings.SearchAsYouType;
IndexStartupSwitch.IsOn = main.Settings.IndexOnStartup;
RecycleSwitch.IsOn = main.DeleteToRecycleBin;
ConflictBox.SelectedIndex = main.Settings.DefaultConflictPolicy switch
{
ConflictPolicySetting.Replace => 1,
ConflictPolicySetting.Skip => 2,
ConflictPolicySetting.KeepBoth => 3,
_ => 0
};
IndexStatusText.Text = $"{main.IndexSummary}({Environment.ProcessorCount} 核并行扫描;NTFS 索引可让全盘搜索稳定在毫秒级)";
_initializing = false;
}
private void OnThemeChanged(object sender, SelectionChangedEventArgs e)
{
if (_initializing) return;
_main.ThemeMode = ThemeBox.SelectedIndex switch
{
1 => AppThemeMode.Light,
2 => AppThemeMode.Dark,
_ => AppThemeMode.System
};
}
private void OnAnimationToggled(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
if (_initializing) return;
_main.AnimationsEnabled = AnimationSwitch.IsOn;
}
private void OnHiddenToggled(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
if (_initializing) return;
_main.ShowHiddenFiles = HiddenSwitch.IsOn;
}
private void OnSystemToggled(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
if (_initializing) return;
_main.ShowSystemFiles = SystemSwitch.IsOn;
}
private void OnExtensionToggled(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
if (_initializing) return;
_main.ShowFileExtensions = ExtensionSwitch.IsOn;
}
private void OnCheckBoxToggled(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
if (_initializing) return;
_main.AlwaysShowCheckBoxes = CheckBoxSwitch.IsOn;
}
private void OnNewTabToggled(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
if (_initializing) return;
_main.Settings.OpenFoldersInNewTab = NewTabSwitch.IsOn;
_main.Settings.Save();
}
private void OnScopeToggled(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
if (_initializing) return;
_main.SearchInCurrentFolderOnly = ScopeSwitch.IsOn;
}
private void OnAsYouTypeToggled(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
if (_initializing) return;
_main.Settings.SearchAsYouType = AsYouTypeSwitch.IsOn;
_main.Settings.Save();
}
private void OnIndexStartupToggled(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
if (_initializing) return;
_main.Settings.IndexOnStartup = IndexStartupSwitch.IsOn;
_main.Settings.Save();
}
private void OnRecycleToggled(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
if (_initializing) return;
_main.DeleteToRecycleBin = RecycleSwitch.IsOn;
}
private void OnConflictChanged(object sender, SelectionChangedEventArgs e)
{
if (_initializing) return;
_main.Settings.DefaultConflictPolicy = ConflictBox.SelectedIndex switch
{
1 => ConflictPolicySetting.Replace,
2 => ConflictPolicySetting.Skip,
3 => ConflictPolicySetting.KeepBoth,
_ => ConflictPolicySetting.Ask
};
_main.Settings.Save();
}
private void OnBuildIndexClick(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
_main.BuildIndexCommand.Execute(null);
IndexStatusText.Text = "正在建立索引…(首次读取 MFT 通常几秒内完成,之后靠 USN 增量保持实时)";
}
private void OnRestartElevatedClick(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
=> _main.RestartElevatedCommand.Execute(null);
}