mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Custom Explorer Binding (Part 1)
This commit is contained in:
parent
7dc5806a2d
commit
4eb36c8ba3
7 changed files with 181 additions and 85 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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<CustomExplorerViewModel> 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"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// when false Alphabet static service will always return empty results
|
||||
|
|
|
|||
|
|
@ -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 ---------------------------------------------------- ");
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,7 +138,8 @@
|
|||
<system:String x:Key="fileManager_tips">Please specify the file location of the file manager you using and add arguments (optional) if necessary.</system:String>
|
||||
<system:String x:Key="fileManager_name">File Manager</system:String>
|
||||
<system:String x:Key="fileManager_path">Path</system:String>
|
||||
<system:String x:Key="fileManager_arg">Argument</system:String>
|
||||
<system:String x:Key="fileManager_directory_arg">Argument For Directory</system:String>
|
||||
<system:String x:Key="fileManager_file_arg">Argument For File Parent Directory</system:String>
|
||||
|
||||
<!--Priority Setting Dialog-->
|
||||
<system:String x:Key="changePriorityWindow">Change Priority</system:String>
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="80"/>
|
||||
<RowDefinition Height="80" />
|
||||
</Grid.RowDefinitions>
|
||||
<Border BorderThickness="0 0 0 1" BorderBrush="#e5e5e5" Background="#ffffff" Padding="26 26 26 0">
|
||||
<Border Padding="26,26,26,0"
|
||||
Background="#ffffff"
|
||||
BorderBrush="#e5e5e5"
|
||||
BorderThickness="0,0,0,1">
|
||||
<Grid>
|
||||
<StackPanel>
|
||||
<StackPanel Grid.Row="0" Margin="0 0 0 12">
|
||||
<TextBlock Grid.Column="0" Text="{DynamicResource fileManagerWindow}" FontSize="20" FontWeight="SemiBold" FontFamily="Segoe UI" TextAlignment="Left"
|
||||
Margin="0 0 0 0" />
|
||||
<StackPanel Grid.Row="0" Margin="0,0,0,12">
|
||||
<TextBlock Grid.Column="0"
|
||||
Margin="0,0,0,0"
|
||||
FontFamily="Segoe UI"
|
||||
FontSize="20"
|
||||
FontWeight="SemiBold"
|
||||
Text="{DynamicResource fileManagerWindow}"
|
||||
TextAlignment="Left" />
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<TextBlock
|
||||
Text="{DynamicResource fileManager_tips}" Foreground="#1b1b1b" FontSize="14" TextWrapping="WrapWithOverflow" TextAlignment="Left"/>
|
||||
<TextBlock FontSize="14"
|
||||
Foreground="#1b1b1b"
|
||||
Text="{DynamicResource fileManager_tips}"
|
||||
TextAlignment="Left"
|
||||
TextWrapping="WrapWithOverflow" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="14 28 0 0">
|
||||
<TextBlock FontSize="14" Grid.Column="1" VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left" Text="{DynamicResource fileManager_name}" />
|
||||
<ComboBox Height="35" SelectedIndex="0" HorizontalAlignment="Left" Margin="14 0 0 0" Name="comboBox" VerticalAlignment="Center" Width="200">
|
||||
<ComboBoxItem Content="Explorer (Default)" />
|
||||
<ComboBoxItem Content="Custom" />
|
||||
<ComboBoxItem Content="Files" />
|
||||
<ComboBoxItem Content="Directory Opus" />
|
||||
<ComboBoxItem Content="Total Commander" />
|
||||
<StackPanel Margin="14,28,0,0" Orientation="Horizontal">
|
||||
<TextBlock Grid.Column="1"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Text="{DynamicResource fileManager_name}" />
|
||||
<ComboBox Name="comboBox"
|
||||
Width="200"
|
||||
Height="35"
|
||||
Margin="14,0,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
ItemsSource="{Binding Settings.CustomExplorerList}"
|
||||
SelectedIndex="0"
|
||||
SelectedItem="{Binding Settings.CustomExplorer}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
<Rectangle Margin="0 20 0 12" Height="1" Fill="#cecece"></Rectangle>
|
||||
<StackPanel Orientation="Horizontal" Margin="0 0 0 0" HorizontalAlignment="Stretch">
|
||||
<Rectangle Height="1" Margin="0,20,0,12" Fill="#cecece" />
|
||||
<StackPanel Margin="0,0,0,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
DataContext="{Binding Settings.CustomExplorer}"
|
||||
Orientation="Horizontal">
|
||||
<Grid Width="430">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="100" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="50" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock FontSize="14" VerticalAlignment="Center" Grid.Column="0" Grid.Row="0"
|
||||
HorizontalAlignment="Left" Text="{DynamicResource fileManager_path}" Margin="14 0 0 0"/>
|
||||
<TextBox Margin="10 0 15 0" Width="Auto" VerticalAlignment="Center" HorizontalAlignment="Stretch" Grid.Column="1" Grid.Row="0">
|
||||
<TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Margin="14,0,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Text="{DynamicResource fileManager_path}" />
|
||||
<TextBox Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Width="Auto"
|
||||
Margin="10,0,15,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center"
|
||||
IsEnabled="{Binding Editable}"
|
||||
Text="{Binding Path}">
|
||||
<TextBox.Style>
|
||||
<Style TargetType="TextBox">
|
||||
<Setter Property="Background" Value="#ffffff"/>
|
||||
<Setter Property="Height" Value="34"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
<Setter Property="Padding" Value="6 6 0 0"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
|
||||
<Setter Property="BorderBrush" Value="#000000"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Path=SelectedIndex, ElementName=comboBox}" Value="0">
|
||||
<Setter Property="IsEnabled" Value="False"/>
|
||||
<Setter Property="Text" Value=""/>
|
||||
<Setter Property="Background" Value="#cecece"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Path=SelectedIndex, ElementName=comboBox}" Value="2">
|
||||
<Setter Property="Text" Value="Files"/>
|
||||
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Path=SelectedIndex, ElementName=comboBox}" Value="3">
|
||||
<Setter Property="Text" Value="c:\programe files\dopus\dopus.exe"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Path=SelectedIndex, ElementName=comboBox}" Value="4">
|
||||
<Setter Property="Text" Value="C:\Program Files\TOTALCMD\totalcommander.exe"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
<Setter Property="Background" Value="#ffffff" />
|
||||
<Setter Property="Height" Value="34" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Padding" Value="6,6,0,0" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="BorderBrush" Value="#000000" />
|
||||
</Style>
|
||||
</TextBox.Style>
|
||||
|
||||
</TextBox>
|
||||
|
||||
|
||||
|
||||
<TextBlock FontSize="14" VerticalAlignment="Center" Margin="14 0 0 0"
|
||||
HorizontalAlignment="Left" Text="{DynamicResource fileManager_arg}" Grid.Column="0" Grid.Row="1"/>
|
||||
<TextBox Margin="10 0 15 0" Width="Auto" VerticalAlignment="Center" HorizontalAlignment="Stretch" Grid.Column="1" Grid.Row="1" >
|
||||
<TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Margin="14,0,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Text="{DynamicResource fileManager_directory_arg}" />
|
||||
<TextBox Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Width="Auto"
|
||||
Margin="10,0,15,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding DirectoryArgument}">
|
||||
<TextBox.Style>
|
||||
<Style TargetType="TextBox">
|
||||
<Setter Property="Background" Value="#ffffff"/>
|
||||
<Setter Property="Height" Value="34"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
<Setter Property="Padding" Value="6 6 0 0"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
|
||||
<Setter Property="BorderBrush" Value="#000000"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Path=SelectedIndex, ElementName=comboBox}" Value="0">
|
||||
<Setter Property="IsEnabled" Value="False"/>
|
||||
<Setter Property="Text" Value=""/>
|
||||
<Setter Property="Background" Value="#cecece"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Path=SelectedIndex, ElementName=comboBox}" Value="2">
|
||||
<Setter Property="Text" Value=""/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Path=SelectedIndex, ElementName=comboBox}" Value="3">
|
||||
<Setter Property="Text" Value=""/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
<Setter Property="Background" Value="#ffffff" />
|
||||
<Setter Property="Height" Value="34" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Padding" Value="6,6,0,0" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="BorderBrush" Value="#000000" />
|
||||
</Style>
|
||||
</TextBox.Style>
|
||||
</TextBox>
|
||||
<TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Margin="14,0,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Text="{DynamicResource fileManager_directory_arg}" />
|
||||
<TextBox Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Width="Auto"
|
||||
Margin="10,0,15,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding FileArgument}">
|
||||
<TextBox.Style>
|
||||
<Style TargetType="TextBox">
|
||||
<Setter Property="Background" Value="#ffffff" />
|
||||
<Setter Property="Height" Value="34" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="Padding" Value="6,6,0,0" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="BorderBrush" Value="#000000" />
|
||||
</Style>
|
||||
</TextBox.Style>
|
||||
</TextBox>
|
||||
|
|
@ -116,10 +158,16 @@
|
|||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="1">
|
||||
<Button x:Name="btnCancel" Margin="0 0 5 0" Width="100" Height="30"
|
||||
<StackPanel Grid.Row="1" HorizontalAlignment="Center" Orientation="Horizontal">
|
||||
<Button x:Name="btnCancel"
|
||||
Width="100"
|
||||
Height="30"
|
||||
Margin="0,0,5,0"
|
||||
Content="{DynamicResource cancel}" />
|
||||
<Button x:Name="btnDone" Margin="5 0 0 0" Width="100" Height="30">
|
||||
<Button x:Name="btnDone"
|
||||
Width="100"
|
||||
Height="30"
|
||||
Margin="5,0,0,0">
|
||||
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
|
|
|||
|
|
@ -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
|
|||
/// </summary>
|
||||
public partial class SelectFileManagerWindow : Window
|
||||
{
|
||||
public SelectFileManagerWindow()
|
||||
public Settings Settings { get; }
|
||||
|
||||
public SelectFileManagerWindow(Settings settings)
|
||||
{
|
||||
Settings = settings;
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue