Merge Dev

This commit is contained in:
DB p 2021-11-14 11:35:28 +09:00
commit e04944ffd6
20 changed files with 635 additions and 112 deletions

View file

@ -0,0 +1,30 @@
using Flow.Launcher.Plugin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Flow.Launcher.ViewModel
{
public class CustomExplorerViewModel : BaseModel
{
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;
public CustomExplorerViewModel Copy()
{
return new CustomExplorerViewModel
{
Name = Name,
Path = Path,
FileArgument = FileArgument,
DirectoryArgument = DirectoryArgument,
Editable = Editable
};
}
}
}

View file

@ -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,49 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public string ResultFontStretch { get; set; }
public bool UseGlyphIcons { get; set; } = true;
public int CustomExplorerIndex { get; set; } = 0;
[JsonIgnore]
public CustomExplorerViewModel CustomExplorer
{
get => CustomExplorerList[CustomExplorerIndex < CustomExplorerList.Count ? CustomExplorerIndex : 0];
set => CustomExplorerList[CustomExplorerIndex] = value;
}
public List<CustomExplorerViewModel> CustomExplorerList { get; set; } = new()
{
new()
{
Name = "Explorer",
Path = "explorer",
DirectoryArgument = "\"%d\"",
FileArgument = "/select, \"%f\"",
Editable = false
},
new()
{
Name = "Total Commander",
Path = @"C:\Program Files\totalcmd\TOTALCMD64.exe",
DirectoryArgument = "/O /A /S /T \"%d\"",
FileArgument = "/O /A /S /T \"%f\""
},
new()
{
Name = "Directory Opus",
Path = @"C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe",
DirectoryArgument = "/cmd Go \"%d\" NEW",
FileArgument = "/cmd Go \"%f\" NEW"
},
new()
{
Name = "Files",
Path = "Files",
DirectoryArgument = "-select \"%d\"",
FileArgument = "-select \"%f\""
}
};
public bool UseAnimation { get; set; } = true;
public bool UseSound { get; set; } = false;

View file

@ -190,5 +190,12 @@ namespace Flow.Launcher.Plugin
/// <typeparam name="T">Type for Serialization</typeparam>
/// <returns></returns>
void SaveSettingJsonStorage<T>() where T : new();
/// <summary>
/// Open directory in an explorer configured by user via Flow's Settings. The default is Windows Explorer
/// </summary>
/// <param name="DirectoryPath">Directory Path to open</param>
/// <param name="FileName">Extra FileName Info</param>
public void OpenDirectory(string DirectoryPath, string FileName = null);
}
}

View file

@ -34,6 +34,8 @@
<system:String x:Key="maxShowResults">Maximum results shown</system:String>
<system:String x:Key="ignoreHotkeysOnFullscreen">Ignore hotkeys in fullscreen mode</system:String>
<system:String x:Key="ignoreHotkeysOnFullscreenToolTip">Disable Flow Launcher activation when a full screen application is active (Recommended for games).</system:String>
<system:String x:Key="defaultFileManager">Default File Manager</system:String>
<system:String x:Key="defaultFileManagerToolTip">Select the file manager to use when opening the folder.</system:String>
<system:String x:Key="pythonDirectory">Python Directory</system:String>
<system:String x:Key="autoUpdates">Auto Update</system:String>
<system:String x:Key="selectPythonDirectory">Select</system:String>
@ -138,6 +140,16 @@
<system:String x:Key="releaseNotes">Release Notes</system:String>
<system:String x:Key="documentation">Usage Tips:</system:String>
<!-- FileManager Setting Dialog -->
<system:String x:Key="fileManagerWindow">Select File Manager</system:String>
<system:String x:Key="fileManager_tips">Please specify the file location of the file manager you using and add arguments if necessary. The default arguments is &quot;%d&quot;, and a path is entered at that location. For example, If a command is required such as &quot;totalcmd.exe /A c:\windows&quot;, argument is /A &quot;%d&quot;.</system:String>
<system:String x:Key="fileManager_tips2">&quot;%f&quot; is an argument that represent the file path. It is used to emphasize the file/folder name when opening a specific file location in 3rd party file manager. This argument is only available in the &quot;Arg for File&quot; item. If the file manager does not have that function, you can use &quot;%d&quot;.</system:String>
<system:String x:Key="fileManager_name">File Manager</system:String>
<system:String x:Key="fileManager_profile_name">Profile Name</system:String>
<system:String x:Key="fileManager_path">File Manager Path</system:String>
<system:String x:Key="fileManager_directory_arg">Arg For Folder</system:String>
<system:String x:Key="fileManager_file_arg">Arg For File</system:String>
<!-- Priority Setting Dialog -->
<system:String x:Key="changePriorityWindow">Change Priority</system:String>
<system:String x:Key="priority_tips">Greater the number, the higher the result will be ranked. Try setting it as 5. If you want the results to be lower than any other plugin's, provide a negative number</system:String>

