Flow.Launcher/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs

98 lines
3.1 KiB
C#
Raw Normal View History

2025-04-15 05:21:00 +00:00
using System.ComponentModel;
2020-06-06 12:13:22 +00:00
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
2025-04-15 05:21:00 +00:00
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
using Flow.Launcher.Plugin.Explorer.ViewModels;
2020-06-06 12:13:22 +00:00
using DataFormats = System.Windows.DataFormats;
using DragDropEffects = System.Windows.DragDropEffects;
using DragEventArgs = System.Windows.DragEventArgs;
namespace Flow.Launcher.Plugin.Explorer.Views
{
/// <summary>
/// Interaction logic for ExplorerSettings.xaml
/// </summary>
2020-06-06 12:13:22 +00:00
public partial class ExplorerSettings
{
private readonly SettingsViewModel viewModel;
public ExplorerSettings(SettingsViewModel viewModel)
{
DataContext = viewModel;
InitializeComponent();
2020-06-06 12:13:22 +00:00
this.viewModel = viewModel;
2020-06-06 12:13:22 +00:00
DataContext = viewModel;
ActionKeywordModel.Init(viewModel.Settings);
2020-06-06 12:13:22 +00:00
2021-01-26 09:46:05 +00:00
lbxAccessLinks.Items.SortDescriptions.Add(new SortDescription("Path", ListSortDirection.Ascending));
2020-06-06 12:13:22 +00:00
lbxExcludedPaths.Items.SortDescriptions.Add(new SortDescription("Path", ListSortDirection.Ascending));
2020-07-16 11:45:08 +00:00
}
2020-06-06 12:13:22 +00:00
private void AccessLinkDragDrop(string containerName, DragEventArgs e)
2020-06-06 12:13:22 +00:00
{
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files == null || !files.Any())
2020-06-06 12:13:22 +00:00
{
return;
}
foreach (var s in files)
{
if (Directory.Exists(s))
2020-06-06 12:13:22 +00:00
{
var newFolderLink = new AccessLink
2020-06-06 12:13:22 +00:00
{
Path = s
};
viewModel.AppendLink(containerName, newFolderLink);
2020-06-06 12:13:22 +00:00
}
}
}
2021-01-26 09:46:05 +00:00
private void lbxAccessLinks_DragEnter(object sender, DragEventArgs e)
2020-06-06 12:13:22 +00:00
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effects = DragDropEffects.Link;
}
else
{
e.Effects = DragDropEffects.None;
}
}
private void btnOpenIndexingOptions_Click(object sender, RoutedEventArgs e)
{
SettingsViewModel.OpenWindowsIndexingOptions();
}
private void EverythingSortOptionChanged(object sender, SelectionChangedEventArgs e)
{
if (tbFastSortWarning is not null)
{
tbFastSortWarning.Visibility = viewModel.FastSortWarningVisibility;
tbFastSortWarning.Text = viewModel.SortOptionWarningMessage;
}
}
private void LbxAccessLinks_OnDrop(object sender, DragEventArgs e)
{
AccessLinkDragDrop("QuickAccessLink", e);
}
private void LbxExcludedPaths_OnDrop(object sender, DragEventArgs e)
{
AccessLinkDragDrop("IndexSearchExcludedPath", e);
}
2024-08-10 11:24:48 +00:00
private void AllowOnlyNumericInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
{
e.Handled = e.Text.ToCharArray().Any(c => !char.IsDigit(c));
}
2020-07-16 11:45:08 +00:00
}
}