From 4eb36c8ba3a9f14b4e092da4744769ed3ae0de26 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Tue, 2 Nov 2021 15:07:11 -0500 Subject: [PATCH] Custom Explorer Binding (Part 1) --- .../UserSettings/CustomExplorerViewModel.cs | 17 ++ .../UserSettings/Settings.cs | 25 +++ Flow.Launcher/App.xaml.cs | 2 +- Flow.Launcher/Languages/en.xaml | 3 +- Flow.Launcher/SelectFileManagerWindow.xaml | 208 +++++++++++------- Flow.Launcher/SelectFileManagerWindow.xaml.cs | 9 +- Flow.Launcher/SettingWindow.xaml.cs | 2 +- 7 files changed, 181 insertions(+), 85 deletions(-) create mode 100644 Flow.Launcher.Infrastructure/UserSettings/CustomExplorerViewModel.cs diff --git a/Flow.Launcher.Infrastructure/UserSettings/CustomExplorerViewModel.cs b/Flow.Launcher.Infrastructure/UserSettings/CustomExplorerViewModel.cs new file mode 100644 index 000000000..4fd5e317a --- /dev/null +++ b/Flow.Launcher.Infrastructure/UserSettings/CustomExplorerViewModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Flow.Launcher.ViewModel +{ + public class CustomExplorerViewModel + { + public string Name { get; set; } + public string Path { get; set; } + public string FileArgument { get; set; } = "\"%d\""; + public string DirectoryArgument { get; set; } = "\"%d\""; + public bool Editable { get; init; } = true; + } +} diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 5f9082fe9..53ced1524 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -1,10 +1,12 @@ using System; +using System.Collections.Generic; using System.Collections.ObjectModel; using System.Drawing; using System.Text.Json.Serialization; using Flow.Launcher.Plugin; using Flow.Launcher.Plugin.SharedModels; using Flow.Launcher; +using Flow.Launcher.ViewModel; namespace Flow.Launcher.Infrastructure.UserSettings { @@ -37,6 +39,29 @@ namespace Flow.Launcher.Infrastructure.UserSettings public string ResultFontStretch { get; set; } public bool UseGlyphIcons { get; set; } = true; + public CustomExplorerViewModel CustomExplorer { get; set; } + public List CustomExplorerList { get; set; } = new() + { + new() + { + Name = "Explorer", + Path = "explorer", + FileArgument = "/select, \"%f\"", + DirectoryArgument = "\"%d\"", + Editable = false + }, + new() + { + Name = "Total Commander", + Path = @"C:\Program Files\TOTALCMD\totalcommander.exe" + }, + new() + { + Name = "Dopus", + Path = @"c:\programe files\dopus\dopus.exe" + } + }; + /// /// when false Alphabet static service will always return empty results diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index 8c869e941..75925b1e0 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -101,7 +101,7 @@ namespace Flow.Launcher API.SaveAppAllSettings(); - _mainVM.MainWindowVisibility = _settings.HideOnStartup ? Visibility.Hidden : Visibility.Visible; + _mainVM.MainWindowVisibility = _settings.HideOnStartup ? Visibility.Collapsed : Visibility.Visible; Log.Info("|App.OnStartup|End Flow Launcher startup ---------------------------------------------------- "); }); } diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 9d8e0caa0..e8469763f 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -138,7 +138,8 @@ Please specify the file location of the file manager you using and add arguments (optional) if necessary. File Manager Path - Argument + Argument For Directory + Argument For File Parent Directory Change Priority diff --git a/Flow.Launcher/SelectFileManagerWindow.xaml b/Flow.Launcher/SelectFileManagerWindow.xaml index 9fb9ee1cd..55eceae27 100644 --- a/Flow.Launcher/SelectFileManagerWindow.xaml +++ b/Flow.Launcher/SelectFileManagerWindow.xaml @@ -2,112 +2,154 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="clr-namespace:Flow.Launcher" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ui="http://schemas.modernwpf.com/2019" - xmlns:local="clr-namespace:Flow.Launcher" - mc:Ignorable="d" + Title="{DynamicResource fileManagerWindow}" + Width="500" + Height="420" + Background="#f3f3f3" + DataContext="{Binding RelativeSource={RelativeSource Self}}" + ResizeMode="NoResize" WindowStartupLocation="CenterScreen" - Title="{DynamicResource fileManagerWindow}" Height="420" Width="500" ResizeMode="NoResize" Background="#f3f3f3"> + mc:Ignorable="d"> - + - + - - + + - + - - - - - - - - + + + + + + + + - - + + - + - + - - + + - - - - - - + + + + + + + + @@ -116,10 +158,16 @@ - - diff --git a/Flow.Launcher/SelectFileManagerWindow.xaml.cs b/Flow.Launcher/SelectFileManagerWindow.xaml.cs index 6fcf6feef..429ccec49 100644 --- a/Flow.Launcher/SelectFileManagerWindow.xaml.cs +++ b/Flow.Launcher/SelectFileManagerWindow.xaml.cs @@ -1,4 +1,6 @@ -using System; +using Flow.Launcher.Infrastructure.UserSettings; +using Flow.Launcher.ViewModel; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -19,8 +21,11 @@ namespace Flow.Launcher /// public partial class SelectFileManagerWindow : Window { - public SelectFileManagerWindow() + public Settings Settings { get; } + + public SelectFileManagerWindow(Settings settings) { + Settings = settings; InitializeComponent(); } } diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index 62ef96b38..38ede8076 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -117,7 +117,7 @@ namespace Flow.Launcher private void OnSelectFileManagerClick(object sender, RoutedEventArgs e) { - SelectFileManagerWindow fileManagerChangeWindow = new SelectFileManagerWindow(); + SelectFileManagerWindow fileManagerChangeWindow = new SelectFileManagerWindow(settings); fileManagerChangeWindow.ShowDialog(); }