@@ -5,8 +5,8 @@ namespace GeekDesk.Constant
|
||||
{
|
||||
public enum CommonEnum
|
||||
{
|
||||
WINDOW_WIDTH = 666, //默认窗体宽度
|
||||
WINDOW_HEIGHT = 500, //默认窗体高度
|
||||
WINDOW_WIDTH = 850, //默认窗体宽度
|
||||
WINDOW_HEIGHT = 600, //默认窗体高度
|
||||
MENU_CARD_WIDHT = 165, //默认菜单栏宽度
|
||||
IMAGE_WIDTH = 45, //默认图标宽度
|
||||
IMAGE_HEIGHT = 45, //默认图标高度
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace GeekDesk.Constant
|
||||
|
||||
public static string ERROR_FILE_PATH = APP_DIR + "Error.log";
|
||||
|
||||
public static int SHADOW_WIDTH = 20;
|
||||
|
||||
//系统图标
|
||||
public static Hashtable SYSTEM_ICONS = (Hashtable)ConfigurationManager.GetSection("SystemIcons");
|
||||
|
||||
|
||||
26
Constant/RunTimeStatus.cs
Normal file
26
Constant/RunTimeStatus.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.Constant
|
||||
{
|
||||
internal class RunTimeStatus
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 查询框是否在工作
|
||||
/// </summary>
|
||||
public static bool SEARCH_BOX_SHOW = false;
|
||||
|
||||
/// <summary>
|
||||
/// 贴边隐藏后 以非鼠标经过方式触发显示
|
||||
/// </summary>
|
||||
public static bool MARGIN_HIDE_AND_OTHER_SHOW = false;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,9 @@
|
||||
public enum SortType
|
||||
{
|
||||
CUSTOM = 1, //自定义排序
|
||||
NAME = 2, //按名称排序
|
||||
COUNT = 3 //按使用次数排序
|
||||
COUNT_UP = 2, //按使用次数升序
|
||||
COUNT_LOW = 3, //按使用次数降序
|
||||
NAME_UP = 4, //按名称升序
|
||||
NAME_LOW = 5, //按名称降序
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox Content="鼠标中间呼出" Click="MouseMiddle_Changed" IsChecked="{Binding MouseMiddleShow}">
|
||||
<CheckBox Content="鼠标中键呼出" Click="MouseMiddle_Changed" IsChecked="{Binding MouseMiddleShow}">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
@@ -60,6 +60,16 @@
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox Content="悬停切换菜单" IsChecked="{Binding HoverMenu}">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
</LinearGradientBrush>
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox Content="贴边隐藏" IsChecked="{Binding MarginHide}" Click="MarginHide_Changed">
|
||||
<CheckBox.Background>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Control.Windows;
|
||||
using GeekDesk.Thread;
|
||||
using GeekDesk.MyThread;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using HandyControl.Data;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
<UserControl.Resources>
|
||||
<cvt:UpdateTypeConvert x:Key="UpdateTypeConvert"/>
|
||||
<cvt:SortTypeConvert x:Key="SortTypeConvert"/>
|
||||
</UserControl.Resources>
|
||||
<Grid MouseDown="DragMove" Background="Transparent">
|
||||
<hc:SimplePanel Margin="20" >
|
||||
@@ -40,6 +41,45 @@
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
<TextBlock Text="排序方式" Margin="0,25,0,0"/>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="20,8,0,0">
|
||||
<RadioButton x:Name="CustomSort" Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
|
||||
Style="{StaticResource RadioButtonIcon}" Content="自定义"
|
||||
Tag="1"
|
||||
hc:IconElement.Geometry="{StaticResource CustomSort}"
|
||||
PreviewMouseLeftButtonDown="SortType_PreviewMouseLeftButtonDown"
|
||||
IsChecked="{Binding IconSortType, Mode=OneWay, Converter={StaticResource SortTypeConvert}, ConverterParameter=1}"/>
|
||||
|
||||
<RadioButton x:Name="CountUpSort" Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
|
||||
hc:IconElement.Geometry="{StaticResource UpSort}"
|
||||
Style="{StaticResource RadioButtonIcon}" Content="使用次数"
|
||||
Tag="2"
|
||||
PreviewMouseLeftButtonDown="SortType_PreviewMouseLeftButtonDown"
|
||||
IsChecked="{Binding IconSortType, Mode=OneWay, Converter={StaticResource SortTypeConvert}, ConverterParameter=2}"/>
|
||||
|
||||
<RadioButton x:Name="CountLowSort" Margin="10,0,0,0" Visibility="Collapsed" Background="{DynamicResource SecondaryRegionBrush}"
|
||||
hc:IconElement.Geometry="{StaticResource LowSort}"
|
||||
Style="{StaticResource RadioButtonIcon}" Content="使用次数"
|
||||
Tag="3"
|
||||
PreviewMouseLeftButtonDown="SortType_PreviewMouseLeftButtonDown"
|
||||
IsChecked="{Binding IconSortType, Mode=OneWay, Converter={StaticResource SortTypeConvert}, ConverterParameter=3}"/>
|
||||
|
||||
<RadioButton x:Name="NameUpSort" Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
|
||||
hc:IconElement.Geometry="{StaticResource UpSort}"
|
||||
Style="{StaticResource RadioButtonIcon}" Content="名称"
|
||||
Tag="4"
|
||||
PreviewMouseLeftButtonDown="SortType_PreviewMouseLeftButtonDown"
|
||||
IsChecked="{Binding IconSortType, Mode=OneWay, Converter={StaticResource SortTypeConvert}, ConverterParameter=4}"/>
|
||||
|
||||
<RadioButton x:Name="NameLowSort" Margin="10,0,0,0" Visibility="Collapsed" Background="{DynamicResource SecondaryRegionBrush}"
|
||||
hc:IconElement.Geometry="{StaticResource LowSort}"
|
||||
Style="{StaticResource RadioButtonIcon}" Content="名称"
|
||||
Tag="5"
|
||||
PreviewMouseLeftButtonDown="SortType_PreviewMouseLeftButtonDown"
|
||||
IsChecked="{Binding IconSortType, Mode=OneWay, Converter={StaticResource SortTypeConvert}, ConverterParameter=5}"/>
|
||||
|
||||
</hc:UniformSpacingPanel>
|
||||
<TextBlock Text="更新源" Margin="0,25,0,0"/>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="20,8,0,0">
|
||||
<RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
|
||||
|
||||
@@ -26,6 +26,13 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
public OtherControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Loaded += OtherControl_Loaded;
|
||||
|
||||
}
|
||||
|
||||
private void OtherControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Sort_Check();
|
||||
}
|
||||
|
||||
private void SelfStartUpBox_Click(object sender, RoutedEventArgs e)
|
||||
@@ -46,5 +53,70 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
Window.GetWindow(this).DragMove();
|
||||
}
|
||||
}
|
||||
|
||||
private void SortType_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
RadioButton rb = sender as RadioButton;
|
||||
SortType type = (SortType)int.Parse(rb.Tag.ToString());
|
||||
|
||||
SortType resType = type;
|
||||
switch (type)
|
||||
{
|
||||
case SortType.CUSTOM:
|
||||
break;
|
||||
case SortType.COUNT_UP:
|
||||
if (rb.IsChecked == true)
|
||||
{
|
||||
CountLowSort.IsChecked = true;
|
||||
CountUpSort.Visibility = Visibility.Collapsed;
|
||||
CountLowSort.Visibility = Visibility.Visible;
|
||||
resType = SortType.COUNT_LOW;
|
||||
}
|
||||
break;
|
||||
case SortType.COUNT_LOW:
|
||||
if (rb.IsChecked == true)
|
||||
{
|
||||
CountUpSort.IsChecked = true;
|
||||
CountLowSort.Visibility = Visibility.Collapsed;
|
||||
CountUpSort.Visibility = Visibility.Visible;
|
||||
resType = SortType.COUNT_UP;
|
||||
}
|
||||
break;
|
||||
case SortType.NAME_UP:
|
||||
if (rb.IsChecked == true)
|
||||
{
|
||||
NameLowSort.IsChecked = true;
|
||||
NameUpSort.Visibility = Visibility.Collapsed;
|
||||
NameLowSort.Visibility = Visibility.Visible;
|
||||
resType = SortType.NAME_LOW;
|
||||
}
|
||||
break;
|
||||
case SortType.NAME_LOW:
|
||||
if (rb.IsChecked == true)
|
||||
{
|
||||
NameUpSort.IsChecked = true;
|
||||
NameLowSort.Visibility = Visibility.Collapsed;
|
||||
NameUpSort.Visibility = Visibility.Visible;
|
||||
resType = SortType.NAME_UP;
|
||||
}
|
||||
break;
|
||||
}
|
||||
MainWindow.appData.AppConfig.IconSortType = resType;
|
||||
CommonCode.SortIconList();
|
||||
}
|
||||
|
||||
private void Sort_Check()
|
||||
{
|
||||
if (NameLowSort.IsChecked == true)
|
||||
{
|
||||
NameUpSort.Visibility = Visibility.Collapsed;
|
||||
NameLowSort.Visibility = Visibility.Visible;
|
||||
}
|
||||
if (CountLowSort.IsChecked == true)
|
||||
{
|
||||
CountUpSort.Visibility = Visibility.Collapsed;
|
||||
CountLowSort.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
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.UserControls.Config"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
Background="Transparent"
|
||||
@@ -133,19 +132,26 @@
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
|
||||
<TextBlock VerticalAlignment="Center" Text="图标字体颜色:" />
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding TextColor}" Width="100"/>
|
||||
<Button Content="选择" Click="ColorButton_Click"/>
|
||||
<Button Content="选择" Margin="0,-10,0,0" Click="ColorButton_Click"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<StackPanel x:Name="ColorPanel" Visibility="Collapsed" VerticalAlignment="Center">
|
||||
<StackPanel x:Name="ColorPanel" Panel.ZIndex="1"
|
||||
Visibility="Collapsed"
|
||||
Height="500"
|
||||
Width="450"
|
||||
VerticalAlignment="Center">
|
||||
<StackPanel.Background>
|
||||
<SolidColorBrush Color="AliceBlue" Opacity="0"/>
|
||||
</StackPanel.Background>
|
||||
<hc:ColorPicker
|
||||
Name="ColorPicker"
|
||||
Canceled="ColorPicker_Canceled"
|
||||
SelectedColorChanged="ColorPicker_SelectedColorChanged"/>
|
||||
|
||||
<hc:ColorPicker Name="MyColorPicker"
|
||||
ToggleButton.Checked="MyColorPicker_Checked"
|
||||
Canceled="MyColorPicker_Canceled"
|
||||
Confirmed="MyColorPicker_Confirmed"
|
||||
SelectedColorChanged="MyColorPicker_SelectedColorChanged"/>
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
|
||||
@@ -6,13 +6,17 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
@@ -27,6 +31,8 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
{
|
||||
|
||||
private static AppConfig appConfig = MainWindow.appData.AppConfig;
|
||||
|
||||
private System.Windows.Controls.Primitives.ToggleButton toggleButton = null;
|
||||
public ThemeControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -84,16 +90,24 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
ColorPanel.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void ColorPicker_Canceled(object sender, EventArgs e)
|
||||
/// <summary>
|
||||
/// 取消按钮事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MyColorPicker_Canceled(object sender, EventArgs e)
|
||||
{
|
||||
ColorPanel.Visibility = Visibility.Collapsed;
|
||||
MyColorPickerClose(sender);
|
||||
}
|
||||
private void MyColorPicker_Confirmed(object sender, HandyControl.Data.FunctionEventArgs<Color> e)
|
||||
{
|
||||
MyColorPickerClose(sender);
|
||||
}
|
||||
|
||||
private void ColorPicker_SelectedColorChanged(object sender, HandyControl.Data.FunctionEventArgs<Color> e)
|
||||
private void MyColorPicker_SelectedColorChanged(object sender, HandyControl.Data.FunctionEventArgs<Color> e)
|
||||
{
|
||||
SolidColorBrush scb = ColorPicker.SelectedBrush;
|
||||
SolidColorBrush scb = MyColorPicker.SelectedBrush;
|
||||
appConfig.TextColor = scb.ToString();
|
||||
ColorPanel.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -143,5 +157,27 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void MyColorPicker_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
toggleButton = e.OriginalSource as System.Windows.Controls.Primitives.ToggleButton;
|
||||
}
|
||||
|
||||
|
||||
private void MyColorPickerClose(object sender)
|
||||
{
|
||||
if (toggleButton != null && toggleButton.IsChecked == true)
|
||||
{
|
||||
HandyControl.Controls.ColorPicker cp = sender as HandyControl.Controls.ColorPicker;
|
||||
const BindingFlags InstanceBindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
|
||||
Type type = cp.GetType();
|
||||
toggleButton.IsChecked = false;
|
||||
MethodInfo mi = type.GetMethod("ToggleButtonDropper_Click", InstanceBindFlags);
|
||||
mi.Invoke(cp, new object[] { null, null });
|
||||
}
|
||||
ColorPanel.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<EventSetter Event="MouseLeftButtonDown" Handler="MenuClick"/>
|
||||
<EventSetter Event="MouseRightButtonDown" Handler="MenuClick"/>
|
||||
<EventSetter Event="MouseEnter" Handler="Menu_MouseEnter"/>
|
||||
<!--<EventSetter Event="Unselected" Handler="Lbi_Unselected"/>-->
|
||||
<Style.Triggers>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
@@ -43,14 +43,33 @@
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</MultiTrigger.ExitActions>
|
||||
<MultiTrigger.Setters>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
</MultiTrigger.Setters>
|
||||
</MultiTrigger>
|
||||
<!--<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#FFE4DBDB"/>
|
||||
</Trigger>-->
|
||||
<Trigger Property="IsSelected" Value="true">
|
||||
<Setter Property="Background" Value="#FFECECEC"/>
|
||||
|
||||
|
||||
<!--移到代码设置-->
|
||||
<!--<Trigger Property="IsSelected" Value="False">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="#ECECEC"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
</Trigger>
|
||||
|
||||
<Trigger Property="IsMouseOver" Value="False">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
</Trigger>-->
|
||||
<Trigger Property="IsMouseOver" Value="False">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
</Trigger>
|
||||
|
||||
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<cvt:MenuWidthConvert x:Key="MenuWidthConvert"/>
|
||||
@@ -61,6 +80,7 @@
|
||||
BorderThickness="1"
|
||||
Effect="{DynamicResource EffectShadow2}"
|
||||
Margin="5,0,0,5"
|
||||
MouseDown="MyCard_MouseDown"
|
||||
>
|
||||
<hc:Card.Background>
|
||||
<SolidColorBrush Color="#FFFFFFFF" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}">
|
||||
@@ -77,12 +97,13 @@
|
||||
</hc:Card.ContextMenu>
|
||||
<WrapPanel Orientation="Horizontal">
|
||||
<ListBox x:Name="MenuListBox"
|
||||
Padding="2,3,0,2"
|
||||
ItemsSource="{Binding MenuList}"
|
||||
Tag="{Binding AppConfig.MenuCardWidth}"
|
||||
BorderThickness="0" Foreground="{x:Null}"
|
||||
SelectedIndex="{Binding AppConfig.SelectedMenuIndex}"
|
||||
VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
SelectionChanged="menus_SelectionChanged"
|
||||
SelectionChanged="Menu_SelectionChanged"
|
||||
>
|
||||
<ListBox.Resources>
|
||||
<ContextMenu x:Key="MenuDialog" Width="200">
|
||||
@@ -110,21 +131,24 @@
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel MouseLeftButtonDown="MenuClick" MouseRightButtonDown="MenuClick" Tag="{Binding}">
|
||||
<hc:TextBox Text="{Binding Path=MenuName, Mode=TwoWay}"
|
||||
<StackPanel Tag="{Binding}" MouseDown="ListBoxItem_MouseDown">
|
||||
<TextBox Text="{Binding Path=MenuName, Mode=TwoWay}"
|
||||
HorizontalAlignment="Left"
|
||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}, ConverterParameter=35}"
|
||||
FontSize="16"
|
||||
Height="25"
|
||||
Height="28"
|
||||
VerticalAlignment="Center"
|
||||
TextAlignment="Left"
|
||||
LostFocus="LostFocusOrEnterDown"
|
||||
KeyDown="LostFocusOrEnterDown"
|
||||
Tag="{Binding}"
|
||||
Margin="2"
|
||||
Padding="2"
|
||||
BorderThickness="0"
|
||||
IsVisibleChanged="MenuEditWhenVisibilityChanged"
|
||||
Visibility="{Binding MenuEdit}"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<StackPanel Orientation="Horizontal"
|
||||
IsVisibleChanged="MenuWhenVisibilityChanged"
|
||||
Visibility="{Binding NotMenuEdit}">
|
||||
<Button Background="Transparent"
|
||||
BorderThickness="0"
|
||||
hc:IconElement.Geometry="{Binding MenuGeometry}"
|
||||
@@ -138,8 +162,6 @@
|
||||
HorizontalAlignment="Center"
|
||||
TextAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
IsVisibleChanged="MenuWhenVisibilityChanged"
|
||||
Visibility="{Binding NotMenuEdit}"
|
||||
/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
using DraggAnimatedPanelExample;
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Control.Windows;
|
||||
using GeekDesk.MyThread;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using System;
|
||||
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
@@ -21,16 +24,65 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
private int menuSelectIndexTemp = -1;
|
||||
private AppData appData = MainWindow.appData;
|
||||
private SolidColorBrush bac = new SolidColorBrush(Color.FromRgb(236, 236, 236));
|
||||
|
||||
|
||||
//是否正在修改菜单
|
||||
private static bool IS_EDIT = false;
|
||||
|
||||
public LeftCardControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
this.Loaded += (s, e) =>
|
||||
{
|
||||
SelectLastMenu();
|
||||
SetMenuListBoxItemEvent();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private void SetMenuListBoxItemEvent()
|
||||
{
|
||||
int size = MenuListBox.Items.Count;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
ListBoxItem lbi = (ListBoxItem)(MenuListBox.ItemContainerGenerator.ContainerFromIndex(i));
|
||||
if (lbi != null)
|
||||
{
|
||||
SetListBoxItemEvent(lbi);
|
||||
}
|
||||
}
|
||||
//首次触发不了Selected事件
|
||||
object obj = MenuListBox.ItemContainerGenerator.ContainerFromIndex(MenuListBox.SelectedIndex);
|
||||
Lbi_Selected(obj, null);
|
||||
}
|
||||
|
||||
private void SetListBoxItemEvent(ListBoxItem lbi)
|
||||
{
|
||||
lbi.MouseEnter += (s, me) =>
|
||||
{
|
||||
lbi.Background = bac;
|
||||
};
|
||||
lbi.Unselected += Lbi_Unselected;
|
||||
|
||||
lbi.MouseLeave += Lbi_MouseLeave;
|
||||
|
||||
lbi.Selected += Lbi_Selected;
|
||||
}
|
||||
|
||||
private void SelectLastMenu()
|
||||
{
|
||||
if (appData.AppConfig.SelectedMenuIndex >= appData.MenuList.Count || appData.AppConfig.SelectedMenuIndex == -1)
|
||||
{
|
||||
MenuListBox.SelectedIndex = 0;
|
||||
appData.AppConfig.SelectedMenuIndex = MenuListBox.SelectedIndex;
|
||||
appData.AppConfig.SelectedMenuIcons = appData.MenuList[0].IconList;
|
||||
}
|
||||
else
|
||||
{
|
||||
MenuListBox.SelectedIndex = appData.AppConfig.SelectedMenuIndex;
|
||||
appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
|
||||
}
|
||||
}
|
||||
@@ -60,13 +112,6 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
}
|
||||
}
|
||||
|
||||
////菜单点击事件
|
||||
private void MenuClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
//设置对应菜单的图标列表
|
||||
MenuInfo mi = (MenuInfo)(((StackPanel)sender).Tag);
|
||||
appData.AppConfig.SelectedMenuIcons = mi.IconList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当修改菜单元素可见时 设置原菜单为不可见 并且不可选中
|
||||
@@ -76,9 +121,12 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
/// <param name="e"></param>
|
||||
private void MenuWhenVisibilityChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
TextBlock tb = sender as TextBlock;
|
||||
if (tb.Visibility == Visibility.Collapsed)
|
||||
StackPanel sp = sender as StackPanel;
|
||||
|
||||
ListBoxItem lbi = (sp.TemplatedParent as ContentPresenter).TemplatedParent as ListBoxItem;
|
||||
if (sp.Visibility == Visibility.Collapsed)
|
||||
{
|
||||
lbi.MouseEnter += Lbi_MouseEnter;
|
||||
if (MenuListBox.SelectedIndex != -1)
|
||||
{
|
||||
menuSelectIndexTemp = MenuListBox.SelectedIndex;
|
||||
@@ -89,7 +137,50 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
MenuListBox.SelectedIndex = menuSelectIndexTemp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lbi.MouseEnter += (s, me) =>
|
||||
{
|
||||
lbi.Background = bac;
|
||||
};
|
||||
|
||||
lbi.MouseLeave += Lbi_MouseLeave;
|
||||
lbi.Selected += Lbi_Selected;
|
||||
}
|
||||
}
|
||||
|
||||
#region 设置菜单触发事件
|
||||
private void Lbi_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
ListBoxItem lbi = sender as ListBoxItem;
|
||||
lbi.Background = Brushes.Transparent;
|
||||
}
|
||||
|
||||
private void Lbi_Unselected(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//添加Leave效果
|
||||
ListBoxItem lbi = sender as ListBoxItem;
|
||||
lbi.Background = Brushes.Transparent;
|
||||
lbi.MouseLeave += Lbi_MouseLeave;
|
||||
}
|
||||
|
||||
private void Lbi_Selected(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ListBoxItem lbi = sender as ListBoxItem;
|
||||
|
||||
SolidColorBrush fontColor = new SolidColorBrush(Colors.Black);
|
||||
|
||||
lbi.MouseLeave -= Lbi_MouseLeave;
|
||||
lbi.Background = bac;
|
||||
lbi.Foreground = fontColor;
|
||||
}
|
||||
|
||||
private void Lbi_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
ListBoxItem lbi = sender as ListBoxItem;
|
||||
lbi.Background = Brushes.Transparent;
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 新建菜单
|
||||
@@ -100,12 +191,16 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
MenuInfo info = new MenuInfo() { MenuEdit = Visibility.Collapsed, MenuId = System.Guid.NewGuid().ToString(), MenuName = "NewMenu" };
|
||||
appData.MenuList.Add(info);
|
||||
MenuListBox.Items.Refresh();
|
||||
MenuListBox.SelectedIndex = appData.MenuList.Count - 1;
|
||||
appData.AppConfig.SelectedMenuIndex = MenuListBox.SelectedIndex;
|
||||
appData.AppConfig.SelectedMenuIcons = info.IconList;
|
||||
//首次触发不了Selected事件
|
||||
object obj = MenuListBox.ItemContainerGenerator.ContainerFromIndex(MenuListBox.SelectedIndex);
|
||||
SetListBoxItemEvent((ListBoxItem)obj);
|
||||
Lbi_Selected(obj, null);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重命名菜单 将textbox 设置为可见
|
||||
/// </summary>
|
||||
@@ -115,6 +210,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo;
|
||||
menuInfo.MenuEdit = (int)Visibility.Visible;
|
||||
IS_EDIT = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -134,9 +230,10 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
if (index == 0)
|
||||
{
|
||||
index = 0;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
index = index - 1;
|
||||
index--;
|
||||
}
|
||||
|
||||
appData.MenuList.Remove(menuInfo);
|
||||
@@ -153,6 +250,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
/// <param name="e"></param>
|
||||
private void LostFocusOrEnterDown(object sender, EventArgs e)
|
||||
{
|
||||
bool done = true;
|
||||
TextBox menuBox = null;
|
||||
if (e.GetType() == typeof(KeyEventArgs))
|
||||
{
|
||||
@@ -161,12 +259,18 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
menuBox = ((TextBox)sender);
|
||||
}
|
||||
else
|
||||
{
|
||||
done = false;
|
||||
}
|
||||
}
|
||||
else if (e.GetType() == typeof(RoutedEventArgs))
|
||||
{
|
||||
menuBox = ((TextBox)sender);
|
||||
}
|
||||
|
||||
if (done)
|
||||
{
|
||||
if (menuBox != null)
|
||||
{
|
||||
MenuInfo menuInfo = menuBox.Tag as MenuInfo;
|
||||
@@ -174,6 +278,9 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
menuInfo.MenuName = text;
|
||||
menuInfo.MenuEdit = Visibility.Collapsed;
|
||||
}
|
||||
IS_EDIT = false;
|
||||
MenuListBox.SelectedIndex = menuSelectIndexTemp;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -184,6 +291,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
private void MenuEditWhenVisibilityChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
TextBox box = sender as TextBox;
|
||||
MenuInfo mi = box.Tag as MenuInfo;
|
||||
if (box.Visibility == Visibility.Visible)
|
||||
{
|
||||
Keyboard.Focus(box);
|
||||
@@ -202,17 +310,68 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
IconfontWindow.Show(SvgToGeometry.GetIconfonts(), menuInfo);
|
||||
}
|
||||
|
||||
private void menus_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
private void Menu_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
//设置对应菜单的图标列表
|
||||
if (MenuListBox.SelectedIndex == -1)
|
||||
{
|
||||
appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.MenuList.Count - 1].IconList;
|
||||
//appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.MenuList.Count - 1].IconList;
|
||||
}
|
||||
else
|
||||
{
|
||||
appData.AppConfig.SelectedMenuIcons = appData.MenuList[MenuListBox.SelectedIndex].IconList;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标悬停切换菜单
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Menu_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (appData.AppConfig.HoverMenu && !IS_EDIT)
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(200);
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
ListBoxItem lbi = sender as ListBoxItem;
|
||||
if (lbi.IsMouseOver)
|
||||
{
|
||||
int index = MenuListBox.ItemContainerGenerator.IndexFromContainer(lbi);
|
||||
MenuListBox.SelectedIndex = index;
|
||||
}
|
||||
});
|
||||
}).Start();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 点击菜单后 隐藏搜索框
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ListBoxItem_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (RunTimeStatus.SEARCH_BOX_SHOW) {
|
||||
MainWindow.mainWindow.HidedSearchBox();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 隐藏搜索框
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MyCard_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (RunTimeStatus.SEARCH_BOX_SHOW)
|
||||
{
|
||||
MainWindow.mainWindow.HidedSearchBox();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
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.UserControls.PannelCard"
|
||||
xmlns:temp="clr-namespace:GeekDesk.ViewModel.Temp"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
||||
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
|
||||
@@ -12,6 +12,22 @@
|
||||
>
|
||||
<UserControl.Resources>
|
||||
<!--右侧栏样式动画-->
|
||||
<!--<Style x:Key="PanelStyle" TargetType="hc:SimpleStackPanel">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="true">
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>-->
|
||||
|
||||
<Storyboard x:Key="Custom1Transition" x:Shared="False">
|
||||
<DoubleAnimation From="50" To="0" Duration="0:0:0.4" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
|
||||
<DoubleAnimation.EasingFunction>
|
||||
<ElasticEase Oscillations="1"/>
|
||||
</DoubleAnimation.EasingFunction>
|
||||
</DoubleAnimation>
|
||||
</Storyboard>
|
||||
|
||||
<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}"/>
|
||||
@@ -31,9 +47,14 @@
|
||||
</Style>
|
||||
|
||||
<cvt:OpcityConvert x:Key="OpcityConvert"/>
|
||||
<cvt:SearchResWidth x:Key="SearchResWidth"/>
|
||||
<temp:SearchIconList x:Key="SearchIconList"/>
|
||||
</UserControl.Resources>
|
||||
<!--右侧栏-->
|
||||
<Grid>
|
||||
<hc:Card AllowDrop="True"
|
||||
x:Name="WrapCard"
|
||||
Visibility="Visible"
|
||||
Drop="Wrap_Drop"
|
||||
BorderThickness="1"
|
||||
Effect="{DynamicResource EffectShadow2}"
|
||||
@@ -50,11 +71,13 @@
|
||||
<MenuItem Header="添加系统项目" Click="AddSystemIcon"/>
|
||||
</ContextMenu>
|
||||
</hc:Card.ContextMenu>
|
||||
<Grid>
|
||||
<StackPanel Panel.ZIndex="1" Margin="0,-10,-300,0" hc:Growl.GrowlParent="True" hc:Growl.Token="MainWindowGrowl"/>
|
||||
<WrapPanel Orientation="Horizontal" VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
VirtualizingPanel.IsVirtualizing="True"
|
||||
VirtualizingPanel.IsContainerVirtualizable="True"
|
||||
>
|
||||
<ListBox x:Name="IconListBox" ItemsSource="{Binding AppConfig.SelectedMenuIcons, Mode=TwoWay}"
|
||||
<ListBox x:Name="IconListBox" ItemsSource="{Binding AppConfig.SelectedMenuIcons, Mode=OneWay}"
|
||||
BorderThickness="0"
|
||||
Padding="0,10,0,0"
|
||||
>
|
||||
@@ -86,12 +109,8 @@
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem" BasedOn="{StaticResource MyListBoxItemStyle}">
|
||||
<Setter Property="ContextMenu" Value="{StaticResource IconDialog}"/>
|
||||
<!--<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImgPanelWidth, Mode=OneWay}"/>
|
||||
<Setter Property="Height" Value="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImgPanelHeight, Mode=OneWay}"/>-->
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
<!--Height="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImgPanelHeight, Mode=OneWay}"
|
||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImgPanelWidth, Mode=OneWay}"-->
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
@@ -99,17 +118,20 @@
|
||||
Height="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImgPanelHeight, Mode=OneWay}"
|
||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImgPanelWidth, Mode=OneWay}"
|
||||
HorizontalAlignment="Center"
|
||||
hc:Poptip.HitMode="None"
|
||||
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
|
||||
hc:Poptip.Content="{Binding Content}"
|
||||
hc:Poptip.Placement="BottomLeft"
|
||||
Background="#00FFFFFF"
|
||||
MouseLeftButtonDown="Icon_MouseLeftButtonDown"
|
||||
MouseLeftButtonUp="Icon_MouseLeftButtonUp"
|
||||
MouseEnter="StackPanel_MouseEnter"
|
||||
MouseLeave="StackPanel_MouseLeave"
|
||||
MouseLeftButtonDown="Icon_MouseLeftButtonDown"
|
||||
MouseLeftButtonUp="Icon_MouseLeftButtonUp"
|
||||
>
|
||||
<Image Style="{StaticResource ImageStyle}" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
<!--<StackPanel Background="#00FFFFFF"
|
||||
MouseEnter="CursorPanel_MouseEnter"
|
||||
MouseLeave="CursorPanel_MouseLeave"
|
||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageWidth, Mode=OneWay}">-->
|
||||
<Image Style="{StaticResource ImageStyle}"
|
||||
RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
<TextBlock MaxWidth="80"
|
||||
Margin="0,5,0,0"
|
||||
MaxHeight="40"
|
||||
@@ -120,11 +142,109 @@
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.TextColor}"
|
||||
Text="{Binding Name}"/>
|
||||
<!--</StackPanel>-->
|
||||
|
||||
</hc:SimpleStackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
</WrapPanel>
|
||||
|
||||
</Grid>
|
||||
</hc:Card>
|
||||
|
||||
<hc:Card x:Name="VerticalCard"
|
||||
Visibility="Hidden"
|
||||
BorderThickness="1"
|
||||
Effect="{DynamicResource EffectShadow2}"
|
||||
Margin="5,0,5,5" Grid.ColumnSpan="2"
|
||||
MouseLeftButtonDown="VerticalCard_MouseLeftButtonDown"
|
||||
>
|
||||
<hc:Card.Background>
|
||||
<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>
|
||||
<StackPanel Panel.ZIndex="1" Margin="0,-10,-300,0" hc:Growl.GrowlParent="True" hc:Growl.Token="MainWindowGrowl"/>
|
||||
<WrapPanel Orientation="Horizontal" VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
VirtualizingPanel.IsVirtualizing="True"
|
||||
VirtualizingPanel.IsContainerVirtualizable="True"
|
||||
>
|
||||
<hc:TransitioningContentControl TransitionStoryboard="{StaticResource Custom1Transition}">
|
||||
<ListBox ItemsSource="{Binding Source={StaticResource SearchIconList},Path=IconList}"
|
||||
BorderThickness="0"
|
||||
Padding="0,10,0,0"
|
||||
>
|
||||
<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 MyListBoxItemStyle}">
|
||||
<Setter Property="ContextMenu" Value="{StaticResource IconDialog}"/>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Background="#00FFFFFF"
|
||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.MenuCardWidth, Mode=OneWay, Converter={StaticResource SearchResWidth}, ConverterParameter=1}"
|
||||
/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<WrapPanel Tag="{Binding}"
|
||||
Height="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageHeight, Mode=OneWay}"
|
||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.MenuCardWidth, Mode=OneWay, Converter={StaticResource SearchResWidth}, ConverterParameter=2}"
|
||||
HorizontalAlignment="Left"
|
||||
hc:Poptip.HitMode="None"
|
||||
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
|
||||
hc:Poptip.Content="{Binding Content}"
|
||||
hc:Poptip.Placement="BottomLeft"
|
||||
Background="#00FFFFFF"
|
||||
MouseLeftButtonDown="Icon_MouseLeftButtonDown"
|
||||
MouseLeftButtonUp="Icon_MouseLeftButtonUp"
|
||||
Margin="25,20,0,0"
|
||||
>
|
||||
<Image Style="{StaticResource ImageStyle}" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
<TextBlock
|
||||
Margin="10,5,0,0"
|
||||
MaxHeight="40"
|
||||
FontSize="13"
|
||||
TextWrapping="Wrap"
|
||||
TextTrimming="WordEllipsis"
|
||||
TextAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.TextColor}"
|
||||
Text="{Binding Name}"/>
|
||||
</WrapPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</hc:TransitioningContentControl>
|
||||
|
||||
|
||||
</WrapPanel>
|
||||
|
||||
</Grid>
|
||||
</hc:Card>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -26,6 +26,9 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
private AppData appData = MainWindow.appData;
|
||||
|
||||
private volatile static bool DROP_ICON = false;
|
||||
private Thread dropCheckThread = null;
|
||||
|
||||
public RightCardControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -42,6 +45,34 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
_swap = new DelegateCommand<int[]>(
|
||||
(indexes) =>
|
||||
{
|
||||
DROP_ICON = true;
|
||||
if (appData.AppConfig.IconSortType != SortType.CUSTOM
|
||||
&& (dropCheckThread == null || !dropCheckThread.IsAlive))
|
||||
{
|
||||
dropCheckThread = new Thread(() =>
|
||||
{
|
||||
do
|
||||
{
|
||||
DROP_ICON = false;
|
||||
Thread.Sleep(1000);
|
||||
} while (DROP_ICON);
|
||||
|
||||
MainWindow.appData.AppConfig.IconSortType = SortType.CUSTOM;
|
||||
App.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed
|
||||
|| MainWindow.mainWindow.Opacity != 1)
|
||||
{
|
||||
Growl.WarningGlobal("已将图标排序规则重置为自定义!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Warning("已将图标排序规则重置为自定义!", "MainWindowGrowl");
|
||||
}
|
||||
});
|
||||
});
|
||||
dropCheckThread.Start();
|
||||
}
|
||||
int fromS = indexes[0];
|
||||
int to = indexes[1];
|
||||
ObservableCollection<IconInfo> iconList = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
|
||||
@@ -86,7 +117,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
if (appData.AppConfig.DoubleOpen && e.ClickCount >= 2)
|
||||
{
|
||||
IconInfo icon = (IconInfo)((SimpleStackPanel)sender).Tag;
|
||||
IconInfo icon = (IconInfo)((Panel)sender).Tag;
|
||||
if (icon.AdminStartUp)
|
||||
{
|
||||
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
||||
@@ -98,7 +129,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
}
|
||||
else if (!appData.AppConfig.DoubleOpen && e.ClickCount == 1)
|
||||
{
|
||||
IconInfo icon = (IconInfo)((SimpleStackPanel)sender).Tag;
|
||||
IconInfo icon = (IconInfo)((Panel)sender).Tag;
|
||||
if (icon.AdminStartUp)
|
||||
{
|
||||
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
||||
@@ -165,9 +196,9 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
case IconStartType.ADMIN_STARTUP:
|
||||
//p.StartInfo.Arguments = "1";//启动参数
|
||||
p.StartInfo.Verb = "runas";
|
||||
p.StartInfo.CreateNoWindow = false; //设置显示窗口
|
||||
p.StartInfo.UseShellExecute = false;//不使用操作系统外壳程序启动进程
|
||||
p.StartInfo.ErrorDialog = false;
|
||||
//p.StartInfo.CreateNoWindow = false; //设置显示窗口
|
||||
p.StartInfo.UseShellExecute = true;//不使用操作系统外壳程序启动进程
|
||||
//p.StartInfo.ErrorDialog = false;
|
||||
if (appData.AppConfig.AppHideType == AppHideType.START_EXE)
|
||||
{
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
@@ -230,6 +261,12 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
}
|
||||
}
|
||||
icon.Count++;
|
||||
|
||||
//隐藏搜索框
|
||||
if (RunTimeStatus.SEARCH_BOX_SHOW)
|
||||
{
|
||||
MainWindow.mainWindow.HidedSearchBox();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -330,8 +367,9 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
string path = (string)obj;
|
||||
IconInfo iconInfo = CommonCode.GetIconInfoByPath(path);
|
||||
MainWindow.appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList.Add(iconInfo);
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
}
|
||||
CommonCode.SortIconList();
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -539,5 +577,51 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
SystemItemWindow.Show();
|
||||
}
|
||||
|
||||
public void VisibilitySearchCard(Visibility vb)
|
||||
{
|
||||
VerticalCard.Visibility = vb;
|
||||
if (vb == Visibility.Visible)
|
||||
{
|
||||
WrapCard.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
WrapCard.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 搜索Card点击事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void VerticalCard_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
//隐藏搜索框
|
||||
if (RunTimeStatus.SEARCH_BOX_SHOW)
|
||||
{
|
||||
MainWindow.mainWindow.HidedSearchBox();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置光标
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void CursorPanel_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
this.Cursor = Cursors.Hand;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置光标
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void CursorPanel_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
this.Cursor = Cursors.Arrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
33
Converts/SearchResWidth.cs
Normal file
33
Converts/SearchResWidth.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace GeekDesk.Converts
|
||||
{
|
||||
class SearchResWidth : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
string param = parameter as string;
|
||||
if ("1".Equals(param))
|
||||
{
|
||||
double menuLeftWidth = double.Parse(value.ToString());
|
||||
return MainWindow.mainWindow.Width - menuLeftWidth;
|
||||
} else
|
||||
{
|
||||
double menuLeftWidth = double.Parse(value.ToString());
|
||||
return (MainWindow.mainWindow.Width - menuLeftWidth) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Converts/SortTypeConvert.cs
Normal file
29
Converts/SortTypeConvert.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using GeekDesk.Constant;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace GeekDesk.Converts
|
||||
{
|
||||
public class SortTypeConvert : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return (SortType)value == (SortType)int.Parse(parameter.ToString());
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
bool isChecked = (bool)value;
|
||||
if (!isChecked)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (SortType)int.Parse(parameter.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,9 @@
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NPinyin.Core, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\NPinyin.Core.3.0.0\lib\net45\NPinyin.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Quartz, Version=3.3.3.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Quartz.3.3.3\lib\net472\Quartz.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -127,6 +130,7 @@
|
||||
<Compile Include="Constant\IconType.cs" />
|
||||
<Compile Include="Constant\CommonEnum.cs" />
|
||||
<Compile Include="Constant\IconStartType.cs" />
|
||||
<Compile Include="Constant\RunTimeStatus.cs" />
|
||||
<Compile Include="Constant\SortType.cs" />
|
||||
<Compile Include="Constant\TodoTaskExecType.cs" />
|
||||
<Compile Include="Constant\UpdateType.cs" />
|
||||
@@ -189,6 +193,8 @@
|
||||
</Compile>
|
||||
<Compile Include="Converts\DoubleToGridLength.cs" />
|
||||
<Compile Include="Converts\MenuInfoConvert.cs" />
|
||||
<Compile Include="Converts\SearchResWidth.cs" />
|
||||
<Compile Include="Converts\SortTypeConvert.cs" />
|
||||
<Compile Include="Converts\TodoTaskExecConvert.cs" />
|
||||
<Compile Include="Converts\IntToCornerRadius.cs" />
|
||||
<Compile Include="Converts\OpcityConvert.cs" />
|
||||
@@ -198,24 +204,20 @@
|
||||
<Compile Include="Converts\HideTypeConvert.cs" />
|
||||
<Compile Include="Interface\IWindowCommon.cs" />
|
||||
<Compile Include="Task\ToDoTask.cs" />
|
||||
<Compile Include="Thread\MouseHookThread.cs" />
|
||||
<Compile Include="Thread\DispatcherBuild.cs" />
|
||||
<Compile Include="Thread\UpdateThread.cs" />
|
||||
<Compile Include="MyThread\MouseHookThread.cs" />
|
||||
<Compile Include="MyThread\DispatcherBuild.cs" />
|
||||
<Compile Include="MyThread\UpdateThread.cs" />
|
||||
<Compile Include="Util\AeroGlassHelper.cs" />
|
||||
<Compile Include="Util\GlobalHotKey.cs" />
|
||||
<Compile Include="Util\CommonCode.cs" />
|
||||
<Compile Include="Util\ConsoleManager.cs" />
|
||||
<Compile Include="Util\DragAdorner.cs" />
|
||||
<Compile Include="Util\FileIcon.cs" />
|
||||
<Compile Include="Util\FileUtil.cs" />
|
||||
<Compile Include="Util\LogUtil.cs" />
|
||||
<Compile Include="Util\MarginHide.cs" />
|
||||
<Compile Include="Util\HttpUtil.cs" />
|
||||
<Compile Include="Util\ImageUtil.cs" />
|
||||
<Compile Include="Util\ListViewDragDropManager.cs" />
|
||||
<Compile Include="Converts\MenuWidthConvert.cs" />
|
||||
<Compile Include="Util\MouseUtil.cs" />
|
||||
<Compile Include="Util\MouseUtilities.cs" />
|
||||
<Compile Include="Util\RegisterUtil.cs" />
|
||||
<Compile Include="Util\ShellContextMenu.cs" />
|
||||
<Compile Include="Util\ShowWindowFollowMouse.cs" />
|
||||
@@ -223,6 +225,7 @@
|
||||
<Compile Include="Util\SvgToGeometry.cs" />
|
||||
<Compile Include="ViewModel\AppConfig.cs" />
|
||||
<Compile Include="ViewModel\AppData.cs" />
|
||||
<Compile Include="ViewModel\Temp\SearchIconList.cs" />
|
||||
<Compile Include="ViewModel\ToDoInfo.cs" />
|
||||
<Compile Include="ViewModel\IconfontInfo.cs" />
|
||||
<Compile Include="ViewModel\IconInfo.cs" />
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:GeekDesk"
|
||||
xmlns:uc="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
|
||||
mc:Ignorable="d"
|
||||
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
||||
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
|
||||
x:Name="window"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:AppData}"
|
||||
Title="GeekDesk"
|
||||
@@ -18,33 +16,43 @@
|
||||
Background="Transparent"
|
||||
ShowInTaskbar="False"
|
||||
Opacity="0"
|
||||
Deactivated="Window_Deactivated"
|
||||
Deactivated="App_LostFocus"
|
||||
SizeChanged="Window_SizeChanged"
|
||||
KeyDown="OnKeyDown"
|
||||
Focusable="True"
|
||||
MouseDown="MainWindow_MouseDown"
|
||||
MouseEnter="MainWindow_MouseEnter"
|
||||
>
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="0" ResizeBorderThickness="15"/>
|
||||
</WindowChrome.WindowChrome>
|
||||
<Window.Resources>
|
||||
<RoutedUICommand x:Key="SearchItem" Text="SearchItem"/>
|
||||
|
||||
<cvt:MenuWidthConvert x:Key="MenuWidthConvert"/>
|
||||
<cvt:OpcityConvert x:Key="OpcityConvert"/>
|
||||
<cvt:IntToCornerRadius x:Key="IntToCornerRadius"/>
|
||||
<cvt:DoubleToGridLength x:Key="DoubleToGridLength"/>
|
||||
</Window.Resources>
|
||||
<Window.InputBindings>
|
||||
<KeyBinding Gesture="Ctrl+F" Key="F" Command="{StaticResource SearchItem}"/>
|
||||
</Window.InputBindings>
|
||||
<Window.CommandBindings>
|
||||
<CommandBinding Command="{StaticResource SearchItem}" CanExecute="SearchItem"/>
|
||||
</Window.CommandBindings>
|
||||
|
||||
<Window.Effect>
|
||||
<DropShadowEffect BlurRadius="30" Direction="-90" Color="Gray"
|
||||
RenderingBias="Quality" ShadowDepth="2"/>
|
||||
</Window.Effect>
|
||||
<Border Margin="20" CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}" BorderThickness="0"
|
||||
Background="AliceBlue" LostFocus="App_LostFocus"
|
||||
Background="AliceBlue"
|
||||
Opacity="{Binding AppConfig.PannelOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"
|
||||
VirtualizingPanel.VirtualizationMode="Recycling" VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.IsContainerVirtualizable="True"
|
||||
hc:Dialog.Token="IconInfoDialog"
|
||||
Focusable="True"
|
||||
>
|
||||
<hc:DialogContainer>
|
||||
<hc:DialogContainer Focusable="True">
|
||||
|
||||
<Border CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}" BorderThickness="0">
|
||||
<!--背景图片-->
|
||||
@@ -62,6 +70,7 @@
|
||||
</VisualBrush>
|
||||
</Border.Background>
|
||||
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40" MouseMove="DragMove"></RowDefinition>
|
||||
@@ -69,9 +78,11 @@
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition x:Name="LeftColumn" MinWidth="80" Width="{Binding AppConfig.MenuCardWidth, Mode=TwoWay, Converter={StaticResource DoubleToGridLength}}" MaxWidth="200"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
<ColumnDefinition x:Name="RightColumn" Width="*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!--获取焦点用-->
|
||||
<TextBox x:Name="EmptyTextBox" Width="0"/>
|
||||
|
||||
|
||||
<DockPanel Grid.Row="0" Grid.Column="0" MouseMove="DragMove">
|
||||
@@ -123,7 +134,20 @@
|
||||
<!--分割线-->
|
||||
<GridSplitter Opacity="0" Grid.Row="1" Grid.Column="0" Width="1" VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
|
||||
|
||||
<uc:RightCardControl Grid.Row="1" Grid.Column="1"/>
|
||||
<!--搜索输入框-->
|
||||
<TextBox Panel.ZIndex="2" Grid.Row="0" Grid.Column="1"
|
||||
x:Name="SearchBox"
|
||||
Visibility="Collapsed"
|
||||
Margin="-100,5,0,0"
|
||||
Height="32"
|
||||
FontSize="16"
|
||||
Width="400"
|
||||
BorderThickness="0"
|
||||
TextChanged="SearchBox_TextChanged"
|
||||
/>
|
||||
|
||||
|
||||
<uc:RightCardControl x:Name="RightCard" Grid.Row="1" Grid.Column="1"/>
|
||||
|
||||
<hc:NotifyIcon Icon="/Taskbar.ico" Click="NotifyIcon_Click" x:Name="BarIcon"
|
||||
Visibility="{Binding AppConfig.ShowBarIcon, Mode=TwoWay, Converter={StaticResource Boolean2VisibilityConverter}}">
|
||||
|
||||
@@ -1,28 +1,23 @@
|
||||
using DraggAnimatedPanelExample;
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Control;
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Control.UserControls.Config;
|
||||
using GeekDesk.Control.Windows;
|
||||
using GeekDesk.Interface;
|
||||
using GeekDesk.Task;
|
||||
using GeekDesk.Thread;
|
||||
using GeekDesk.MyThread;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using Gma.System.MouseKeyHook;
|
||||
using HandyControl.Data;
|
||||
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using static GeekDesk.Util.ShowWindowFollowMouse;
|
||||
using System.Collections.ObjectModel;
|
||||
using NPinyin;
|
||||
using GeekDesk.ViewModel.Temp;
|
||||
using System.Threading;
|
||||
|
||||
namespace GeekDesk
|
||||
{
|
||||
@@ -48,6 +43,7 @@ namespace GeekDesk
|
||||
this.SizeChanged += MainWindow_Resize;
|
||||
ToDoTask.BackLogCheck();
|
||||
|
||||
|
||||
////实例化隐藏 Hide类,进行时间timer设置
|
||||
MarginHide.ReadyHide(this);
|
||||
if (appData.AppConfig.MarginHide)
|
||||
@@ -56,6 +52,59 @@ namespace GeekDesk
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示搜索框
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SearchItem(object sender, CanExecuteRoutedEventArgs e)
|
||||
{
|
||||
RunTimeStatus.SEARCH_BOX_SHOW = true;
|
||||
RightCard.VisibilitySearchCard(Visibility.Visible);
|
||||
SearchBox.Visibility = Visibility.Visible;
|
||||
SearchBox.Focus();
|
||||
}
|
||||
/// <summary>
|
||||
/// 搜索开始
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SearchBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
string inputText = SearchBox.Text.ToLower();
|
||||
if (!string.IsNullOrEmpty(inputText))
|
||||
{
|
||||
SearchIconList.IconList.Clear();
|
||||
ObservableCollection<MenuInfo> menuList = appData.MenuList;
|
||||
foreach (MenuInfo menu in menuList)
|
||||
{
|
||||
ObservableCollection<IconInfo> iconList = menu.IconList;
|
||||
foreach (IconInfo icon in iconList)
|
||||
{
|
||||
string pyName = Pinyin.GetInitials(icon.Name).ToLower();
|
||||
if (icon.Name.Contains(inputText) || pyName.Contains(inputText))
|
||||
{
|
||||
SearchIconList.IconList.Add(icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchIconList.IconList.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void HidedSearchBox()
|
||||
{
|
||||
RunTimeStatus.SEARCH_BOX_SHOW = false;
|
||||
SearchBox.Visibility = Visibility.Collapsed;
|
||||
SearchIconList.IconList.Clear();
|
||||
RightCard.VisibilitySearchCard(Visibility.Collapsed);
|
||||
SearchBox.Text = "";
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加载缓存数据
|
||||
/// </summary>
|
||||
@@ -72,6 +121,7 @@ namespace GeekDesk
|
||||
this.Height = appData.AppConfig.WindowHeight;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 窗口加载完毕 执行方法
|
||||
/// </summary>
|
||||
@@ -290,7 +340,7 @@ namespace GeekDesk
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ShowApp(object sender, RoutedEventArgs e)
|
||||
public void ShowApp(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowApp();
|
||||
}
|
||||
@@ -301,19 +351,53 @@ namespace GeekDesk
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
|
||||
//修改贴边隐藏状态为未隐藏
|
||||
if (MarginHide.ON_HIDE)
|
||||
{
|
||||
MarginHide.IS_HIDE = false;
|
||||
if (!CommonCode.MouseInWindow(mainWindow))
|
||||
{
|
||||
RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW = true;
|
||||
MarginHide.WaitHide(3000);
|
||||
}
|
||||
}
|
||||
|
||||
if (appData.AppConfig.FollowMouse)
|
||||
{
|
||||
ShowWindowFollowMouse.Show(mainWindow, MousePosition.CENTER, 0, 0, false);
|
||||
}
|
||||
|
||||
FadeStoryBoard(1, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Visible);
|
||||
Keyboard.Focus(mainWindow);
|
||||
|
||||
Keyboard.Focus(mainWindow.EmptyTextBox);
|
||||
}
|
||||
|
||||
public static void HideApp()
|
||||
{
|
||||
if (!MarginHide.IS_HIDE)
|
||||
{
|
||||
if (RunTimeStatus.SEARCH_BOX_SHOW)
|
||||
{
|
||||
mainWindow.HidedSearchBox();
|
||||
new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
App.Current.Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
|
||||
}));
|
||||
}).Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
|
||||
}
|
||||
} else
|
||||
{
|
||||
ShowApp();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -342,6 +426,7 @@ namespace GeekDesk
|
||||
else
|
||||
{
|
||||
mainWindow.Opacity = 0;
|
||||
CommonCode.SortIconList();
|
||||
}
|
||||
};
|
||||
Timeline.SetDesiredFrameRate(opacityAnimation, 60);
|
||||
@@ -352,6 +437,10 @@ namespace GeekDesk
|
||||
//防止关闭动画后 窗体仍是0透明度
|
||||
mainWindow.Opacity = 1;
|
||||
mainWindow.Visibility = visibility;
|
||||
if (visibility == Visibility.Collapsed)
|
||||
{
|
||||
CommonCode.SortIconList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,26 +529,19 @@ namespace GeekDesk
|
||||
SettingButton.ContextMenu = null;
|
||||
}
|
||||
|
||||
private void App_LostFocus(object sender, RoutedEventArgs e)
|
||||
private void App_LostFocus(object sender, EventArgs e)
|
||||
{
|
||||
if (appData.AppConfig.AppHideType == AppHideType.LOST_FOCUS)
|
||||
if (appData.AppConfig.AppHideType == AppHideType.LOST_FOCUS
|
||||
&& this.Opacity == 1)
|
||||
{
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (appData.AppConfig.MarginHide && !MarginHide.IS_HIDE)
|
||||
if (!appData.AppConfig.MarginHide || (appData.AppConfig.MarginHide && !MarginHide.IS_HIDE))
|
||||
{
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
HideApp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Deactivated(object sender, EventArgs e)
|
||||
{
|
||||
if (appData.AppConfig.AppHideType == AppHideType.LOST_FOCUS)
|
||||
{
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
if (this.DataContext != null)
|
||||
@@ -523,9 +605,26 @@ namespace GeekDesk
|
||||
HideApp();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为了让修改菜单的textBox失去焦点
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MainWindow_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
EmptyTextBox.Focus();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标进入后
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MainWindow_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
//防止延迟贴边隐藏
|
||||
RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
9
MainWindow.xaml.rej
Normal file
9
MainWindow.xaml.rej
Normal file
@@ -0,0 +1,9 @@
|
||||
diff a/MainWindow.xaml b/MainWindow.xaml (rejected hunks)
|
||||
@@ -20,6 +20,7 @@
|
||||
SizeChanged="Window_SizeChanged"
|
||||
KeyDown="OnKeyDown"
|
||||
Focusable="True"
|
||||
+ GotFocus="MainWindow_GotFocus"
|
||||
MouseDown="MainWindow_MouseDown"
|
||||
>
|
||||
<WindowChrome.WindowChrome>
|
||||
@@ -6,7 +6,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace GeekDesk.Thread
|
||||
namespace GeekDesk.MyThread
|
||||
{
|
||||
public class DispatcherBuild
|
||||
{
|
||||
@@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace GeekDesk.Thread
|
||||
namespace GeekDesk.MyThread
|
||||
{
|
||||
public class MouseHookThread
|
||||
{
|
||||
@@ -26,13 +26,13 @@ namespace GeekDesk.Thread
|
||||
dispatcher = DispatcherBuild.Build();
|
||||
dispatcher.Invoke((Action)(() =>
|
||||
{
|
||||
m_GlobalHook.MouseDownExt += M_GlobalHook_MouseDownExt;
|
||||
m_GlobalHook.MouseUpExt += M_GlobalHook_MouseUpExt;
|
||||
}));
|
||||
}
|
||||
|
||||
public static void Dispose()
|
||||
{
|
||||
m_GlobalHook.MouseDownExt -= M_GlobalHook_MouseDownExt;
|
||||
m_GlobalHook.MouseUpExt -= M_GlobalHook_MouseUpExt;
|
||||
m_GlobalHook.Dispose();
|
||||
dispatcher.InvokeShutdown();
|
||||
}
|
||||
@@ -42,13 +42,13 @@ namespace GeekDesk.Thread
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private static void M_GlobalHook_MouseDownExt(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
private static void M_GlobalHook_MouseUpExt(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
if (appConfig.MouseMiddleShow && e.Button == System.Windows.Forms.MouseButtons.Middle)
|
||||
{
|
||||
if (MotionControl.hotkeyFinished)
|
||||
{
|
||||
MainWindow.mainWindow.Dispatcher.Invoke((Action)(() =>
|
||||
App.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() =>
|
||||
{
|
||||
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed || MainWindow.mainWindow.Opacity == 0)
|
||||
{
|
||||
@@ -12,7 +12,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace GeekDesk.Thread
|
||||
namespace GeekDesk.MyThread
|
||||
{
|
||||
public class UpdateThread
|
||||
{
|
||||
@@ -49,5 +49,5 @@ using System.Windows;
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.4.1.2")]
|
||||
[assembly: AssemblyFileVersion("2.4.1.2")]
|
||||
[assembly: AssemblyVersion("2.4.1.4")]
|
||||
[assembly: AssemblyFileVersion("2.4.1.4")]
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
M512 0c282.775704 0 512 229.224296 512 512S794.775704 1024 512 1024 0 794.775704 0 512 229.224296 0 512 0zM303.407407 455.111111a56.888889 56.888889 0 1 0 0 113.777778 56.888889 56.888889 0 0 0 0-113.777778z m208.592593 0a56.888889 56.888889 0 1 0 0 113.777778 56.888889 56.888889 0 0 0 0-113.777778z m208.592593 0a56.888889 56.888889 0 1 0 0 113.777778 56.888889 56.888889 0 0 0 0-113.777778z
|
||||
</Geometry>
|
||||
|
||||
<!--更新源-->
|
||||
<Geometry x:Key="Gitee">
|
||||
M512 0C230.4 0 0 230.4 0 512s230.4 512 512 512 512-230.4 512-512S793.6 0 512 0z m284.8 313.6c0 12.8-12.8 25.6-25.6 25.6H416c-41.6 0-76.8 35.2-76.8 76.8v243.2c0 12.8 12.8 25.6 25.6 25.6h240c41.6 0 76.8-35.2 76.8-76.8v-12.8c0-12.8-12.8-25.6-25.6-25.6H480c-12.8 0-25.6-12.8-25.6-25.6v-64c0-12.8 12.8-25.6 25.6-25.6h291.2c12.8 0 25.6 12.8 25.6 25.6v144c0 92.8-76.8 169.6-169.6 169.6H252.8c-12.8 0-25.6-12.8-25.6-25.6V412.8C227.2 310.4 310.4 224 416 224h355.2c12.8 0 25.6 12.8 25.6 25.6v64z
|
||||
</Geometry>
|
||||
@@ -44,6 +45,23 @@
|
||||
<Geometry x:Key="GitHub">
|
||||
M1021.72444445 512a495.16088889 495.16088889 0 0 1-97.57582223 299.64515555 500.62222222 500.62222222 0 0 1-250.85724444 184.22897778 30.58346667 30.58346667 0 0 1-26.2144-4.73315555 25.85031111 25.85031111 0 0 1-8.00995556-20.02488889v-139.81013334a119.05706667 119.05706667 0 0 0-34.58844444-94.29902222 473.31555555 473.31555555 0 0 0 67.72053333-11.65084444 248.30862222 248.30862222 0 0 0 62.2592-26.2144 187.50577778 187.50577778 0 0 0 53.52106667-43.69066667 209.35111111 209.35111111 0 0 0 36.40888889-69.90506667 334.2336 334.2336 0 0 0 13.83537778-100.12444444 191.87484445 191.87484445 0 0 0-52.7928889-136.53333333 176.21902222 176.21902222 0 0 0-5.09724444-135.44106667 87.01724445 87.01724445 0 0 0-53.52106666 7.28177778 341.87946667 341.87946667 0 0 0-61.16693334 29.12711111l-25.12213333 15.65582222a473.31555555 473.31555555 0 0 0-254.86222223 0c-7.28177778-5.09724445-16.384-10.55857778-28.03484444-17.84035555A371.00657778 371.00657778 0 0 0 300.82844445 220.72888889a94.29902222 94.29902222 0 0 0-57.16195556-9.10222222 178.40355555 178.40355555 0 0 0-4.73315556 136.53333333 197.70026667 197.70026667 0 0 0-52.4288 137.26151111A327.68 327.68 0 0 0 200.33991111 584.81777778a223.55057778 223.55057778 0 0 0 36.40888889 69.90506667 172.94222222 172.94222222 0 0 0 53.52106667 44.41884444 304.7424 304.7424 0 0 0 62.2592 26.2144 471.13102222 471.13102222 0 0 0 68.08462222 11.65084444 105.22168889 105.22168889 0 0 0-32.768 68.44871112 112.86755555 112.86755555 0 0 1-30.21937778 9.4663111 190.41848889 190.41848889 0 0 1-36.40888889 3.2768A78.6432 78.6432 0 0 1 274.61404445 803.27111111a124.5184 124.5184 0 0 1-36.4088889-41.50613333 109.22666667 109.22666667 0 0 0-32.03982222-34.58844445 91.7504 91.7504 0 0 0-32.768-16.01991111h-13.1072a47.33155555 47.33155555 0 0 0-19.29671111 2.91271111q-5.46133333 3.2768-3.2768 7.64586667a50.24426667 50.24426667 0 0 0 6.18951111 9.10222222 62.98737778 62.98737778 0 0 0 8.73813334 8.37404445l4.73315555 2.91271111a88.83768889 88.83768889 0 0 1 29.12711111 25.12213333 179.49582222 179.49582222 0 0 1 20.75306667 33.49617778l6.5536 15.29173333a82.28408889 82.28408889 0 0 0 29.12711111 41.14204445 109.22666667 109.22666667 0 0 0 44.05475556 18.93262222 223.18648889 223.18648889 0 0 0 45.8752 4.73315556 207.16657778 207.16657778 0 0 0 36.40888888-2.54862223l15.29173334-2.54862222v95.39128889a26.2144 26.2144 0 0 1-8.73813334 20.02488889 31.67573333 31.67573333 0 0 1-26.57848888 4.73315555 498.43768889 498.43768889 0 0 1-249.40088889-185.32124444A486.78684445 486.78684445 0 0 1 2.27555555 512a497.70951111 497.70951111 0 0 1 68.44871112-254.86222222A504.6272 504.6272 0 0 1 257.13777778 70.72426667 497.70951111 497.70951111 0 0 1 512 2.27555555a497.70951111 497.70951111 0 0 1 254.86222222 68.44871112A504.6272 504.6272 0 0 1 953.27573333 257.13777778 496.98133333 496.98133333 0 0 1 1021.72444445 512z
|
||||
</Geometry>
|
||||
<!--更新源-->
|
||||
|
||||
<!--排序方式-->
|
||||
<Geometry x:Key="CustomSort">
|
||||
M950.896028 907.262252 799.11209 753.232157c-12.108782-12.302187-31.893384-12.434194-44.163849-0.325411-12.286838 12.103666-12.434194 31.878035-0.325411 44.163849l151.783938 154.030096c6.110161 6.206352 14.177907 9.31311 22.24463 9.31311 7.919367 0 15.839757-2.989077 21.919219-8.987698C962.857455 939.323459 963.004811 919.54909 950.896028 907.262252z
|
||||
M884.039341 602.546226c30.65723-17.944697 39.848567-39.624463 42.156122-54.645574 2.26253-14.700817 0.147356-37.530778-22.773679-62.84021-44.830021-49.441039-119.794363-128.689964-142.222165-152.352897-5.586229-32.177863-24.425296-139.980101-37.535895-206.1655-4.869914-24.50716-19.174712-44.387953-39.248909-54.53915-19.896142-10.060123-43.38102-9.739828-66.149583 0.919952-61.168128 28.716019-160.318312 77.455069-189.568497 91.861174-32.803103-3.975545-145.002488-17.466814-211.030297-24.145933-21.283746-2.170432-42.202171 5.363148-57.380872 20.608364-15.971763 16.038278-24.099884 38.928614-21.751397 61.238736 7.060813 67.115584 20.99415 179.407066 25.055652 211.919551-14.049994 29.635971-62.535265 132.146693-90.514503 194.163141-13.837146 30.555923-8.352225 53.30402-1.311879 67.004043 9.378601 18.249643 27.083845 31.165814 48.677653 35.461653 64.594157 12.617365 177.831174 32.345686 211.060997 38.104853 23.967878 22.915919 104.747669 99.984179 153.59826 144.738475 19.759019 18.116613 38.028105 22.941502 51.890834 22.941502 3.360538 0 6.461155-0.284479 9.261944-0.726547 14.365172-2.292206 34.922371-11.127432 51.245128-40.153512 33.336246-59.07342 87.722924-160.679539 103.425557-190.086289 28.390607-15.70775 124.57218-69.067029 183.102225-103.293551C884.029108 602.551342 884.034225 602.551342 884.039341 602.546226zM852.482625 548.642548c-68.234057 39.898709-188.638311 106.333794-189.842743 106.998943-5.301749 2.922563-9.642614 7.324826-12.484336 12.672624-0.681522 1.276063-68.345598 128.328737-107.075691 196.964954-2.948145 5.236258-5.428639 7.848759-6.699586 8.860808-1.514493-0.568958-4.666276-2.272763-9.06854-6.308683-57.065693-52.281737-158.473291-149.420101-159.490457-150.396335-4.493338-4.306072-10.17678-7.172353-16.312524-8.230452-1.428535-0.243547-143.858432-24.786523-218.98548-39.45664-2.917446-0.579191-4.793166-1.942235-5.195326-2.725064-0.457418-0.889253-0.873903-4.900613 2.673899-12.728906 32.568766-72.198346 93.310176-200.045105 93.920066-201.331401 2.562359-5.383614 3.523243-11.391445 2.780323-17.309224-0.178055-1.408069-17.827017-141.622508-26.047236-219.706911-0.381693-3.634784 1.183965-7.90504 3.89368-10.623965 2.115174-2.124384 4.122901-2.592035 5.779633-2.592035 0.37146 0 0.721431 0.020466 1.057075 0.056282 76.915787 7.777127 217.582527 24.954345 218.995713 25.127284 6.019087 0.726547 12.164041-0.310062 17.619286-2.99931 1.245364-0.615007 125.360126-61.899792 196.786898-95.439676 4.895497-2.297322 9.063423-2.922563 11.437493-1.733481 2.699482 1.367137 5.118578 5.67321 6.17156 10.959609 15.310707 77.302597 38.628786 212.590839 38.862099 213.947743 1.046842 6.089695 3.883447 11.732206 8.138354 16.211217 0.950651 0.9967 95.328136 100.345406 147.737786 158.14788 5.880941 6.491855 7.284917 10.608615 7.345292 11.30037C864.163665 539.349905 861.291245 543.483038 852.482625 548.642548z
|
||||
M348.905458 492.080322c-12.169157-12.220323-31.948643-12.266371-44.168965-0.085958-12.220323 12.169157-12.261255 31.943526-0.085958 44.168965l22.676465 22.768563c6.099928 6.125511 14.111392 9.190313 22.127973 9.190313 7.970532 0 15.94618-3.035126 22.040992-9.104355 12.220323-12.169157 12.261255-31.948643 0.085958-44.168965L348.905458 492.080322z
|
||||
M508.766352 376.774179c6.105045 6.125511 14.116509 9.190313 22.127973 9.190313 7.970532 0 15.94618-3.035126 22.040992-9.104355 12.220323-12.174274 12.261255-31.948643 0.085958-44.168965l-22.681582-22.768563c-12.17939-12.220323-31.948643-12.256138-44.168965-0.085958-12.220323 12.174274-12.261255 31.948643-0.085958 44.168965L508.766352 376.774179z
|
||||
M564.67878 441.515692c-16.851806 3.680832-27.53103 20.322861-23.856337 37.174668 0.056282 0.248663 4.707209 25.564235-11.290137 41.621956-15.524578 15.575744-39.035038 11.153014-40.616046 10.832719-16.673751-3.715625-33.310663 6.668886-37.225833 23.352871-3.934612 16.790408 6.486738 33.596166 23.281239 37.535895 6.003737 1.408069 13.852496 2.409886 22.748097 2.409886 22.895453 0 52.745295-6.634094 76.067466-30.04734 32.16763-32.289404 32.777521-77.43972 28.065196-99.023294C598.167498 448.51613 581.51933 437.856349 564.67878 441.515692z
|
||||
</Geometry>
|
||||
<Geometry x:Key="UpSort">
|
||||
M470.016 976.896q-44.032 0-59.392-20.48t-15.36-65.536q0-20.48-0.512-64.512t-1.024-93.696-1.536-96.768-1.024-74.752q0-39.936-7.68-62.464t-35.328-21.504q-20.48 0-48.64-1.024t-49.664 0q-35.84 0-45.568-19.456t13.824-50.176q24.576-30.72 57.344-72.704t67.584-86.016 68.096-87.04 58.88-75.776q23.552-29.696 45.568-30.72t46.592 26.624q24.576 29.696 56.832 69.632t67.072 82.432 68.608 83.968 60.416 73.216q29.696 35.84 23.04 58.88t-43.52 23.04q-11.264 0-25.088 0.512t-29.184 1.024-30.208 1.024-27.136 0.512q-25.6 1.024-32.256 16.384t-5.632 41.984q0 29.696 0.512 77.824t1.024 100.352 1.536 101.376 1.024 79.872q0 13.312-2.048 27.648t-9.728 26.112-21.504 19.968-36.352 8.192q-27.648 0-52.736 0.512t-56.832 1.536z
|
||||
</Geometry>
|
||||
<Geometry x:Key="LowSort">
|
||||
M564.224 44.032q43.008 0 58.368 20.48t15.36 65.536q0 20.48 0.512 64.512t0.512 93.696 0.512 96.768 0.512 74.752q0 38.912 7.68 61.952t35.328 22.016q19.456 0 48.128 1.024t49.152 1.024q35.84 0 45.568 18.944t-13.824 49.664q-24.576 30.72-57.344 72.704t-68.096 86.016-69.12 86.528-59.392 75.264q-23.552 29.696-45.568 30.72t-45.568-27.648q-24.576-29.696-57.344-69.632t-67.072-82.432-67.584-83.968-59.904-74.24q-29.696-35.84-22.528-58.88t44.032-23.04l24.576 0q14.336 0 29.696-0.512t30.208-1.536 26.112-1.024q26.624 0 32.768-15.36t6.144-41.984q0-29.696-0.512-77.824t-0.512-100.352-0.512-101.376-0.512-79.872q0-13.312 2.048-27.648t9.728-26.112 20.992-19.456 36.864-7.68q27.648 0 53.248-0.512t57.344-0.512z
|
||||
</Geometry>
|
||||
<!--排序方式-->
|
||||
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"title": "GeekDesk版本更新",
|
||||
"subTitle": "V2.4.12",
|
||||
"subTitle": "V2.4.14",
|
||||
"msgTitle": "本次更新内容如下",
|
||||
"msg": "['各位兄弟去给我点个免费Star呗','这是个修复版本,主要修复上个版本的bug','修复图标无法拖动','修复界面遮挡任务栏']",
|
||||
"msg": "['这次更新间隔比较久, 一个是工作比较忙, 另一个是因为老毛病颈椎病犯了, 但新版本总归是来了','增加图标排序功能','增加鼠标悬停切换菜单','增加搜索功能,显示界面后按下Ctrl+F','其它已知问题修复','老规矩兄弟萌, 我用爱发电, 你们点免费Star']",
|
||||
"githubUrl": "https://github.com/Demo-Liu/GeekDesk/releases",
|
||||
"giteeUrl": "https://gitee.com/demo_liu/GeekDesk/releases",
|
||||
"version": "2.4.12"
|
||||
"version": "2.4.14"
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
@@ -186,8 +188,68 @@ namespace GeekDesk.Util
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 排序图标
|
||||
/// </summary>
|
||||
public static void SortIconList()
|
||||
{
|
||||
if (MainWindow.appData.AppConfig.IconSortType != SortType.CUSTOM)
|
||||
{
|
||||
ObservableCollection<MenuInfo> menuList = MainWindow.appData.MenuList;
|
||||
//List<IconInfo> list = new List<IconInfo>(menuList[MainWindow.appData.AppConfig.SelectedMenuIndex].IconList);
|
||||
List<IconInfo> list;
|
||||
foreach (MenuInfo menuInfo in menuList)
|
||||
{
|
||||
list = new List<IconInfo>(menuInfo.IconList);
|
||||
switch (MainWindow.appData.AppConfig.IconSortType)
|
||||
{
|
||||
case SortType.COUNT_UP:
|
||||
list.Sort((x, y) => x.Count.CompareTo(y.Count));
|
||||
break;
|
||||
case SortType.COUNT_LOW:
|
||||
list.Sort((x, y) => y.Count.CompareTo(x.Count));
|
||||
break;
|
||||
case SortType.NAME_UP:
|
||||
list.Sort((x, y) => x.Name.CompareTo(y.Name));
|
||||
break;
|
||||
case SortType.NAME_LOW:
|
||||
list.Sort((x, y) => y.Name.CompareTo(x.Name));
|
||||
break;
|
||||
}
|
||||
menuInfo.IconList = new ObservableCollection<IconInfo>(list);
|
||||
}
|
||||
MainWindow.appData.AppConfig.SelectedMenuIcons = MainWindow.appData.MenuList[MainWindow.appData.AppConfig.SelectedMenuIndex].IconList;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 判断鼠标是否在窗口内
|
||||
/// </summary>
|
||||
/// <param name="window"></param>
|
||||
/// <returns></returns>
|
||||
public static bool MouseInWindow(Window window)
|
||||
{
|
||||
double windowHeight = window.Height;
|
||||
double windowWidth = window.Width;
|
||||
|
||||
double windowTop = window.Top;
|
||||
double windowLeft = window.Left;
|
||||
|
||||
//获取鼠标位置
|
||||
System.Windows.Point p = MouseUtil.GetMousePosition();
|
||||
double mouseX = p.X;
|
||||
double mouseY = p.Y;
|
||||
|
||||
//鼠标不在窗口上
|
||||
if (mouseX < windowLeft || mouseX > windowLeft + windowWidth
|
||||
|| mouseY < windowTop || mouseY > windowTop + windowHeight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
public static class ConsoleManager
|
||||
{
|
||||
private const string Kernel32_DllName = "kernel32.dll";
|
||||
|
||||
[DllImport(Kernel32_DllName)]
|
||||
private static extern bool AllocConsole();
|
||||
|
||||
[DllImport(Kernel32_DllName)]
|
||||
private static extern bool FreeConsole();
|
||||
|
||||
[DllImport(Kernel32_DllName)]
|
||||
private static extern IntPtr GetConsoleWindow();
|
||||
|
||||
[DllImport(Kernel32_DllName)]
|
||||
private static extern int GetConsoleOutputCP();
|
||||
|
||||
public static bool HasConsole
|
||||
{
|
||||
get { return GetConsoleWindow() != IntPtr.Zero; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new console instance if the process is not attached to a console already.
|
||||
/// </summary>
|
||||
public static void Show()
|
||||
{
|
||||
//#if DEBUG
|
||||
if (!HasConsole)
|
||||
{
|
||||
AllocConsole();
|
||||
InvalidateOutAndError();
|
||||
}
|
||||
//#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the process has a console attached to it, it will be detached and no longer visible. Writing to the System.Console is still possible, but no output will be shown.
|
||||
/// </summary>
|
||||
public static void Hide()
|
||||
{
|
||||
//#if DEBUG
|
||||
if (HasConsole)
|
||||
{
|
||||
SetOutAndErrorNull();
|
||||
FreeConsole();
|
||||
}
|
||||
//#endif
|
||||
}
|
||||
|
||||
public static void Toggle()
|
||||
{
|
||||
if (HasConsole)
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
Show();
|
||||
}
|
||||
}
|
||||
|
||||
static void InvalidateOutAndError()
|
||||
{
|
||||
Type type = typeof(System.Console);
|
||||
|
||||
System.Reflection.FieldInfo _out = type.GetField("_out",
|
||||
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
|
||||
|
||||
System.Reflection.FieldInfo _error = type.GetField("_error",
|
||||
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
|
||||
|
||||
System.Reflection.MethodInfo _InitializeStdOutError = type.GetMethod("InitializeStdOutError",
|
||||
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
|
||||
|
||||
Debug.Assert(_out != null);
|
||||
Debug.Assert(_error != null);
|
||||
|
||||
Debug.Assert(_InitializeStdOutError != null);
|
||||
|
||||
_out.SetValue(null, null);
|
||||
_error.SetValue(null, null);
|
||||
|
||||
_InitializeStdOutError.Invoke(null, new object[] { true });
|
||||
}
|
||||
|
||||
static void SetOutAndErrorNull()
|
||||
{
|
||||
Console.SetOut(TextWriter.Null);
|
||||
Console.SetError(TextWriter.Null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,170 +0,0 @@
|
||||
// Copyright (C) Josh Smith - January 2007
|
||||
using System.Windows;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace WPF.JoshSmith.Adorners
|
||||
{
|
||||
/// <summary>
|
||||
/// Renders a visual which can follow the mouse cursor,
|
||||
/// such as during a drag-and-drop operation.
|
||||
/// </summary>
|
||||
public class DragAdorner : Adorner
|
||||
{
|
||||
#region Data
|
||||
|
||||
private Rectangle child = null;
|
||||
private double offsetLeft = 0;
|
||||
private double offsetTop = 0;
|
||||
|
||||
#endregion // Data
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of DragVisualAdorner.
|
||||
/// </summary>
|
||||
/// <param name="adornedElement">The element being adorned.</param>
|
||||
/// <param name="size">The size of the adorner.</param>
|
||||
/// <param name="brush">A brush to with which to paint the adorner.</param>
|
||||
public DragAdorner(UIElement adornedElement, Size size, Brush brush)
|
||||
: base(adornedElement)
|
||||
{
|
||||
Rectangle rect = new Rectangle();
|
||||
rect.Fill = brush;
|
||||
rect.Width = size.Width;
|
||||
rect.Height = size.Height;
|
||||
rect.IsHitTestVisible = false;
|
||||
this.child = rect;
|
||||
}
|
||||
|
||||
#endregion // Constructor
|
||||
|
||||
#region Public Interface
|
||||
|
||||
#region GetDesiredTransform
|
||||
|
||||
/// <summary>
|
||||
/// Override.
|
||||
/// </summary>
|
||||
/// <param name="transform"></param>
|
||||
/// <returns></returns>
|
||||
public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
|
||||
{
|
||||
GeneralTransformGroup result = new GeneralTransformGroup();
|
||||
result.Children.Add(base.GetDesiredTransform(transform));
|
||||
result.Children.Add(new TranslateTransform(this.offsetLeft, this.offsetTop));
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion // GetDesiredTransform
|
||||
|
||||
#region OffsetLeft
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets the horizontal offset of the adorner.
|
||||
/// </summary>
|
||||
public double OffsetLeft
|
||||
{
|
||||
get { return this.offsetLeft; }
|
||||
set
|
||||
{
|
||||
this.offsetLeft = value;
|
||||
UpdateLocation();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // OffsetLeft
|
||||
|
||||
#region SetOffsets
|
||||
|
||||
/// <summary>
|
||||
/// Updates the location of the adorner in one atomic operation.
|
||||
/// </summary>
|
||||
/// <param name="left"></param>
|
||||
/// <param name="top"></param>
|
||||
public void SetOffsets(double left, double top)
|
||||
{
|
||||
this.offsetLeft = left;
|
||||
this.offsetTop = top;
|
||||
this.UpdateLocation();
|
||||
}
|
||||
|
||||
#endregion // SetOffsets
|
||||
|
||||
#region OffsetTop
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets the vertical offset of the adorner.
|
||||
/// </summary>
|
||||
public double OffsetTop
|
||||
{
|
||||
get { return this.offsetTop; }
|
||||
set
|
||||
{
|
||||
this.offsetTop = value;
|
||||
UpdateLocation();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // OffsetTop
|
||||
|
||||
#endregion // Public Interface
|
||||
|
||||
#region Protected Overrides
|
||||
|
||||
/// <summary>
|
||||
/// Override.
|
||||
/// </summary>
|
||||
/// <param name="constraint"></param>
|
||||
/// <returns></returns>
|
||||
protected override Size MeasureOverride(Size constraint)
|
||||
{
|
||||
this.child.Measure(constraint);
|
||||
return this.child.DesiredSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override.
|
||||
/// </summary>
|
||||
/// <param name="finalSize"></param>
|
||||
/// <returns></returns>
|
||||
protected override Size ArrangeOverride(Size finalSize)
|
||||
{
|
||||
this.child.Arrange(new Rect(finalSize));
|
||||
return finalSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override.
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
protected override Visual GetVisualChild(int index)
|
||||
{
|
||||
return this.child;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override. Always returns 1.
|
||||
/// </summary>
|
||||
protected override int VisualChildrenCount
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
#endregion // Protected Overrides
|
||||
|
||||
#region Private Helpers
|
||||
|
||||
private void UpdateLocation()
|
||||
{
|
||||
AdornerLayer adornerLayer = this.Parent as AdornerLayer;
|
||||
if (adornerLayer != null)
|
||||
adornerLayer.Update(this.AdornedElement);
|
||||
}
|
||||
|
||||
#endregion // Private Helpers
|
||||
}
|
||||
}
|
||||
@@ -1,862 +0,0 @@
|
||||
// Copyright (C) Josh Smith - January 2007
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using WPF.JoshSmith.Adorners;
|
||||
using WPF.JoshSmith.Controls.Utilities;
|
||||
|
||||
namespace WPF.JoshSmith.ServiceProviders.UI
|
||||
{
|
||||
#region ListViewDragDropManager
|
||||
|
||||
/// <summary>
|
||||
/// Manages the dragging and dropping of ListViewItems in a ListView.
|
||||
/// The ItemType type parameter indicates the type of the objects in
|
||||
/// the ListView's items source. The ListView's ItemsSource must be
|
||||
/// set to an instance of ObservableCollection of ItemType, or an
|
||||
/// Exception will be thrown.
|
||||
/// </summary>
|
||||
/// <typeparam name="ItemType">The type of the ListView's items.</typeparam>
|
||||
public class ListViewDragDropManager<ItemType> where ItemType : class
|
||||
{
|
||||
#region Data
|
||||
|
||||
bool canInitiateDrag;
|
||||
DragAdorner dragAdorner;
|
||||
double dragAdornerOpacity;
|
||||
int indexToSelect;
|
||||
bool isDragInProgress;
|
||||
ItemType itemUnderDragCursor;
|
||||
ListView listView;
|
||||
Point ptMouseDown;
|
||||
bool showDragAdorner;
|
||||
|
||||
#endregion // Data
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of ListViewDragManager.
|
||||
/// </summary>
|
||||
public ListViewDragDropManager()
|
||||
{
|
||||
this.canInitiateDrag = false;
|
||||
this.dragAdornerOpacity = 0.7;
|
||||
this.indexToSelect = -1;
|
||||
this.showDragAdorner = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of ListViewDragManager.
|
||||
/// </summary>
|
||||
/// <param name="listView"></param>
|
||||
public ListViewDragDropManager(ListView listView)
|
||||
: this()
|
||||
{
|
||||
this.ListView = listView;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of ListViewDragManager.
|
||||
/// </summary>
|
||||
/// <param name="listView"></param>
|
||||
/// <param name="dragAdornerOpacity"></param>
|
||||
public ListViewDragDropManager(ListView listView, double dragAdornerOpacity)
|
||||
: this(listView)
|
||||
{
|
||||
this.DragAdornerOpacity = dragAdornerOpacity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of ListViewDragManager.
|
||||
/// </summary>
|
||||
/// <param name="listView"></param>
|
||||
/// <param name="showDragAdorner"></param>
|
||||
public ListViewDragDropManager(ListView listView, bool showDragAdorner)
|
||||
: this(listView)
|
||||
{
|
||||
this.ShowDragAdorner = showDragAdorner;
|
||||
}
|
||||
|
||||
#endregion // Constructors
|
||||
|
||||
#region Public Interface
|
||||
|
||||
#region DragAdornerOpacity
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets the opacity of the drag adorner. This property has no
|
||||
/// effect if ShowDragAdorner is false. The default value is 0.7
|
||||
/// </summary>
|
||||
public double DragAdornerOpacity
|
||||
{
|
||||
get { return this.dragAdornerOpacity; }
|
||||
set
|
||||
{
|
||||
if (this.IsDragInProgress)
|
||||
throw new InvalidOperationException("Cannot set the DragAdornerOpacity property during a drag operation.");
|
||||
|
||||
if (value < 0.0 || value > 1.0)
|
||||
throw new ArgumentOutOfRangeException("DragAdornerOpacity", value, "Must be between 0 and 1.");
|
||||
|
||||
this.dragAdornerOpacity = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // DragAdornerOpacity
|
||||
|
||||
#region IsDragInProgress
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if there is currently a drag operation being managed.
|
||||
/// </summary>
|
||||
public bool IsDragInProgress
|
||||
{
|
||||
get { return this.isDragInProgress; }
|
||||
private set { this.isDragInProgress = value; }
|
||||
}
|
||||
|
||||
#endregion // IsDragInProgress
|
||||
|
||||
#region ListView
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets the ListView whose dragging is managed. This property
|
||||
/// can be set to null, to prevent drag management from occuring. If
|
||||
/// the ListView's AllowDrop property is false, it will be set to true.
|
||||
/// </summary>
|
||||
public ListView ListView
|
||||
{
|
||||
get { return listView; }
|
||||
set
|
||||
{
|
||||
if (this.IsDragInProgress)
|
||||
throw new InvalidOperationException("Cannot set the ListView property during a drag operation.");
|
||||
|
||||
if (this.listView != null)
|
||||
{
|
||||
#region Unhook Events
|
||||
|
||||
this.listView.PreviewMouseLeftButtonDown -= listView_PreviewMouseLeftButtonDown;
|
||||
this.listView.PreviewMouseMove -= listView_PreviewMouseMove;
|
||||
this.listView.DragOver -= listView_DragOver;
|
||||
this.listView.DragLeave -= listView_DragLeave;
|
||||
this.listView.DragEnter -= listView_DragEnter;
|
||||
this.listView.Drop -= listView_Drop;
|
||||
|
||||
#endregion // Unhook Events
|
||||
}
|
||||
|
||||
this.listView = value;
|
||||
|
||||
if (this.listView != null)
|
||||
{
|
||||
if (!this.listView.AllowDrop)
|
||||
this.listView.AllowDrop = true;
|
||||
|
||||
#region Hook Events
|
||||
|
||||
this.listView.PreviewMouseLeftButtonDown += listView_PreviewMouseLeftButtonDown;
|
||||
this.listView.PreviewMouseMove += listView_PreviewMouseMove;
|
||||
this.listView.DragOver += listView_DragOver;
|
||||
this.listView.DragLeave += listView_DragLeave;
|
||||
this.listView.DragEnter += listView_DragEnter;
|
||||
this.listView.Drop += listView_Drop;
|
||||
|
||||
#endregion // Hook Events
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // ListView
|
||||
|
||||
#region ProcessDrop [event]
|
||||
|
||||
/// <summary>
|
||||
/// Raised when a drop occurs. By default the dropped item will be moved
|
||||
/// to the target index. Handle this event if relocating the dropped item
|
||||
/// requires custom behavior. Note, if this event is handled the default
|
||||
/// item dropping logic will not occur.
|
||||
/// </summary>
|
||||
public event EventHandler<ProcessDropEventArgs<ItemType>> ProcessDrop;
|
||||
|
||||
#endregion // ProcessDrop [event]
|
||||
|
||||
#region ShowDragAdorner
|
||||
|
||||
/// <summary>
|
||||
/// Gets/sets whether a visual representation of the ListViewItem being dragged
|
||||
/// follows the mouse cursor during a drag operation. The default value is true.
|
||||
/// </summary>
|
||||
public bool ShowDragAdorner
|
||||
{
|
||||
get { return this.showDragAdorner; }
|
||||
set
|
||||
{
|
||||
if (this.IsDragInProgress)
|
||||
throw new InvalidOperationException("Cannot set the ShowDragAdorner property during a drag operation.");
|
||||
|
||||
this.showDragAdorner = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // ShowDragAdorner
|
||||
|
||||
#endregion // Public Interface
|
||||
|
||||
#region Event Handling Methods
|
||||
|
||||
#region listView_PreviewMouseLeftButtonDown
|
||||
|
||||
void listView_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (this.IsMouseOverScrollbar)
|
||||
{
|
||||
// 4/13/2007 - Set the flag to false when cursor is over scrollbar.
|
||||
this.canInitiateDrag = false;
|
||||
return;
|
||||
}
|
||||
|
||||
int index = this.IndexUnderDragCursor;
|
||||
this.canInitiateDrag = index > -1;
|
||||
|
||||
if (this.canInitiateDrag)
|
||||
{
|
||||
// Remember the location and index of the ListViewItem the user clicked on for later.
|
||||
this.ptMouseDown = MouseUtilities.GetMousePosition(this.listView);
|
||||
this.indexToSelect = index;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ptMouseDown = new Point(-10000, -10000);
|
||||
this.indexToSelect = -1;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // listView_PreviewMouseLeftButtonDown
|
||||
|
||||
#region listView_PreviewMouseMove
|
||||
|
||||
void listView_PreviewMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (!this.CanStartDragOperation)
|
||||
return;
|
||||
|
||||
// Select the item the user clicked on.
|
||||
if (this.listView.SelectedIndex != this.indexToSelect)
|
||||
this.listView.SelectedIndex = this.indexToSelect;
|
||||
|
||||
// If the item at the selected index is null, there's nothing
|
||||
// we can do, so just return;
|
||||
if (this.listView.SelectedItem == null)
|
||||
return;
|
||||
|
||||
ListViewItem itemToDrag = this.GetListViewItem(this.listView.SelectedIndex);
|
||||
if (itemToDrag == null)
|
||||
return;
|
||||
|
||||
AdornerLayer adornerLayer = this.ShowDragAdornerResolved ? this.InitializeAdornerLayer(itemToDrag) : null;
|
||||
|
||||
this.InitializeDragOperation(itemToDrag);
|
||||
this.PerformDragOperation();
|
||||
this.FinishDragOperation(itemToDrag, adornerLayer);
|
||||
}
|
||||
|
||||
#endregion // listView_PreviewMouseMove
|
||||
|
||||
#region listView_DragOver
|
||||
|
||||
void listView_DragOver(object sender, DragEventArgs e)
|
||||
{
|
||||
e.Effects = DragDropEffects.Move;
|
||||
|
||||
if (this.ShowDragAdornerResolved)
|
||||
this.UpdateDragAdornerLocation();
|
||||
|
||||
// Update the item which is known to be currently under the drag cursor.
|
||||
int index = this.IndexUnderDragCursor;
|
||||
this.ItemUnderDragCursor = index < 0 ? null : this.ListView.Items[index] as ItemType;
|
||||
}
|
||||
|
||||
#endregion // listView_DragOver
|
||||
|
||||
#region listView_DragLeave
|
||||
|
||||
void listView_DragLeave(object sender, DragEventArgs e)
|
||||
{
|
||||
if (!this.IsMouseOver(this.listView))
|
||||
{
|
||||
if (this.ItemUnderDragCursor != null)
|
||||
this.ItemUnderDragCursor = null;
|
||||
|
||||
if (this.dragAdorner != null)
|
||||
this.dragAdorner.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // listView_DragLeave
|
||||
|
||||
#region listView_DragEnter
|
||||
|
||||
void listView_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (this.dragAdorner != null && this.dragAdorner.Visibility != Visibility.Visible)
|
||||
{
|
||||
// Update the location of the adorner and then show it.
|
||||
this.UpdateDragAdornerLocation();
|
||||
this.dragAdorner.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // listView_DragEnter
|
||||
|
||||
#region listView_Drop
|
||||
|
||||
void listView_Drop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (this.ItemUnderDragCursor != null)
|
||||
this.ItemUnderDragCursor = null;
|
||||
|
||||
e.Effects = DragDropEffects.None;
|
||||
|
||||
if (!e.Data.GetDataPresent(typeof(ItemType)))
|
||||
return;
|
||||
|
||||
// Get the data object which was dropped.
|
||||
ItemType data = e.Data.GetData(typeof(ItemType)) as ItemType;
|
||||
if (data == null)
|
||||
return;
|
||||
|
||||
// Get the ObservableCollection<ItemType> which contains the dropped data object.
|
||||
ObservableCollection<ItemType> itemsSource = this.listView.ItemsSource as ObservableCollection<ItemType>;
|
||||
if (itemsSource == null)
|
||||
throw new Exception(
|
||||
"A ListView managed by ListViewDragManager must have its ItemsSource set to an ObservableCollection<ItemType>.");
|
||||
|
||||
int oldIndex = itemsSource.IndexOf(data);
|
||||
int newIndex = this.IndexUnderDragCursor;
|
||||
|
||||
if (newIndex < 0)
|
||||
{
|
||||
// The drag started somewhere else, and our ListView is empty
|
||||
// so make the new item the first in the list.
|
||||
if (itemsSource.Count == 0)
|
||||
newIndex = 0;
|
||||
|
||||
// The drag started somewhere else, but our ListView has items
|
||||
// so make the new item the last in the list.
|
||||
else if (oldIndex < 0)
|
||||
newIndex = itemsSource.Count;
|
||||
|
||||
// The user is trying to drop an item from our ListView into
|
||||
// our ListView, but the mouse is not over an item, so don't
|
||||
// let them drop it.
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
// Dropping an item back onto itself is not considered an actual 'drop'.
|
||||
if (oldIndex == newIndex)
|
||||
return;
|
||||
|
||||
if (this.ProcessDrop != null)
|
||||
{
|
||||
// Let the client code process the drop.
|
||||
ProcessDropEventArgs<ItemType> args = new ProcessDropEventArgs<ItemType>(itemsSource, data, oldIndex, newIndex, e.AllowedEffects);
|
||||
this.ProcessDrop(this, args);
|
||||
e.Effects = args.Effects;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Move the dragged data object from it's original index to the
|
||||
// new index (according to where the mouse cursor is). If it was
|
||||
// not previously in the ListBox, then insert the item.
|
||||
if (oldIndex > -1)
|
||||
itemsSource.Move(oldIndex, newIndex);
|
||||
else
|
||||
itemsSource.Insert(newIndex, data);
|
||||
|
||||
// Set the Effects property so that the call to DoDragDrop will return 'Move'.
|
||||
e.Effects = DragDropEffects.Move;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // listView_Drop
|
||||
|
||||
#endregion // Event Handling Methods
|
||||
|
||||
#region Private Helpers
|
||||
|
||||
#region CanStartDragOperation
|
||||
|
||||
bool CanStartDragOperation
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Mouse.LeftButton != MouseButtonState.Pressed)
|
||||
return false;
|
||||
|
||||
if (!this.canInitiateDrag)
|
||||
return false;
|
||||
|
||||
if (this.indexToSelect == -1)
|
||||
return false;
|
||||
|
||||
if (!this.HasCursorLeftDragThreshold)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // CanStartDragOperation
|
||||
|
||||
#region FinishDragOperation
|
||||
|
||||
void FinishDragOperation(ListViewItem draggedItem, AdornerLayer adornerLayer)
|
||||
{
|
||||
// Let the ListViewItem know that it is not being dragged anymore.
|
||||
ListViewItemDragState.SetIsBeingDragged(draggedItem, false);
|
||||
|
||||
this.IsDragInProgress = false;
|
||||
|
||||
if (this.ItemUnderDragCursor != null)
|
||||
this.ItemUnderDragCursor = null;
|
||||
|
||||
// Remove the drag adorner from the adorner layer.
|
||||
if (adornerLayer != null)
|
||||
{
|
||||
adornerLayer.Remove(this.dragAdorner);
|
||||
this.dragAdorner = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // FinishDragOperation
|
||||
|
||||
#region GetListViewItem
|
||||
|
||||
ListViewItem GetListViewItem(int index)
|
||||
{
|
||||
if (this.listView.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated)
|
||||
return null;
|
||||
|
||||
return this.listView.ItemContainerGenerator.ContainerFromIndex(index) as ListViewItem;
|
||||
}
|
||||
|
||||
ListViewItem GetListViewItem(ItemType dataItem)
|
||||
{
|
||||
if (this.listView.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated)
|
||||
return null;
|
||||
|
||||
return this.listView.ItemContainerGenerator.ContainerFromItem(dataItem) as ListViewItem;
|
||||
}
|
||||
|
||||
#endregion // GetListViewItem
|
||||
|
||||
#region HasCursorLeftDragThreshold
|
||||
|
||||
bool HasCursorLeftDragThreshold
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.indexToSelect < 0)
|
||||
return false;
|
||||
|
||||
ListViewItem item = this.GetListViewItem(this.indexToSelect);
|
||||
Rect bounds = VisualTreeHelper.GetDescendantBounds(item);
|
||||
Point ptInItem = this.listView.TranslatePoint(this.ptMouseDown, item);
|
||||
|
||||
// In case the cursor is at the very top or bottom of the ListViewItem
|
||||
// we want to make the vertical threshold very small so that dragging
|
||||
// over an adjacent item does not select it.
|
||||
double topOffset = Math.Abs(ptInItem.Y);
|
||||
double btmOffset = Math.Abs(bounds.Height - ptInItem.Y);
|
||||
double vertOffset = Math.Min(topOffset, btmOffset);
|
||||
|
||||
double width = SystemParameters.MinimumHorizontalDragDistance * 2;
|
||||
double height = Math.Min(SystemParameters.MinimumVerticalDragDistance, vertOffset) * 2;
|
||||
Size szThreshold = new Size(width, height);
|
||||
|
||||
Rect rect = new Rect(this.ptMouseDown, szThreshold);
|
||||
rect.Offset(szThreshold.Width / -2, szThreshold.Height / -2);
|
||||
Point ptInListView = MouseUtilities.GetMousePosition(this.listView);
|
||||
return !rect.Contains(ptInListView);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // HasCursorLeftDragThreshold
|
||||
|
||||
#region IndexUnderDragCursor
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index of the ListViewItem underneath the
|
||||
/// drag cursor, or -1 if the cursor is not over an item.
|
||||
/// </summary>
|
||||
int IndexUnderDragCursor
|
||||
{
|
||||
get
|
||||
{
|
||||
int index = -1;
|
||||
for (int i = 0; i < this.listView.Items.Count; ++i)
|
||||
{
|
||||
ListViewItem item = this.GetListViewItem(i);
|
||||
if (this.IsMouseOver(item))
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // IndexUnderDragCursor
|
||||
|
||||
#region InitializeAdornerLayer
|
||||
|
||||
AdornerLayer InitializeAdornerLayer(ListViewItem itemToDrag)
|
||||
{
|
||||
// Create a brush which will paint the ListViewItem onto
|
||||
// a visual in the adorner layer.
|
||||
VisualBrush brush = new VisualBrush(itemToDrag);
|
||||
|
||||
// Create an element which displays the source item while it is dragged.
|
||||
this.dragAdorner = new DragAdorner(this.listView, itemToDrag.RenderSize, brush);
|
||||
|
||||
// Set the drag adorner's opacity.
|
||||
this.dragAdorner.Opacity = this.DragAdornerOpacity;
|
||||
|
||||
AdornerLayer layer = AdornerLayer.GetAdornerLayer(this.listView);
|
||||
layer.Add(dragAdorner);
|
||||
|
||||
// Save the location of the cursor when the left mouse button was pressed.
|
||||
this.ptMouseDown = MouseUtilities.GetMousePosition(this.listView);
|
||||
|
||||
return layer;
|
||||
}
|
||||
|
||||
#endregion // InitializeAdornerLayer
|
||||
|
||||
#region InitializeDragOperation
|
||||
|
||||
void InitializeDragOperation(ListViewItem itemToDrag)
|
||||
{
|
||||
// Set some flags used during the drag operation.
|
||||
this.IsDragInProgress = true;
|
||||
this.canInitiateDrag = false;
|
||||
|
||||
// Let the ListViewItem know that it is being dragged.
|
||||
ListViewItemDragState.SetIsBeingDragged(itemToDrag, true);
|
||||
}
|
||||
|
||||
#endregion // InitializeDragOperation
|
||||
|
||||
#region IsMouseOver
|
||||
|
||||
bool IsMouseOver(Visual target)
|
||||
{
|
||||
// We need to use MouseUtilities to figure out the cursor
|
||||
// coordinates because, during a drag-drop operation, the WPF
|
||||
// mechanisms for getting the coordinates behave strangely.
|
||||
|
||||
Rect bounds = VisualTreeHelper.GetDescendantBounds(target);
|
||||
Point mousePos = MouseUtilities.GetMousePosition(target);
|
||||
return bounds.Contains(mousePos);
|
||||
}
|
||||
|
||||
#endregion // IsMouseOver
|
||||
|
||||
#region IsMouseOverScrollbar
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the mouse cursor is over a scrollbar in the ListView.
|
||||
/// </summary>
|
||||
bool IsMouseOverScrollbar
|
||||
{
|
||||
get
|
||||
{
|
||||
Point ptMouse = MouseUtilities.GetMousePosition(this.listView);
|
||||
HitTestResult res = VisualTreeHelper.HitTest(this.listView, ptMouse);
|
||||
if (res == null)
|
||||
return false;
|
||||
|
||||
DependencyObject depObj = res.VisualHit;
|
||||
while (depObj != null)
|
||||
{
|
||||
if (depObj is ScrollBar)
|
||||
return true;
|
||||
|
||||
// VisualTreeHelper works with objects of type Visual or Visual3D.
|
||||
// If the current object is not derived from Visual or Visual3D,
|
||||
// then use the LogicalTreeHelper to find the parent element.
|
||||
if (depObj is Visual || depObj is System.Windows.Media.Media3D.Visual3D)
|
||||
depObj = VisualTreeHelper.GetParent(depObj);
|
||||
else
|
||||
depObj = LogicalTreeHelper.GetParent(depObj);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // IsMouseOverScrollbar
|
||||
|
||||
#region ItemUnderDragCursor
|
||||
|
||||
ItemType ItemUnderDragCursor
|
||||
{
|
||||
get { return this.itemUnderDragCursor; }
|
||||
set
|
||||
{
|
||||
if (this.itemUnderDragCursor == value)
|
||||
return;
|
||||
|
||||
// The first pass handles the previous item under the cursor.
|
||||
// The second pass handles the new one.
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
if (i == 1)
|
||||
this.itemUnderDragCursor = value;
|
||||
|
||||
if (this.itemUnderDragCursor != null)
|
||||
{
|
||||
ListViewItem listViewItem = this.GetListViewItem(this.itemUnderDragCursor);
|
||||
if (listViewItem != null)
|
||||
ListViewItemDragState.SetIsUnderDragCursor(listViewItem, i == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // ItemUnderDragCursor
|
||||
|
||||
#region PerformDragOperation
|
||||
|
||||
void PerformDragOperation()
|
||||
{
|
||||
ItemType selectedItem = this.listView.SelectedItem as ItemType;
|
||||
DragDropEffects allowedEffects = DragDropEffects.Move | DragDropEffects.Move | DragDropEffects.Link;
|
||||
if (DragDrop.DoDragDrop(this.listView, selectedItem, allowedEffects) != DragDropEffects.None)
|
||||
{
|
||||
// The item was dropped into a new location,
|
||||
// so make it the new selected item.
|
||||
this.listView.SelectedItem = selectedItem;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // PerformDragOperation
|
||||
|
||||
#region ShowDragAdornerResolved
|
||||
|
||||
bool ShowDragAdornerResolved
|
||||
{
|
||||
get { return this.ShowDragAdorner && this.DragAdornerOpacity > 0.0; }
|
||||
}
|
||||
|
||||
#endregion // ShowDragAdornerResolved
|
||||
|
||||
#region UpdateDragAdornerLocation
|
||||
|
||||
void UpdateDragAdornerLocation()
|
||||
{
|
||||
if (this.dragAdorner != null)
|
||||
{
|
||||
Point ptCursor = MouseUtilities.GetMousePosition(this.ListView);
|
||||
|
||||
double left = ptCursor.X - this.ptMouseDown.X;
|
||||
|
||||
// 4/13/2007 - Made the top offset relative to the item being dragged.
|
||||
ListViewItem itemBeingDragged = this.GetListViewItem(this.indexToSelect);
|
||||
Point itemLoc = itemBeingDragged.TranslatePoint(new Point(0, 0), this.ListView);
|
||||
double top = itemLoc.Y + ptCursor.Y - this.ptMouseDown.Y;
|
||||
|
||||
this.dragAdorner.SetOffsets(left, top);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion // UpdateDragAdornerLocation
|
||||
|
||||
#endregion // Private Helpers
|
||||
}
|
||||
|
||||
#endregion // ListViewDragDropManager
|
||||
|
||||
#region ListViewItemDragState
|
||||
|
||||
/// <summary>
|
||||
/// Exposes attached properties used in conjunction with the ListViewDragDropManager class.
|
||||
/// Those properties can be used to allow triggers to modify the appearance of ListViewItems
|
||||
/// in a ListView during a drag-drop operation.
|
||||
/// </summary>
|
||||
public static class ListViewItemDragState
|
||||
{
|
||||
#region IsBeingDragged
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the ListViewItemDragState's IsBeingDragged attached property.
|
||||
/// This field is read-only.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IsBeingDraggedProperty =
|
||||
DependencyProperty.RegisterAttached(
|
||||
"IsBeingDragged",
|
||||
typeof(bool),
|
||||
typeof(ListViewItemDragState),
|
||||
new UIPropertyMetadata(false));
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the specified ListViewItem is being dragged, else false.
|
||||
/// </summary>
|
||||
/// <param name="item">The ListViewItem to check.</param>
|
||||
public static bool GetIsBeingDragged(ListViewItem item)
|
||||
{
|
||||
return (bool)item.GetValue(IsBeingDraggedProperty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the IsBeingDragged attached property for the specified ListViewItem.
|
||||
/// </summary>
|
||||
/// <param name="item">The ListViewItem to set the property on.</param>
|
||||
/// <param name="value">Pass true if the element is being dragged, else false.</param>
|
||||
internal static void SetIsBeingDragged(ListViewItem item, bool value)
|
||||
{
|
||||
item.SetValue(IsBeingDraggedProperty, value);
|
||||
}
|
||||
|
||||
#endregion // IsBeingDragged
|
||||
|
||||
#region IsUnderDragCursor
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the ListViewItemDragState's IsUnderDragCursor attached property.
|
||||
/// This field is read-only.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IsUnderDragCursorProperty =
|
||||
DependencyProperty.RegisterAttached(
|
||||
"IsUnderDragCursor",
|
||||
typeof(bool),
|
||||
typeof(ListViewItemDragState),
|
||||
new UIPropertyMetadata(false));
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the specified ListViewItem is currently underneath the cursor
|
||||
/// during a drag-drop operation, else false.
|
||||
/// </summary>
|
||||
/// <param name="item">The ListViewItem to check.</param>
|
||||
public static bool GetIsUnderDragCursor(ListViewItem item)
|
||||
{
|
||||
return (bool)item.GetValue(IsUnderDragCursorProperty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the IsUnderDragCursor attached property for the specified ListViewItem.
|
||||
/// </summary>
|
||||
/// <param name="item">The ListViewItem to set the property on.</param>
|
||||
/// <param name="value">Pass true if the element is underneath the drag cursor, else false.</param>
|
||||
internal static void SetIsUnderDragCursor(ListViewItem item, bool value)
|
||||
{
|
||||
item.SetValue(IsUnderDragCursorProperty, value);
|
||||
}
|
||||
|
||||
#endregion // IsUnderDragCursor
|
||||
}
|
||||
|
||||
#endregion // ListViewItemDragState
|
||||
|
||||
#region ProcessDropEventArgs
|
||||
|
||||
/// <summary>
|
||||
/// Event arguments used by the ListViewDragDropManager.ProcessDrop event.
|
||||
/// </summary>
|
||||
/// <typeparam name="ItemType">The type of data object being dropped.</typeparam>
|
||||
public class ProcessDropEventArgs<ItemType> : EventArgs where ItemType : class
|
||||
{
|
||||
#region Data
|
||||
|
||||
ObservableCollection<ItemType> itemsSource;
|
||||
ItemType dataItem;
|
||||
int oldIndex;
|
||||
int newIndex;
|
||||
DragDropEffects allowedEffects = DragDropEffects.None;
|
||||
DragDropEffects effects = DragDropEffects.None;
|
||||
|
||||
#endregion // Data
|
||||
|
||||
#region Constructor
|
||||
|
||||
internal ProcessDropEventArgs(
|
||||
ObservableCollection<ItemType> itemsSource,
|
||||
ItemType dataItem,
|
||||
int oldIndex,
|
||||
int newIndex,
|
||||
DragDropEffects allowedEffects)
|
||||
{
|
||||
this.itemsSource = itemsSource;
|
||||
this.dataItem = dataItem;
|
||||
this.oldIndex = oldIndex;
|
||||
this.newIndex = newIndex;
|
||||
this.allowedEffects = allowedEffects;
|
||||
}
|
||||
|
||||
#endregion // Constructor
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// The items source of the ListView where the drop occurred.
|
||||
/// </summary>
|
||||
public ObservableCollection<ItemType> ItemsSource
|
||||
{
|
||||
get { return this.itemsSource; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The data object which was dropped.
|
||||
/// </summary>
|
||||
public ItemType DataItem
|
||||
{
|
||||
get { return this.dataItem; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The current index of the data item being dropped, in the ItemsSource collection.
|
||||
/// </summary>
|
||||
public int OldIndex
|
||||
{
|
||||
get { return this.oldIndex; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The target index of the data item being dropped, in the ItemsSource collection.
|
||||
/// </summary>
|
||||
public int NewIndex
|
||||
{
|
||||
get { return this.newIndex; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The drag drop effects allowed to be performed.
|
||||
/// </summary>
|
||||
public DragDropEffects AllowedEffects
|
||||
{
|
||||
get { return allowedEffects; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The drag drop effect(s) performed on the dropped item.
|
||||
/// </summary>
|
||||
public DragDropEffects Effects
|
||||
{
|
||||
get { return effects; }
|
||||
set { effects = value; }
|
||||
}
|
||||
|
||||
#endregion // Public Properties
|
||||
}
|
||||
|
||||
#endregion // ProcessDropEventArgs
|
||||
}
|
||||
@@ -1,15 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media;
|
||||
using GeekDesk.Constant;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
@@ -24,6 +18,7 @@ namespace GeekDesk.Util
|
||||
RIGHT_HIDE = 6
|
||||
}
|
||||
|
||||
|
||||
public class MarginHide
|
||||
{
|
||||
private static Window window;//定义使用该方法的窗体
|
||||
@@ -33,9 +28,13 @@ namespace GeekDesk.Util
|
||||
private static readonly int fadeShowTime = 200;
|
||||
private static readonly int taskTime = 250;
|
||||
|
||||
public static readonly int shadowWidth = 20;
|
||||
|
||||
public static bool ON_HIDE = false;
|
||||
|
||||
|
||||
private static double showMarginWidth = 1;
|
||||
|
||||
public static bool IS_RUN = false;
|
||||
public static bool IS_HIDE = false;
|
||||
|
||||
private static Timer timer = null;
|
||||
@@ -43,11 +42,6 @@ namespace GeekDesk.Util
|
||||
public static void ReadyHide(Window window)
|
||||
{
|
||||
MarginHide.window = window;
|
||||
if (timer != null) return;
|
||||
timer = new Timer();//添加timer计时器,隐藏功能
|
||||
timer.Interval = taskTime;
|
||||
timer.Tick += HideWindow;
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +71,8 @@ namespace GeekDesk.Util
|
||||
#region 窗体贴边隐藏功能
|
||||
private static void HideWindow(object o, EventArgs e)
|
||||
{
|
||||
if (window.Visibility != Visibility.Visible || !IS_RUN) return;
|
||||
if (window.Visibility != Visibility.Visible
|
||||
|| RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW) return;
|
||||
|
||||
double screenLeft = SystemParameters.VirtualScreenLeft;
|
||||
double screenTop = SystemParameters.VirtualScreenTop;
|
||||
@@ -158,12 +153,23 @@ namespace GeekDesk.Util
|
||||
|
||||
public static void StartHide()
|
||||
{
|
||||
IS_RUN = true;
|
||||
ON_HIDE = true;
|
||||
if (timer != null) return;
|
||||
timer = new Timer
|
||||
{
|
||||
Interval = taskTime
|
||||
};//添加timer计时器,隐藏功能
|
||||
timer.Tick += HideWindow;
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
public static void StopHide()
|
||||
{
|
||||
IS_RUN = false;
|
||||
ON_HIDE = false;
|
||||
if (timer == null) return;
|
||||
timer.Stop();
|
||||
timer.Dispose();
|
||||
timer = null;
|
||||
//功能关闭 如果界面是隐藏状态 那么要显示界面 ↓
|
||||
if (IS_HIDE)
|
||||
{
|
||||
@@ -239,15 +245,26 @@ namespace GeekDesk.Util
|
||||
To = to,
|
||||
Duration = new Duration(TimeSpan.FromMilliseconds(hideTime))
|
||||
};
|
||||
// 如果是显示 则贴屏幕侧不显示阴影
|
||||
bool isShow = false;
|
||||
int shadowWidthTemp = Constants.SHADOW_WIDTH;
|
||||
if (hideType <= HideType.RIGHT_SHOW)
|
||||
{
|
||||
isShow = true;
|
||||
if (hideType == HideType.RIGHT_SHOW)
|
||||
{
|
||||
shadowWidthTemp = -shadowWidthTemp;
|
||||
}
|
||||
}
|
||||
da.Completed += (s, e) =>
|
||||
{
|
||||
if ("Top".Equals(property.Name))
|
||||
{
|
||||
window.Top = toTemp;
|
||||
window.Top = isShow ? toTemp - shadowWidthTemp : toTemp;
|
||||
}
|
||||
else
|
||||
{
|
||||
window.Left = toTemp;
|
||||
window.Left = isShow ? toTemp - shadowWidthTemp : toTemp;
|
||||
}
|
||||
window.BeginAnimation(property, null);
|
||||
};
|
||||
@@ -283,6 +300,20 @@ namespace GeekDesk.Util
|
||||
}
|
||||
|
||||
|
||||
public static void WaitHide(int waitTime)
|
||||
{
|
||||
new System.Threading.Thread(()=>
|
||||
{
|
||||
System.Threading.Thread.Sleep(waitTime);
|
||||
//修改状态为false 继续执行贴边隐藏
|
||||
RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW = false;
|
||||
}).Start();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace WPF.JoshSmith.Controls.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides access to the mouse location by calling unmanaged code.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This class was written by Dan Crevier (Microsoft).
|
||||
/// http://blogs.msdn.com/llobo/archive/2006/09/06/Scrolling-Scrollviewer-on-Mouse-Drag-at-the-boundaries.aspx
|
||||
/// </remarks>
|
||||
public class MouseUtilities
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct Win32Point
|
||||
{
|
||||
public Int32 X;
|
||||
public Int32 Y;
|
||||
};
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool GetCursorPos(ref Win32Point pt);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool ScreenToClient(IntPtr hwnd, ref Win32Point pt);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the mouse cursor location. This method is necessary during
|
||||
/// a drag-drop operation because the WPF mechanisms for retrieving the
|
||||
/// cursor coordinates are unreliable.
|
||||
/// </summary>
|
||||
/// <param name="relativeTo">The Visual to which the mouse coordinates will be relative.</param>
|
||||
public static Point GetMousePosition(Visual relativeTo)
|
||||
{
|
||||
Win32Point mouse = new Win32Point();
|
||||
GetCursorPos(ref mouse);
|
||||
|
||||
// Using PointFromScreen instead of Dan Crevier's code (commented out below)
|
||||
// is a bug fix created by William J. Roberts. Read his comments about the fix
|
||||
// here: http://www.codeproject.com/useritems/ListViewDragDropManager.asp?msg=1911611#xx1911611xx
|
||||
return relativeTo.PointFromScreen(new Point((double)mouse.X, (double)mouse.Y));
|
||||
|
||||
#region Commented Out
|
||||
//System.Windows.Interop.HwndSource presentationSource =
|
||||
// (System.Windows.Interop.HwndSource)PresentationSource.FromVisual( relativeTo );
|
||||
//ScreenToClient( presentationSource.Handle, ref mouse );
|
||||
//GeneralTransform transform = relativeTo.TransformToAncestor( presentationSource.RootVisual );
|
||||
//Point offset = transform.Transform( new Point( 0, 0 ) );
|
||||
//return new Point( mouse.X - offset.X, mouse.Y - offset.Y );
|
||||
#endregion // Commented Out
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using GeekDesk.Constant;
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
@@ -27,7 +28,7 @@ namespace GeekDesk.Util
|
||||
double left = SystemParameters.VirtualScreenLeft;
|
||||
double top = SystemParameters.VirtualScreenTop;
|
||||
double width = SystemParameters.VirtualScreenWidth;
|
||||
double height = SystemParameters.WorkArea.Height + 20;
|
||||
double height = SystemParameters.WorkArea.Height;
|
||||
double right = width - Math.Abs(left);
|
||||
double bottom = height - Math.Abs(top);
|
||||
|
||||
@@ -73,12 +74,12 @@ namespace GeekDesk.Util
|
||||
if (p.X - afterWidth < left)
|
||||
{
|
||||
//判断是否在最左边缘
|
||||
window.Left = left;
|
||||
window.Left = left - Constants.SHADOW_WIDTH;
|
||||
}
|
||||
else if (p.X + afterWidth > right)
|
||||
{
|
||||
//判断是否在最右边缘
|
||||
window.Left = right - window.Width;
|
||||
window.Left = right - window.Width + Constants.SHADOW_WIDTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -89,12 +90,12 @@ namespace GeekDesk.Util
|
||||
if (p.Y - afterHeight < top)
|
||||
{
|
||||
//判断是否在最上边缘
|
||||
window.Top = top;
|
||||
window.Top = top - Constants.SHADOW_WIDTH;
|
||||
}
|
||||
else if (p.Y + afterHeight > bottom)
|
||||
{
|
||||
//判断是否在最下边缘
|
||||
window.Top = bottom - window.Height;
|
||||
window.Top = bottom - window.Height + Constants.SHADOW_WIDTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -73,7 +73,23 @@ namespace GeekDesk.ViewModel
|
||||
|
||||
private bool doubleOpen = false; //双击打开项目 默认关闭
|
||||
|
||||
private bool hoverMenu = false; //悬停切换菜单 默认关闭
|
||||
|
||||
#region GetSet
|
||||
|
||||
public bool HoverMenu
|
||||
{
|
||||
get
|
||||
{
|
||||
return hoverMenu;
|
||||
}
|
||||
set
|
||||
{
|
||||
hoverMenu = value;
|
||||
OnPropertyChanged("HoverMenu");
|
||||
}
|
||||
}
|
||||
|
||||
public bool DoubleOpen
|
||||
{
|
||||
get
|
||||
|
||||
31
ViewModel/Temp/SearchIconList.cs
Normal file
31
ViewModel/Temp/SearchIconList.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace GeekDesk.ViewModel.Temp
|
||||
{
|
||||
public class SearchIconList
|
||||
{
|
||||
|
||||
private static ObservableCollection<IconInfo> iconList = new ObservableCollection<IconInfo>();
|
||||
|
||||
public static ObservableCollection<IconInfo> IconList
|
||||
{
|
||||
get
|
||||
{
|
||||
return iconList;
|
||||
}
|
||||
set
|
||||
{
|
||||
iconList = value;
|
||||
OnPropertyChanged("IconList");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static event PropertyChangedEventHandler PropertyChanged;
|
||||
private static void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(null, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
<package id="Microsoft.Extensions.Logging.Abstractions" version="2.1.1" targetFramework="net472" />
|
||||
<package id="MouseKeyHook" version="5.6.0" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
|
||||
<package id="NPinyin.Core" version="3.0.0" targetFramework="net472" />
|
||||
<package id="Quartz" version="3.3.3" targetFramework="net472" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
|
||||
<package id="System.Diagnostics.DiagnosticSource" version="4.7.1" targetFramework="net472" />
|
||||
|
||||
Reference in New Issue
Block a user