🐔 优化everything搜索

This commit is contained in:
BookerLiu
2023-04-14 21:30:15 +08:00
parent 85ad6a6bc4
commit dd41635199
7 changed files with 71 additions and 112 deletions

View File

@@ -77,6 +77,6 @@
/// <summary> /// <summary>
/// 控制主界面热键按下规定时间内只执行一次show hide /// 控制主界面热键按下规定时间内只执行一次show hide
/// </summary> /// </summary>
public static volatile int MAIN_HOT_KEY_TIME = 500; public static volatile int MAIN_HOT_KEY_TIME = 300;
} }
} }

View File

@@ -95,18 +95,16 @@
</ListBox.Background> </ListBox.Background>
<ListBox.Resources> <ListBox.Resources>
<!--<ContextMenu x:Key="IconDialog" Width="200"> <ContextMenu x:Key="IconDialog" Width="200">
<MenuItem Header="管理员方式运行" Click="IconAdminStart" Tag="{Binding}"/> <MenuItem Header="管理员方式运行" Click="IconAdminStart" Tag="{Binding}"/>
<MenuItem Header="打开文件所在位置" Click="ShowInExplore" Tag="{Binding}"/> <MenuItem Header="打开文件所在位置" Click="ShowInExplore" Tag="{Binding}"/>
<MenuItem Header="添加URL项目" Click="AddUrlIcon"/>
<MenuItem Header="添加系统项目" Click="AddSystemIcon"/>
<MenuItem Header="资源管理器菜单" Click="SystemContextMenu" Tag="{Binding}"/> <MenuItem Header="资源管理器菜单" Click="SystemContextMenu" Tag="{Binding}"/>
<MenuItem Header="属性" Click="PropertyConfig" Tag="{Binding}"/> </ContextMenu>
</ContextMenu>-->
</ListBox.Resources> </ListBox.Resources>
<ListBox.ItemContainerStyle> <ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource SearchListBoxItemStyle}"> <Style TargetType="ListBoxItem" BasedOn="{StaticResource SearchListBoxItemStyle}">
<Setter Property="ContextMenu" Value="{StaticResource IconDialog}"/>
</Style> </Style>
</ListBox.ItemContainerStyle> </ListBox.ItemContainerStyle>

View File

@@ -1,4 +1,5 @@
using GeekDesk.Constant; using GeekDesk.Constant;
using GeekDesk.Control.Windows;
using GeekDesk.Plugins.EveryThing; using GeekDesk.Plugins.EveryThing;
using GeekDesk.Util; using GeekDesk.Util;
using GeekDesk.ViewModel; using GeekDesk.ViewModel;
@@ -278,5 +279,54 @@ namespace GeekDesk.Control.Other
} }
} }
/// <summary>
/// 管理员方式启动
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void IconAdminStart(object sender, RoutedEventArgs e)
{
IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
ProcessUtil.StartIconApp(icon, IconStartType.ADMIN_STARTUP);
}
/// <summary>
/// 打开文件所在位置
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ShowInExplore(object sender, RoutedEventArgs e)
{
IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
ProcessUtil.StartIconApp(icon, IconStartType.SHOW_IN_EXPLORE);
}
private void SystemContextMenu(object sender, RoutedEventArgs e)
{
IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
DirectoryInfo[] folders = new DirectoryInfo[1];
folders[0] = new DirectoryInfo(icon.Path);
ShellContextMenu scm = new ShellContextMenu();
System.Drawing.Point p = System.Windows.Forms.Cursor.Position;
p.X -= 80;
p.Y -= 80;
scm.ShowContextMenu(folders, p);
}
} }
} }

View File