View file

@ -22,6 +22,8 @@ using System.Runtime.CompilerServices;
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Infrastructure.Storage;
using System.Collections.Concurrent;
using Flow.Launcher.Plugin.SharedCommands;
using System.Diagnostics;
namespace Flow.Launcher
{
@ -158,7 +160,7 @@ namespace Flow.Launcher
if (!_pluginJsonStorages.ContainsKey(type))
_pluginJsonStorages[type] = new PluginJsonStorage<T>();
return ((PluginJsonStorage<T>) _pluginJsonStorages[type]).Load();
return ((PluginJsonStorage<T>)_pluginJsonStorages[type]).Load();
}
public void SaveSettingJsonStorage<T>() where T : new()
@ -167,7 +169,7 @@ namespace Flow.Launcher
if (!_pluginJsonStorages.ContainsKey(type))
_pluginJsonStorages[type] = new PluginJsonStorage<T>();
((PluginJsonStorage<T>) _pluginJsonStorages[type]).Save();
((PluginJsonStorage<T>)_pluginJsonStorages[type]).Save();
}
public void SaveJsonStorage<T>(T settings) where T : new()
@ -175,7 +177,22 @@ namespace Flow.Launcher
var type = typeof(T);
_pluginJsonStorages[type] = new PluginJsonStorage<T>(settings);
((PluginJsonStorage<T>) _pluginJsonStorages[type]).Save();
((PluginJsonStorage<T>)_pluginJsonStorages[type]).Save();
}
public void OpenDirectory(string DirectoryPath, string FileName = null)
{
using Process explorer = new Process();
var explorerInfo = _settingsVM.Settings.CustomExplorer;
explorer.StartInfo = new ProcessStartInfo
{
FileName = explorerInfo.Path,
Arguments = FileName is null ?
explorerInfo.DirectoryArgument.Replace("%d", DirectoryPath) :
explorerInfo.FileArgument.Replace("%d", DirectoryPath).Replace("%f",
Path.IsPathRooted(FileName) ? FileName : Path.Combine(DirectoryPath, FileName))
};
explorer.Start();
}
public event FlowLauncherGlobalKeyboardEventHandler GlobalKeyboardEvent;
@ -188,7 +205,7 @@ namespace Flow.Launcher
{
if (GlobalKeyboardEvent != null)
{
return GlobalKeyboardEvent((int) keyevent, vkcode, state);
return GlobalKeyboardEvent((int)keyevent, vkcode, state);
}
return true;

View file

@ -0,0 +1,244 @@
<Window
x:Class="Flow.Launcher.SelectFileManagerWindow"
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"
Title="{DynamicResource fileManagerWindow}"
Background="#f3f3f3"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
ResizeMode="NoResize"
SizeToContent="WidthAndHeight"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<Grid Width="600">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="80" />
</Grid.RowDefinitions>
<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"
Margin="0,0,0,0"
FontFamily="Segoe UI"
FontSize="20"
FontWeight="SemiBold"
Text="{DynamicResource fileManagerWindow}"
TextAlignment="Left" />
</StackPanel>
<StackPanel>
<TextBlock
FontSize="14"
Foreground="#1b1b1b"
Text="{DynamicResource fileManager_tips}"
TextAlignment="Left"
TextWrapping="WrapWithOverflow" />
<TextBlock
Margin="0,14,0,0"
FontSize="14"
Foreground="#1b1b1b">
<TextBlock Text="{DynamicResource fileManager_tips2}" TextWrapping="WrapWithOverflow" />
</TextBlock>
</StackPanel>
<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 CustomExplorers}"
SelectedIndex="{Binding SelectedCustomExplorerIndex}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Button
Margin="10,0,0,0"
Click="btnAdd_Click"
Content="{DynamicResource add}" />
<Button
Margin="10,0,0,0"
Click="btnDelete_Click"
Content="{DynamicResource delete}"
IsEnabled="{Binding CustomExplorer.Editable}" />
</StackPanel>
<Rectangle
Height="1"
Margin="0,20,0,12"
Fill="#cecece" />
<StackPanel
Margin="0,0,0,0"
HorizontalAlignment="Stretch"
DataContext="{Binding CustomExplorer}"
Orientation="Horizontal">
<Grid Width="545">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="180" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock
Grid.Row="0"
Grid.Column="0"
Margin="14,5,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
Text="{DynamicResource fileManager_profile_name}" />
<TextBox
x:Name="ProfileTextBox"
Grid.Row="0"
Grid.Column="1"
Width="Auto"
Margin="10,5,15,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
IsEnabled="{Binding Editable}"
Text="{Binding Name}" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="14,10,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
Text="{DynamicResource fileManager_path}" />
<DockPanel Grid.Row="1" Grid.Column="1">
<TextBox
x:Name="PathTextBox"
Width="250"
Margin="10,10,10,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
IsEnabled="{Binding Editable}"
Text="{Binding Path}" />
<Button
Name="btnBrowseFile"
Width="80"
Margin="0,10,15,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Click="btnBrowseFile_Click"
Content="{DynamicResource selectPythonDirectory}"
DockPanel.Dock="Right">
<Button.Style>
<Style BasedOn="{StaticResource DefaultButtonStyle}" TargetType="{x:Type Button}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=ProfileTextBox, UpdateSourceTrigger=PropertyChanged, Path=IsEnabled}" Value="False">
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</DockPanel>
<TextBlock
Grid.Row="2"
Grid.Column="0"
Margin="14,10,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
Text="{DynamicResource fileManager_directory_arg}"
TextWrapping="WrapWithOverflow" />
<TextBox
x:Name="directoryArgTextBox"
Grid.Row="2"
Grid.Column="1"
Width="Auto"
Margin="10,10,15,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
IsEnabled="{Binding Editable}"
Text="{Binding DirectoryArgument}" />
<TextBlock
Grid.Row="3"
Grid.Column="0"
Margin="14,10,0,20"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
Text="{DynamicResource fileManager_file_arg}"
TextWrapping="WrapWithOverflow" />
<TextBox
x:Name="fileArgTextBox"
Grid.Row="3"
Grid.Column="1"
Width="Auto"
Margin="10,10,15,20"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
IsEnabled="{Binding Editable}"
Text="{Binding FileArgument}" />
</Grid>
</StackPanel>
</StackPanel>
</Grid>
</Border>
<StackPanel
Grid.Row="1"
HorizontalAlignment="Center"
Orientation="Horizontal">
<Button
x:Name="btnCancel"
Width="100"
Height="30"
Margin="0,0,5,0"
Click="btnCancel_Click"
Content="{DynamicResource cancel}" />
<Button
x:Name="btnDone"
Width="100"
Height="30"
Margin="5,0,0,0"
Click="btnDone_Click"
Content="{DynamicResource done}"
ForceCursor="True">
<Button.Style>
<Style BasedOn="{StaticResource DefaultButtonStyle}" TargetType="{x:Type Button}">
<Style.Triggers>
<DataTrigger Binding="{Binding Text.Length, ElementName=ProfileTextBox, UpdateSourceTrigger=PropertyChanged}" Value="0">
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
<DataTrigger Binding="{Binding Text.Length, ElementName=PathTextBox, UpdateSourceTrigger=PropertyChanged}" Value="0">
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
<DataTrigger Binding="{Binding Text.Length, ElementName=directoryArgTextBox, UpdateSourceTrigger=PropertyChanged}" Value="0">
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
<DataTrigger Binding="{Binding Text.Length, ElementName=fileArgTextBox, UpdateSourceTrigger=PropertyChanged}" Value="0">
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</StackPanel>
</Grid>
</Window>

View file

@ -0,0 +1,88 @@
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.ViewModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Flow.Launcher
{
public partial class SelectFileManagerWindow : Window, INotifyPropertyChanged
{
private int selectedCustomExplorerIndex;
public event PropertyChangedEventHandler PropertyChanged;
public Settings Settings { get; }
public int SelectedCustomExplorerIndex
{
get => selectedCustomExplorerIndex; set
{
selectedCustomExplorerIndex = value;
PropertyChanged?.Invoke(this, new(nameof(CustomExplorer)));
}
}
public ObservableCollection<CustomExplorerViewModel> CustomExplorers { get; set; }
public CustomExplorerViewModel CustomExplorer => CustomExplorers[SelectedCustomExplorerIndex];
public SelectFileManagerWindow(Settings settings)
{
Settings = settings;
CustomExplorers = new ObservableCollection<CustomExplorerViewModel>(Settings.CustomExplorerList.Select(x => x.Copy()));
SelectedCustomExplorerIndex = Settings.CustomExplorerIndex;
InitializeComponent();
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void btnDone_Click(object sender, RoutedEventArgs e)
{
Settings.CustomExplorerList = CustomExplorers.ToList();
Settings.CustomExplorerIndex = SelectedCustomExplorerIndex;
Close();
}
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
CustomExplorers.Add(new()
{
Name = "New Profile"
});
SelectedCustomExplorerIndex = CustomExplorers.Count - 1;
}
private void btnDelete_Click(object sender, RoutedEventArgs e)
{
CustomExplorers.RemoveAt(SelectedCustomExplorerIndex--);
}
private void btnBrowseFile_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
TextBox path = (TextBox)(((FrameworkElement)sender).Parent as FrameworkElement).FindName("PathTextBox");
path.Text = dlg.FileName;
path.Focus();
((Button)sender).Focus();
}
}
}
}

