mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Data binding for suffixes
This commit is contained in:
parent
d5be961975
commit
d13c3817e4
5 changed files with 46 additions and 19 deletions
|
|
@ -9,6 +9,7 @@
|
|||
Width="600"
|
||||
Background="{DynamicResource PopuBGColor}"
|
||||
Foreground="{DynamicResource PopupTextColor}"
|
||||
DataContext="{Binding RelativeSource={RelativeSource Self}}"
|
||||
ResizeMode="NoResize"
|
||||
SizeToContent="Height"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
|
|
@ -166,12 +167,13 @@
|
|||
FontSize="16"
|
||||
FontWeight="SemiBold"
|
||||
Text="{DynamicResource flowlauncher_plugin_program_suffixes_excutable_types}" />
|
||||
<CheckBox Name="apprefMS" Margin="10,0,0,0">appref-ms</CheckBox>
|
||||
<CheckBox Name="EXE" Margin="10,0,0,0">EXE</CheckBox>
|
||||
<CheckBox Name="LNK" Margin="10,0,0,0">Lnk</CheckBox>
|
||||
<CheckBox Name="apprefMS" Margin="10,0,0,0" IsChecked="{Binding _settings.BuiltinSuffixesStatus[appref-ms]}">appref-ms</CheckBox>
|
||||
<CheckBox Name="exe" Margin="10,0,0,0" IsChecked="{Binding _settings.BuiltinSuffixesStatus[exe]}">exe</CheckBox>
|
||||
<CheckBox Name="lnk" Margin="10,0,0,0" IsChecked="{Binding _settings.BuiltinSuffixesStatus[lnk]}">lnk</CheckBox>
|
||||
<CheckBox
|
||||
Name="CustomFiles"
|
||||
Margin="10,0,0,0"
|
||||
IsChecked="{Binding _settings.UseCustomSuffixes}"
|
||||
Content="{DynamicResource flowlauncher_plugin_program_suffixes_custom_file_types}" />
|
||||
<TextBox
|
||||
x:Name="tbSuffixes"
|
||||
|
|
@ -197,6 +199,7 @@
|
|||
<CheckBox
|
||||
Name="CustomProtocol"
|
||||
Margin="10,0,0,0"
|
||||
IsChecked="{Binding _settings.UseCustomProtocols}"
|
||||
Content="{DynamicResource flowlauncher_plugin_program_suffixes_custom_urls}" />
|
||||
<TextBox
|
||||
x:Name="tbProtocols"
|
||||
|
|
@ -214,11 +217,11 @@
|
|||
BorderThickness="0,1,0,0">
|
||||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
|
||||
<Button
|
||||
x:Name="btnResetl"
|
||||
x:Name="btnReset"
|
||||
Height="30"
|
||||
MinWidth="140"
|
||||
Margin="0,0,5,0"
|
||||
Click="BtnCancel_OnClick"
|
||||
Click="BtnReset_OnClick"
|
||||
Content="{DynamicResource flowlauncher_plugin_program_reset}" />
|
||||
<Button
|
||||
x:Name="btnCancel"
|
||||
|
|
@ -233,7 +236,7 @@
|
|||
MinWidth="140"
|
||||
Margin="5,0,0,0"
|
||||
HorizontalAlignment="Right"
|
||||
Click="ButtonBase_OnClick"
|
||||
Click="BtnAdd_OnClick"
|
||||
Content="{DynamicResource flowlauncher_plugin_program_update}"
|
||||
Style="{DynamicResource AccentButtonStyle}" />
|
||||
</StackPanel>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,8 @@
|
|||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Program
|
||||
{
|
||||
/// <summary>
|
||||
/// ProgramSuffixes.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ProgramSuffixes
|
||||
{
|
||||
private PluginInitContext context;
|
||||
|
|
@ -18,13 +13,15 @@ namespace Flow.Launcher.Plugin.Program
|
|||
this.context = context;
|
||||
InitializeComponent();
|
||||
_settings = settings;
|
||||
tbSuffixes.Text = string.Join(Settings.SuffixSeperator.ToString(), _settings.ProgramSuffixes);
|
||||
tbSuffixes.Text = string.Join(Settings.SuffixSeperator.ToString(), _settings.CustomSuffixes);
|
||||
}
|
||||
|
||||
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
|
||||
|
||||
private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var suffixes = tbSuffixes.Text.Split(Settings.SuffixSeperator, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
|
|
@ -35,12 +32,17 @@ namespace Flow.Launcher.Plugin.Program
|
|||
return;
|
||||
}
|
||||
|
||||
_settings.ProgramSuffixes = suffixes;
|
||||
_settings.CustomSuffixes = suffixes;
|
||||
|
||||
string msg = context.API.GetTranslation("flowlauncher_plugin_program_update_file_suffixes");
|
||||
MessageBox.Show(msg);
|
||||
|
||||
DialogResult = true;
|
||||
}
|
||||
|
||||
private void BtnReset_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -537,7 +537,7 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
{
|
||||
var programs = Enumerable.Empty<Win32>();
|
||||
|
||||
var unregistered = UnregisteredPrograms(settings.ProgramSources, settings.ProgramSuffixes);
|
||||
var unregistered = UnregisteredPrograms(settings.ProgramSources, settings.CustomSuffixes);
|
||||
|
||||
programs = programs.Concat(unregistered);
|
||||
|
||||
|
|
@ -545,13 +545,13 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
|
||||
if (settings.EnableRegistrySource)
|
||||
{
|
||||
var appPaths = AppPathsPrograms(settings.ProgramSuffixes);
|
||||
var appPaths = AppPathsPrograms(settings.CustomSuffixes);
|
||||
autoIndexPrograms = autoIndexPrograms.Concat(appPaths);
|
||||
}
|
||||
|
||||
if (settings.EnableStartMenuSource)
|
||||
{
|
||||
var startMenu = StartMenuPrograms(settings.ProgramSuffixes);
|
||||
var startMenu = StartMenuPrograms(settings.CustomSuffixes);
|
||||
autoIndexPrograms = autoIndexPrograms.Concat(startMenu);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Program
|
||||
{
|
||||
|
|
@ -9,7 +10,28 @@ namespace Flow.Launcher.Plugin.Program
|
|||
public DateTime LastIndexTime { get; set; }
|
||||
public List<ProgramSource> ProgramSources { get; set; } = new List<ProgramSource>();
|
||||
public List<DisabledProgramSource> DisabledProgramSources { get; set; } = new List<DisabledProgramSource>();
|
||||
public string[] ProgramSuffixes { get; set; } = {"appref-ms", "exe", "lnk", "url"};
|
||||
public string[] CustomSuffixes { get; set; } = { "appref-ms", "exe", "lnk" };
|
||||
|
||||
public Dictionary<string, bool> BuiltinSuffixesStatus { get; set; } = new Dictionary<string, bool>{
|
||||
{ "exe", true }, { "appref-ms", true }, { "lnk", true }
|
||||
};
|
||||
|
||||
public bool UseCustomSuffixes = false;
|
||||
public bool UseCustomProtocols = false;
|
||||
|
||||
public string[] GetProgramExtensions()
|
||||
{
|
||||
List<string> extensions = new List<string>();
|
||||
foreach(var item in BuiltinSuffixesStatus)
|
||||
{
|
||||
if (item.Value)
|
||||
{
|
||||
extensions.Add(item.Key);
|
||||
}
|
||||
}
|
||||
|
||||
return extensions.Concat(CustomSuffixes).DistinctBy(x => x.ToLower()).ToArray();
|
||||
}
|
||||
|
||||
public bool EnableStartMenuSource { get; set; } = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Flow.Launcher.Plugin.Program
|
|||
var text = value as string[];
|
||||
if (text != null)
|
||||
{
|
||||
return string.Join(";", text);
|
||||
return string.Join(Settings.SuffixSeperator, text);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue