[Localization] Move PowerToys Run string resources from xaml files to resx (#6165)

* Removed xaml files, added resx file and removed references for PowerLauncher project

* Added resx file for wox.plugin

* Moved Calculator resources to resx

* Migrated resources for Folder and Indexer plugins

* Migrated resources for Program and Shell plugin

* Migrated resources for URI and Window Walker

* Removed GetTranslation, tests need to be refactored

* Removed internationalization classes

* Removed Wox.Core.Resource references

* Fixed Programs plugin tests

* Fixed tests

* Removed language xaml files from installer

* Added locProject.json files

* Fixed resource not found error

* Reverted addition of resx file for Wox.Plugin
This commit is contained in:
Arjun Balgovind
2020-09-02 15:24:59 -07:00
committed by GitHub
parent c9f536c635
commit 1b598ad87e
130 changed files with 3978 additions and 5390 deletions

View File

@@ -1,22 +0,0 @@
<Window x:Class="Microsoft.Plugin.Program.AddProgramSource"
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"
mc:Ignorable="d"
Width="400"
Height="120"
WindowStartupLocation="CenterScreen">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Label Content="{DynamicResource wox_plugin_program_directory}"/>
<TextBox Name="Directory" VerticalAlignment="Center" Width="300" Margin="0,7" />
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Click="BrowseButton_Click" Content="{DynamicResource wox_plugin_program_browse}"
HorizontalAlignment="Right" Margin="10" Height="20" Width="70" />
<Button Click="ButtonAdd_OnClick" Content="{DynamicResource wox_plugin_program_update}"
HorizontalAlignment="Right" Margin="10" Height="20" Width="70" />
</StackPanel>
</StackPanel>
</Window>

View File

@@ -1,84 +0,0 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Linq;
using System.Windows;
using System.Windows.Forms;
using Microsoft.Plugin.Program.Views;
using Wox.Plugin;
namespace Microsoft.Plugin.Program
{
/// <summary>
/// Interaction logic for AddProgramSource.xaml
/// </summary>
public partial class AddProgramSource
{
private PluginInitContext _context;
private ProgramSource _editing;
private ProgramPluginSettings _settings;
public AddProgramSource(PluginInitContext context, ProgramPluginSettings settings)
{
InitializeComponent();
_context = context;
_settings = settings;
Directory.Focus();
}
public AddProgramSource(ProgramSource edit, ProgramPluginSettings settings)
{
_editing = edit ?? throw new ArgumentNullException(nameof(edit));
_settings = settings;
InitializeComponent();
Directory.Text = _editing.Location;
}
private void BrowseButton_Click(object sender, RoutedEventArgs e)
{
using (var dialog = new FolderBrowserDialog())
{
DialogResult result = dialog.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
{
Directory.Text = dialog.SelectedPath;
}
}
}
private void ButtonAdd_OnClick(object sender, RoutedEventArgs e)
{
string s = Directory.Text;
if (!System.IO.Directory.Exists(s))
{
System.Windows.MessageBox.Show(_context.API.GetTranslation("wox_plugin_program_invalid_path"));
return;
}
if (_editing == null)
{
if (!ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == Directory.Text))
{
var source = new ProgramSource
{
Location = Directory.Text,
UniqueIdentifier = Directory.Text,
};
_settings.ProgramSources.Insert(0, source);
ProgramSetting.ProgramSettingDisplayList.Add(source);
}
}
else
{
_editing.Location = Directory.Text;
}
DialogResult = true;
Close();
}
}
}

View File

@@ -1,47 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!--Program setting-->
<system:String x:Key="wox_plugin_program_delete">Löschen</system:String>
<system:String x:Key="wox_plugin_program_edit">Bearbeiten</system:String>
<system:String x:Key="wox_plugin_program_add">Hinzufügen</system:String>
<system:String x:Key="wox_plugin_program_location">Speicherort</system:String>
<system:String x:Key="wox_plugin_program_suffixes">Indexiere Dateiendungen</system:String>
<system:String x:Key="wox_plugin_program_reindex">erneut Indexieren</system:String>
<system:String x:Key="wox_plugin_program_indexing">Indexieren</system:String>
<system:String x:Key="wox_plugin_program_index_start">Indexierungs Startmenü</system:String>
<system:String x:Key="wox_plugin_program_index_registry">Indexierungsspeicher</system:String>
<system:String x:Key="wox_plugin_program_suffixes_header">Endungen</system:String>
<system:String x:Key="wox_plugin_program_max_depth_header">Maximale Tiefe</system:String>
<system:String x:Key="wox_plugin_program_directory">Verzeichnis:</system:String>
<system:String x:Key="wox_plugin_program_browse">Durchsuchen</system:String>
<system:String x:Key="wox_plugin_program_file_suffixes">Dateiendungen:</system:String>
<system:String x:Key="wox_plugin_program_max_search_depth">Maximale Suchtiefe (-1 ist unlimitiert):</system:String>
<system:String x:Key="wox_plugin_program_pls_select_program_source">Bitte wähle eine Programmquelle</system:String>
<system:String x:Key="wox_plugin_program_update">Aktualisieren</system:String>
<system:String x:Key="wox_plugin_program_only_index_tip">Wox indexiert nur Datien mit folgenden Endungen:</system:String>
<system:String x:Key="wox_plugin_program_split_by_tip">(Jede Endung muss durch ein ; getrennt werden)</system:String>
<system:String x:Key="wox_plugin_program_update_file_suffixes">Dateiendungen wurden erfolgreich aktualisiert</system:String>
<system:String x:Key="wox_plugin_program_suffixes_cannot_empty">Dateiendungen dürfen nicht leer sein</system:String>
<system:String x:Key="wox_plugin_program_run_as_administrator">Als Administrator ausführen (Ctrl+Shift+Enter)</system:String>
<system:String x:Key="wox_plugin_program_open_containing_folder">Enthaltenden Ordner öffnen (Ctrl+Shift+E)</system:String>
<system:String x:Key="wox_plugin_program_open_in_console">Open path in console (Ctrl+Shift+C)</system:String>
<system:String x:Key="wox_plugin_program_plugin_name">Programm</system:String>
<system:String x:Key="wox_plugin_program_plugin_description">Suche Programme mit Wox</system:String>
<!--Application subtitle-->
<system:String x:Key="powertoys_run_plugin_program_win32_application">Anwendung</system:String>
<system:String x:Key="powertoys_run_plugin_program_internet_shortcut_application">Weblink-Anwendung</system:String>
<system:String x:Key="powertoys_run_plugin_program_web_application">Web-Anwendung</system:String>
<system:String x:Key="powertoys_run_plugin_program_run_command">Run command</system:String>
<system:String x:Key="powertoys_run_plugin_program_packaged_application">Packaged application</system:String>
<system:String x:Key="powertoys_run_plugin_program_file_name">Name</system:String>
<system:String x:Key="powertoys_run_plugin_program_file_path">Path</system:String>
</ResourceDictionary>

View File

