🚀 减少everything搜索卡顿
This commit is contained in:
198
Control/Other/SearchResControl.xaml
Normal file
198
Control/Other/SearchResControl.xaml
Normal file
@@ -0,0 +1,198 @@
|
||||
<UserControl x:Class="GeekDesk.Control.Other.SearchResControl"
|
||||
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"
|
||||
xmlns:local="clr-namespace:GeekDesk.Control.Other"
|
||||
xmlns:temp="clr-namespace:GeekDesk.ViewModel.Temp"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
||||
xmlns:cst="clr-namespace:GeekDesk.Constant"
|
||||
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
|
||||
xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF"
|
||||
xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
>
|
||||
<UserControl.Resources>
|
||||
<Style x:Key="SearchListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ListBoxItem}">
|
||||
<Border>
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ImageStyle" TargetType="Image">
|
||||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageWidth, Mode=OneWay}"/>
|
||||
<Setter Property="Height" Value="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageHeight, Mode=OneWay}"/>
|
||||
<Setter Property="Source" Value="{Binding BitmapImage}"/>
|
||||
</Style>
|
||||
<Style x:Key="ImageStyleNoWrite" TargetType="Image">
|
||||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageWidth, Mode=OneWay}"/>
|
||||
<Setter Property="Height" Value="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageHeight, Mode=OneWay}"/>
|
||||
<Setter Property="Source" Value="{Binding BitmapImage_NoWrite}"/>
|
||||
</Style>
|
||||
|
||||
<cvt:OpcityConvert x:Key="OpcityConvert"/>
|
||||
<cvt:GetWidthByWWConvert x:Key="GetWidthByWWConvert"/>
|
||||
<cvt:Visibility2BooleanConverter x:Key="Visibility2BooleanConverter"/>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid>
|
||||
<WrapPanel Orientation="Horizontal"
|
||||
Margin="10"
|
||||
Panel.ZIndex="1"
|
||||
>
|
||||
<UniformGrid x:Name="VerticalUFG"
|
||||
xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeIn}, Event=Loaded}"
|
||||
xf:Animations.Secondary="{xf:Animate BasedOn={StaticResource FadeOut}, Event=None}"
|
||||
xf:Animations.SecondaryBinding="{Binding Visibility,
|
||||
Converter={StaticResource Visibility2BooleanConverter}, ConverterParameter='reverse',
|
||||
ElementName=VerticalUFG}"
|
||||
>
|
||||
<!--<hc:TransitioningContentControl TransitionMode="Left2RightWithFade">-->
|
||||
<ListBox VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
VirtualizingPanel.IsVirtualizing="True"
|
||||
VirtualizingPanel.IsContainerVirtualizable="True"
|
||||
VirtualizingPanel.ScrollUnit="Pixel"
|
||||
ItemsSource="{Binding}"
|
||||
BorderThickness="0"
|
||||
Padding="0,10,0,0"
|
||||
x:Name="SearchListBox"
|
||||
SelectionChanged="SearchListBox_SelectionChanged"
|
||||
>
|
||||
<ListBox.Template>
|
||||
<ControlTemplate TargetType="ListBox">
|
||||
<hc:ScrollViewer
|
||||
HorizontalScrollBarVisibility="Hidden"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
IsInertiaEnabled="True"
|
||||
CanContentScroll="True"
|
||||
PreviewMouseWheel="VerticalIconList_PreviewMouseWheel"
|
||||
ScrollChanged="VerticalCard_ScrollChanged"
|
||||
>
|
||||
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderBrush}">
|
||||
<ItemsPresenter/>
|
||||
</Border>
|
||||
</hc:ScrollViewer>
|
||||
</ControlTemplate>
|
||||
</ListBox.Template>
|
||||
|
||||
<ListBox.Background>
|
||||
<SolidColorBrush Opacity="0"/>
|
||||
</ListBox.Background>
|
||||
|
||||
<ListBox.Resources>
|
||||
<!--<ContextMenu x:Key="IconDialog" Width="200">
|
||||
<MenuItem Header="管理员方式运行" Click="IconAdminStart" 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="PropertyConfig" Tag="{Binding}"/>
|
||||
</ContextMenu>-->
|
||||
</ListBox.Resources>
|
||||
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem" BasedOn="{StaticResource SearchListBoxItemStyle}">
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<VirtualizingStackPanel
|
||||
Orientation="Vertical"
|
||||
Background="#00FFFFFF"
|
||||
VirtualizationMode="Recycling"
|
||||
IsVirtualizing="True"
|
||||
IsContainerVirtualizable="True"
|
||||
VirtualizingPanel.ScrollUnit="Pixel"
|
||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.WindowWidth, Mode=OneWay,
|
||||
Converter={StaticResource GetWidthByWWConvert},
|
||||
ConverterParameter={x:Static cst:WidthTypeEnum.RIGHT_CARD}}"
|
||||
/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border CornerRadius="8">
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem }}}"
|
||||
Value="True">
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="White" Opacity="0.68"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
<WrapPanel Tag="{Binding}"
|
||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.WindowWidth, Mode=OneWay,
|
||||
Converter={StaticResource GetWidthByWWConvert},
|
||||
ConverterParameter={x:Static cst:WidthTypeEnum.RIGHT_CARD_HALF}}"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
hc:Poptip.HitMode="None"
|
||||
hc:Poptip.Placement="BottomLeft"
|
||||
Background="#00FFFFFF"
|
||||
MouseEnter="SearchIcon_MouseEnter"
|
||||
MouseLeave="SearchIcon_MouseLeave"
|
||||
MouseLeftButtonDown="Icon_MouseLeftButtonDown"
|
||||
MouseLeftButtonUp="Icon_MouseLeftButtonUp"
|
||||
MouseMove="SearchIcon_MouseMove"
|
||||
Margin="25,10,0,10"
|
||||
>
|
||||
<Image Style="{StaticResource ImageStyleNoWrite}" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
<StackPanel Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.WindowWidth, Mode=OneWay,
|
||||
Converter={StaticResource GetWidthByWWConvert},
|
||||
ConverterParameter={x:Static cst:WidthTypeEnum.RIGHT_CARD_HALF_TEXT}}" >
|
||||
<TextBlock
|
||||
Margin="10,5,0,0"
|
||||
MaxHeight="40"
|
||||
FontSize="13"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
TextAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.TextColor}"
|
||||
Text="{Binding Name}"/>
|
||||
<TextBlock
|
||||
Margin="10,10,0,0"
|
||||
MaxHeight="40"
|
||||
FontSize="11"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
TextAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.TextColor}"
|
||||
Text="{Binding Path}"/>
|
||||
</StackPanel>
|
||||
</WrapPanel>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<!--</hc:TransitioningContentControl>-->
|
||||
</UniformGrid>
|
||||
</WrapPanel>
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
282
Control/Other/SearchResControl.xaml.cs
Normal file
282
Control/Other/SearchResControl.xaml.cs
Normal file
@@ -0,0 +1,282 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Plugins.EveryThing;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using GeekDesk.ViewModel.Temp;
|
||||
using HandyControl.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
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;
|
||||
|
||||
namespace GeekDesk.Control.Other
|
||||
{
|
||||
/// <summary>
|
||||
/// SearchResControl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class SearchResControl : UserControl
|
||||
{
|
||||
public SearchResControl(ObservableCollection<IconInfo> iconList)
|
||||
{
|
||||
this.DataContext = iconList;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void SearchListBoxIndexAdd()
|
||||
{
|
||||
//控制移动后 鼠标即使在图标上也不显示popup
|
||||
RunTimeStatus.MOUSE_MOVE_COUNT = 0;
|
||||
MainWindow.mainWindow.RightCard.MyPoptip.IsOpen = false;
|
||||
|
||||
if (SearchListBox.Items.Count > 0)
|
||||
{
|
||||
if (SearchListBox.SelectedIndex < SearchListBox.Items.Count - 1)
|
||||
{
|
||||
SearchListBox.SelectedIndex += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SearchListBoxIndexSub()
|
||||
{
|
||||
//控制移动后 鼠标即使在图标上也不显示popup
|
||||
RunTimeStatus.MOUSE_MOVE_COUNT = 0;
|
||||
MainWindow.mainWindow.RightCard.MyPoptip.IsOpen = false;
|
||||
|
||||
if (SearchListBox.Items.Count > 0)
|
||||
{
|
||||
if (SearchListBox.SelectedIndex > 0)
|
||||
{
|
||||
SearchListBox.SelectedIndex -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void StartupSelectionItem()
|
||||
{
|
||||
if (SearchListBox.SelectedItem != null)
|
||||
{
|
||||
IconInfo icon = SearchListBox.SelectedItem as IconInfo;
|
||||
if (icon.AdminStartUp)
|
||||
{
|
||||
ProcessUtil.StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessUtil.StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SearchListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
SearchListBox.ScrollIntoView(SearchListBox.SelectedItem);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询结果ICON鼠标移动事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SearchIcon_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
//控制首次刷新搜索结果后, 鼠标首次移动后显示popup
|
||||
RunTimeStatus.MOUSE_MOVE_COUNT++;
|
||||
|
||||
//防止移动后不刷新popup content
|
||||
IconInfo info = (sender as Panel).Tag as IconInfo;
|
||||
MainWindow.mainWindow.RightCard.MyPoptipContent.Text = info.Content;
|
||||
MainWindow.mainWindow.RightCard.MyPoptip.VerticalOffset = 30;
|
||||
|
||||
if (RunTimeStatus.MOUSE_MOVE_COUNT > 1 && !RunTimeStatus.ICONLIST_MOUSE_WHEEL)
|
||||
{
|
||||
MainWindow.mainWindow.RightCard.MyPoptip.IsOpen = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询结果 ICON 鼠标进入事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SearchIcon_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
|
||||
//显示popup
|
||||
RunTimeStatus.MOUSE_ENTER_ICON = true;
|
||||
if (!RunTimeStatus.ICONLIST_MOUSE_WHEEL)
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
this.Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
IconInfo info = (sender as Panel).Tag as IconInfo;
|
||||
MainWindow.mainWindow.RightCard.MyPoptipContent.Text = info.Content;
|
||||
MainWindow.mainWindow.RightCard.MyPoptip.VerticalOffset = 30;
|
||||
Thread.Sleep(100);
|
||||
if (!RunTimeStatus.ICONLIST_MOUSE_WHEEL && RunTimeStatus.MOUSE_MOVE_COUNT > 1)
|
||||
{
|
||||
MainWindow.mainWindow.RightCard.MyPoptip.IsOpen = true;
|
||||
}
|
||||
}));
|
||||
}).Start();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询结果ICON鼠标离开事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SearchIcon_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
RunTimeStatus.MOUSE_ENTER_ICON = false;
|
||||
MainWindow.mainWindow.RightCard.MyPoptip.IsOpen = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 搜索结果icon 列表鼠标滚轮预处理时间
|
||||
/// 主要使用自定义popup解决卡顿问题解决卡顿问题
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void VerticalIconList_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
//控制在滚动时不显示popup 否则会在低GPU性能机器上造成卡顿
|
||||
MainWindow.mainWindow.RightCard.MyPoptip.IsOpen = false;
|
||||
if (RunTimeStatus.ICONLIST_MOUSE_WHEEL)
|
||||
{
|
||||
RunTimeStatus.MOUSE_WHEEL_WAIT_MS = 500;
|
||||
}
|
||||
else
|
||||
{
|
||||
RunTimeStatus.ICONLIST_MOUSE_WHEEL = true;
|
||||
|
||||
new Thread(() =>
|
||||
{
|
||||
while (RunTimeStatus.MOUSE_WHEEL_WAIT_MS > 0)
|
||||
{
|
||||
Thread.Sleep(1);
|
||||
RunTimeStatus.MOUSE_WHEEL_WAIT_MS -= 1;
|
||||
}
|
||||
if (RunTimeStatus.MOUSE_ENTER_ICON)
|
||||
{
|
||||
this.Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
MainWindow.mainWindow.RightCard.MyPoptip.IsOpen = true;
|
||||
}));
|
||||
}
|
||||
RunTimeStatus.MOUSE_WHEEL_WAIT_MS = 100;
|
||||
RunTimeStatus.ICONLIST_MOUSE_WHEEL = false;
|
||||
}).Start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Icon_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (MainWindow.appData.AppConfig.DoubleOpen)
|
||||
{
|
||||
IconClick(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void Icon_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (!MainWindow.appData.AppConfig.DoubleOpen)
|
||||
{
|
||||
IconClick(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 图标点击事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void IconClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (MainWindow.appData.AppConfig.DoubleOpen && e.ClickCount >= 2)
|
||||
{
|
||||
IconInfo icon = (IconInfo)((Panel)sender).Tag;
|
||||
if (icon.AdminStartUp)
|
||||
{
|
||||
ProcessUtil.StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessUtil.StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
|
||||
}
|
||||
}
|
||||
else if (!MainWindow.appData.AppConfig.DoubleOpen && e.ClickCount == 1)
|
||||
{
|
||||
IconInfo icon = (IconInfo)((Panel)sender).Tag;
|
||||
if (icon.AdminStartUp)
|
||||
{
|
||||
ProcessUtil.StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessUtil.StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static volatile bool EveryThingRuning = false;
|
||||
private void VerticalCard_ScrollChanged(object sender, ScrollChangedEventArgs e)
|
||||
{
|
||||
if (MainWindow.appData.AppConfig.EnableEveryThing == true && EveryThingUtil.HasNext())
|
||||
{
|
||||
HandyControl.Controls.ScrollViewer sv = sender as HandyControl.Controls.ScrollViewer;
|
||||
if (sv.ExtentHeight - (sv.ActualHeight + sv.VerticalOffset) < 100
|
||||
&& EveryThingUtil.HasNext()
|
||||
&& !EveryThingRuning)
|
||||
{
|
||||
EveryThingRuning = true;
|
||||
MainWindow.mainWindow.RightCard.Loading_RightCard.Visibility = Visibility.Visible;
|
||||
string[] split = MainWindow.mainWindow.TotalMsgBtn.Content.ToString().Split(' ');
|
||||
long count = Convert.ToInt64(split[0]);
|
||||
|
||||
ObservableCollection<IconInfo> resList = this.DataContext as ObservableCollection<IconInfo>;
|
||||
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
{
|
||||
ObservableCollection<IconInfo> searchRes = EveryThingUtil.NextPage();
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
count += searchRes.Count;
|
||||
MainWindow.mainWindow.TotalMsgBtn.Content = count + " of " + split[split.Length - 1];
|
||||
foreach (IconInfo info in searchRes)
|
||||
{
|
||||
resList.Add(info);
|
||||
}
|
||||
MainWindow.mainWindow.RightCard.Loading_RightCard.Visibility = Visibility.Collapsed;
|
||||
EveryThingRuning = false;
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@
|
||||
xmlns:component="clr-namespace:GeekDesk.CustomComponent.VirtualizingWrapPanel"
|
||||
xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF"
|
||||
xmlns:ot="clr-namespace:GeekDesk.Control.Other"
|
||||
xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:AppData}"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
>
|
||||
@@ -162,7 +161,6 @@
|
||||
|
||||
<WrapPanel Orientation="Horizontal"
|
||||
Margin="10"
|
||||
|
||||
>
|
||||
<UniformGrid x:Name="WrapUFG" xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeInAndGrowHorizontally}, Event=Visibility}">
|
||||
<!--<hc:TransitioningContentControl TransitionStoryboard="{StaticResource Custom3Transition3}">-->
|
||||
@@ -280,164 +278,31 @@
|
||||
</hc:DialogContainer>
|
||||
</hc:Card>
|
||||
|
||||
|
||||
<hc:Card x:Name="VerticalCard"
|
||||
Visibility="Hidden"
|
||||
Visibility="Visible"
|
||||
BorderThickness="1"
|
||||
Effect="{DynamicResource EffectShadow2}"
|
||||
Margin="5,0,5,5" Grid.ColumnSpan="2"
|
||||
MouseLeftButtonDown="VerticalCard_MouseLeftButtonDown"
|
||||
>
|
||||
<hc:Card.Background>
|
||||
<SolidColorBrush Color="AliceBlue"
|
||||
<SolidColorBrush Color="AliceBlue"
|
||||
hc:GeometryEffect.GeometryEffect="20"
|
||||
Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"/>
|
||||
</hc:Card.Background>
|
||||
<hc:Card.BorderBrush>
|
||||
<SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
|
||||
</hc:Card.BorderBrush>
|
||||
<Grid>
|
||||
|
||||
|
||||
<WrapPanel Orientation="Horizontal"
|
||||
Margin="10"
|
||||
>
|
||||
<UniformGrid x:Name="VerticalUFG"
|
||||
xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeIn}, OffsetY= -10, Event=Visibility}"
|
||||
>
|
||||
<!--<hc:TransitioningContentControl TransitionMode="Left2RightWithFade">-->
|
||||
<ListBox ItemsSource="{Binding Source={StaticResource SearchIconList},Path=IconList, Mode=OneWay}"
|
||||
VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
VirtualizingPanel.IsVirtualizing="True"
|
||||
VirtualizingPanel.IsContainerVirtualizable="True"
|
||||
VirtualizingPanel.ScrollUnit="Pixel"
|
||||
BorderThickness="0"
|
||||
Padding="0,10,0,0"
|
||||
x:Name="SearchListBox"
|
||||
SelectionChanged="SearchListBox_SelectionChanged"
|
||||
>
|
||||
|
||||
<ListBox.Template>
|
||||
<ControlTemplate TargetType="ListBox">
|
||||
<hc:ScrollViewer
|
||||
HorizontalScrollBarVisibility="Hidden"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
IsInertiaEnabled="True"
|
||||
CanContentScroll="True"
|
||||
PreviewMouseWheel="VerticalIconList_PreviewMouseWheel"
|
||||
ScrollChanged="VerticalCard_ScrollChanged"
|
||||
>
|
||||
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderBrush}">
|
||||
<ItemsPresenter/>
|
||||
</Border>
|
||||
</hc:ScrollViewer>
|
||||
</ControlTemplate>
|
||||
</ListBox.Template>
|
||||
|
||||
<ListBox.Background>
|
||||
<SolidColorBrush Opacity="0"/>
|
||||
</ListBox.Background>
|
||||
|
||||
<ListBox.Resources>
|
||||
<ContextMenu x:Key="IconDialog" Width="200">
|
||||
<MenuItem Header="管理员方式运行" Click="IconAdminStart" 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="PropertyConfig" Tag="{Binding}"/>
|
||||
</ContextMenu>
|
||||
</ListBox.Resources>
|
||||
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem" BasedOn="{StaticResource SearchListBoxItemStyle}">
|
||||
<Setter Property="ContextMenu" Value="{StaticResource IconDialog}"/>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<VirtualizingStackPanel
|
||||
Orientation="Vertical"
|
||||
Background="#00FFFFFF"
|
||||
VirtualizationMode="Recycling"
|
||||
IsVirtualizing="True"
|
||||
IsContainerVirtualizable="True"
|
||||
VirtualizingPanel.ScrollUnit="Pixel"
|
||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.WindowWidth, Mode=OneWay,
|
||||
Converter={StaticResource GetWidthByWWConvert},
|
||||
ConverterParameter={x:Static cst:WidthTypeEnum.RIGHT_CARD}}"
|
||||
/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border CornerRadius="8">
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem }}}"
|
||||
Value="True">
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="White" Opacity="0.68"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
<WrapPanel Tag="{Binding}"
|
||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.WindowWidth, Mode=OneWay,
|
||||
Converter={StaticResource GetWidthByWWConvert},
|
||||
ConverterParameter={x:Static cst:WidthTypeEnum.RIGHT_CARD_HALF}}"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
hc:Poptip.HitMode="None"
|
||||
hc:Poptip.Placement="BottomLeft"
|
||||
Background="#00FFFFFF"
|
||||
MouseEnter="SearchIcon_MouseEnter"
|
||||
MouseLeave="SearchIcon_MouseLeave"
|
||||
MouseLeftButtonDown="Icon_MouseLeftButtonDown"
|
||||
MouseLeftButtonUp="Icon_MouseLeftButtonUp"
|
||||
MouseMove="SearchIcon_MouseMove"
|
||||
Margin="25,10,0,10"
|
||||
>
|
||||
<Image Style="{StaticResource ImageStyleNoWrite}" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
<StackPanel Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.WindowWidth, Mode=OneWay,
|
||||
Converter={StaticResource GetWidthByWWConvert},
|
||||
ConverterParameter={x:Static cst:WidthTypeEnum.RIGHT_CARD_HALF_TEXT}}" >
|
||||
<TextBlock
|
||||
Margin="10,5,0,0"
|
||||
MaxHeight="40"
|
||||
FontSize="13"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
TextAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.TextColor}"
|
||||
Text="{Binding Name}"/>
|
||||
<TextBlock
|
||||
Margin="10,10,0,0"
|
||||
MaxHeight="40"
|
||||
FontSize="11"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
TextAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.TextColor}"
|
||||
Text="{Binding Path}"/>
|
||||
</StackPanel>
|
||||
</WrapPanel>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<!--</hc:TransitioningContentControl>-->
|
||||
</UniformGrid>
|
||||
</WrapPanel>
|
||||
|
||||
</Grid>
|
||||
</hc:Card>
|
||||
</hc:Card.Background>
|
||||
<hc:Card.BorderBrush>
|
||||
<SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
|
||||
</hc:Card.BorderBrush>
|
||||
</hc:Card>
|
||||
<hc:LoadingCircle x:Name="Loading_RightCard"
|
||||
Width="45" Height="45"
|
||||
DotBorderBrush="White"
|
||||
DotBorderThickness="2"
|
||||
Foreground="DarkGray"
|
||||
Opacity="0.8"
|
||||
DotDiameter="10"
|
||||
Margin="-50,-150,0,0"
|
||||
Visibility="Collapsed"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -131,11 +131,11 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
IconInfo icon = (IconInfo)((Panel)sender).Tag;
|
||||
if (icon.AdminStartUp)
|
||||
{
|
||||
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
||||
ProcessUtil.StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
|
||||
ProcessUtil.StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
|
||||
}
|
||||
}
|
||||
else if (!appData.AppConfig.DoubleOpen && e.ClickCount == 1)
|
||||
@@ -143,11 +143,11 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
IconInfo icon = (IconInfo)((Panel)sender).Tag;
|
||||
if (icon.AdminStartUp)
|
||||
{
|
||||
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
||||
ProcessUtil.StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
|
||||
ProcessUtil.StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
private void IconAdminStart(object sender, RoutedEventArgs e)
|
||||
{
|
||||
IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
|
||||
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
||||
ProcessUtil.StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -172,227 +172,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
private void ShowInExplore(object sender, RoutedEventArgs e)
|
||||
{
|
||||
IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
|
||||
StartIconApp(icon, IconStartType.SHOW_IN_EXPLORE);
|
||||
}
|
||||
|
||||
private void StartIconApp(IconInfo icon, IconStartType type, bool useRelativePath = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Process p = new Process())
|
||||
{
|
||||
string startArg = icon.StartArg;
|
||||
|
||||
if (startArg != null && Constants.SYSTEM_ICONS.ContainsKey(startArg))
|
||||
{
|
||||
StartSystemApp(startArg, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
string path;
|
||||
if (useRelativePath)
|
||||
{
|
||||
string fullPath = Path.Combine(Constants.APP_DIR, icon.RelativePath);
|
||||
path = Path.GetFullPath(fullPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
path = icon.Path;
|
||||
}
|
||||
p.StartInfo.FileName = path;
|
||||
if (!StringUtil.IsEmpty(startArg))
|
||||
{
|
||||
p.StartInfo.Arguments = startArg;
|
||||
}
|
||||
if (icon.IconType == IconType.OTHER)
|
||||
{
|
||||
if (!File.Exists(path) && !Directory.Exists(path))
|
||||
{
|
||||
//如果没有使用相对路径 那么使用相对路径启动一次
|
||||
if (!useRelativePath)
|
||||
{
|
||||
StartIconApp(icon, type, true);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(文件路径不存在或已删除)!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
p.StartInfo.WorkingDirectory = path.Substring(0, path.LastIndexOf("\\"));
|
||||
switch (type)
|
||||
{
|
||||
case IconStartType.ADMIN_STARTUP:
|
||||
//p.StartInfo.Arguments = "1";//启动参数
|
||||
p.StartInfo.Verb = "runas";
|
||||
//p.StartInfo.CreateNoWindow = false; //设置显示窗口
|
||||
p.StartInfo.UseShellExecute = true;//不使用操作系统外壳程序启动进程
|
||||
//p.StartInfo.ErrorDialog = false;
|
||||
if (appData.AppConfig.AppHideType == AppHideType.START_EXE && !RunTimeStatus.LOCK_APP_PANEL)
|
||||
{
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (appData.AppConfig.MarginHide)
|
||||
{
|
||||
if (!MarginHide.IsMargin())
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
|
||||
}
|
||||
break;// c#好像不能case穿透
|
||||
case IconStartType.DEFAULT_STARTUP:
|
||||
if (appData.AppConfig.AppHideType == AppHideType.START_EXE && !RunTimeStatus.LOCK_APP_PANEL)
|
||||
{
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (appData.AppConfig.MarginHide)
|
||||
{
|
||||
if (!MarginHide.IsMargin())
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IconStartType.SHOW_IN_EXPLORE:
|
||||
p.StartInfo.FileName = "Explorer.exe";
|
||||
p.StartInfo.Arguments = "/e,/select," + icon.Path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (appData.AppConfig.AppHideType == AppHideType.START_EXE && !RunTimeStatus.LOCK_APP_PANEL)
|
||||
{
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (appData.AppConfig.MarginHide)
|
||||
{
|
||||
if (!MarginHide.IS_HIDE)
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
}
|
||||
p.Start();
|
||||
if (useRelativePath)
|
||||
{
|
||||
//如果使用相对路径启动成功 那么重新设置程序绝对路径
|
||||
icon.Path = path;
|
||||
}
|
||||
}
|
||||
}
|
||||
icon.Count++;
|
||||
|
||||
//隐藏搜索框
|
||||
if (RunTimeStatus.SEARCH_BOX_SHOW)
|
||||
{
|
||||
MainWindow.mainWindow.HidedSearchBox();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (!useRelativePath)
|
||||
{
|
||||
StartIconApp(icon, type, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(可能为不支持的启动方式)!");
|
||||
LogUtil.WriteErrorLog(e, "程序启动失败:path=" + icon.Path + ",type=" + type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void StartSystemApp(string startArg, IconStartType type)
|
||||
{
|
||||
if (type == IconStartType.SHOW_IN_EXPLORE)
|
||||
{
|
||||
Growl.WarningGlobal("系统项目不支持打开文件位置操作!");
|
||||
return;
|
||||
}
|
||||
switch (startArg)
|
||||
{
|
||||
case "Calculator":
|
||||
Process.Start("calc.exe");
|
||||
break;
|
||||
case "Computer":
|
||||
Process.Start("explorer.exe");
|
||||
break;
|
||||
case "GroupPolicy":
|
||||
Process.Start("gpedit.msc");
|
||||
break;
|
||||
case "Notepad":
|
||||
Process.Start("notepad");
|
||||
break;
|
||||
case "Network":
|
||||
Process.Start("ncpa.cpl");
|
||||
break;
|
||||
case "RecycleBin":
|
||||
Process.Start("shell:RecycleBinFolder");
|
||||
break;
|
||||
case "Registry":
|
||||
Process.Start("regedit.exe");
|
||||
break;
|
||||
case "Mstsc":
|
||||
if (type == IconStartType.ADMIN_STARTUP)
|
||||
{
|
||||
Process.Start("mstsc", "-admin");
|
||||
}
|
||||
else
|
||||
{
|
||||
Process.Start("mstsc");
|
||||
}
|
||||
break;
|
||||
case "Control":
|
||||
Process.Start("Control");
|
||||
break;
|
||||
case "CMD":
|
||||
if (type == IconStartType.ADMIN_STARTUP)
|
||||
{
|
||||
using (Process process = new Process())
|
||||
{
|
||||
process.StartInfo.FileName = "cmd.exe";
|
||||
process.StartInfo.Verb = "runas";
|
||||
process.Start();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Process.Start("cmd");
|
||||
}
|
||||
break;
|
||||
case "Services":
|
||||
Process.Start("services.msc");
|
||||
break;
|
||||
}
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (appData.AppConfig.MarginHide)
|
||||
{
|
||||
if (!MarginHide.IS_HIDE)
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
ProcessUtil.StartIconApp(icon, IconStartType.SHOW_IN_EXPLORE);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -778,56 +558,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
}
|
||||
}
|
||||
|
||||
public void SearchListBoxIndexAdd()
|
||||
{
|
||||
//控制移动后 鼠标即使在图标上也不显示popup
|
||||
RunTimeStatus.MOUSE_MOVE_COUNT = 0;
|
||||
MyPoptip.IsOpen = false;
|
||||
|
||||
if (SearchListBox.Items.Count > 0)
|
||||
{
|
||||
if (SearchListBox.SelectedIndex < SearchListBox.Items.Count - 1)
|
||||
{
|
||||
SearchListBox.SelectedIndex += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SearchListBoxIndexSub()
|
||||
{
|
||||
//控制移动后 鼠标即使在图标上也不显示popup
|
||||
RunTimeStatus.MOUSE_MOVE_COUNT = 0;
|
||||
MyPoptip.IsOpen = false;
|
||||
|
||||
if (SearchListBox.Items.Count > 0)
|
||||
{
|
||||
if (SearchListBox.SelectedIndex > 0)
|
||||
{
|
||||
SearchListBox.SelectedIndex -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void StartupSelectionItem()
|
||||
{
|
||||
if (SearchListBox.SelectedItem != null)
|
||||
{
|
||||
IconInfo icon = SearchListBox.SelectedItem as IconInfo;
|
||||
if (icon.AdminStartUp)
|
||||
{
|
||||
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SearchListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
SearchListBox.ScrollIntoView(SearchListBox.SelectedItem);
|
||||
}
|
||||
|
||||
|
||||
private void PDDialog_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
@@ -937,105 +668,6 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 搜索结果icon 列表鼠标滚轮预处理时间
|
||||
/// 主要使用自定义popup解决卡顿问题解决卡顿问题
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void VerticalIconList_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
//控制在滚动时不显示popup 否则会在低GPU性能机器上造成卡顿
|
||||
MyPoptip.IsOpen = false;
|
||||
if (RunTimeStatus.ICONLIST_MOUSE_WHEEL)
|
||||
{
|
||||
RunTimeStatus.MOUSE_WHEEL_WAIT_MS = 500;
|
||||
}
|
||||
else
|
||||
{
|
||||
RunTimeStatus.ICONLIST_MOUSE_WHEEL = true;
|
||||
|
||||
new Thread(() =>
|
||||
{
|
||||
while (RunTimeStatus.MOUSE_WHEEL_WAIT_MS > 0)
|
||||
{
|
||||
Thread.Sleep(1);
|
||||
RunTimeStatus.MOUSE_WHEEL_WAIT_MS -= 1;
|
||||
}
|
||||
if (RunTimeStatus.MOUSE_ENTER_ICON)
|
||||
{
|
||||
this.Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
MyPoptip.IsOpen = true;
|
||||
}));
|
||||
}
|
||||
RunTimeStatus.MOUSE_WHEEL_WAIT_MS = 100;
|
||||
RunTimeStatus.ICONLIST_MOUSE_WHEEL = false;
|
||||
}).Start();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询结果 ICON 鼠标进入事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SearchIcon_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
|
||||
//显示popup
|
||||
RunTimeStatus.MOUSE_ENTER_ICON = true;
|
||||
if (!RunTimeStatus.ICONLIST_MOUSE_WHEEL)
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
this.Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
IconInfo info = (sender as Panel).Tag as IconInfo;
|
||||
MyPoptipContent.Text = info.Content;
|
||||
MyPoptip.VerticalOffset = 30;
|
||||
Thread.Sleep(100);
|
||||
if (!RunTimeStatus.ICONLIST_MOUSE_WHEEL && RunTimeStatus.MOUSE_MOVE_COUNT > 1)
|
||||
{
|
||||
MyPoptip.IsOpen = true;
|
||||
}
|
||||
}));
|
||||
}).Start();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询结果ICON鼠标离开事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SearchIcon_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
RunTimeStatus.MOUSE_ENTER_ICON = false;
|
||||
MyPoptip.IsOpen = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询结果ICON鼠标移动事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SearchIcon_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
//控制首次刷新搜索结果后, 鼠标首次移动后显示popup
|
||||
RunTimeStatus.MOUSE_MOVE_COUNT++;
|
||||
|
||||
//防止移动后不刷新popup content
|
||||
IconInfo info = (sender as Panel).Tag as IconInfo;
|
||||
MyPoptipContent.Text = info.Content;
|
||||
MyPoptip.VerticalOffset = 30;
|
||||
|
||||
if (RunTimeStatus.MOUSE_MOVE_COUNT > 1 && !RunTimeStatus.ICONLIST_MOUSE_WHEEL)
|
||||
{
|
||||
MyPoptip.IsOpen = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// menu结果ICON鼠标移动事件
|
||||
/// </summary>
|
||||
@@ -1049,48 +681,6 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
MyPoptip.VerticalOffset = 30;
|
||||
}
|
||||
|
||||
private void VerticalCard_ScrollChanged(object sender, ScrollChangedEventArgs e)
|
||||
{
|
||||
if (appData.AppConfig.EnableEveryThing == true && EveryThingUtil.HasNext())
|
||||
{
|
||||
HandyControl.Controls.ScrollViewer sv = sender as HandyControl.Controls.ScrollViewer;
|
||||
if (sv.ExtentHeight - (sv.ActualHeight + sv.VerticalOffset) < 200 && EveryThingUtil.HasNext())
|
||||
{
|
||||
string[] split = MainWindow.mainWindow.TotalMsgBtn.Content.ToString().Split(' ');
|
||||
long count = Convert.ToInt64(split[0]);
|
||||
ObservableCollection<IconInfo> iconBakList = EveryThingUtil.NextPage();
|
||||
count += iconBakList.Count;
|
||||
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
MainWindow.mainWindow.TotalMsgBtn.Content = count + " of " + split[split.Length - 1];
|
||||
foreach (IconInfo icon in iconBakList)
|
||||
{
|
||||
if (RunTimeStatus.EVERYTHING_NEW_SEARCH) return;
|
||||
SearchIconList.IconList.Add(icon);
|
||||
}
|
||||
});
|
||||
//异步加载图标
|
||||
if (iconBakList != null && iconBakList.Count > 0)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
{
|
||||
foreach (IconInfo icon in iconBakList)
|
||||
{
|
||||
if (RunTimeStatus.EVERYTHING_NEW_SEARCH) return;
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
icon.BitmapImage_NoWrite = ImageUtil.GetBitmapIconByUnknownPath(icon.Path);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@ namespace GeekDesk.Converts
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if ((Visibility)value == Visibility.Visible)
|
||||
if (parameter == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return (Visibility)value == Visibility.Visible;
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
return !((Visibility)value == Visibility.Visible);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
|
||||
@@ -200,6 +200,9 @@
|
||||
<Compile Include="Control\Other\IconInfoUrlDialog.xaml.cs">
|
||||
<DependentUpon>IconInfoUrlDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Control\Other\SearchResControl.xaml.cs">
|
||||
<DependentUpon>SearchResControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Control\UserControls\Config\OtherControl.xaml.cs">
|
||||
<DependentUpon>OtherControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -315,6 +318,7 @@
|
||||
<Compile Include="Util\MouseHook.cs" />
|
||||
<Compile Include="Util\MouseUtil.cs" />
|
||||
<Compile Include="Util\NativeMethods.cs" />
|
||||
<Compile Include="Util\ProcessUtil.cs" />
|
||||
<Compile Include="Util\RegisterUtil.cs" />
|
||||
<Compile Include="Util\RelayCommand.cs" />
|
||||
<Compile Include="Util\ScreenUtil.cs" />
|
||||
@@ -369,6 +373,10 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Control\Other\SearchResControl.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Control\UserControls\Config\OtherControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
||||
x:Name="AppWindow"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel"
|
||||
xmlns:my="clr-namespace:GeekDesk.Util"
|
||||
d:DataContext="{d:DesignInstance Type=viewmodel:AppData}"
|
||||
Title="GeekDesk_Main_8400A17AEEF7C029"
|
||||
MinWidth="600"
|
||||
@@ -196,6 +197,7 @@
|
||||
|
||||
<uc:RightCardControl x:Name="RightCard" Grid.Row="1" Grid.Column="1"/>
|
||||
|
||||
|
||||
<StackPanel hc:Growl.GrowlParent="True" VerticalAlignment="Top" Margin="0,10,10,0"/>
|
||||
</Grid>
|
||||
</hc:DialogContainer>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Control.Other;
|
||||
using GeekDesk.Control.UserControls.Config;
|
||||
using GeekDesk.Control.UserControls.PannelCard;
|
||||
using GeekDesk.Control.Windows;
|
||||
@@ -124,24 +125,30 @@ namespace GeekDesk
|
||||
RightCard.MyPoptip.IsOpen = false;
|
||||
|
||||
string inputText = SearchBox.Text.ToLower();
|
||||
RightCard.VerticalUFG.Visibility = Visibility.Collapsed;
|
||||
if (!string.IsNullOrEmpty(inputText))
|
||||
{
|
||||
RunTimeStatus.EVERYTHING_SEARCH_DELAY_TIME = 300;
|
||||
if (!RunTimeStatus.EVERYTHING_NEW_SEARCH)
|
||||
{
|
||||
RunTimeStatus.EVERYTHING_NEW_SEARCH = true;
|
||||
object obj = RightCard.VerticalCard.Content;
|
||||
if (obj != null)
|
||||
{
|
||||
SearchResControl control = obj as SearchResControl;
|
||||
control.VerticalUFG.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
SearchDelay();
|
||||
}
|
||||
} else
|
||||
{
|
||||
new Thread(() =>
|
||||
//清空查询结果
|
||||
object obj = RightCard.VerticalCard.Content;
|
||||
if (obj != null)
|
||||
{
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
SearchIconList.RemoveAll();
|
||||
});
|
||||
}).Start();
|
||||
SearchResControl control = obj as SearchResControl;
|
||||
control.VerticalUFG.Visibility = Visibility.Collapsed;
|
||||
control.SearchListBox.Items.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -162,77 +169,149 @@ namespace GeekDesk
|
||||
|
||||
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)
|
||||
new Thread(() =>
|
||||
{
|
||||
ObservableCollection<IconInfo> iconList = menu.IconList;
|
||||
foreach (IconInfo icon in iconList)
|
||||
ObservableCollection<IconInfo> resList = new ObservableCollection<IconInfo>();
|
||||
|
||||
DateTime bf = DateTime.Now;
|
||||
ObservableCollection<IconInfo> iconBakList = EveryThingUtil.Search(inputText);
|
||||
|
||||
foreach (IconInfo icon in iconBakList)
|
||||
{
|
||||
if (RunTimeStatus.EVERYTHING_NEW_SEARCH) return;
|
||||
string pyName = Pinyin.GetInitials(icon.Name).ToLower();
|
||||
if (icon.Name.Contains(inputText) || pyName.Contains(inputText))
|
||||
resList.Add(icon);
|
||||
}
|
||||
|
||||
DateTime af = DateTime.Now;
|
||||
|
||||
//GeekDesk数据搜索
|
||||
ObservableCollection<MenuInfo> menuList = appData.MenuList;
|
||||
foreach (MenuInfo menu in menuList)
|
||||
{
|
||||
ObservableCollection<IconInfo> iconList = menu.IconList;
|
||||
foreach (IconInfo icon in iconList)
|
||||
{
|
||||
SearchIconList.IconList.Add(icon);
|
||||
count++;
|
||||
if (RunTimeStatus.EVERYTHING_NEW_SEARCH) return;
|
||||
string pyName = Pinyin.GetInitials(icon.Name).ToLower();
|
||||
if (icon.Name.Contains(inputText) || pyName.Contains(inputText))
|
||||
{
|
||||
resList.Add(icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Console.WriteLine("查询耗时:{0}ms.", af.Subtract(bf).TotalMilliseconds);
|
||||
|
||||
|
||||
if (appData.AppConfig.EnableEveryThing == true)
|
||||
{
|
||||
new Thread(() =>
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
//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();
|
||||
}
|
||||
SearchResControl control = new SearchResControl(resList);
|
||||
bf = DateTime.Now;
|
||||
RightCard.VerticalCard.Content = control;
|
||||
//显示加载效果
|
||||
RightCard.Loading_RightCard.Visibility = Visibility.Collapsed;
|
||||
af = DateTime.Now;
|
||||
Console.WriteLine("渲染耗时:{0}ms.", af.Subtract(bf).TotalMilliseconds);
|
||||
});
|
||||
}).Start();
|
||||
|
||||
|
||||
|
||||
|
||||
if (RightCard.SearchListBox.Items.Count > 0)
|
||||
{
|
||||
RightCard.SearchListBox.SelectedIndex = 0;
|
||||
}
|
||||
RightCard.VerticalUFG.Visibility = Visibility.Visible;
|
||||
////异步加载图标
|
||||
//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();
|
||||
}
|
||||
|
||||
@@ -880,15 +959,18 @@ namespace GeekDesk
|
||||
{
|
||||
if (e.Key == Key.Down || e.Key == Key.Tab)
|
||||
{
|
||||
RightCard.SearchListBoxIndexAdd();
|
||||
SearchResControl res = RightCard.VerticalCard.Content as SearchResControl;
|
||||
res.SearchListBoxIndexAdd();
|
||||
}
|
||||
else if (e.Key == Key.Up)
|
||||
{
|
||||
RightCard.SearchListBoxIndexSub();
|
||||
SearchResControl res = RightCard.VerticalCard.Content as SearchResControl;
|
||||
res.SearchListBoxIndexSub();
|
||||
}
|
||||
else if (e.Key == Key.Enter)
|
||||
{
|
||||
RightCard.StartupSelectionItem();
|
||||
SearchResControl res = RightCard.VerticalCard.Content as SearchResControl;
|
||||
res.StartupSelectionItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
@@ -92,19 +93,25 @@ namespace GeekDesk.Plugins.EveryThing
|
||||
|
||||
public static void DisableEveryThing()
|
||||
{
|
||||
if (IsByGeekDesk)
|
||||
try
|
||||
{
|
||||
if (Environment.Is64BitOperatingSystem)
|
||||
if (IsByGeekDesk)
|
||||
{
|
||||
EveryThing64.Everything_Exit();
|
||||
} else
|
||||
{
|
||||
EveryThing32.Everything_Exit();
|
||||
if (Environment.Is64BitOperatingSystem)
|
||||
{
|
||||
EveryThing64.Everything_Exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
EveryThing32.Everything_Exit();
|
||||
}
|
||||
}
|
||||
if (exeProcess != null) exeProcess.Kill();
|
||||
if (serviceProcess != null) serviceProcess.Kill();
|
||||
} catch (Exception e)
|
||||
{
|
||||
LogUtil.WriteErrorLog(e);
|
||||
}
|
||||
if (exeProcess != null) exeProcess.Kill();
|
||||
if (serviceProcess != null) serviceProcess.Kill();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -179,7 +186,7 @@ namespace GeekDesk.Plugins.EveryThing
|
||||
{
|
||||
Path_NoWrite = filePath,
|
||||
LnkPath_NoWrite = tempPath,
|
||||
BitmapImage_NoWrite = null,
|
||||
BitmapImage_NoWrite = ImageUtil.GetBitmapIconByUnknownPath(filePath),
|
||||
StartArg_NoWrite = FileUtil.GetArgByLnk(tempPath),
|
||||
Name_NoWrite = name,
|
||||
};
|
||||
|
||||
245
Util/ProcessUtil.cs
Normal file
245
Util/ProcessUtil.cs
Normal file
@@ -0,0 +1,245 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.ViewModel;
|
||||
using HandyControl.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class ProcessUtil
|
||||
{
|
||||
|
||||
|
||||
public static void StartIconApp(IconInfo icon, IconStartType type, bool useRelativePath = false)
|
||||
{
|
||||
App.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
using (Process p = new Process())
|
||||
{
|
||||
string startArg = icon.StartArg;
|
||||
|
||||
if (startArg != null && Constants.SYSTEM_ICONS.ContainsKey(startArg))
|
||||
{
|
||||
StartSystemApp(startArg, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
string path;
|
||||
if (useRelativePath)
|
||||
{
|
||||
string fullPath = Path.Combine(Constants.APP_DIR, icon.RelativePath);
|
||||
path = Path.GetFullPath(fullPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
path = icon.Path;
|
||||
}
|
||||
p.StartInfo.FileName = path;
|
||||
if (!StringUtil.IsEmpty(startArg))
|
||||
{
|
||||
p.StartInfo.Arguments = startArg;
|
||||
}
|
||||
if (icon.IconType == IconType.OTHER)
|
||||
{
|
||||
if (!File.Exists(path) && !Directory.Exists(path))
|
||||
{
|
||||
//如果没有使用相对路径 那么使用相对路径启动一次
|
||||
if (!useRelativePath)
|
||||
{
|
||||
StartIconApp(icon, type, true);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(文件路径不存在或已删除)!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
p.StartInfo.WorkingDirectory = path.Substring(0, path.LastIndexOf("\\"));
|
||||
switch (type)
|
||||
{
|
||||
case IconStartType.ADMIN_STARTUP:
|
||||
//p.StartInfo.Arguments = "1";//启动参数
|
||||
p.StartInfo.Verb = "runas";
|
||||
//p.StartInfo.CreateNoWindow = false; //设置显示窗口
|
||||
p.StartInfo.UseShellExecute = true;//不使用操作系统外壳程序启动进程
|
||||
//p.StartInfo.ErrorDialog = false;
|
||||
if (MainWindow.appData.AppConfig.AppHideType == AppHideType.START_EXE && !RunTimeStatus.LOCK_APP_PANEL)
|
||||
{
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (MainWindow.appData.AppConfig.MarginHide)
|
||||
{
|
||||
if (!MarginHide.IsMargin())
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
|
||||
}
|
||||
break;// c#好像不能case穿透
|
||||
case IconStartType.DEFAULT_STARTUP:
|
||||
if (MainWindow.appData.AppConfig.AppHideType == AppHideType.START_EXE && !RunTimeStatus.LOCK_APP_PANEL)
|
||||
{
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (MainWindow.appData.AppConfig.MarginHide)
|
||||
{
|
||||
if (!MarginHide.IsMargin())
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IconStartType.SHOW_IN_EXPLORE:
|
||||
p.StartInfo.FileName = "Explorer.exe";
|
||||
p.StartInfo.Arguments = "/e,/select," + icon.Path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MainWindow.appData.AppConfig.AppHideType == AppHideType.START_EXE && !RunTimeStatus.LOCK_APP_PANEL)
|
||||
{
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (MainWindow.appData.AppConfig.MarginHide)
|
||||
{
|
||||
if (!MarginHide.IS_HIDE)
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
}
|
||||
p.Start();
|
||||
if (useRelativePath)
|
||||
{
|
||||
//如果使用相对路径启动成功 那么重新设置程序绝对路径
|
||||
icon.Path = path;
|
||||
}
|
||||
}
|
||||
}
|
||||
icon.Count++;
|
||||
|
||||
//隐藏搜索框
|
||||
if (RunTimeStatus.SEARCH_BOX_SHOW)
|
||||
{
|
||||
MainWindow.mainWindow.HidedSearchBox();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (!useRelativePath)
|
||||
{
|
||||
StartIconApp(icon, type, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(可能为不支持的启动方式)!");
|
||||
LogUtil.WriteErrorLog(e, "程序启动失败:path=" + icon.Path + ",type=" + type);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void StartSystemApp(string startArg, IconStartType type)
|
||||
{
|
||||
if (type == IconStartType.SHOW_IN_EXPLORE)
|
||||
{
|
||||
Growl.WarningGlobal("系统项目不支持打开文件位置操作!");
|
||||
return;
|
||||
}
|
||||
switch (startArg)
|
||||
{
|
||||
case "Calculator":
|
||||
Process.Start("calc.exe");
|
||||
break;
|
||||
case "Computer":
|
||||
Process.Start("explorer.exe");
|
||||
break;
|
||||
case "GroupPolicy":
|
||||
Process.Start("gpedit.msc");
|
||||
break;
|
||||
case "Notepad":
|
||||
Process.Start("notepad");
|
||||
break;
|
||||
case "Network":
|
||||
Process.Start("ncpa.cpl");
|
||||
break;
|
||||
case "RecycleBin":
|
||||
Process.Start("shell:RecycleBinFolder");
|
||||
break;
|
||||
case "Registry":
|
||||
Process.Start("regedit.exe");
|
||||
break;
|
||||
case "Mstsc":
|
||||
if (type == IconStartType.ADMIN_STARTUP)
|
||||
{
|
||||
Process.Start("mstsc", "-admin");
|
||||
}
|
||||
else
|
||||
{
|
||||
Process.Start("mstsc");
|
||||
}
|
||||
break;
|
||||
case "Control":
|
||||
Process.Start("Control");
|
||||
break;
|
||||
case "CMD":
|
||||
if (type == IconStartType.ADMIN_STARTUP)
|
||||
{
|
||||
using (Process process = new Process())
|
||||
{
|
||||
process.StartInfo.FileName = "cmd.exe";
|
||||
process.StartInfo.Verb = "runas";
|
||||
process.Start();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Process.Start("cmd");
|
||||
}
|
||||
break;
|
||||
case "Services":
|
||||
Process.Start("services.msc");
|
||||
break;
|
||||
}
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (MainWindow.appData.AppConfig.MarginHide)
|
||||
{
|
||||
if (!MarginHide.IS_HIDE)
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user