2025-08-31 07:53:21 +00:00
|
|
|
using System.Collections.Generic;
|
2025-06-06 08:05:12 +00:00
|
|
|
using System.ComponentModel;
|
2020-06-06 12:13:22 +00:00
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
2020-05-11 13:15:15 +00:00
|
|
|
using System.Windows;
|
2022-07-04 00:50:02 +00:00
|
|
|
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;
|
2020-05-11 13:15:15 +00:00
|
|
|
|
|
|
|
|
namespace Flow.Launcher.Plugin.Explorer.Views
|
|
|
|
|
{
|
2020-06-06 12:13:22 +00:00
|
|
|
public partial class ExplorerSettings
|
2020-05-11 13:15:15 +00:00
|
|
|
{
|
2025-06-06 08:15:26 +00:00
|
|
|
private readonly SettingsViewModel _viewModel;
|
2025-06-06 09:03:20 +00:00
|
|
|
private readonly List<Expander> _expanders;
|
2020-07-18 14:12:11 +00:00
|
|
|
|
2020-06-08 04:20:22 +00:00
|
|
|
public ExplorerSettings(SettingsViewModel viewModel)
|
2020-05-11 13:15:15 +00:00
|
|
|
{
|
2025-06-06 08:15:26 +00:00
|
|
|
_viewModel = viewModel;
|
2022-03-25 21:19:00 +00:00
|
|
|
DataContext = viewModel;
|
2025-06-06 08:15:26 +00:00
|
|
|
|
2020-05-11 13:15:15 +00:00
|
|
|
InitializeComponent();
|
2025-06-06 08:15:26 +00:00
|
|
|
|
|
|
|
|
DataContext = viewModel;
|
2022-03-13 03:27:46 +00:00
|
|
|
|
2022-07-01 04:56:15 +00:00
|
|
|
ActionKeywordModel.Init(viewModel.Settings);
|
2025-06-06 09:03:20 +00:00
|
|
|
|
|
|
|
|
_expanders = new List<Expander>
|
|
|
|
|
{
|
|
|
|
|
GeneralSettingsExpander,
|
|
|
|
|
ContextMenuExpander,
|
|
|
|
|
PreviewPanelExpander,
|
|
|
|
|
EverythingExpander,
|
|
|
|
|
ActionKeywordsExpander,
|
|
|
|
|
QuickAccessExpander,
|
|
|
|
|
ExcludedPathsExpander
|
|
|
|
|
};
|
2020-07-16 11:45:08 +00:00
|
|
|
}
|
2020-06-06 12:13:22 +00:00
|
|
|
|
2022-07-04 00:50:02 +00:00
|
|
|
private void AccessLinkDragDrop(string containerName, DragEventArgs e)
|
2020-06-06 12:13:22 +00:00
|
|
|
{
|
2022-07-04 00:50:02 +00:00
|
|
|
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
2020-07-17 11:14:15 +00:00
|
|
|
|
2025-07-20 15:33:38 +00:00
|
|
|
if (files == null || files.Length == 0)
|
2020-06-06 12:13:22 +00:00
|
|
|
{
|
2022-07-04 00:50:02 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
foreach (var s in files)
|
|
|
|
|
{
|
|
|
|
|
if (Directory.Exists(s))
|
2020-06-06 12:13:22 +00:00
|
|
|
{
|
2022-07-04 00:50:02 +00:00
|
|
|
var newFolderLink = new AccessLink
|
2020-06-06 12:13:22 +00:00
|
|
|
{
|
2022-07-04 00:50:02 +00:00
|
|
|
Path = s
|
|
|
|
|
};
|
2025-06-06 08:15:26 +00:00
|
|
|
_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;
|
|
|
|
|
}
|
2020-05-11 13:15:15 +00:00
|
|
|
}
|
2020-06-08 08:41:59 +00:00
|
|
|
|
|
|
|
|
private void btnOpenIndexingOptions_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2022-03-25 21:19:00 +00:00
|
|
|
SettingsViewModel.OpenWindowsIndexingOptions();
|
2020-06-08 08:41:59 +00:00
|
|
|
}
|
2025-07-16 13:28:17 +00:00
|
|
|
|
2022-07-04 00:50:02 +00:00
|
|
|
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));
|
|
|
|
|
}
|
2025-06-06 08:05:12 +00:00
|
|
|
|
|
|
|
|
private void Expander_Expanded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (sender is Expander expandedExpander)
|
|
|
|
|
{
|
|
|
|
|
// Ensure _expanders is not null and contains items
|
2025-07-20 15:33:38 +00:00
|
|
|
if (_expanders == null || _expanders.Count == 0) return;
|
2025-06-06 08:05:12 +00:00
|
|
|
|
|
|
|
|
foreach (var expander in _expanders)
|
|
|
|
|
{
|
|
|
|
|
if (expander != null && expander != expandedExpander && expander.IsExpanded)
|
|
|
|
|
{
|
|
|
|
|
expander.IsExpanded = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-06-06 08:20:43 +00:00
|
|
|
|
|
|
|
|
private void lbxAccessLinks_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
lbxAccessLinks.Items.SortDescriptions.Add(new SortDescription("Path", ListSortDirection.Ascending));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lbxExcludedPaths_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
lbxExcludedPaths.Items.SortDescriptions.Add(new SortDescription("Path", ListSortDirection.Ascending));
|
|
|
|
|
}
|
2025-06-07 05:46:57 +00:00
|
|
|
|
|
|
|
|
private void lbxAccessLinks_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (sender is not ListView listView) return;
|
|
|
|
|
if (listView.View is not GridView gView) return;
|
|
|
|
|
|
|
|
|
|
var workingWidth =
|
|
|
|
|
listView.ActualWidth - SystemParameters.VerticalScrollBarWidth; // take into account vertical scrollbar
|
|
|
|
|
|
|
|
|
|
if (workingWidth <= 0) return;
|
|
|
|
|
|
2025-06-07 06:12:22 +00:00
|
|
|
var col1 = 0.4;
|
|
|
|
|
var col2 = 0.6;
|
2025-06-07 05:46:57 +00:00
|
|
|
|
|
|
|
|
gView.Columns[0].Width = workingWidth * col1;
|
|
|
|
|
gView.Columns[1].Width = workingWidth * col2;
|
|
|
|
|
}
|
2020-07-16 11:45:08 +00:00
|
|
|
}
|
2022-11-29 03:38:17 +00:00
|
|
|
}
|