✅ 优化everything功能
This commit is contained in:
@@ -199,7 +199,7 @@ namespace GeekDesk.Control.UserControls.Config
|
|||||||
EveryThingUtil.EnableEveryThing(0);
|
EveryThingUtil.EnableEveryThing(0);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
EveryThingUtil.DisableEveryThing();
|
EveryThingUtil.DisableEveryThing(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
|||||||
object obj = MenuListBox.ItemContainerGenerator.ContainerFromIndex(MenuListBox.SelectedIndex);
|
object obj = MenuListBox.ItemContainerGenerator.ContainerFromIndex(MenuListBox.SelectedIndex);
|
||||||
SetListBoxItemEvent((ListBoxItem)obj);
|
SetListBoxItemEvent((ListBoxItem)obj);
|
||||||
Lbi_Selected(obj, null);
|
Lbi_Selected(obj, null);
|
||||||
HandyControl.Controls.Growl.Success("菜单关联成功, 后台加载列表!", "MainWindowGrowl");
|
HandyControl.Controls.Growl.Success("菜单关联成功, 加载列表中, 稍后重新进入此菜单可查看列表!", "MainWindowGrowl");
|
||||||
FileWatcher.LinkMenuWatcher(menuInfo);
|
FileWatcher.LinkMenuWatcher(menuInfo);
|
||||||
|
|
||||||
new Thread(() =>
|
new Thread(() =>
|
||||||
@@ -260,10 +260,11 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
|||||||
}
|
}
|
||||||
this.Dispatcher.Invoke(() =>
|
this.Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
foreach (IconInfo iconInfo in iconList)
|
menuInfo.IconList = iconList;
|
||||||
{
|
//foreach (IconInfo iconInfo in iconList)
|
||||||
menuInfo.IconList.Add(iconInfo);
|
//{
|
||||||
}
|
// menuInfo.IconList = iconList;
|
||||||
|
//}
|
||||||
});
|
});
|
||||||
}).Start();
|
}).Start();
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
xmlns:ot="clr-namespace:GeekDesk.Control.Other"
|
xmlns:ot="clr-namespace:GeekDesk.Control.Other"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450" d:DesignWidth="800"
|
d:DesignHeight="450" d:DesignWidth="800"
|
||||||
|
AllowDrop="True"
|
||||||
>
|
>
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<!--右侧栏样式动画-->
|
<!--右侧栏样式动画-->
|
||||||
@@ -280,7 +281,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<hc:Card x:Name="VerticalCard"
|
<hc:Card x:Name="VerticalCard"
|
||||||
Visibility="Visible"
|
Visibility="Collapsed"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
Effect="{DynamicResource EffectShadow2}"
|
Effect="{DynamicResource EffectShadow2}"
|
||||||
Margin="5,0,5,5" Grid.ColumnSpan="2"
|
Margin="5,0,5,5" Grid.ColumnSpan="2"
|
||||||
@@ -303,6 +304,7 @@
|
|||||||
Opacity="0.8"
|
Opacity="0.8"
|
||||||
DotDiameter="10"
|
DotDiameter="10"
|
||||||
Margin="-50,-150,0,0"
|
Margin="-50,-150,0,0"
|
||||||
Visibility="Collapsed"/>
|
Visibility="Collapsed"
|
||||||
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -108,6 +108,7 @@
|
|||||||
<HintPath>packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
<HintPath>packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Configuration" />
|
<Reference Include="System.Configuration" />
|
||||||
|
<Reference Include="System.Configuration.Install" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\System.Diagnostics.DiagnosticSource.4.7.1\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
<HintPath>packages\System.Diagnostics.DiagnosticSource.4.7.1\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
||||||
@@ -131,6 +132,7 @@
|
|||||||
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Runtime.Remoting" />
|
<Reference Include="System.Runtime.Remoting" />
|
||||||
|
<Reference Include="System.ServiceProcess" />
|
||||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
<HintPath>packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ namespace GeekDesk
|
|||||||
if (!RunTimeStatus.EVERYTHING_NEW_SEARCH)
|
if (!RunTimeStatus.EVERYTHING_NEW_SEARCH)
|
||||||
{
|
{
|
||||||
RunTimeStatus.EVERYTHING_NEW_SEARCH = true;
|
RunTimeStatus.EVERYTHING_NEW_SEARCH = true;
|
||||||
|
//显示搜索结果列表
|
||||||
|
RightCard.VisibilitySearchCard(Visibility.Visible);
|
||||||
object obj = RightCard.VerticalCard.Content;
|
object obj = RightCard.VerticalCard.Content;
|
||||||
if (obj != null)
|
if (obj != null)
|
||||||
{
|
{
|
||||||
@@ -175,16 +177,15 @@ namespace GeekDesk
|
|||||||
{
|
{
|
||||||
ObservableCollection<IconInfo> resList = new ObservableCollection<IconInfo>();
|
ObservableCollection<IconInfo> resList = new ObservableCollection<IconInfo>();
|
||||||
|
|
||||||
DateTime bf = DateTime.Now;
|
if (appData.AppConfig.EnableEveryThing == true)
|
||||||
ObservableCollection<IconInfo> iconBakList = EveryThingUtil.Search(inputText);
|
|
||||||
|
|
||||||
foreach (IconInfo icon in iconBakList)
|
|
||||||
{
|
{
|
||||||
resList.Add(icon);
|
ObservableCollection<IconInfo> iconBakList = EveryThingUtil.Search(inputText);
|
||||||
|
foreach (IconInfo icon in iconBakList)
|
||||||
|
{
|
||||||
|
resList.Add(icon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime af = DateTime.Now;
|
|
||||||
|
|
||||||
//GeekDesk数据搜索
|
//GeekDesk数据搜索
|
||||||
ObservableCollection<MenuInfo> menuList = appData.MenuList;
|
ObservableCollection<MenuInfo> menuList = appData.MenuList;
|
||||||
foreach (MenuInfo menu in menuList)
|
foreach (MenuInfo menu in menuList)
|
||||||
@@ -200,17 +201,17 @@ namespace GeekDesk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Console.WriteLine("查询耗时:{0}ms.", af.Subtract(bf).TotalMilliseconds);
|
|
||||||
|
|
||||||
this.Dispatcher.Invoke(() =>
|
this.Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
|
if (appData.AppConfig.EnableEveryThing == true)
|
||||||
|
{
|
||||||
|
TotalMsgBtn.Visibility = Visibility.Visible;
|
||||||
|
}
|
||||||
SearchResControl control = new SearchResControl(resList);
|
SearchResControl control = new SearchResControl(resList);
|
||||||
bf = DateTime.Now;
|
|
||||||
RightCard.VerticalCard.Content = control;
|
RightCard.VerticalCard.Content = control;
|
||||||
//显示加载效果
|
//显示加载效果
|
||||||
RightCard.Loading_RightCard.Visibility = Visibility.Collapsed;
|
RightCard.Loading_RightCard.Visibility = Visibility.Collapsed;
|
||||||
af = DateTime.Now;
|
|
||||||
Console.WriteLine("渲染耗时:{0}ms.", af.Subtract(bf).TotalMilliseconds);
|
|
||||||
});
|
});
|
||||||
}).Start();
|
}).Start();
|
||||||
|
|
||||||
@@ -338,9 +339,8 @@ namespace GeekDesk
|
|||||||
SearchBox.Width = 0;
|
SearchBox.Width = 0;
|
||||||
TotalMsgBtn.Content = "0 of 0";
|
TotalMsgBtn.Content = "0 of 0";
|
||||||
TotalMsgBtn.Visibility = Visibility.Hidden;
|
TotalMsgBtn.Visibility = Visibility.Hidden;
|
||||||
|
RightCard.VerticalCard.Content = null;
|
||||||
RightCard.VisibilitySearchCard(Visibility.Collapsed);
|
RightCard.VisibilitySearchCard(Visibility.Collapsed);
|
||||||
|
|
||||||
SearchIconList.RemoveAll();
|
|
||||||
});
|
});
|
||||||
}).Start();
|
}).Start();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,14 @@ using GeekDesk.Plugins.EveryThing.Constant;
|
|||||||
using GeekDesk.Util;
|
using GeekDesk.Util;
|
||||||
using GeekDesk.ViewModel;
|
using GeekDesk.ViewModel;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Configuration.Install;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.ServiceProcess;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -17,69 +20,58 @@ namespace GeekDesk.Plugins.EveryThing
|
|||||||
|
|
||||||
public class EveryThingUtil
|
public class EveryThingUtil
|
||||||
{
|
{
|
||||||
//检查是否是由GeekDesk启动的EveryThing
|
|
||||||
private static bool IsByGeekDesk = true;
|
|
||||||
|
|
||||||
//每次加载20条
|
//每次加载20条
|
||||||
private static long pageCount = 20;
|
private static long pageCount = 20;
|
||||||
private static UInt32 ui = 0;
|
private static UInt32 ui = 0;
|
||||||
|
|
||||||
private static Process serviceProcess = null;
|
|
||||||
private static Process exeProcess = null;
|
|
||||||
|
|
||||||
|
|
||||||
public static void EnableEveryThing(int delayTime = 2000)
|
public static void EnableEveryThing(int delayTime = 2000)
|
||||||
{
|
{
|
||||||
string pluginsPath = Constants.PLUGINS_PATH;
|
string pluginsPath = Constants.PLUGINS_PATH;
|
||||||
|
|
||||||
bool Is64Bit = Environment.Is64BitOperatingSystem;
|
bool Is64Bit = Environment.Is64BitOperatingSystem;
|
||||||
string everyThingPath = pluginsPath + "/EveryThing/" + (Is64Bit ? 64 : 32) + "/EveryThing.exe";
|
string everyThingPath = pluginsPath + "/EveryThing/" + (Is64Bit ? 64 : 32) + "/EveryThing.exe";
|
||||||
|
string installUtilPath = "C:\\Windows\\Microsoft.NET\\Framework"+ (Is64Bit ? "64" : "") + "\\v4.0.30319\\InstallUtil.exe";
|
||||||
new Thread(() =>
|
new Thread(() =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Thread.Sleep(delayTime);
|
Thread.Sleep(delayTime);
|
||||||
|
|
||||||
//判断EveryThing服务是否已启动
|
//判断EveryThing服务是否存在
|
||||||
bool enabled = false;
|
ServiceController sc = GetService("Everything");
|
||||||
Process[] processList = Process.GetProcesses();
|
if (sc != null)
|
||||||
foreach (System.Diagnostics.Process process in processList)
|
|
||||||
{
|
{
|
||||||
if (process.ProcessName.ToUpper().Equals("EVERYTHING"))
|
//判断是否启动
|
||||||
|
if (sc.Status != ServiceControllerStatus.StartPending
|
||||||
|
&& sc.Status != ServiceControllerStatus.Running)
|
||||||
{
|
{
|
||||||
enabled = true;
|
//启动服务
|
||||||
IsByGeekDesk = false;
|
EveryThingService(ServiceType.START);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!enabled)
|
} else
|
||||||
{
|
{
|
||||||
//启动服务
|
//安装服务
|
||||||
serviceProcess = new Process();
|
EveryThingService(ServiceType.INSTALL);
|
||||||
serviceProcess.StartInfo.FileName = everyThingPath;
|
|
||||||
serviceProcess.StartInfo.UseShellExecute = true;
|
|
||||||
serviceProcess.StartInfo.Verb = "runas";
|
|
||||||
serviceProcess.StartInfo.Arguments = " -svc";
|
|
||||||
serviceProcess.Start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.Sleep(2000);
|
Thread.Sleep(2000);
|
||||||
processList = Process.GetProcesses();
|
|
||||||
|
|
||||||
//启动程序
|
if (GetService("Everything") != null)
|
||||||
exeProcess = new Process();
|
|
||||||
exeProcess.StartInfo.FileName = everyThingPath;
|
|
||||||
exeProcess.Start();
|
|
||||||
int waitTime = 5000;
|
|
||||||
while (true && waitTime > 0)
|
|
||||||
{
|
{
|
||||||
Thread.Sleep(100);
|
//启动程序
|
||||||
waitTime -= 100;
|
Process exeProcess = new Process();
|
||||||
exeProcess.CloseMainWindow();
|
exeProcess.StartInfo.FileName = everyThingPath;
|
||||||
|
exeProcess.Start();
|
||||||
|
int waitTime = 5000;
|
||||||
|
while (true && waitTime > 0)
|
||||||
|
{
|
||||||
|
Thread.Sleep(100);
|
||||||
|
waitTime -= 100;
|
||||||
|
exeProcess.CloseMainWindow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -89,29 +81,84 @@ namespace GeekDesk.Plugins.EveryThing
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ServiceType
|
||||||
|
{
|
||||||
|
START,
|
||||||
|
STOP,
|
||||||
|
INSTALL,
|
||||||
|
UNINSTALL
|
||||||
|
}
|
||||||
|
private static void EveryThingService(ServiceType type)
|
||||||
|
{
|
||||||
|
string pluginsPath = Constants.PLUGINS_PATH;
|
||||||
|
bool Is64Bit = Environment.Is64BitOperatingSystem;
|
||||||
|
string everyThingPath = pluginsPath + "/EveryThing/" + (Is64Bit ? 64 : 32) + "/EveryThing.exe";
|
||||||
|
string installUtilPath = "C:\\Windows\\Microsoft.NET\\Framework" + (Is64Bit ? "64" : "") + "\\v4.0.30319\\InstallUtil.exe";
|
||||||
|
|
||||||
|
Process p = new Process();
|
||||||
|
p.StartInfo.FileName = everyThingPath;
|
||||||
|
string arg;
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
arg = "-start-service";
|
||||||
|
break;
|
||||||
|
case ServiceType.STOP:
|
||||||
|
arg = "-stop-service";
|
||||||
|
break;
|
||||||
|
case ServiceType.INSTALL:
|
||||||
|
arg = "-install-service";
|
||||||
|
break;
|
||||||
|
case ServiceType.UNINSTALL:
|
||||||
|
arg = "-uninstall-service";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
p.StartInfo.Arguments = arg;
|
||||||
|
p.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void DisableEveryThing()
|
public static ServiceController GetService(string serviceName)
|
||||||
|
{
|
||||||
|
ServiceController[] services = ServiceController.GetServices();
|
||||||
|
foreach (ServiceController s in services)
|
||||||
|
{
|
||||||
|
if (s.ServiceName.ToLower().Equals(serviceName.ToLower()))
|
||||||
|
{
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void DisableEveryThing(bool uninstall = false)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (IsByGeekDesk)
|
if (Environment.Is64BitOperatingSystem)
|
||||||
{
|
{
|
||||||
if (Environment.Is64BitOperatingSystem)
|
EveryThing64.Everything_Exit();
|
||||||
{
|
}
|
||||||
EveryThing64.Everything_Exit();
|
else
|
||||||
}
|
{
|
||||||
else
|
EveryThing32.Everything_Exit();
|
||||||
{
|
|
||||||
EveryThing32.Everything_Exit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (exeProcess != null) exeProcess.Kill();
|
|
||||||
if (serviceProcess != null) serviceProcess.Kill();
|
|
||||||
} catch (Exception e)
|
|
||||||
{
|
|
||||||
LogUtil.WriteErrorLog(e);
|
|
||||||
}
|
}
|
||||||
|
catch (Exception e) { }
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (uninstall)
|
||||||
|
{
|
||||||
|
EveryThingService(ServiceType.UNINSTALL);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
EveryThingService(ServiceType.STOP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@@ -240,6 +241,37 @@ namespace GeekDesk.Util
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
private enum ProcessAccessFlags : uint
|
||||||
|
{
|
||||||
|
QueryLimitedInformation = 0x00001000
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
|
private static extern bool QueryFullProcessImageName(
|
||||||
|
[In] IntPtr hProcess,
|
||||||
|
[In] int dwFlags,
|
||||||
|
[Out] StringBuilder lpExeName,
|
||||||
|
ref int lpdwSize);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
|
private static extern IntPtr OpenProcess(
|
||||||
|
ProcessAccessFlags processAccess,
|
||||||
|
bool bInheritHandle,
|
||||||
|
int processId);
|
||||||
|
|
||||||
|
public static String GetProcessFilename(Process p)
|
||||||
|
{
|
||||||
|
int capacity = 2000;
|
||||||
|
StringBuilder builder = new StringBuilder(capacity);
|
||||||
|
IntPtr ptr = OpenProcess(ProcessAccessFlags.QueryLimitedInformation, false, p.Id);
|
||||||
|
if (!QueryFullProcessImageName(ptr, 0, builder, ref capacity))
|
||||||
|
{
|
||||||
|
return String.Empty;
|
||||||
|
}
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user