@@ -1,59 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!--Program setting-->
<system:String x:Key="wox_plugin_program_delete">Delete</system:String>
<system:String x:Key="wox_plugin_program_edit">Edit</system:String>
<system:String x:Key="wox_plugin_program_add">Add</system:String>
<system:String x:Key="wox_plugin_program_disable">Disable</system:String>
<system:String x:Key="wox_plugin_program_location">Location</system:String>
<system:String x:Key="wox_plugin_program_all_programs">All programs</system:String>
<system:String x:Key="wox_plugin_program_suffixes">File suffixes</system:String>
<system:String x:Key="wox_plugin_program_reindex">Reindex</system:String>
<system:String x:Key="wox_plugin_program_indexing">Indexing</system:String>
<system:String x:Key="wox_plugin_program_index_start">Index start menu</system:String>
<system:String x:Key="wox_plugin_program_index_registry">Index registry</system:String>
<system:String x:Key="wox_plugin_program_suffixes_header">Suffixes</system:String>
<system:String x:Key="wox_plugin_program_max_depth_header">Max depth</system:String>
<system:String x:Key="wox_plugin_program_directory">Directory:</system:String>
<system:String x:Key="wox_plugin_program_browse">Browse</system:String>
<system:String x:Key="wox_plugin_program_file_suffixes">File suffixes:</system:String>
<system:String x:Key="wox_plugin_program_max_search_depth">Maximum search depth (-1 is unlimited):</system:String>
<system:String x:Key="wox_plugin_program_pls_select_program_source">Please select a program source</system:String>
<system:String x:Key="wox_plugin_program_delete_program_source">Are you sure you want to delete the selected program sources?</system:String>
<system:String x:Key="wox_plugin_program_update">Update</system:String>
<system:String x:Key="wox_plugin_program_only_index_tip">Wox will only index files that end with the following suffixes:</system:String>
<system:String x:Key="wox_plugin_program_split_by_tip">(Each suffix should split by ';' )</system:String>
<system:String x:Key="wox_plugin_program_update_file_suffixes">Successfully updated file suffixes</system:String>
<system:String x:Key="wox_plugin_program_suffixes_cannot_empty">File suffixes can't be empty</system:String>
<system:String x:Key="wox_plugin_program_run_as_different_user">Run as different user</system:String>
<system:String x:Key="wox_plugin_program_run_as_administrator">Run as administrator (Ctrl+Shift+Enter)</system:String>
<system:String x:Key="wox_plugin_program_open_containing_folder">Open containing folder (Ctrl+Shift+E)</system:String>
<system:String x:Key="wox_plugin_program_disable_program">Disable this program from displaying</system:String>
<system:String x:Key="wox_plugin_program_open_in_console">Open path in console (Ctrl+Shift+C)</system:String>
<system:String x:Key="wox_plugin_program_plugin_name">Program</system:String>
<system:String x:Key="wox_plugin_program_plugin_description">Search programs in Wox</system:String>
<system:String x:Key="wox_plugin_program_invalid_path">Invalid Path</system:String>
<!--Dialogs-->
<system:String x:Key="wox_plugin_program_disable_dlgtitle_success">Success</system:String>
<system:String x:Key="wox_plugin_program_disable_dlgtitle_success_message">Successfully disabled this program from displaying in your query</system:String>
<!--Application subtitle-->
<system:String x:Key="powertoys_run_plugin_program_win32_application">Application</system:String>
<system:String x:Key="powertoys_run_plugin_program_internet_shortcut_application">Internet shortcut application</system:String>
<system:String x:Key="powertoys_run_plugin_program_web_application">Web application</system:String>
<system:String x:Key="powertoys_run_plugin_program_run_command">Run command</system:String>
<system:String x:Key="powertoys_run_plugin_program_packaged_application">Packaged application</system:String>
<system:String x:Key="powertoys_run_plugin_program_file_name">Name</system:String>
<system:String x:Key="powertoys_run_plugin_program_file_path">Path</system:String>
</ResourceDictionary>

View File

@@ -1,49 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!--Program setting-->
<system:String x:Key="wox_plugin_program_delete">Delete</system:String>
<system:String x:Key="wox_plugin_program_edit">Edit</system:String>
<system:String x:Key="wox_plugin_program_add">Add</system:String>
<system:String x:Key="wox_plugin_program_location">Location</system:String>
<system:String x:Key="wox_plugin_program_suffixes">Index file suffixes</system:String>
<system:String x:Key="wox_plugin_program_reindex">Reindex</system:String>
<system:String x:Key="wox_plugin_program_indexing">Indexing</system:String>
<system:String x:Key="wox_plugin_program_index_start">Index start menu</system:String>
<system:String x:Key="wox_plugin_program_index_registry">Index registry</system:String>
<system:String x:Key="wox_plugin_program_suffixes_header">Suffixes</system:String>
<system:String x:Key="wox_plugin_program_max_depth_header">Max depth</system:String>
<system:String x:Key="wox_plugin_program_directory">Directory:</system:String>
<system:String x:Key="wox_plugin_program_browse">Browse</system:String>
<system:String x:Key="wox_plugin_program_file_suffixes">File suffixes:</system:String>
<system:String x:Key="wox_plugin_program_max_search_depth">Maximum search depth (-1 is unlimited):</system:String>
<system:String x:Key="wox_plugin_program_pls_select_program_source">Please select a program source</system:String>
<system:String x:Key="wox_plugin_program_delete_program_source">Are your sure to delete {0}?</system:String>
<system:String x:Key="wox_plugin_program_update">Update</system:String>
<system:String x:Key="wox_plugin_program_only_index_tip">Wox will only index files that end with following suffixes:</system:String>
<system:String x:Key="wox_plugin_program_split_by_tip">(Each suffix should split by ;)</system:String>
<system:String x:Key="wox_plugin_program_update_file_suffixes">Sucessfully update file suffixes</system:String>
<system:String x:Key="wox_plugin_program_suffixes_cannot_empty">File suffixes can't be empty</system:String>
<system:String x:Key="wox_plugin_program_run_as_administrator">Run as administrator (Ctrl+Shift+Enter)</system:String>
<system:String x:Key="wox_plugin_program_open_containing_folder">Open containing folder (Ctrl+Shift+E)</system:String>
<system:String x:Key="wox_plugin_program_open_in_console">Open path in console (Ctrl+Shift+C)</system:String>
<system:String x:Key="wox_plugin_program_plugin_name">Program</system:String>
<system:String x:Key="wox_plugin_program_plugin_description">Search programs in Wox</system:String>
<!--Application subtitle-->
<system:String x:Key="powertoys_run_plugin_program_win32_application">Application</system:String>
<system:String x:Key="powertoys_run_plugin_program_internet_shortcut_application">Internet shortcut application</system:String>
<system:String x:Key="powertoys_run_plugin_program_web_application">Web application</system:String>
<system:String x:Key="powertoys_run_plugin_program_run_command">Run command</system:String>
<system:String x:Key="powertoys_run_plugin_program_packaged_application">Packaged application</system:String>
<system:String x:Key="powertoys_run_plugin_program_file_name">Name</system:String>
<system:String x:Key="powertoys_run_plugin_program_file_path">Path</system:String>
</ResourceDictionary>

View File

