mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-10 05:06:36 +02:00
Add dynamic Delete to the Enable/Disable button
This commit is contained in:
@@ -21,7 +21,6 @@
|
|||||||
<system:String x:Key="wox_plugin_program_max_search_depth">Maximale Suchtiefe (-1 ist unlimitiert):</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_pls_select_program_source">Bitte wähle eine Programmquelle</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_delete_program_source">Willst du wirklich {0} löschen?</system:String>
|
|
||||||
|
|
||||||
<system:String x:Key="wox_plugin_program_update">Aktualisieren</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_only_index_tip">Wox indexiert nur Datien mit folgenden Endungen:</system:String>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<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_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_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 {0}?</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_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_only_index_tip">Wox will only index files that end with the following suffixes:</system:String>
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
<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_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_pls_select_program_source">Musisz wybrać katalog programu</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_delete_program_source">Czy jesteś pewien że chcesz usunąć {0}?</system:String>
|
|
||||||
|
|
||||||
<system:String x:Key="wox_plugin_program_update">Aktualizuj</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_only_index_tip">Wox będzie indeksował tylko te pliki z podanymi rozszerzeniami:</system:String>
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
<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_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_pls_select_program_source">İşlem yapmak istediğiniz klasörü seçin.</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_delete_program_source">{0} klasörünü silmek istediğinize emin misiniz?</system:String>
|
|
||||||
|
|
||||||
<system:String x:Key="wox_plugin_program_update">Güncelle</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_only_index_tip">Wox yalnızca aşağıdaki uzantılara sahip dosyaları indeksleyecektir:</system:String>
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
<system:String x:Key="wox_plugin_program_max_search_depth">最大搜索深度(-1是无限的):</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_pls_select_program_source">请先选择一项</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_delete_program_source">你确定要删除{0}吗?</system:String>
|
|
||||||
|
|
||||||
<system:String x:Key="wox_plugin_program_update">更新</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_only_index_tip">Wox仅索引下列后缀的文件:</system:String>
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
<system:String x:Key="wox_plugin_program_max_search_depth">最大搜尋深度(-1是無限的):</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_pls_select_program_source">請先選擇一項</system:String>
|
||||||
<system:String x:Key="wox_plugin_program_delete_program_source">你確定要刪除{0}嗎?</system:String>
|
|
||||||
|
|
||||||
<system:String x:Key="wox_plugin_program_update">更新</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_only_index_tip">Wox 僅索引下列副檔名的檔案:</system:String>
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ namespace Wox.Plugin.Program.Views.Commands
|
|||||||
&& selectedItems.Where(t1 => t1.Enabled && !Main._win32s.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier)).Count() > 0)
|
&& selectedItems.Where(t1 => t1.Enabled && !Main._win32s.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier)).Count() > 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Program Sources holds list of user added directories,
|
// ProgramSources holds list of user added directories,
|
||||||
// so when we enable/disable we need to reindex to show/not show the programs
|
// so when we enable/disable we need to reindex to show/not show the programs
|
||||||
// that are found in those directories.
|
// that are found in those directories.
|
||||||
if (selectedItems.Where(t1 => Main._settings.ProgramSources.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier)).Count() > 0)
|
if (selectedItems.Where(t1 => Main._settings.ProgramSources.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier)).Count() > 0)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
Drop="programSourceView_Drop" >
|
Drop="programSourceView_Drop" >
|
||||||
<ListView.ItemContainerStyle>
|
<ListView.ItemContainerStyle>
|
||||||
<Style TargetType="ListViewItem">
|
<Style TargetType="ListViewItem">
|
||||||
<EventSetter Event="PreviewMouseUp" Handler="Row_Click"/>
|
<EventSetter Event="PreviewMouseUp" Handler="Row_OnClick"/>
|
||||||
</Style>
|
</Style>
|
||||||
</ListView.ItemContainerStyle>
|
</ListView.ItemContainerStyle>
|
||||||
<ListView.View>
|
<ListView.View>
|
||||||
@@ -63,7 +63,6 @@
|
|||||||
<TextBlock Margin="10 0 0 0" Height="20" HorizontalAlignment="Center" Text="{DynamicResource wox_plugin_program_indexing}" />
|
<TextBlock Margin="10 0 0 0" Height="20" HorizontalAlignment="Center" Text="{DynamicResource wox_plugin_program_indexing}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
|
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
|
||||||
<Button x:Name="btnDeleteProgramSource" Click="btnDeleteProgramSource_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_program_delete}"/>
|
|
||||||
<Button x:Name="btnEditProgramSource" Click="btnEditProgramSource_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_program_edit}"/>
|
<Button x:Name="btnEditProgramSource" Click="btnEditProgramSource_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_program_edit}"/>
|
||||||
<Button x:Name="btnAddProgramSource" Click="btnAddProgramSource_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_program_add}"/>
|
<Button x:Name="btnAddProgramSource" Click="btnAddProgramSource_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_program_add}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@@ -64,24 +64,12 @@ namespace Wox.Plugin.Program.Views
|
|||||||
programSourceView.Items.Refresh();
|
programSourceView.Items.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnDeleteProgramSource_OnClick(object sender, RoutedEventArgs e)
|
private void DeleteProgramSources(List<ProgramSource> itemsToDelete)
|
||||||
{
|
{
|
||||||
var selectedProgramSource = programSourceView.SelectedItem as Settings.ProgramSource;
|
itemsToDelete.ForEach(x => _settings.ProgramSources.Remove(x));
|
||||||
if (selectedProgramSource != null)
|
itemsToDelete.ForEach(x => ProgramSettingDisplayList.Remove(x));
|
||||||
{
|
ReIndexing();
|
||||||
string msg = string.Format(context.API.GetTranslation("wox_plugin_program_delete_program_source"), selectedProgramSource.Location);
|
|
||||||
|
|
||||||
if (MessageBox.Show(msg, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
|
||||||
{
|
|
||||||
_settings.ProgramSources.Remove(selectedProgramSource);
|
|
||||||
ReIndexing();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string msg = context.API.GetTranslation("wox_plugin_program_pls_select_program_source");
|
|
||||||
MessageBox.Show(msg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnEditProgramSource_OnClick(object sender, RoutedEventArgs e)
|
private void btnEditProgramSource_OnClick(object sender, RoutedEventArgs e)
|
||||||
@@ -171,7 +159,29 @@ namespace Wox.Plugin.Program.Views
|
|||||||
.SelectedItems.Cast<ProgramSource>()
|
.SelectedItems.Cast<ProgramSource>()
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
if (IsSelectedRowStatusEnabledMoreOrEqualThanDisabled())
|
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))
|
||||||
|
.Count() == 0)
|
||||||
|
{
|
||||||
|
var msg = string.Format(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.SetProgramSourcesStatus(selectedItems, false);
|
||||||
|
|
||||||
@@ -243,18 +253,28 @@ namespace Wox.Plugin.Program.Views
|
|||||||
dataView.Refresh();
|
dataView.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsSelectedRowStatusEnabledMoreOrEqualThanDisabled()
|
private 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
|
var selectedItems = programSourceView
|
||||||
.SelectedItems.Cast<ProgramSource>()
|
.SelectedItems.Cast<ProgramSource>()
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
return selectedItems.Where(x => x.Enabled).Count() >= selectedItems.Where(x => !x.Enabled).Count();
|
if (selectedItems
|
||||||
}
|
.Where(t1 => !_settings
|
||||||
|
.ProgramSources
|
||||||
|
.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier))
|
||||||
|
.Count() == 0)
|
||||||
|
{
|
||||||
|
btnProgramSourceStatus.Content = context.API.GetTranslation("wox_plugin_program_delete");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
private void Row_Click(object sender, RoutedEventArgs e)
|
if (IsSelectedRowStatusEnabledMoreOrEqualThanDisabled(selectedItems))
|
||||||
{
|
|
||||||
if (IsSelectedRowStatusEnabledMoreOrEqualThanDisabled())
|
|
||||||
{
|
{
|
||||||
btnProgramSourceStatus.Content = "Disable";
|
btnProgramSourceStatus.Content = "Disable";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user