@@ -133,7 +133,10 @@ namespace GeekDesk
RunTimeStatus.EVERYTHING_NEW_SEARCH = true; RunTimeStatus.EVERYTHING_NEW_SEARCH = true;
//显示搜索结果列表 //显示搜索结果列表
RightCard.VisibilitySearchCard(Visibility.Visible); RightCard.VisibilitySearchCard(Visibility.Visible);
//暂时隐藏条目信息
SearchResContainer.Visibility = Visibility.Collapsed; SearchResContainer.Visibility = Visibility.Collapsed;
//显示加载条
RightCard.Loading_RightCard.Visibility = Visibility.Visible;
object obj = RightCard.VerticalCard.Content; object obj = RightCard.VerticalCard.Content;
if (obj != null) if (obj != null)
{ {
@@ -144,6 +147,8 @@ namespace GeekDesk
} }
} else } else
{ {
//隐藏条目信息
SearchResContainer.Visibility = Visibility.Collapsed;
//清空查询结果 //清空查询结果
object obj = RightCard.VerticalCard.Content; object obj = RightCard.VerticalCard.Content;
if (obj != null) if (obj != null)
@@ -210,109 +215,13 @@ namespace GeekDesk
} }
SearchResControl control = new SearchResControl(resList); SearchResControl control = new SearchResControl(resList);
RightCard.VerticalCard.Content = control; RightCard.VerticalCard.Content = control;
//显示加载效果 //关闭加载效果
RightCard.Loading_RightCard.Visibility = Visibility.Collapsed; RightCard.Loading_RightCard.Visibility = Visibility.Collapsed;
}); });
}).Start(); }).Start();
////异步加载图标
//if (iconBakList != null && iconBakList.Count > 0)
//{
// new Thread(() =>
// {
// }).Start();
//}
}); });
//EveryThing全盘搜索
//this.Dispatcher.Invoke(() =>
//{
// if (SearchIconList.IconList.Count > 0)
// {
// SearchIconList.RemoveAll();
// }
// string inputText = SearchBox.Text.ToLower().Trim();
// int count = 0;
// //GeekDesk数据搜索
// ObservableCollection<MenuInfo> menuList = appData.MenuList;
// foreach (MenuInfo menu in menuList)
// {
// ObservableCollection<IconInfo> iconList = menu.IconList;
// foreach (IconInfo icon in iconList)
// {
// if (RunTimeStatus.EVERYTHING_NEW_SEARCH) return;
// string pyName = Pinyin.GetInitials(icon.Name).ToLower();
// if (icon.Name.Contains(inputText) || pyName.Contains(inputText))
// {
// SearchIconList.IconList.Add(icon);
// count++;
// }
// }
// }
// if (appData.AppConfig.EnableEveryThing == true)
// {
// new Thread(() =>
// {
// //EveryThing全盘搜索
// ObservableCollection<IconInfo> iconBakList = EveryThingUtil.Search(inputText);
// count += iconBakList.Count;
// this.Dispatcher.Invoke(() =>
// {
// TotalMsgBtn.Visibility = Visibility.Visible;
// TotalMsgBtn.Content = count + " of " + Convert.ToInt64(EveryThingUtil.Everything_GetNumResults());
// foreach (IconInfo icon in iconBakList)
// {
// if (RunTimeStatus.EVERYTHING_NEW_SEARCH) return;
// SearchIconList.IconList.Add(icon);
// }
// });
// //异步加载图标
// if (iconBakList != null && iconBakList.Count > 0)
// {
// new Thread(() =>
// {
// foreach (IconInfo icon in iconBakList)
// {
// if (RunTimeStatus.EVERYTHING_NEW_SEARCH) return;
// this.Dispatcher.Invoke(() =>
// {
// icon.BitmapImage_NoWrite = ImageUtil.GetBitmapIconByUnknownPath(icon.Path);
// }, DispatcherPriority.SystemIdle);
// }
// }).Start();
// }
// }).Start();
// }
// //if (RightCard.SearchListBox.Items.Count > 0)
// //{
// // RightCard.SearchListBox.SelectedIndex = 0;
// //}
// //RightCard.VerticalUFG.Visibility = Visibility.Visible;
//});
}).Start(); }).Start();
} }

View File

@@ -43,7 +43,7 @@ namespace GeekDesk.Plugins.EveryThing
public static extern UInt32 Everything_GetLastError(); public static extern UInt32 Everything_GetLastError();
[DllImport(@"lib\Plugins\EveryThing\lib\Everything32.dll")] [DllImport(@"lib\Plugins\EveryThing\lib\Everything32.dll")]
public static extern bool Everything_QueryW(bool bWait); public static extern bool Everything_Query(bool bWait);
[DllImport(@"lib\Plugins\EveryThing\lib\Everything32.dll")] [DllImport(@"lib\Plugins\EveryThing\lib\Everything32.dll")]
public static extern void Everything_SortResultsByPath(); public static extern void Everything_SortResultsByPath();

View File

@@ -43,7 +43,7 @@ namespace GeekDesk.Plugins.EveryThing
public static extern UInt32 Everything_GetLastError(); public static extern UInt32 Everything_GetLastError();
[DllImport(@"lib\Plugins\EveryThing\lib\Everything64.dll")] [DllImport(@"lib\Plugins\EveryThing\lib\Everything64.dll")]
public static extern bool Everything_QueryW(bool bWait); public static extern bool Everything_Query(bool bWait);
[DllImport(@"lib\Plugins\EveryThing\lib\Everything64.dll")] [DllImport(@"lib\Plugins\EveryThing\lib\Everything64.dll")]
public static extern void Everything_SortResultsByPath(); public static extern void Everything_SortResultsByPath();

View File

@@ -184,8 +184,11 @@ namespace GeekDesk.Plugins.EveryThing
| EveryThingConst.EVERYTHING_REQUEST_PATH | EveryThingConst.EVERYTHING_REQUEST_PATH
| EveryThingConst.EVERYTHING_REQUEST_DATE_MODIFIED | EveryThingConst.EVERYTHING_REQUEST_DATE_MODIFIED
| EveryThingConst.EVERYTHING_REQUEST_SIZE); | EveryThingConst.EVERYTHING_REQUEST_SIZE);
EveryThingUtil.Everything_SetSort(13); EveryThingUtil.Everything_SetSort(
EveryThingUtil.Everything_QueryW(true); EveryThingConst.EVERYTHING_SORT_DATE_MODIFIED_DESCENDING
| EveryThingConst.EVERYTHING_SORT_TYPE_NAME_DESCENDING
| EveryThingConst.EVERYTHING_SORT_RUN_COUNT_DESCENDING);
EveryThingUtil.Everything_Query(true);
return NextPage(); return NextPage();
} }
@@ -227,9 +230,8 @@ namespace GeekDesk.Plugins.EveryThing
} }
} }
string name = System.IO.Path.GetFileNameWithoutExtension(tempPath); string name = System.IO.Path.GetFileNameWithoutExtension(tempPath);
if (String.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(tempPath))
{ {
name = tempPath.Substring(tempPath.LastIndexOf("\\")); name = tempPath.Substring(tempPath.LastIndexOf("\\"));
} }
@@ -289,15 +291,15 @@ namespace GeekDesk.Plugins.EveryThing
} }
} }
public static bool Everything_QueryW(bool bWait) public static bool Everything_Query(bool bWait)
{ {
if (Environment.Is64BitOperatingSystem) if (Environment.Is64BitOperatingSystem)
{ {
return EveryThing64.Everything_QueryW(bWait); return EveryThing64.Everything_Query(bWait);
} }
else else
{ {
return EveryThing32.Everything_QueryW(bWait); return EveryThing32.Everything_Query(bWait);
} }
} }