@@ -1,48 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!--Program setting-->
<system:String x:Key="wox_plugin_program_delete">Usuń</system:String>
<system:String x:Key="wox_plugin_program_edit">Edytuj</system:String>
<system:String x:Key="wox_plugin_program_add">Dodaj</system:String>
<system:String x:Key="wox_plugin_program_location">Lokalizacja</system:String>
<system:String x:Key="wox_plugin_program_suffixes">Rozszerzenia indeksowanych plików</system:String>
<system:String x:Key="wox_plugin_program_reindex">Re-indeksuj</system:String>
<system:String x:Key="wox_plugin_program_indexing">Indeksowanie</system:String>
<system:String x:Key="wox_plugin_program_index_start">Indeksuj Menu Start</system:String>
<system:String x:Key="wox_plugin_program_index_registry">Indeksuj rejestr</system:String>
<system:String x:Key="wox_plugin_program_suffixes_header">Rozszerzenia</system:String>
<system:String x:Key="wox_plugin_program_max_depth_header">Maksymalna głębokość</system:String>
<system:String x:Key="wox_plugin_program_directory">Katalog:</system:String>
<system:String x:Key="wox_plugin_program_browse">Przeglądaj</system:String>
<system:String x:Key="wox_plugin_program_file_suffixes">Rozszerzenia plików:</system:String>
<system:String x:Key="wox_plugin_program_max_search_depth">Maksymalna głębokość wyszukiwania (-1 to nieograniczona):</system:String>
<system:String x:Key="wox_plugin_program_pls_select_program_source">Musisz wybrać katalog programu</system:String>
<system:String x:Key="wox_plugin_program_update">Aktualizuj</system:String>
<system:String x:Key="wox_plugin_program_only_index_tip">Wox będzie indeksował tylko te pliki z podanymi rozszerzeniami:</system:String>
<system:String x:Key="wox_plugin_program_split_by_tip">(Każde rozszerzenie musi być oddzielone ;)</system:String>
<system:String x:Key="wox_plugin_program_update_file_suffixes">Pomyślnie zaktualizowano rozszerzenia plików</system:String>
<system:String x:Key="wox_plugin_program_suffixes_cannot_empty">Musisz podać rozszerzenia plików</system:String>
<system:String x:Key="wox_plugin_program_run_as_administrator">Uruchom jako administrator (Ctrl+Shift+Enter)</system:String>
<system:String x:Key="wox_plugin_program_open_containing_folder">Otwórz folder zawierający (Ctrl+Shift+E)</system:String>
<system:String x:Key="wox_plugin_program_plugin_name">Programy</system:String>
<system:String x:Key="wox_plugin_program_plugin_description">Szukaj i uruchamiaj programy z poziomu Woxa</system:String>
<system:String x:Key="wox_plugin_program_open_in_console">Open path in console (Ctrl+Shift+C)</system:String>
<!--Application subtitle-->
<system:String x:Key="powertoys_run_plugin_program_win32_application">Application</system:String>
<system:String x:Key="powertoys_run_plugin_program_internet_shortcut_application">Internet shortcut application</system:String>
<system:String x:Key="powertoys_run_plugin_program_web_application">Web application</system:String>
<system:String x:Key="powertoys_run_plugin_program_run_command">Run command</system:String>
<system:String x:Key="powertoys_run_plugin_program_packaged_application">Packaged application</system:String>
<system:String x:Key="powertoys_run_plugin_program_file_name">Name</system:String>
<system:String x:Key="powertoys_run_plugin_program_file_path">Path</system:String>
</ResourceDictionary>

View File

@@ -1,50 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!--Program setting-->
<system:String x:Key="wox_plugin_program_delete">Sil</system:String>
<system:String x:Key="wox_plugin_program_edit">Düzenle</system:String>
<system:String x:Key="wox_plugin_program_add">Ekle</system:String>
<system:String x:Key="wox_plugin_program_location">Konum</system:String>
<system:String x:Key="wox_plugin_program_suffixes">İndekslenecek Uzantılar</system:String>
<system:String x:Key="wox_plugin_program_reindex">Yeniden İndeksle</system:String>
<system:String x:Key="wox_plugin_program_indexing">İndeksleniyor</system:String>
<system:String x:Key="wox_plugin_program_index_start">Başlat Menüsünü İndeksle</system:String>
<system:String x:Key="wox_plugin_program_index_registry">Registry'i İndeksle</system:String>
<system:String x:Key="wox_plugin_program_suffixes_header">Uzantılar</system:String>
<system:String x:Key="wox_plugin_program_max_depth_header">Derinlik</system:String>
<system:String x:Key="wox_plugin_program_directory">Dizin:</system:String>
<system:String x:Key="wox_plugin_program_browse">Gözat</system:String>
<system:String x:Key="wox_plugin_program_file_suffixes">Dosya Uzantıları:</system:String>
<system:String x:Key="wox_plugin_program_max_search_depth">Maksimum Arama Derinliği (Limitsiz için -1):</system:String>
<system:String x:Key="wox_plugin_program_pls_select_program_source">İşlem yapmak istediğiniz klasörü seçin.</system:String>
<system:String x:Key="wox_plugin_program_update">Güncelle</system:String>
<system:String x:Key="wox_plugin_program_only_index_tip">Wox yalnızca aşağıdaki uzantılara sahip dosyaları indeksleyecektir:</system:String>
<system:String x:Key="wox_plugin_program_split_by_tip">(Her uzantıyı ; işareti ile ayırın)</system:String>
<system:String x:Key="wox_plugin_program_update_file_suffixes">Dosya uzantıları başarıyla güncellendi</system:String>
<system:String x:Key="wox_plugin_program_suffixes_cannot_empty">Dosya uzantıları boş olamaz</system:String>
<system:String x:Key="wox_plugin_program_run_as_administrator">Yönetici Olarak Çalıştır (Ctrl+Shift+Enter)</system:String>
<system:String x:Key="wox_plugin_program_open_containing_folder">İçeren Klasörü Aç (Ctrl+Shift+E)</system:String>
<system:String x:Key="wox_plugin_program_open_in_console">Open path in console (Ctrl+Shift+C)</system:String>
<system:String x:Key="wox_plugin_program_plugin_name">Program</system:String>
<system:String x:Key="wox_plugin_program_plugin_description">Programları Wox'tan arayın</system:String>
<system:String x:Key="wox_plugin_program_invalid_path">Geçersiz Konum</system:String>
<!--Application subtitle-->
<system:String x:Key="powertoys_run_plugin_program_win32_application">Application</system:String>
<system:String x:Key="powertoys_run_plugin_program_internet_shortcut_application">Internet shortcut application</system:String>
<system:String x:Key="powertoys_run_plugin_program_web_application">Web application</system:String>
<system:String x:Key="powertoys_run_plugin_program_run_command">Run command</system:String>
<system:String x:Key="powertoys_run_plugin_program_packaged_application">Packaged application</system:String>
<system:String x:Key="powertoys_run_plugin_program_file_name">Name</system:String>
<system:String x:Key="powertoys_run_plugin_program_file_path">Path</system:String>
</ResourceDictionary>

View File