View file

@ -688,6 +688,35 @@
</StackPanel>
</Border>
<Border Margin="0,30,0,0" Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
Text="{DynamicResource defaultFileManager}" />
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource defaultFileManagerToolTip}" />
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal">
<Button
Width="160"
MaxWidth="250"
Margin="10,0,18,0"
Click="OnSelectFileManagerClick"
Content="{Binding Settings.CustomExplorer.Name}" />
</StackPanel>
<TextBlock
Grid.Column="0"
Margin="24,0,16,0"
VerticalAlignment="Center"
FontFamily="/Resources/#Segoe Fluent Icons"
FontSize="20">
&#xe838;
</TextBlock>
</ItemsControl>
</Border>
<Border Margin="0,30,0,0" Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">

View file

@ -125,6 +125,12 @@ namespace Flow.Launcher
}
}
private void OnSelectFileManagerClick(object sender, RoutedEventArgs e)
{
SelectFileManagerWindow fileManagerChangeWindow = new SelectFileManagerWindow(settings);
fileManagerChangeWindow.ShowDialog();
}
#endregion
#region Hotkey
@ -235,7 +241,7 @@ namespace Flow.Launcher
{
var directory = viewModel.SelectedPlugin.PluginPair.Metadata.PluginDirectory;
if (!string.IsNullOrEmpty(directory))
FilesFolders.OpenPath(directory);
PluginManager.API.OpenDirectory(directory);
}
}
#endregion
@ -273,7 +279,7 @@ namespace Flow.Launcher
private void OpenPluginFolder(object sender, RoutedEventArgs e)
{
FilesFolders.OpenPath(Path.Combine(DataLocation.DataDirectory(), Constant.Themes));
PluginManager.API.OpenDirectory(Path.Combine(DataLocation.DataDirectory(), Constant.Themes));
}
private void OnPluginStoreRefreshClick(object sender, RoutedEventArgs e)

View file

