Expose index file suffixes config [WIP]

This commit is contained in:
qianlifeng 2014-08-13 23:16:45 +08:00
parent eee76222bd
commit 5d1006f05b
9 changed files with 108 additions and 20 deletions

View File

@ -67,6 +67,9 @@ namespace Wox.Infrastructure.Storage.UserSettings
[JsonProperty]
public double Opacity { get; set; }
[JsonProperty]
public List<string> ProgramSuffixes { get; set; }
[JsonProperty]
public OpacityMode OpacityMode { get; set; }
@ -162,6 +165,16 @@ namespace Wox.Infrastructure.Storage.UserSettings
{
storage.CustomizedPluginConfigs = new List<CustomizedPluginConfig>();
}
if (storage.ProgramSuffixes == null || storage.ProgramSuffixes.Count == 0)
{
storage.ProgramSuffixes = new List<string>()
{
"lnk",
"exe",
"appref-ms",
"bat"
};
}
}
}

View File

@ -16,9 +16,10 @@
<RowDefinition Height="*"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<DockPanel Grid.Row="0">
<Button Height="30" HorizontalAlignment="Right" x:Name="btnReindex" Width="100" Click="btnReindex_Click">Re-Index</Button>
</DockPanel>
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Height="30" HorizontalAlignment="Right" x:Name="btnProgramSuffixes" Width="130" Click="BtnProgramSuffixes_OnClick">Index File Type</Button>
<Button Height="30" HorizontalAlignment="Right" Margin="10 0 0 0" x:Name="btnReindex" Width="100" Click="btnReindex_Click">Re-Index</Button>
</StackPanel>
<ListView x:Name="programSourceView" Grid.Row="1">
<ListView.View>
<GridView>

View File

@ -95,5 +95,12 @@ namespace Wox.Plugin.SystemPlugins.Program
{
ReIndexing();
}
private void BtnProgramSuffixes_OnClick(object sender, RoutedEventArgs e)
{
ProgramSuffixes p = new ProgramSuffixes();
p.ShowDialog();
}
}
}

View File

@ -8,19 +8,12 @@ namespace Wox.Plugin.SystemPlugins.Program.ProgramSources
public class FileSystemProgramSource : AbstractProgramSource
{
public string BaseDirectory;
public List<string> Suffixes = new List<string>() { "lnk", "exe", "appref-ms" };
public FileSystemProgramSource(string baseDirectory)
{
BaseDirectory = baseDirectory;
}
public FileSystemProgramSource(string baseDirectory, List<string> suffixes)
: this(baseDirectory)
{
Suffixes = suffixes;
}
public FileSystemProgramSource(ProgramSource source)
: this(source.Location)
{
@ -41,7 +34,7 @@ namespace Wox.Plugin.SystemPlugins.Program.ProgramSources
{
foreach (string file in Directory.GetFiles(path))
{
if (Suffixes.Any(o => file.EndsWith("." + o)))
if (UserSettingStorage.Instance.ProgramSuffixes.Any(o => file.EndsWith("." + o)))
{
Program p = CreateEntry(file);
list.Add(p);

View File

@ -0,0 +1,32 @@
<Window x:Class="Wox.Plugin.SystemPlugins.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"
d:DesignHeight="300" d:DesignWidth="300">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<ListView x:Name="lvProgramSuffixes" Grid.Row="0" ItemsSource="{Binding UserSettingStorage.Instance.ProgramSuffixes}">
<ListView.View>
<GridView>
<GridViewColumn Header="Suffixes" Width="200">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
<StackPanel Grid.Row="1" HorizontalAlignment="Right" Orientation="Horizontal">
<Button x:Name="btnDelete" Click="btnDelete_OnClick" Width="100" Margin="10" Content="Delete"/>
<Button x:Name="btnEdit" Click="btnEdit_OnClick" Width="100" Margin="10" Content="Edit"/>
<Button x:Name="btnAdd" Click="btnAdd_OnClick" Width="100" Margin="10" Content="Add"/>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Wox.Plugin.SystemPlugins.Program
{
/// <summary>
/// ProgramSuffixes.xaml 的交互逻辑
/// </summary>
public partial class ProgramSuffixes
{
public ProgramSuffixes()
{
InitializeComponent();
}
private void btnDelete_OnClick(object sender, RoutedEventArgs e)
{
}
private void btnEdit_OnClick(object sender, RoutedEventArgs e)
{
}
private void btnAdd_OnClick(object sender, RoutedEventArgs e)
{
}
}
}

View File

@ -131,8 +131,7 @@ namespace Wox.Plugin.SystemPlugins
var dlg = new Microsoft.Win32.OpenFileDialog
{
DefaultExt = ".png",
Filter =
"JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif"
Filter ="Image files (*.jpg, *.jpeg, *.gif, *.png, *.bmp) | *.jpg; *.jpeg; *.gif; *.png, *.bmp"
};
bool? result = dlg.ShowDialog();

View File

@ -76,6 +76,9 @@
<Compile Include="Calculator.cs" />
<Compile Include="Program\ProgramSources\FileSystemProgramSource.cs" />
<Compile Include="Program\ProgramSources\UserStartMenuProgramSource.cs" />
<Compile Include="Program\ProgramSuffixes.xaml.cs">
<DependentUpon>ProgramSuffixes.xaml</DependentUpon>
</Compile>
<Compile Include="SuggestionSources\Baidu.cs" />
<Compile Include="SuggestionSources\SuggestionSourceFactory.cs" />
<Compile Include="Sys\SysSettings.xaml.cs">
@ -122,6 +125,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Program\ProgramSuffixes.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Sys\SysSettings.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -576,13 +576,7 @@ namespace Wox
{
if (o.AutoAjustScore) o.Score += UserSelectedRecordStorage.Instance.GetSelectedCount(o);
});
lock (locker)
{
waitShowResultList.AddRange(list);
}
List<Result> l = waitShowResultList.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == lastQuery).ToList();
waitShowResultList.Clear();
List<Result> l = list.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == lastQuery).ToList();
Dispatcher.Invoke(new Action(() => resultCtrl.AddResults(l)));
}
}