@@ -1,50 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!--Program setting-->
<system:String x:Key="wox_plugin_program_delete">删除</system:String>
<system:String x:Key="wox_plugin_program_edit">编辑</system:String>
<system:String x:Key="wox_plugin_program_add">增加</system:String>
<system:String x:Key="wox_plugin_program_location">位置</system:String>
<system:String x:Key="wox_plugin_program_suffixes">索引文件后缀</system:String>
<system:String x:Key="wox_plugin_program_reindex">重新索引</system:String>
<system:String x:Key="wox_plugin_program_indexing">索引中</system:String>
<system:String x:Key="wox_plugin_program_index_start">索引开始菜单</system:String>
<system:String x:Key="wox_plugin_program_index_registry">索引注册表</system:String>
<system:String x:Key="wox_plugin_program_suffixes_header">后缀</system:String>
<system:String x:Key="wox_plugin_program_max_depth_header">最大深度</system:String>
<system:String x:Key="wox_plugin_program_directory">目录</system:String>
<system:String x:Key="wox_plugin_program_browse">浏览</system:String>
<system:String x:Key="wox_plugin_program_file_suffixes">文件后缀</system:String>
<system:String x:Key="wox_plugin_program_max_search_depth">最大搜索深度(-1是无限的</system:String>
<system:String x:Key="wox_plugin_program_pls_select_program_source">请先选择一项</system:String>
<system:String x:Key="wox_plugin_program_update">更新</system:String>
<system:String x:Key="wox_plugin_program_only_index_tip">Wox仅索引下列后缀的文件</system:String>
<system:String x:Key="wox_plugin_program_split_by_tip">(每个后缀以英文状态下的分号分隔)</system:String>
<system:String x:Key="wox_plugin_program_update_file_suffixes">成功更新索引文件后缀</system:String>
<system:String x:Key="wox_plugin_program_suffixes_cannot_empty">文件后缀不能为空</system:String>
<system:String x:Key="wox_plugin_program_run_as_administrator">以管理员身份运行 (Ctrl+Shift+Enter)</system:String>
<system:String x:Key="wox_plugin_program_open_containing_folder">打开所属文件夹 (Ctrl+Shift+E)</system:String>
<system:String x:Key="wox_plugin_program_open_in_console">Open path in console (Ctrl+Shift+C)</system:String>
<system:String x:Key="wox_plugin_program_plugin_name">程序</system:String>
<system:String x:Key="wox_plugin_program_plugin_description">在Wox中搜索程序</system:String>
<system:String x:Key="wox_plugin_program_invalid_path">无效路径</system:String>
<!--Application subtitle-->
<system:String x:Key="powertoys_run_plugin_program_win32_application">Application</system:String>
<system:String x:Key="powertoys_run_plugin_program_internet_shortcut_application">Internet shortcut application</system:String>
<system:String x:Key="powertoys_run_plugin_program_web_application">Web application</system:String>
<system:String x:Key="powertoys_run_plugin_program_run_command">Run command</system:String>
<system:String x:Key="powertoys_run_plugin_program_packaged_application">Packaged application</system:String>
<system:String x:Key="powertoys_run_plugin_program_file_name">Name</system:String>
<system:String x:Key="powertoys_run_plugin_program_file_path">Path</system:String>
</ResourceDictionary>

View File

@@ -1,48 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!--Program setting-->
<system:String x:Key="wox_plugin_program_delete">刪除</system:String>
<system:String x:Key="wox_plugin_program_edit">編輯</system:String>
<system:String x:Key="wox_plugin_program_add">新增</system:String>
<system:String x:Key="wox_plugin_program_location">路徑</system:String>
<system:String x:Key="wox_plugin_program_suffixes">索引副檔名清單</system:String>
<system:String x:Key="wox_plugin_program_reindex">重新建立索引</system:String>
<system:String x:Key="wox_plugin_program_indexing">正在建立索引</system:String>
<system:String x:Key="wox_plugin_program_index_start">替開始選單建立索引</system:String>
<system:String x:Key="wox_plugin_program_index_registry">替登錄檔建立索引</system:String>
<system:String x:Key="wox_plugin_program_suffixes_header">副檔名</system:String>
<system:String x:Key="wox_plugin_program_max_depth_header">最大深度</system:String>
<system:String x:Key="wox_plugin_program_directory">目錄</system:String>
<system:String x:Key="wox_plugin_program_browse">瀏覽</system:String>
<system:String x:Key="wox_plugin_program_file_suffixes">副檔名</system:String>
<system:String x:Key="wox_plugin_program_max_search_depth">最大搜尋深度(-1是無限的</system:String>
<system:String x:Key="wox_plugin_program_pls_select_program_source">請先選擇一項</system:String>
<system:String x:Key="wox_plugin_program_update">更新</system:String>
<system:String x:Key="wox_plugin_program_only_index_tip">Wox 僅索引下列副檔名的檔案:</system:String>
<system:String x:Key="wox_plugin_program_split_by_tip">(每個副檔名以英文的分號分隔)</system:String>
<system:String x:Key="wox_plugin_program_update_file_suffixes">成功更新索引副檔名清單</system:String>
<system:String x:Key="wox_plugin_program_suffixes_cannot_empty">副檔名不能為空</system:String>
<system:String x:Key="wox_plugin_program_run_as_administrator">以系統管理員身分執行 (Ctrl+Shift+Enter)</system:String>
<system:String x:Key="wox_plugin_program_open_containing_folder">開啟檔案位置 (Ctrl+Shift+E)</system:String>
<system:String x:Key="wox_plugin_program_open_in_console">Open path in console (Ctrl+Shift+C)</system:String>
<system:String x:Key="wox_plugin_program_plugin_name">程式</system:String>
<system:String x:Key="wox_plugin_program_plugin_description">在 Wox 中搜尋程式</system:String>
<!--Application subtitle-->
<system:String x:Key="powertoys_run_plugin_program_win32_application">Application</system:String>
<system:String x:Key="powertoys_run_plugin_program_internet_shortcut_application">Internet shortcut application</system:String>
<system:String x:Key="powertoys_run_plugin_program_web_application">Web application</system:String>
<system:String x:Key="powertoys_run_plugin_program_run_command">Run command</system:String>
<system:String x:Key="powertoys_run_plugin_program_packaged_application">Packaged application</system:String>
<system:String x:Key="powertoys_run_plugin_program_file_name">Name</system:String>
<system:String x:Key="powertoys_run_plugin_program_file_path">Path</system:String>
</ResourceDictionary>

View File

@@ -0,0 +1,14 @@
{
"Projects": [
{
"LanguageSet": "Azure_Languages",
"LocItems": [
{
"SourceFile": "src\\modules\\launcher\\Plugins\\Microsoft.Plugin.Program\\Properties\\Resources.resx",
"CopyOption": "LangIDOnName",
"OutputPath": "src\\modules\\launcher\\Plugins\\Microsoft.Plugin.Program\\Properties"
}
]
}
]
}

View File

@@ -111,12 +111,12 @@ namespace Microsoft.Plugin.Program
public string GetTranslatedPluginTitle()
{
return _context.API.GetTranslation("wox_plugin_program_plugin_name");
return Properties.Resources.wox_plugin_program_plugin_name;
}
public string GetTranslatedPluginDescription()
{
return _context.API.GetTranslation("wox_plugin_program_plugin_description");
return Properties.Resources.wox_plugin_program_plugin_description;
}
public List<ContextMenuResult> LoadContextMenus(Result selectedResult)

View File

@@ -13,6 +13,7 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<Platforms>x64</Platforms>
<NeutralLanguage>en-US</NeutralLanguage>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -41,48 +42,19 @@
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Languages\**" />
<EmbeddedResource Remove="Languages\**" />
<None Remove="Languages\**" />
<Page Remove="Languages\**" />
</ItemGroup>
<ItemGroup>
<None Include="plugin.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="Languages\en.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="Languages\zh-cn.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Languages\zh-tw.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Languages\de.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Languages\pl.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Languages\tr.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Wox.Infrastructure\Wox.Infrastructure.csproj" />
@@ -155,4 +127,17 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@@ -1,24 +0,0 @@
<Window x:Class="Microsoft.Plugin.Program.ProgramSuffixes"
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"
mc:Ignorable="d"
Width="400"
Height="180"
WindowStartupLocation="CenterScreen"
d:DesignHeight="400" d:DesignWidth="300">
<StackPanel>
<TextBlock Margin="10 10 0 0" Foreground="Gray" Text="{DynamicResource wox_plugin_program_only_index_tip}" />
<TextBlock Margin="10 10 0 0" Foreground="Gray" Text="{DynamicResource wox_plugin_program_split_by_tip}" />
<TextBox x:Name="tbSuffixes" Margin="10"/>
<Button HorizontalAlignment="Right" Height="30" Width="80" Click="ButtonBase_OnClick" Margin="10" Content="{DynamicResource wox_plugin_program_update}" />
</StackPanel>
</Window>

View File

@@ -1,44 +0,0 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Windows;
using Wox.Plugin;
namespace Microsoft.Plugin.Program
{
/// <summary>
/// ProgramSuffixes.xaml 的交互逻辑
/// </summary>
public partial class ProgramSuffixes
{
private PluginInitContext context;
private ProgramPluginSettings _settings;
public ProgramSuffixes(PluginInitContext context, ProgramPluginSettings settings)
{
this.context = context ?? throw new ArgumentNullException(nameof(context));
InitializeComponent();
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
tbSuffixes.Text = string.Join(ProgramPluginSettings.SuffixSeparator.ToString(), _settings.ProgramSuffixes);
}
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(tbSuffixes.Text))
{
string warning = context.API.GetTranslation("wox_plugin_program_suffixes_cannot_empty");
MessageBox.Show(warning);
return;
}
_settings.ProgramSuffixes.Clear();
_settings.ProgramSuffixes.AddRange(tbSuffixes.Text.Split(ProgramPluginSettings.SuffixSeparator));
string msg = context.API.GetTranslation("wox_plugin_program_update_file_suffixes");
MessageBox.Show(msg);
DialogResult = true;
}
}
}

View File