@ -230,7 +230,7 @@ namespace Flow.Launcher.Plugin.Explorer
{
try
{
FilesFolders.OpenContainingFolder(record.FullPath);
Context.API.OpenDirectory(Path.GetDirectoryName(record.FullPath), record.FullPath);
}
catch (Exception e)
{

View file

@ -34,7 +34,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
{
try
{
FilesFolders.OpenPath(path);
Context.API.OpenDirectory(path);
return true;
}
catch (Exception ex)
@ -101,7 +101,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
Score = 500,
Action = c =>
{
FilesFolders.OpenPath(retrievedDirectoryPath);
Context.API.OpenDirectory(retrievedDirectoryPath);
return true;
},
TitleToolTip = retrievedDirectoryPath,
@ -150,7 +150,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
}
else if (c.SpecialKeyState.CtrlPressed)
{
FilesFolders.OpenContainingFolder(filePath);
Context.API.OpenDirectory(Path.GetDirectoryName(filePath), filePath);
}
else
{

View file

@ -10,7 +10,7 @@
"Name": "Explorer",
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
"Author": "Jeremy Wu",
"Version": "1.9.1",
"Version": "1.10.0",
"Language": "csharp",
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
"ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll",

View file

@ -26,7 +26,7 @@ namespace Flow.Launcher.Plugin.Program
private static bool IsStartupIndexProgramsRequired => _settings.LastIndexTime.AddDays(3) < DateTime.Today;
private static PluginInitContext _context;
internal static PluginInitContext Context { get; private set; }
private static BinaryStorage<Win32[]> _win32Storage;
private static BinaryStorage<UWP.Application[]> _uwpStorage;
@ -63,7 +63,7 @@ namespace Flow.Launcher.Plugin.Program
.AsParallel()
.WithCancellation(token)
.Where(p => p.Enabled)
.Select(p => p.Result(query.Search, _context.API))
.Select(p => p.Result(query.Search, Context.API))
.Where(r => r?.Score > 0)
.ToList());
@ -80,7 +80,7 @@ namespace Flow.Launcher.Plugin.Program
public async Task InitAsync(PluginInitContext context)
{
_context = context;
Context = context;
_settings = context.API.LoadSettingJsonStorage<Settings>();
@ -155,17 +155,17 @@ namespace Flow.Launcher.Plugin.Program
public Control CreateSettingPanel()
{
return new ProgramSetting(_context, _settings, _win32s, _uwps);
return new ProgramSetting(Context, _settings, _win32s, _uwps);
}
public string GetTranslatedPluginTitle()
{
return _context.API.GetTranslation("flowlauncher_plugin_program_plugin_name");
return Context.API.GetTranslation("flowlauncher_plugin_program_plugin_name");
}
public string GetTranslatedPluginDescription()
{
return _context.API.GetTranslation("flowlauncher_plugin_program_plugin_description");
return Context.API.GetTranslation("flowlauncher_plugin_program_plugin_description");
}
public List<Result> LoadContextMenus(Result selectedResult)
@ -174,19 +174,19 @@ namespace Flow.Launcher.Plugin.Program
var program = selectedResult.ContextData as IProgram;
if (program != null)
{
menuOptions = program.ContextMenus(_context.API);
menuOptions = program.ContextMenus(Context.API);
}
menuOptions.Add(
new Result
{
Title = _context.API.GetTranslation("flowlauncher_plugin_program_disable_program"),
Title = Context.API.GetTranslation("flowlauncher_plugin_program_disable_program"),
Action = c =>
{
DisableProgram(program);
_context.API.ShowMsg(
_context.API.GetTranslation("flowlauncher_plugin_program_disable_dlgtitle_success"),
_context.API.GetTranslation(
Context.API.ShowMsg(
Context.API.GetTranslation("flowlauncher_plugin_program_disable_dlgtitle_success"),
Context.API.GetTranslation(
"flowlauncher_plugin_program_disable_dlgtitle_success_message"));
return false;
},
@ -235,7 +235,7 @@ namespace Flow.Launcher.Plugin.Program
{
var name = "Plugin: Program";
var message = $"Unable to start: {info.FileName}";
_context.API.ShowMsg(name, message, string.Empty);
Context.API.ShowMsg(name, message, string.Empty);
}
}

View file

@ -362,14 +362,7 @@ namespace Flow.Launcher.Plugin.Program.Programs
Action = _ =>
{
Main.StartProcess(Process.Start,
new ProcessStartInfo(
!string.IsNullOrEmpty(Main._settings.CustomizedExplorer)
? Main._settings.CustomizedExplorer
: Settings.Explorer,
Main._settings.CustomizedArgs
.Replace("%s",$"\"{Package.Location}\"")
.Trim()));
Main.Context.API.OpenDirectory(Package.Location);
return true;
},

View file

@ -177,20 +177,7 @@ namespace Flow.Launcher.Plugin.Program.Programs
Title = api.GetTranslation("flowlauncher_plugin_program_open_containing_folder"),
Action = _ =>
{
var args = !string.IsNullOrWhiteSpace(Main._settings.CustomizedArgs)
? Main._settings.CustomizedArgs
.Replace("%s", $"\"{ParentDirectory}\"")
.Replace("%f", $"\"{FullPath}\"")
: Main._settings.CustomizedExplorer == Settings.Explorer
? $"/select,\"{FullPath}\""
: Settings.ExplorerArgs;
Main.StartProcess(Process.Start,
new ProcessStartInfo(
!string.IsNullOrWhiteSpace(Main._settings.CustomizedExplorer)
? Main._settings.CustomizedExplorer
: Settings.Explorer,
args));
Main.Context.API.OpenDirectory(ParentDirectory, FullPath);
return true;
},

View file

@ -1,91 +1,166 @@
<UserControl x:Class="Flow.Launcher.Plugin.Program.Views.ProgramSetting"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:program="clr-namespace:Flow.Launcher.Plugin.Program"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
mc:Ignorable="d"
d:DesignHeight="404.508" d:DesignWidth="600">
<Grid Margin="10">
<UserControl
x:Class="Flow.Launcher.Plugin.Program.Views.ProgramSetting"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:program="clr-namespace:Flow.Launcher.Plugin.Program"
Height="450"
d:DesignHeight="404.508"
d:DesignWidth="600"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
mc:Ignorable="d">
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="120"/>
<RowDefinition Height="*"/>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
<RowDefinition Height="120" />
<RowDefinition Height="*" />
<RowDefinition Height="50" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Stretch">
<StackPanel Orientation="Vertical" Width="Auto">
<CheckBox Name="StartMenuEnabled" IsChecked="{Binding EnableStartMenuSource}" Margin="5" Content="{DynamicResource flowlauncher_plugin_program_index_start}" ToolTip="{DynamicResource flowlauncher_plugin_program_index_start_tooltip}" />
<CheckBox Name="RegistryEnabled" IsChecked="{Binding EnableRegistrySource}" Margin="5" Content="{DynamicResource flowlauncher_plugin_program_index_registry}" ToolTip="{DynamicResource flowlauncher_plugin_program_index_registry_tooltip}" />
<CheckBox Name="DescriptionEnabled" IsChecked="{Binding EnableDescription}" Margin="5" Content="{DynamicResource flowlauncher_plugin_program_enable_description}" ToolTip="{DynamicResource flowlauncher_plugin_program_enable_description_tooltip}" />
<StackPanel
Grid.Row="0"
HorizontalAlignment="Stretch"
Orientation="Horizontal">
<StackPanel Width="Auto" Orientation="Vertical">
<CheckBox
Name="StartMenuEnabled"
Margin="5"
Content="{DynamicResource flowlauncher_plugin_program_index_start}"
IsChecked="{Binding EnableStartMenuSource}"
ToolTip="{DynamicResource flowlauncher_plugin_program_index_start_tooltip}" />
<CheckBox
Name="RegistryEnabled"
Margin="5"
Content="{DynamicResource flowlauncher_plugin_program_index_registry}"
IsChecked="{Binding EnableRegistrySource}"
ToolTip="{DynamicResource flowlauncher_plugin_program_index_registry_tooltip}" />
<CheckBox
Name="DescriptionEnabled"
Margin="5"
Content="{DynamicResource flowlauncher_plugin_program_enable_description}"
IsChecked="{Binding EnableDescription}"
ToolTip="{DynamicResource flowlauncher_plugin_program_enable_description_tooltip}" />
</StackPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Width="Auto">
<Button Height="31" HorizontalAlignment="Right" Margin="10" Width="100" x:Name="btnLoadAllProgramSource" Click="btnLoadAllProgramSource_OnClick" Content="{DynamicResource flowlauncher_plugin_program_all_programs}" />
<Button Height="31" HorizontalAlignment="Right" Margin="10" Width="100" x:Name="btnProgramSuffixes" Click="BtnProgramSuffixes_OnClick" Content="{DynamicResource flowlauncher_plugin_program_suffixes}" />
<Button Height="31" HorizontalAlignment="Right" Margin="10" Width="100" x:Name="btnReindex" Click="btnReindex_Click" Content="{DynamicResource flowlauncher_plugin_program_reindex}" />
<StackPanel
Width="Auto"
HorizontalAlignment="Right"
Orientation="Horizontal">
<Button
x:Name="btnLoadAllProgramSource"
Width="100"
Height="31"
Margin="10"
HorizontalAlignment="Right"
Click="btnLoadAllProgramSource_OnClick"
Content="{DynamicResource flowlauncher_plugin_program_all_programs}" />
<Button
x:Name="btnProgramSuffixes"
Width="100"
Height="31"
Margin="10"
HorizontalAlignment="Right"
Click="BtnProgramSuffixes_OnClick"
Content="{DynamicResource flowlauncher_plugin_program_suffixes}" />
<Button
x:Name="btnReindex"
Width="100"
Height="31"
Margin="10"
HorizontalAlignment="Right"
Click="btnReindex_Click"
Content="{DynamicResource flowlauncher_plugin_program_reindex}" />
</StackPanel>
</StackPanel>
<ListView x:Name="programSourceView" Grid.Row="1" AllowDrop="True" SelectionMode="Extended" Style="{StaticResource {x:Static GridView.GridViewStyleKey}}"
Margin="0,13,0,10"
BorderBrush="DarkGray"
BorderThickness="1"
GridViewColumnHeader.Click="GridViewColumnHeaderClickedHandler"
PreviewMouseRightButtonUp="ProgramSourceView_PreviewMouseRightButtonUp"
DragEnter="programSourceView_DragEnter"
Drop="programSourceView_Drop">
<ListView
x:Name="programSourceView"
Grid.Row="1"
Margin="0,13,0,10"
AllowDrop="True"
BorderBrush="DarkGray"
BorderThickness="1"
DragEnter="programSourceView_DragEnter"
Drop="programSourceView_Drop"
GridViewColumnHeader.Click="GridViewColumnHeaderClickedHandler"
PreviewMouseRightButtonUp="ProgramSourceView_PreviewMouseRightButtonUp"
SelectionMode="Extended"
Style="{StaticResource {x:Static GridView.GridViewStyleKey}}">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<EventSetter Event="PreviewMouseUp" Handler="Row_OnClick"/>
<EventSetter Event="PreviewMouseUp" Handler="Row_OnClick" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
</ListView.ItemContainerStyle>
<ListView.View>
<GridView>
<GridViewColumn Header="Name" Width="150">
<GridViewColumn Width="150" Header="Name">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Enabled">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Enabled}" MaxWidth="60" TextAlignment="Center"/>
<TextBlock
MaxWidth="60"
Text="{Binding Enabled}"
TextAlignment="Center" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="{DynamicResource flowlauncher_plugin_program_location}" Width="550">
<GridViewColumn Width="550" Header="{DynamicResource flowlauncher_plugin_program_location}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Location, ConverterParameter=(null), Converter={program:LocationConverter}}"/>
<TextBlock Text="{Binding Location, ConverterParameter=(null), Converter={program:LocationConverter}}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
<DockPanel Grid.Row="2" Margin="0,0,0,0" Grid.RowSpan="1">
<StackPanel x:Name="indexingPanel" Visibility="Hidden" HorizontalAlignment="Left" Orientation="Horizontal">
<ProgressBar x:Name="progressBarIndexing" Height="20" Width="80" Minimum="0" Maximum="100" IsIndeterminate="True" />
<TextBlock Margin="10 0 0 0" Height="20" HorizontalAlignment="Center" Text="{DynamicResource flowlauncher_plugin_program_indexing}" />
<DockPanel
Grid.Row="2"
Grid.RowSpan="1"
Margin="0,0,0,0">
<StackPanel
x:Name="indexingPanel"
HorizontalAlignment="Left"
Orientation="Horizontal"
Visibility="Hidden">
<ProgressBar
x:Name="progressBarIndexing"
Width="80"
Height="20"
IsIndeterminate="True"
Maximum="100"
Minimum="0" />
<TextBlock
Height="20"
Margin="10,0,0,0"
HorizontalAlignment="Center"
Text="{DynamicResource flowlauncher_plugin_program_indexing}" />
</StackPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button x:Name="btnProgramSourceStatus" Click="btnProgramSourceStatus_OnClick" Width="100" Margin="10" Content="{DynamicResource flowlauncher_plugin_program_disable}" />
<Button x:Name="btnEditProgramSource" Click="btnEditProgramSource_OnClick" Width="100" Margin="10" Content="{DynamicResource flowlauncher_plugin_program_edit}"/>
<Button x:Name="btnAddProgramSource" Click="btnAddProgramSource_OnClick" Width="100" Margin="10 10 0 10" Content="{DynamicResource flowlauncher_plugin_program_add}"/>
<Button
x:Name="btnProgramSourceStatus"
Width="100"
Margin="10"
Click="btnProgramSourceStatus_OnClick"
Content="{DynamicResource flowlauncher_plugin_program_disable}" />
<Button
x:Name="btnEditProgramSource"
Width="100"
Margin="10"
Click="btnEditProgramSource_OnClick"
Content="{DynamicResource flowlauncher_plugin_program_edit}" />
<Button
x:Name="btnAddProgramSource"
Width="100"
Margin="10,10,0,10"
Click="btnAddProgramSource_OnClick"
Content="{DynamicResource flowlauncher_plugin_program_add}" />
</StackPanel>
</DockPanel>
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Stretch">
<TextBlock Text="{DynamicResource flowlauncher_plugin_program_customizedexplorer}" VerticalAlignment="Center" FontSize="15"
ToolTip= "{DynamicResource flowlauncher_plugin_program_tooltip_customizedexplorer}"/>
<TextBox Margin="10,0,10,0" TextWrapping="NoWrap" VerticalAlignment="Center" Width="200" Height="30" FontSize="15"
Text="{Binding CustomizedExplorerPath}" x:Name="CustomizeExplorerBox"/>
<TextBlock Text="{DynamicResource flowlauncher_plugin_program_args}" VerticalAlignment="Center" FontSize="15"
ToolTip="{DynamicResource flowlauncher_plugin_program_tooltip_args}" />
<TextBox Margin="10,0,0,0" Width="135" Height="30" FontSize="15" x:Name="CustomizeArgsBox" Text="{Binding CustomizedExplorerArg}"></TextBox>
</StackPanel>
</Grid>
</UserControl>

View file

@ -347,15 +347,5 @@ namespace Flow.Launcher.Plugin.Program.Views
btnProgramSourceStatus.Content = "Enable";
}
}
private void CustomizeExplorer(object sender, TextChangedEventArgs e)
{
_settings.CustomizedExplorer = CustomizeExplorerBox.Text;
}
private void CustomizeExplorerArgs(object sender, TextChangedEventArgs e)
{
_settings.CustomizedArgs = CustomizeArgsBox.Text;
}
}
}

View file

@ -4,7 +4,7 @@
"Name": "Program",
"Description": "Search programs in Flow.Launcher",
"Author": "qianlifeng",
"Version": "1.6.1",
"Version": "1.7.0",
"Language": "csharp",
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
"ExecuteFileName": "Flow.Launcher.Plugin.Program.dll",

View file

@ -304,7 +304,7 @@ namespace Flow.Launcher.Plugin.Sys
Action = c =>
{
var logPath = Path.Combine(DataLocation.DataDirectory(), "Logs", Constant.Version);
FilesFolders.OpenPath(logPath);
context.API.OpenDirectory(logPath);
return true;
}
},
@ -326,7 +326,7 @@ namespace Flow.Launcher.Plugin.Sys
IcoPath = "Images\\app.png",
Action = c =>
{
FilesFolders.OpenPath(DataLocation.DataDirectory());
context.API.OpenDirectory(DataLocation.DataDirectory());
return true;
}
}

View file

@ -4,7 +4,7 @@
"Name": "System Commands",
"Description": "Provide System related commands. e.g. shutdown,lock, setting etc.",
"Author": "qianlifeng",
"Version": "1.4.1",
"Version": "1.5.0",
"Language": "csharp",
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
"ExecuteFileName": "Flow.Launcher.Plugin.Sys.dll",