Skip to content

Commit

Permalink
支持 配置字符串列表添加项目
Browse files Browse the repository at this point in the history
支持 修改Everything索引的文件类型
优化 修改搜索框鼠标悬浮时按钮样式
优化 项目图标获取
  • Loading branch information
MakesYT committed May 2, 2024
1 parent 681018c commit ca19965
Show file tree
Hide file tree
Showing 13 changed files with 228 additions and 135 deletions.
1 change: 1 addition & 0 deletions Core.Window/AppTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ internal static void DelNullFile(ConcurrentDictionary<string, SearchViewItem> co
case FileType.PDF文档:
case FileType.PPT文档:
{

if (!File.Exists(searchViewItem.OnlyKey))
{
toRemove.Add(key);
Expand Down
4 changes: 2 additions & 2 deletions Core.Window/Everything/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void main(List<string> Items)
public static void amd32(List<string> Items)
{
Everything32.Everything_Reset();
Everything32.Everything_SetSearchW("*.docx|*.doc|*.xls|*.xlsx|*.pdf|*.ppt|*.pptx");
Everything32.Everything_SetSearchW(String.Join("|",ConfigManger.Config!.everythingSearchExtensions));
Everything32.Everything_SetMatchCase(true);
Everything32.Everything_QueryW(true);
const int bufsize = 260;
Expand All @@ -48,7 +48,7 @@ public static void amd32(List<string> Items)
public static void amd64(List<string> Items)
{
Everything64.Everything_Reset();
Everything64.Everything_SetSearchW("*.docx|*.doc|*.xls|*.xlsx|*.pdf|*.ppt|*.pptx");
Everything64.Everything_SetSearchW(String.Join("|",ConfigManger.Config!.everythingSearchExtensions));
Everything64.Everything_SetMatchCase(true);
Everything64.Everything_QueryW(true);
const int bufsize = 260;
Expand Down
4 changes: 2 additions & 2 deletions Core.Window/IconTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,11 @@ internal static async Task GetIconAsync(string path, SearchViewItem item)

await Task.Run(() =>
{
retry:
var iconBase = GetIconBase(path, cacheKey);
if (iconBase == null)
{
goto retry;
return;
}
var clone = ((Bitmap)iconBase.ToBitmap()).ToAvaloniaBitmap();
Expand Down
4 changes: 2 additions & 2 deletions Core.Window/SearchItemTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ public void OpenFolder(SearchViewItem? searchViewItem)
{
WeakReferenceMessenger.Default.Send("a", "SearchWindowClose");
var item = (SearchViewItem)searchViewItem;
Log.Debug("打开指定内容文件夹" + item.OnlyKey);
Shell32.ShellExecute(IntPtr.Zero, "open", "explorer.exe", "/select," + item.OnlyKey, "",
Log.Debug($"打开指定内容文件夹{item.OnlyKey}_{item.StartDirectory}");
Shell32.ShellExecute(IntPtr.Zero, "open", "explorer.exe", "/select," + item.OnlyKey, item.StartDirectory,
ShowWindowCommand.SW_SHOW);
switch (item.FileType)
Expand Down
85 changes: 49 additions & 36 deletions Core/SDKs/Services/Config/KitopiaConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,60 @@
using PluginCore;
using PluginCore.Attribute;
using PluginCore.Config;
// ReSharper disable InconsistentNaming

namespace Core.SDKs.Services.Config;

[ConfigName("Kitopia主配置文件")]
public class KitopiaConfig : ConfigBase
{
private static ILog log = LogManager.GetLogger("KitopiaConfig");


[ConfigField("截图直接复制到剪贴板","截图直接复制到剪贴板,不显示工具栏", 0xE61C,ConfigFieldType.布尔 )]
public bool 截图直接复制到剪贴板 = true;

public List<string> alwayShows = new();

[ConfigFieldCategory("基本")]
[ConfigField("自动启动","可能被杀毒软件阻止", 0xE61C,ConfigFieldType.布尔 )]
public bool autoStart = true;

[ConfigField("自动启动Everything","在Everything未启动时自动启动", 0xE61C,ConfigFieldType.布尔 )]
public bool autoStartEverything = true;

[ConfigField("允许程序读取剪贴板","自动读取剪贴板路径和剪贴板图像保存依赖于此权限", 0xF2D7,ConfigFieldType.布尔 )]
public bool canReadClipboard = true;
[ConfigField<ThemeEnum>("主题选择","跟随系统,深色还是浅色?", 0xf33c)]
public ThemeEnum themeChoice = ThemeEnum.跟随系统;
public List<PluginInfo> EnabledPluginInfos = new();


[ConfigFieldCategory("搜索框")]
[ConfigField("搜索框快捷键","显示搜索框快捷键", 0xF4B8,ConfigFieldType.快捷键 )]
public HotKeyModel searchHotKey = new()
{
MainName = "Kitopia", Name = "显示搜索框", IsUsable = true, IsSelectCtrl = false, IsSelectAlt = true,
IsSelectWin = false,
IsSelectShift = false, SelectKey = EKey.空格,
};
[ConfigField("允许程序调用Everything索引文档","索引文档依赖于此功能", 0xF3AE,ConfigFieldType.布尔 )]
public bool useEverything = true;

public List<string> customCollections = new();
[ConfigField("最大历史记录","最大历史记录数", 0xF2D7,ConfigFieldType.整数列表 ,null,10,1,1 )]
public int maxHistory = 6;
[ConfigField("输入平滑延时","在指定时间内不处理数据以减轻性能消耗", 0xED9B,ConfigFieldType.整数滑块 ,null,1000,50,10)]
public int inputSmoothingMilliseconds = 50;
public List<PluginInfo> EnabledPluginInfos = new();

public List<string> errorLnk = new();
public string everythingOnlyKey = "";

[ConfigField("允许程序调用Everything索引的文件类型","设置Everything检索的文件类型,注意已索引的项目仅当重启软件后消失", 0xf8cb,ConfigFieldType.字符串列表支持添加 )]
public ObservableCollection<string> everythingSearchExtensions = ["*.docx","*.doc","*.xls","*.xlsx","*.pdf","*.ppt","*.pptx"];

[ConfigField("忽略项","忽略指定的文件或文件夹", 0xF2D7,ConfigFieldType.字符串列表 )]
public ObservableCollection<string> ignoreItems = new();

[ConfigField("输入平滑延时","在指定时间内不处理数据以减轻性能消耗", 0xED9B,ConfigFieldType.整数滑块 ,null,1000,50,10)]
public int inputSmoothingMilliseconds = 50;

public Dictionary<string, int> lastOpens = new();

public List<string> errorLnk = new();
public string everythingOnlyKey = "";



[ConfigField("最大历史记录","最大历史记录数", 0xF2D7,ConfigFieldType.整数列表 ,null,10,1,1 )]
public int maxHistory = 6;

[ConfigFieldCategory("鼠标快捷操作")]
[ConfigField<MouseHookType>("鼠标快捷键","修改鼠标快捷菜单激活按键", 0xF4B8 )]
public MouseHookType mouseKey = MouseHookType.鼠标侧键2;

[ConfigField("鼠标快捷键间隔","按下按键指定时间后触发", 0xED9B,ConfigFieldType.整数滑块 ,null,3000,100,50)]
public int mouseKeyInverval = 1000;

public List<string> mouseQuickItems = new();


[ConfigFieldCategory("截图")]
[ConfigField("截图快捷键","修改截图快捷键", 0xF4B8,ConfigFieldType.快捷键 )]
public HotKeyModel screenShotHotKey = new()
Expand All @@ -62,15 +70,20 @@ public class KitopiaConfig : ConfigBase
IsSelectShift = false, SelectKey = EKey.Q,

};
[ConfigField("截图直接复制到剪贴板","截图直接复制到剪贴板,不显示工具栏", 0xE61C,ConfigFieldType.布尔 )]
public bool 截图直接复制到剪贴板 = true;
[ConfigFieldCategory("鼠标快捷操作")]
[ConfigField<MouseHookType>("鼠标快捷键","修改鼠标快捷菜单激活按键", 0xF4B8 )]
public MouseHookType mouseKey = MouseHookType.鼠标侧键2;
[ConfigField("鼠标快捷键间隔","按下按键指定时间后触发", 0xED9B,ConfigFieldType.整数滑块 ,null,3000,100,50)]
public int mouseKeyInverval = 1000;
public List<string> mouseQuickItems = new();




[ConfigFieldCategory("搜索框")]
[ConfigField("搜索框快捷键","显示搜索框快捷键", 0xF4B8,ConfigFieldType.快捷键 )]
public HotKeyModel searchHotKey = new()
{
MainName = "Kitopia", Name = "显示搜索框", IsUsable = true, IsSelectCtrl = false, IsSelectAlt = true,
IsSelectWin = false,
IsSelectShift = false, SelectKey = EKey.空格,
};

[ConfigField<ThemeEnum>("主题选择","跟随系统,深色还是浅色?", 0xf33c)]
public ThemeEnum themeChoice = ThemeEnum.跟随系统;

[ConfigField("允许程序调用Everything索引文档","索引文档依赖于此功能", 0xF3AE,ConfigFieldType.布尔 )]
public bool useEverything = true;
}
8 changes: 2 additions & 6 deletions KitopiaAvalonia/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
using Core.ViewModel.Pages.customScenario;
using Core.ViewModel.Pages.plugin;
using Core.ViewModel.TaskEditor;

using HotAvalonia;
using Kitopia.Services;
using KitopiaAvalonia.Pages;
using KitopiaAvalonia.Services;
Expand All @@ -45,6 +45,7 @@ public partial class App : Application

public override void Initialize()
{
//this.EnableHotReload();
AvaloniaXamlLoader.Load(this);
}

Expand Down Expand Up @@ -129,9 +130,4 @@ private static IServiceProvider ConfigureServices()

return services.BuildServiceProvider();
}





}
125 changes: 71 additions & 54 deletions KitopiaAvalonia/Controls/ListShow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:system="clr-namespace:System;assembly=System.Runtime"
xmlns:controls1="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia">
<Design.PreviewWith>
<controls:ListShow Width="200">
<controls:ListShow Width="200" Height="200">
<controls:ListShow.ItemsSource>
123
</controls:ListShow.ItemsSource>
Expand All @@ -15,67 +15,84 @@
<!-- Set Defaults -->
<Setter Property="Template">
<ControlTemplate>
<ListBox
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
<ItemsControl>
<ListBox
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ItemsSource="{TemplateBinding ItemsSource}">
<ListBox.ItemContainerTheme>
<ControlTheme TargetType="ListBoxItem">
<Setter Property="Template">
<ControlTemplate>
<ContentPresenter Name="PART_ContentPresenter"
Width="{Binding $parent.Width, Mode=OneWay}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
CornerRadius="{TemplateBinding CornerRadius}" />
</ControlTemplate>

</Setter>
</ControlTheme>
</ListBox.ItemContainerTheme>

ItemsSource="{TemplateBinding ItemsSource}">
<ListBox.ItemContainerTheme>
<ControlTheme TargetType="ListBoxItem">
<Setter Property="Template">
<ControlTemplate>
<ContentPresenter Name="PART_ContentPresenter"
Width="{Binding $parent.Width, Mode=OneWay}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
CornerRadius="{TemplateBinding CornerRadius}" />
</ControlTemplate>
<ListBox.ItemTemplate>
<DataTemplate>
<Button Width="{Binding $parent.Bounds.Width, Mode=OneWay}"
HorizontalContentAlignment="Stretch">
<DockPanel Margin="15,0,0,0">
<TextBlock VerticalAlignment="Center" Text="{ReflectionBinding}" />
<Button Name="Button" Width="24" Height="24"
ToolTip.Tip="删除"
HorizontalAlignment="Right"
Command="{Binding $parent[controls:ListShow].DelCommand}"
CommandParameter="{ReflectionBinding}"
VerticalContentAlignment="Center" HorizontalContentAlignment="Center">
<controls1:FontIcon VerticalAlignment="Center" HorizontalAlignment="Center"
Margin="0,2,0,0"
Width="24"
Height="24"
FontFamily="{StaticResource FluentFont}"
Glyph="&#xf36a;"
FontSize="24" />
<Button.Styles>

</Setter>
</ControlTheme>
</ListBox.ItemContainerTheme>
<Style
Selector="Button#Button:pointerover /template/ controls1|FABorder#Root">

<ListBox.ItemTemplate>
<DataTemplate>
<Button Width="{Binding $parent.Bounds.Width, Mode=OneWay}"
HorizontalContentAlignment="Stretch">
<DockPanel Margin="15,0,0,0">
<TextBlock VerticalAlignment="Center" Text="{ReflectionBinding}" />
<Button Name="Button" Width="24" Height="24"
ToolTip.Tip="删除"
HorizontalAlignment="Right"
Command="{Binding $parent[controls:ListShow].DelCommand}"
CommandParameter="{ReflectionBinding}"
VerticalContentAlignment="Center" HorizontalContentAlignment="Center">
<controls1:FontIcon VerticalAlignment="Center" HorizontalAlignment="Center"
Margin="0,2,0,0"
Width="24"
Height="24"
FontFamily="{StaticResource FluentFont}" Glyph="&#xf36a;"
FontSize="24" />
<Button.Styles>
<Setter Property="Background">
<SolidColorBrush
Color="{DynamicResource TextFillColorSecondary}"
Opacity="0.2" />
</Setter>
</Style>

<Style Selector="Button#Button:pointerover /template/ controls1|FABorder#Root">

<Setter Property="Background">
<SolidColorBrush Color="{DynamicResource TextFillColorSecondary}" Opacity="0.2"/>
</Setter>
</Style>
</Button.Styles>
</Button>
</DockPanel>
</Button>

</Button.Styles>
</Button>
</DockPanel>
</Button>
</DataTemplate>
</ListBox.ItemTemplate>

</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Grid Margin="0,5,0,0" IsVisible="{TemplateBinding WithAdd}" ColumnDefinitions="*,Auto">
<Button Command="{TemplateBinding AddCommand}"
CommandParameter="{TemplateBinding TextValue}"
Grid.Column="1" Height="36" Width="36">
<controls1:FontIcon FontFamily="{StaticResource FluentFont}" Foreground="GreenYellow"
Glyph="&#xf107;" />
</Button>
<DockPanel Grid.Column="0" Margin="0" >
<TextBox
Text="{Binding TextValue,Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" />
</DockPanel>
</Grid>
</ItemsControl>

</ListBox>
</ControlTemplate>
</Setter>
</Style>
Expand Down
Loading

0 comments on commit ca19965

Please sign in to comment.