@@ -74,9 +74,9 @@ namespace Microsoft.Plugin.Program.Programs
}
// Function to set the subtitle based on the Type of application
private static string SetSubtitle(IPublicAPI api)
private static string SetSubtitle()
{
return api.GetTranslation("powertoys_run_plugin_program_packaged_application");
return Properties.Resources.powertoys_run_plugin_program_packaged_application;
}
public Result Result(string query, IPublicAPI api)
@@ -94,7 +94,7 @@ namespace Microsoft.Plugin.Program.Programs
var result = new Result
{
SubTitle = SetSubtitle(api),
SubTitle = SetSubtitle(),
Icon = Logo,
Score = score,
ContextData = this,
@@ -109,8 +109,8 @@ namespace Microsoft.Plugin.Program.Programs
result.Title = DisplayName;
result.TitleHighlightData = StringMatcher.FuzzySearch(query, Name).MatchData;
var toolTipTitle = string.Format(CultureInfo.CurrentCulture, "{0}: {1}", api.GetTranslation("powertoys_run_plugin_program_file_name"), result.Title);
var toolTipText = string.Format(CultureInfo.CurrentCulture, "{0}: {1}", api.GetTranslation("powertoys_run_plugin_program_file_path"), Package.Location);
var toolTipTitle = string.Format(CultureInfo.CurrentCulture, "{0}: {1}", Properties.Resources.powertoys_run_plugin_program_file_name, result.Title);
var toolTipText = string.Format(CultureInfo.CurrentCulture, "{0}: {1}", Properties.Resources.powertoys_run_plugin_program_file_path, Package.Location);
result.ToolTipData = new ToolTipData(toolTipTitle, toolTipText);
return result;
@@ -132,7 +132,7 @@ namespace Microsoft.Plugin.Program.Programs
new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = api.GetTranslation("wox_plugin_program_run_as_administrator"),
Title = Properties.Resources.wox_plugin_program_run_as_administrator,
Glyph = "\xE7EF",
FontFamily = "Segoe MDL2 Assets",
AcceleratorKey = Key.Enter,
@@ -155,7 +155,7 @@ namespace Microsoft.Plugin.Program.Programs
new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = api.GetTranslation("wox_plugin_program_open_containing_folder"),
Title = Properties.Resources.wox_plugin_program_open_containing_folder,
Glyph = "\xE838",
FontFamily = "Segoe MDL2 Assets",
AcceleratorKey = Key.E,
@@ -171,7 +171,7 @@ namespace Microsoft.Plugin.Program.Programs
contextMenus.Add(new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = api.GetTranslation("wox_plugin_program_open_in_console"),
Title = Properties.Resources.wox_plugin_program_open_in_console,
Glyph = "\xE756",
FontFamily = "Segoe MDL2 Assets",
AcceleratorKey = Key.C,

View File

@@ -130,23 +130,23 @@ namespace Microsoft.Plugin.Program.Programs
}
// Function to set the subtitle based on the Type of application
private string SetSubtitle(IPublicAPI api)
private string SetSubtitle()
{
if (AppType == (uint)ApplicationTypes.WIN32_APPLICATION)
{
return api.GetTranslation("powertoys_run_plugin_program_win32_application");
return Properties.Resources.powertoys_run_plugin_program_win32_application;
}
else if (AppType == (uint)ApplicationTypes.INTERNET_SHORTCUT_APPLICATION)
{
return api.GetTranslation("powertoys_run_plugin_program_internet_shortcut_application");
return Properties.Resources.powertoys_run_plugin_program_internet_shortcut_application;
}
else if (AppType == (uint)ApplicationTypes.WEB_APPLICATION)
{
return api.GetTranslation("powertoys_run_plugin_program_web_application");
return Properties.Resources.powertoys_run_plugin_program_web_application;
}
else if (AppType == (uint)ApplicationTypes.RUN_COMMAND)
{
return api.GetTranslation("powertoys_run_plugin_program_run_command");
return Properties.Resources.powertoys_run_plugin_program_run_command;
}
else
{
@@ -200,7 +200,7 @@ namespace Microsoft.Plugin.Program.Programs
var result = new Result
{
SubTitle = SetSubtitle(api),
SubTitle = SetSubtitle(),
IcoPath = IcoPath,
Score = score,
ContextData = this,
@@ -223,8 +223,8 @@ namespace Microsoft.Plugin.Program.Programs
result.Title = Name;
result.TitleHighlightData = StringMatcher.FuzzySearch(query, Name).MatchData;
var toolTipTitle = string.Format(CultureInfo.CurrentCulture, "{0}: {1}", api.GetTranslation("powertoys_run_plugin_program_file_name"), result.Title);
var toolTipText = string.Format(CultureInfo.CurrentCulture, "{0}: {1}", api.GetTranslation("powertoys_run_plugin_program_file_path"), FullPath);
var toolTipTitle = string.Format(CultureInfo.CurrentCulture, "{0}: {1}", Properties.Resources.powertoys_run_plugin_program_file_name, result.Title);
var toolTipText = string.Format(CultureInfo.CurrentCulture, "{0}: {1}", Properties.Resources.powertoys_run_plugin_program_file_path, FullPath);
result.ToolTipData = new ToolTipData(toolTipTitle, toolTipText);
return result;
@@ -245,7 +245,7 @@ namespace Microsoft.Plugin.Program.Programs
contextMenus.Add(new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = api.GetTranslation("wox_plugin_program_run_as_administrator"),
Title = Properties.Resources.wox_plugin_program_run_as_administrator,
Glyph = "\xE7EF",
FontFamily = "Segoe MDL2 Assets",
AcceleratorKey = Key.Enter,
@@ -271,7 +271,7 @@ namespace Microsoft.Plugin.Program.Programs
new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = api.GetTranslation("wox_plugin_program_open_containing_folder"),
Title = Properties.Resources.wox_plugin_program_open_containing_folder,
Glyph = "\xE838",
FontFamily = "Segoe MDL2 Assets",
AcceleratorKey = Key.E,
@@ -287,7 +287,7 @@ namespace Microsoft.Plugin.Program.Programs
new ContextMenuResult
{
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
Title = api.GetTranslation("wox_plugin_program_open_in_console"),
Title = Properties.Resources.wox_plugin_program_open_in_console,
Glyph = "\xE756",
FontFamily = "Segoe MDL2 Assets",
AcceleratorKey = Key.C,

View File

@@ -0,0 +1,432 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Microsoft.Plugin.Program.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Plugin.Program.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to Name.
/// </summary>
public static string powertoys_run_plugin_program_file_name {
get {
return ResourceManager.GetString("powertoys_run_plugin_program_file_name", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Path.
/// </summary>
public static string powertoys_run_plugin_program_file_path {
get {
return ResourceManager.GetString("powertoys_run_plugin_program_file_path", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Internet shortcut application.
/// </summary>
public static string powertoys_run_plugin_program_internet_shortcut_application {
get {
return ResourceManager.GetString("powertoys_run_plugin_program_internet_shortcut_application", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Packaged application.
/// </summary>
public static string powertoys_run_plugin_program_packaged_application {
get {
return ResourceManager.GetString("powertoys_run_plugin_program_packaged_application", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Run command.
/// </summary>
public static string powertoys_run_plugin_program_run_command {
get {
return ResourceManager.GetString("powertoys_run_plugin_program_run_command", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Web application.
/// </summary>
public static string powertoys_run_plugin_program_web_application {
get {
return ResourceManager.GetString("powertoys_run_plugin_program_web_application", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Application.
/// </summary>
public static string powertoys_run_plugin_program_win32_application {
get {
return ResourceManager.GetString("powertoys_run_plugin_program_win32_application", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Add.
/// </summary>
public static string wox_plugin_program_add {
get {
return ResourceManager.GetString("wox_plugin_program_add", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to All programs.
/// </summary>
public static string wox_plugin_program_all_programs {
get {
return ResourceManager.GetString("wox_plugin_program_all_programs", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Browse.
/// </summary>
public static string wox_plugin_program_browse {
get {
return ResourceManager.GetString("wox_plugin_program_browse", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Delete.
/// </summary>
public static string wox_plugin_program_delete {
get {
return ResourceManager.GetString("wox_plugin_program_delete", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Are you sure you want to delete the selected program sources?.
/// </summary>
public static string wox_plugin_program_delete_program_source {
get {
return ResourceManager.GetString("wox_plugin_program_delete_program_source", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Directory:.
/// </summary>
public static string wox_plugin_program_directory {
get {
return ResourceManager.GetString("wox_plugin_program_directory", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Disable.
/// </summary>
public static string wox_plugin_program_disable {
get {
return ResourceManager.GetString("wox_plugin_program_disable", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Success.
/// </summary>
public static string wox_plugin_program_disable_dlgtitle_success {
get {
return ResourceManager.GetString("wox_plugin_program_disable_dlgtitle_success", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Successfully disabled this program from displaying in your query.
/// </summary>
public static string wox_plugin_program_disable_dlgtitle_success_message {
get {
return ResourceManager.GetString("wox_plugin_program_disable_dlgtitle_success_message", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Disable this program from displaying.
/// </summary>
public static string wox_plugin_program_disable_program {
get {
return ResourceManager.GetString("wox_plugin_program_disable_program", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Edit.
/// </summary>
public static string wox_plugin_program_edit {
get {
return ResourceManager.GetString("wox_plugin_program_edit", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to File suffixes:.
/// </summary>
public static string wox_plugin_program_file_suffixes {
get {
return ResourceManager.GetString("wox_plugin_program_file_suffixes", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Index registry.
/// </summary>
public static string wox_plugin_program_index_registry {
get {
return ResourceManager.GetString("wox_plugin_program_index_registry", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Index start menu.
/// </summary>
public static string wox_plugin_program_index_start {
get {
return ResourceManager.GetString("wox_plugin_program_index_start", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Indexing.
/// </summary>
public static string wox_plugin_program_indexing {
get {
return ResourceManager.GetString("wox_plugin_program_indexing", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Invalid Path.
/// </summary>
public static string wox_plugin_program_invalid_path {
get {
return ResourceManager.GetString("wox_plugin_program_invalid_path", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Location.
/// </summary>
public static string wox_plugin_program_location {
get {
return ResourceManager.GetString("wox_plugin_program_location", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Max depth.
/// </summary>
public static string wox_plugin_program_max_depth_header {
get {
return ResourceManager.GetString("wox_plugin_program_max_depth_header", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Maximum search depth (-1 is unlimited):.
/// </summary>
public static string wox_plugin_program_max_search_depth {
get {
return ResourceManager.GetString("wox_plugin_program_max_search_depth", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Wox will only index files that end with the following suffixes:.
/// </summary>
public static string wox_plugin_program_only_index_tip {
get {
return ResourceManager.GetString("wox_plugin_program_only_index_tip", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Open containing folder (Ctrl+Shift+E).
/// </summary>
public static string wox_plugin_program_open_containing_folder {
get {
return ResourceManager.GetString("wox_plugin_program_open_containing_folder", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Open path in console (Ctrl+Shift+C).
/// </summary>
public static string wox_plugin_program_open_in_console {
get {
return ResourceManager.GetString("wox_plugin_program_open_in_console", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Please select a program source.
/// </summary>
public static string wox_plugin_program_pls_select_program_source {
get {
return ResourceManager.GetString("wox_plugin_program_pls_select_program_source", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Search programs in Wox.
/// </summary>
public static string wox_plugin_program_plugin_description {
get {
return ResourceManager.GetString("wox_plugin_program_plugin_description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Program.
/// </summary>
public static string wox_plugin_program_plugin_name {
get {
return ResourceManager.GetString("wox_plugin_program_plugin_name", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Reindex.
/// </summary>
public static string wox_plugin_program_reindex {
get {
return ResourceManager.GetString("wox_plugin_program_reindex", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Run as administrator (Ctrl+Shift+Enter).
/// </summary>
public static string wox_plugin_program_run_as_administrator {
get {
return ResourceManager.GetString("wox_plugin_program_run_as_administrator", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Run as different user.
/// </summary>
public static string wox_plugin_program_run_as_different_user {
get {
return ResourceManager.GetString("wox_plugin_program_run_as_different_user", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to (Each suffix should split by &apos;;&apos; ).
/// </summary>
public static string wox_plugin_program_split_by_tip {
get {
return ResourceManager.GetString("wox_plugin_program_split_by_tip", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to File suffixes.
/// </summary>
public static string wox_plugin_program_suffixes {
get {
return ResourceManager.GetString("wox_plugin_program_suffixes", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to File suffixes can&apos;t be empty.
/// </summary>
public static string wox_plugin_program_suffixes_cannot_empty {
get {
return ResourceManager.GetString("wox_plugin_program_suffixes_cannot_empty", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Suffixes.
/// </summary>
public static string wox_plugin_program_suffixes_header {
get {
return ResourceManager.GetString("wox_plugin_program_suffixes_header", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Update.
/// </summary>
public static string wox_plugin_program_update {
get {
return ResourceManager.GetString("wox_plugin_program_update", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Successfully updated file suffixes.
/// </summary>
public static string wox_plugin_program_update_file_suffixes {
get {
return ResourceManager.GetString("wox_plugin_program_update_file_suffixes", resourceCulture);
}
}
}
}

View File

@@ -0,0 +1,243 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="wox_plugin_program_delete" xml:space="preserve">
<value>Delete</value>
</data>
<data name="wox_plugin_program_edit" xml:space="preserve">
<value>Edit</value>
</data>
<data name="wox_plugin_program_add" xml:space="preserve">
<value>Add</value>
</data>
<data name="wox_plugin_program_disable" xml:space="preserve">
<value>Disable</value>
</data>
<data name="wox_plugin_program_location" xml:space="preserve">
<value>Location</value>
</data>
<data name="wox_plugin_program_all_programs" xml:space="preserve">
<value>All programs</value>
</data>
<data name="wox_plugin_program_suffixes" xml:space="preserve">
<value>File suffixes</value>
</data>
<data name="wox_plugin_program_reindex" xml:space="preserve">
<value>Reindex</value>
</data>
<data name="wox_plugin_program_indexing" xml:space="preserve">
<value>Indexing</value>
</data>
<data name="wox_plugin_program_index_start" xml:space="preserve">
<value>Index start menu</value>
</data>
<data name="wox_plugin_program_index_registry" xml:space="preserve">
<value>Index registry</value>
</data>
<data name="wox_plugin_program_suffixes_header" xml:space="preserve">
<value>Suffixes</value>
</data>
<data name="wox_plugin_program_max_depth_header" xml:space="preserve">
<value>Max depth</value>
</data>
<data name="wox_plugin_program_directory" xml:space="preserve">
<value>Directory:</value>
</data>
<data name="wox_plugin_program_browse" xml:space="preserve">
<value>Browse</value>
</data>
<data name="wox_plugin_program_file_suffixes" xml:space="preserve">
<value>File suffixes:</value>
</data>
<data name="wox_plugin_program_max_search_depth" xml:space="preserve">
<value>Maximum search depth (-1 is unlimited):</value>
</data>
<data name="wox_plugin_program_pls_select_program_source" xml:space="preserve">
<value>Please select a program source</value>
</data>
<data name="wox_plugin_program_delete_program_source" xml:space="preserve">
<value>Are you sure you want to delete the selected program sources?</value>
</data>
<data name="wox_plugin_program_update" xml:space="preserve">
<value>Update</value>
</data>
<data name="wox_plugin_program_only_index_tip" xml:space="preserve">
<value>Wox will only index files that end with the following suffixes:</value>
</data>
<data name="wox_plugin_program_split_by_tip" xml:space="preserve">
<value>(Each suffix should split by ';' )</value>
</data>
<data name="wox_plugin_program_update_file_suffixes" xml:space="preserve">
<value>Successfully updated file suffixes</value>
</data>
<data name="wox_plugin_program_suffixes_cannot_empty" xml:space="preserve">
<value>File suffixes can't be empty</value>
</data>
<data name="wox_plugin_program_run_as_different_user" xml:space="preserve">
<value>Run as different user</value>
</data>
<data name="wox_plugin_program_run_as_administrator" xml:space="preserve">
<value>Run as administrator (Ctrl+Shift+Enter)</value>
</data>
<data name="wox_plugin_program_open_containing_folder" xml:space="preserve">
<value>Open containing folder (Ctrl+Shift+E)</value>
</data>
<data name="wox_plugin_program_disable_program" xml:space="preserve">
<value>Disable this program from displaying</value>
</data>
<data name="wox_plugin_program_open_in_console" xml:space="preserve">
<value>Open path in console (Ctrl+Shift+C)</value>
</data>
<data name="wox_plugin_program_plugin_name" xml:space="preserve">
<value>Program</value>
</data>
<data name="wox_plugin_program_plugin_description" xml:space="preserve">
<value>Search programs in Wox</value>
</data>
<data name="wox_plugin_program_invalid_path" xml:space="preserve">
<value>Invalid Path</value>
</data>
<data name="wox_plugin_program_disable_dlgtitle_success" xml:space="preserve">
<value>Success</value>
</data>
<data name="wox_plugin_program_disable_dlgtitle_success_message" xml:space="preserve">
<value>Successfully disabled this program from displaying in your query</value>
</data>
<data name="powertoys_run_plugin_program_win32_application" xml:space="preserve">
<value>Application</value>
</data>
<data name="powertoys_run_plugin_program_internet_shortcut_application" xml:space="preserve">
<value>Internet shortcut application</value>
</data>
<data name="powertoys_run_plugin_program_web_application" xml:space="preserve">
<value>Web application</value>
</data>
<data name="powertoys_run_plugin_program_run_command" xml:space="preserve">
<value>Run command</value>
</data>
<data name="powertoys_run_plugin_program_packaged_application" xml:space="preserve">
<value>Packaged application</value>
</data>
<data name="powertoys_run_plugin_program_file_name" xml:space="preserve">
<value>Name</value>
</data>
<data name="powertoys_run_plugin_program_file_path" xml:space="preserve">
<value>Path</value>
</data>
</root>

View File

@@ -1,130 +0,0 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.Plugin.Program.Views.Commands
{
internal static class ProgramSettingDisplay
{
internal static List<ProgramSource> LoadProgramSources(this List<ProgramSource> programSources)
{
var list = new List<ProgramSource>();
programSources.ForEach(x => list
.Add(
new ProgramSource
{
Enabled = x.Enabled,
Location = x.Location,
Name = x.Name,
UniqueIdentifier = x.UniqueIdentifier,
}));
// Even though these are disabled, we still want to display them so users can enable later on
Main.Settings
.DisabledProgramSources
.Where(t1 => !Main.Settings
.ProgramSources // program sources added above already, so exclude
.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier))
.Select(x => x)
.ToList()
.ForEach(x => list
.Add(
new ProgramSource
{
Enabled = x.Enabled,
Location = x.Location,
Name = x.Name,
UniqueIdentifier = x.UniqueIdentifier,
}));
return list;
}
internal static void LoadAllApplications(this List<ProgramSource> list)
{
/*Main._win32s
.Where(t1 => !ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier))
.ToList()
.ForEach(t1 => ProgramSetting.ProgramSettingDisplayList
.Add(
new ProgramSource
{
Name = t1.Name,
Location = t1.ParentDirectory,
UniqueIdentifier = t1.UniqueIdentifier,
Enabled = t1.Enabled
}
));*/
}
internal static void SetProgramSourcesStatus(this List<ProgramSource> list, List<ProgramSource> selectedProgramSourcesToDisable, bool status)
{
ProgramSetting.ProgramSettingDisplayList
.Where(t1 => selectedProgramSourcesToDisable.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier && t1.Enabled != status))
.ToList()
.ForEach(t1 => t1.Enabled = status);
/*Main._win32s
.Where(t1 => selectedProgramSourcesToDisable.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier && t1.Enabled != status))
.ToList()
.ForEach(t1 => t1.Enabled = status);*/
}
internal static void StoreDisabledInSettings(this List<ProgramSource> list)
{
Main.Settings.ProgramSources
.Where(t1 => ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier && !x.Enabled))
.ToList()
.ForEach(t1 => t1.Enabled = false);
ProgramSetting.ProgramSettingDisplayList
.Where(t1 => !t1.Enabled
&& !Main.Settings.DisabledProgramSources.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier))
.ToList()
.ForEach(x => Main.Settings.DisabledProgramSources
.Add(
new DisabledProgramSource
{
Name = x.Name,
Location = x.Location,
UniqueIdentifier = x.UniqueIdentifier,
Enabled = false,
}));
}
internal static void RemoveDisabledFromSettings(this List<ProgramSource> list)
{
Main.Settings.ProgramSources
.Where(t1 => ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier && x.Enabled))
.ToList()
.ForEach(t1 => t1.Enabled = true);
Main.Settings.DisabledProgramSources
.Where(t1 => ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier && x.Enabled))
.ToList()
.ForEach(x => Main.Settings.DisabledProgramSources.Remove(x));
}
internal static bool IsReindexRequired(this List<ProgramSource> selectedItems)
{
if (selectedItems.Where(t1 => t1.Enabled).Any())
{
return true;
}
// ProgramSources holds list of user added directories,
// so when we enable/disable we need to reindex to show/not show the programs
// that are found in those directories.
if (selectedItems.Where(t1 => Main.Settings.ProgramSources.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier)).Any())
{
return true;
}
return false;
}
}
}

View File

@@ -1,136 +0,0 @@
<UserControl x:Class="Microsoft.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:Microsoft.Plugin.Program"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="600">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Stretch">
<StackPanel Orientation="Vertical" Width="205">
<CheckBox Name="StartMenuEnabled" Click="StartMenuEnabled_Click" Margin="5" Content="{DynamicResource wox_plugin_program_index_start}" />
<CheckBox Name="RegistryEnabled" Click="RegistryEnabled_Click" Margin="5" Content="{DynamicResource wox_plugin_program_index_registry}" />
</StackPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button Height="30" HorizontalAlignment="Right" Margin="10" Width="100" x:Name="btnLoadAllProgramSource" Click="BtnLoadAllProgramSource_OnClick" Content="{DynamicResource wox_plugin_program_all_programs}" />
<Button Height="30" HorizontalAlignment="Right" Margin="10" Width="100" x:Name="btnProgramSuffixes" Click="BtnProgramSuffixes_OnClick" Content="{DynamicResource wox_plugin_program_suffixes}" />
<Button Height="30" HorizontalAlignment="Right" Margin="10" Width="100" x:Name="btnReindex" Click="BtnReindex_Click" Content="{DynamicResource wox_plugin_program_reindex}" />
</StackPanel>
</StackPanel>
<ListView x:Name="programSourceView" Grid.Row="1" AllowDrop="True" SelectionMode="Extended" GridViewColumnHeader.Click="GridViewColumnHeaderClickedHandler"
PreviewMouseRightButtonUp="ProgramSourceView_PreviewMouseRightButtonUp"
DragEnter="ProgramSourceView_DragEnter"
Drop="ProgramSourceView_Drop" >
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<EventSetter Event="PreviewMouseUp" Handler="Row_OnClick"/>
</Style>
</ListView.ItemContainerStyle>
<ListView.View>
<GridView>
<GridViewColumn Header="Name" Width="150">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Enabled" Width="50">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Enabled}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="{DynamicResource wox_plugin_program_location}" Width="550">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Location, ConverterParameter=(null), Converter={program:LocationConverter}}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
<DockPanel Grid.Row="2">
<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 wox_plugin_program_indexing}" />
</StackPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button x:Name="btnProgramSourceStatus" Click="BtnProgramSourceStatus_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_program_disable}" />
<Button x:Name="btnAddProgramSource" Click="BtnAddProgramSource_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_program_add}"/>
<Button x:Name="btnEditProgramSource" Click="BtnEditProgramSource_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_program_edit}"/>
</StackPanel>
</DockPanel>
</Grid>
</UserControl>

View File

@@ -1,312 +0,0 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using Microsoft.Plugin.Program.Views.Commands;
using Wox.Plugin;
namespace Microsoft.Plugin.Program.Views
{
/// <summary>
/// Interaction logic for ProgramSetting.xaml
/// </summary>
public partial class ProgramSetting : UserControl
{
private PluginInitContext context;
private ProgramPluginSettings _settings;
private GridViewColumnHeader _lastHeaderClicked;
private ListSortDirection _lastDirection;
// We do not save all program sources to settings, so using
// this as temporary holder for displaying all loaded programs sources.
internal static List<ProgramSource> ProgramSettingDisplayList { get; set; }
public ProgramSetting(PluginInitContext context, ProgramPluginSettings settings)
{
this.context = context;
InitializeComponent();
Loaded += Setting_Loaded;
_settings = settings;
}
private void Setting_Loaded(object sender, RoutedEventArgs e)
{
ProgramSettingDisplayList = _settings.ProgramSources.LoadProgramSources();
programSourceView.ItemsSource = ProgramSettingDisplayList;
StartMenuEnabled.IsChecked = _settings.EnableStartMenuSource;
RegistryEnabled.IsChecked = _settings.EnableRegistrySource;
}
private void ReIndexing()
{
programSourceView.Items.Refresh();
Task.Run(() =>
{
Dispatcher.Invoke(() => { indexingPanel.Visibility = Visibility.Visible; });
Dispatcher.Invoke(() => { indexingPanel.Visibility = Visibility.Hidden; });
});
}
private void BtnAddProgramSource_OnClick(object sender, RoutedEventArgs e)
{
var add = new AddProgramSource(context, _settings);
if (add.ShowDialog() ?? false)
{
ReIndexing();
}
programSourceView.Items.Refresh();
}
private void DeleteProgramSources(List<ProgramSource> itemsToDelete)
{
itemsToDelete.ForEach(t1 => _settings.ProgramSources
.Remove(_settings.ProgramSources
.Where(x => x.UniqueIdentifier == t1.UniqueIdentifier)
.FirstOrDefault()));
itemsToDelete.ForEach(x => ProgramSettingDisplayList.Remove(x));
ReIndexing();
}
private void BtnEditProgramSource_OnClick(object sender, RoutedEventArgs e)
{
var selectedProgramSource = programSourceView.SelectedItem as ProgramSource;
if (selectedProgramSource != null)
{
var add = new AddProgramSource(selectedProgramSource, _settings);
if (add.ShowDialog() ?? false)
{
ReIndexing();
}
}
else
{
string msg = context.API.GetTranslation("wox_plugin_program_pls_select_program_source");
MessageBox.Show(msg);
}
}
private void BtnReindex_Click(object sender, RoutedEventArgs e)
{
ReIndexing();
}
private void BtnProgramSuffixes_OnClick(object sender, RoutedEventArgs e)
{
var p = new ProgramSuffixes(context, _settings);
if (p.ShowDialog() ?? false)
{
ReIndexing();
}
}
private void ProgramSourceView_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effects = DragDropEffects.Link;
}
else
{
e.Effects = DragDropEffects.None;
}
}
private void ProgramSourceView_Drop(object sender, DragEventArgs e)
{
var directories = (string[])e.Data.GetData(DataFormats.FileDrop);
var directoriesToAdd = new List<ProgramSource>();
if (directories != null && directories.Length > 0)
{
foreach (string directory in directories)
{
if (Directory.Exists(directory) && !ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == directory))
{
var source = new ProgramSource
{
Location = directory,
UniqueIdentifier = directory,
};
directoriesToAdd.Add(source);
}
}
if (directoriesToAdd.Count > 0)
{
directoriesToAdd.ForEach(x => _settings.ProgramSources.Add(x));
directoriesToAdd.ForEach(x => ProgramSettingDisplayList.Add(x));
programSourceView.Items.Refresh();
ReIndexing();
}
}
}
private void StartMenuEnabled_Click(object sender, RoutedEventArgs e)
{
_settings.EnableStartMenuSource = StartMenuEnabled.IsChecked ?? false;
ReIndexing();
}
private void RegistryEnabled_Click(object sender, RoutedEventArgs e)
{
_settings.EnableRegistrySource = RegistryEnabled.IsChecked ?? false;
ReIndexing();
}
private void BtnLoadAllProgramSource_OnClick(object sender, RoutedEventArgs e)
{
ProgramSettingDisplayList.LoadAllApplications();
programSourceView.Items.Refresh();
}
private void BtnProgramSourceStatus_OnClick(object sender, RoutedEventArgs e)
{
var selectedItems = programSourceView
.SelectedItems.Cast<ProgramSource>()
.ToList();
if (selectedItems.Count == 0)
{
string msg = context.API.GetTranslation("wox_plugin_program_pls_select_program_source");
MessageBox.Show(msg);
return;
}
if (selectedItems
.Where(t1 => !_settings
.ProgramSources
.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier))
.Any())
{
var msg = string.Format(CultureInfo.CurrentCulture, context.API.GetTranslation("wox_plugin_program_delete_program_source"));
if (MessageBox.Show(msg, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
{
return;
}
DeleteProgramSources(selectedItems);
}
else if (IsSelectedRowStatusEnabledMoreOrEqualThanDisabled(selectedItems))
{
ProgramSettingDisplayList.SetProgramSourcesStatus(selectedItems, false);
ProgramSettingDisplayList.StoreDisabledInSettings();
}
else
{
ProgramSettingDisplayList.SetProgramSourcesStatus(selectedItems, true);
ProgramSettingDisplayList.RemoveDisabledFromSettings();
}
if (selectedItems.IsReindexRequired())
{
ReIndexing();
}
programSourceView.SelectedItems.Clear();
programSourceView.Items.Refresh();
}
private void ProgramSourceView_PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
programSourceView.SelectedItems.Clear();
}
private void GridViewColumnHeaderClickedHandler(object sender, RoutedEventArgs e)
{
var headerClicked = e.OriginalSource as GridViewColumnHeader;
ListSortDirection direction;
if (headerClicked != null)
{
if (headerClicked.Role != GridViewColumnHeaderRole.Padding)
{
if (headerClicked != _lastHeaderClicked)
{
direction = ListSortDirection.Ascending;
}
else
{
if (_lastDirection == ListSortDirection.Ascending)
{
direction = ListSortDirection.Descending;
}
else
{
direction = ListSortDirection.Ascending;
}
}
var columnBinding = headerClicked.Column.DisplayMemberBinding as Binding;
var sortBy = columnBinding?.Path.Path ?? headerClicked.Column.Header as string;
Sort(sortBy, direction);
_lastHeaderClicked = headerClicked;
_lastDirection = direction;
}
}
}
private void Sort(string sortBy, ListSortDirection direction)
{
var dataView = CollectionViewSource.GetDefaultView(programSourceView.ItemsSource);
dataView.SortDescriptions.Clear();
SortDescription sd = new SortDescription(sortBy, direction);
dataView.SortDescriptions.Add(sd);
dataView.Refresh();
}
private static bool IsSelectedRowStatusEnabledMoreOrEqualThanDisabled(List<ProgramSource> selectedItems)
{
return selectedItems.Where(x => x.Enabled).Count() >= selectedItems.Where(x => !x.Enabled).Count();
}
private void Row_OnClick(object sender, RoutedEventArgs e)
{
var selectedItems = programSourceView
.SelectedItems.Cast<ProgramSource>()
.ToList();
if (selectedItems
.Where(t1 => !_settings
.ProgramSources
.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier))
.Any())
{
btnProgramSourceStatus.Content = context.API.GetTranslation("wox_plugin_program_delete");
return;
}
if (IsSelectedRowStatusEnabledMoreOrEqualThanDisabled(selectedItems))
{
btnProgramSourceStatus.Content = "Disable";
}
else
{
btnProgramSourceStatus.Content = "Enable";
}
}
}
}