Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3794d877f2 | ||
|
|
be9dcdb923 | ||
|
|
125cc72499 | ||
|
|
6e5163c23c | ||
|
|
e14faecb19 | ||
|
|
dcb2f24f2f | ||
|
|
f763ba7565 | ||
|
|
e263082f0d | ||
|
|
eec261ca4a | ||
|
|
1457265496 | ||
|
|
bec1b8c6ea | ||
|
|
d9270ff337 | ||
|
|
5bd6af6cc7 | ||
|
|
734b78b327 | ||
|
|
701dc27361 | ||
|
|
b0066939dd | ||
|
|
679a0edbed | ||
|
|
f6624caa82 | ||
|
|
c46f66b54d | ||
|
|
7d48b16900 | ||
|
|
9789e9b02b |
@@ -44,7 +44,7 @@
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<appSettings>
|
||||
<add key="Version" value="2.4.13" />
|
||||
<add key="Version" value="2.4.14" />
|
||||
<add key="GitHubUrl" value="https://github.com/Demo-Liu/GeekDesk" />
|
||||
<add key="GiteeUrl" value="https://gitee.com/demo_liu/GeekDesk/tree/master" />
|
||||
<add key="GitHubUpdateUrl" value="https://demo-liu.github.io/GeekDesk/Update.json" />
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace GeekDesk.Constant
|
||||
public static string APP_DIR = AppDomain.CurrentDomain.BaseDirectory.Trim();
|
||||
|
||||
// 是否为开发模式
|
||||
public static bool DEV = true;
|
||||
public static bool DEV = false;
|
||||
|
||||
public static string MY_NAME = DEV ? "GeekDesk-D" : "GeekDesk";
|
||||
|
||||
@@ -26,8 +26,7 @@ namespace GeekDesk.Constant
|
||||
|
||||
public static string ERROR_FILE_PATH = APP_DIR + "Error.log";
|
||||
|
||||
//阴影宽度
|
||||
public static readonly int SHADOW_WIDTH = 20;
|
||||
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;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
||||
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
Background="Transparent"
|
||||
@@ -21,11 +22,11 @@
|
||||
<hc:Shield Subject=".net" Status=">=4.72" Margin="0,0,10,0" Color="#1182c3"/>
|
||||
<hc:Shield Subject="IDE" Status="VS2019" Margin="0,0,10,0" Color="#1182c3"/>
|
||||
|
||||
<hc:Shield Subject="GitHub" Visibility="Visible" Status="Star"
|
||||
<hc:Shield Subject="GitHub" Visibility="Visible" Status="Demo-liu"
|
||||
Command="hc:ControlCommands.OpenLink"
|
||||
CommandParameter="https://github.com/Demo-Liu/GeekDesk"
|
||||
Margin="0,0,10,0" Color="#24292F"/>
|
||||
<hc:Shield Subject="Gitee" Visibility="Visible" Status="Star"
|
||||
<hc:Shield Subject="Gitee" Visibility="Visible" Status="Demo-liu"
|
||||
Command="hc:ControlCommands.OpenLink"
|
||||
CommandParameter="https://gitee.com/demo_liu/GeekDesk"
|
||||
Margin="0,0,10,0" Color="#C71D23"/>
|
||||
@@ -61,9 +62,17 @@
|
||||
</hc:Poptip.Instance>
|
||||
</hc:Shield>
|
||||
</hc:UniformSpacingPanel>
|
||||
<TextBlock Margin="0,20,0,0" FontSize="13" Width="200" TextAlignment="Center"
|
||||
Text="这是个人开发的程序,所有人可任意修改和免费使用(商用请联系作者)" TextWrapping="Wrap"/>
|
||||
<TextBlock Margin="0,20,0,0" FontSize="13" Width="200" TextAlignment="Center" Text="这是个人开发的程序,所有人可任意修改和免费使用(商用请联系作者)" TextWrapping="Wrap"/>
|
||||
|
||||
<!--<hc:UniformSpacingPanel Spacing="10" Visibility="Visible" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10,0,0">
|
||||
<TextBlock Text="更新源:" TextAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
<RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
|
||||
Style="{StaticResource RadioButtonIcon}" Content="Gitee"
|
||||
IsChecked="{Binding UpdateType, Mode=TwoWay, Converter={StaticResource UpdateTypeConvert}, ConverterParameter=1}"/>
|
||||
<RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
|
||||
Style="{StaticResource RadioButtonIcon}" Content="GitHub"
|
||||
IsChecked="{Binding UpdateType, Mode=TwoWay, Converter={StaticResource UpdateTypeConvert}, ConverterParameter=2}"/>
|
||||
</hc:UniformSpacingPanel>-->
|
||||
</StackPanel>
|
||||
</hc:SimplePanel>
|
||||
</Grid>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
</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="自定义"
|
||||
@@ -50,28 +50,28 @@
|
||||
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="名称"
|
||||
@@ -96,6 +96,6 @@
|
||||
</StackPanel>
|
||||
</hc:SimplePanel>
|
||||
</Grid>
|
||||
|
||||
|
||||
|
||||
</UserControl>
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Loaded += OtherControl_Loaded;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void OtherControl_Loaded(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
|
||||
<Grid>
|
||||
<Grid MouseDown="DragMove" Background="Transparent">
|
||||
<StackPanel Margin="20" >
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="背景图片" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="20,0,0,0" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="图片路径:" VerticalAlignment="Center" Margin="0,5,0,0"/>
|
||||
<TextBlock Text="{Binding BacImgName}" Width="200"
|
||||
<StackPanel Margin="20" >
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="背景图片" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="20,0,0,0" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="图片路径:" VerticalAlignment="Center" Margin="0,5,0,0"/>
|
||||
<TextBlock Text="{Binding BacImgName}" Width="200"
|
||||
Margin="0,5,0,0"
|
||||
VerticalAlignment="Center"
|
||||
hc:Poptip.HitMode="None"
|
||||
@@ -25,118 +25,118 @@
|
||||
hc:Poptip.Content="{Binding BacImgName}"
|
||||
hc:Poptip.Placement="TopLeft"
|
||||
/>
|
||||
<Button Content="修改" Click="BGButton_Click"/>
|
||||
<Button Content="默认" Click="DefaultButton_Click"/>
|
||||
<Button Content="修改" Click="BGButton_Click"/>
|
||||
<Button Content="默认" Click="DefaultButton_Click"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="20,0,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox x:Name="IconIsAdmin" Content="毛玻璃效果" IsChecked="{Binding BlurEffect}">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
</LinearGradientBrush>
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="20,5,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox x:Name="BarIcon" Content="显示托盘图标" IsChecked="{Binding ShowBarIcon}">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
</LinearGradientBrush>
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black" Grid.ColumnSpan="4"/>
|
||||
|
||||
<StackPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="托盘不透明度" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="20,0,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox x:Name="IconIsAdmin" Content="毛玻璃效果" IsChecked="{Binding BlurEffect}">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
</LinearGradientBrush>
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="20,5,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox x:Name="BarIcon" Content="显示托盘图标" IsChecked="{Binding ShowBarIcon}">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
</LinearGradientBrush>
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black" Grid.ColumnSpan="4"/>
|
||||
|
||||
<StackPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="托盘不透明度" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<hc:PreviewSlider Value="{Binding CardOpacity}"
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<hc:PreviewSlider Value="{Binding CardOpacity}"
|
||||
Maximum="100"
|
||||
Width="350"
|
||||
>
|
||||
<hc:PreviewSlider.PreviewContent>
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:PreviewSlider.PreviewContent>
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="背景图片不透明度" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<hc:PreviewSlider Value="{Binding BgOpacity}"
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="背景图片不透明度" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<hc:PreviewSlider Value="{Binding BgOpacity}"
|
||||
Maximum="100"
|
||||
Width="350"
|
||||
>
|
||||
<hc:PreviewSlider.PreviewContent>
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:PreviewSlider.PreviewContent>
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="主面板不透明度" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<hc:PreviewSlider Value="{Binding PannelOpacity}"
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="主面板不透明度" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<hc:PreviewSlider Value="{Binding PannelOpacity}"
|
||||
Minimum="50"
|
||||
Maximum="100"
|
||||
Width="350"
|
||||
>
|
||||
<hc:PreviewSlider.PreviewContent>
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:PreviewSlider.PreviewContent>
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="主面板圆角大小" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<hc:PreviewSlider Value="{Binding PannelCornerRadius}"
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="主面板圆角大小" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<hc:PreviewSlider Value="{Binding PannelCornerRadius}"
|
||||
Maximum="25"
|
||||
Width="350"
|
||||
>
|
||||
<hc:PreviewSlider.PreviewContent>
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="图标大小" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4"
|
||||
<hc:PreviewSlider.PreviewContent>
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
|
||||
<TextBlock Text="图标大小" VerticalAlignment="Center"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4"
|
||||
Background="#00FFFFFF"
|
||||
PreviewMouseLeftButtonDown="PreviewSlider_MouseLeftButtonUp"
|
||||
>
|
||||
<hc:PreviewSlider Value="{Binding ImageWidth, Mode=TwoWay}"
|
||||
<hc:PreviewSlider Value="{Binding ImageWidth, Mode=TwoWay}"
|
||||
Minimum="40"
|
||||
Maximum="60"
|
||||
Width="350"
|
||||
>
|
||||
<hc:PreviewSlider.PreviewContent>
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
</StackPanel>
|
||||
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black" Grid.ColumnSpan="4"/>
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
|
||||
<TextBlock VerticalAlignment="Center" Text="图标字体颜色:" />
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding TextColor}" Width="100"/>
|
||||
<Button Content="选择" Margin="0,-10,0,0" Click="ColorButton_Click"/>
|
||||
<hc:PreviewSlider.PreviewContent>
|
||||
<Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
|
||||
</hc:PreviewSlider.PreviewContent>
|
||||
</hc:PreviewSlider>
|
||||
</hc:UniformSpacingPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black" Grid.ColumnSpan="4"/>
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
|
||||
<TextBlock VerticalAlignment="Center" Text="图标字体颜色:" />
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding TextColor}" Width="100"/>
|
||||
<Button Content="选择" Margin="0,-10,0,0" Click="ColorButton_Click"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<StackPanel x:Name="ColorPanel" Panel.ZIndex="1"
|
||||
Visibility="Collapsed"
|
||||
Height="500"
|
||||
@@ -145,14 +145,14 @@
|
||||
<StackPanel.Background>
|
||||
<SolidColorBrush Color="AliceBlue" Opacity="0"/>
|
||||
</StackPanel.Background>
|
||||
|
||||
|
||||
<hc:ColorPicker Name="MyColorPicker"
|
||||
ToggleButton.Checked="MyColorPicker_Checked"
|
||||
Canceled="MyColorPicker_Canceled"
|
||||
Confirmed="MyColorPicker_Confirmed"
|
||||
SelectedColorChanged="MyColorPicker_SelectedColorChanged"/>
|
||||
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
|
||||
</UserControl>
|
||||
|
||||
@@ -178,6 +178,6 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
ColorPanel.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +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:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
||||
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
|
||||
@@ -21,7 +22,7 @@
|
||||
</Setter>
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<EventSetter Event="MouseEnter" Handler="Menu_MouseEnter"/>
|
||||
<!--<EventSetter Event="Unselected" Handler="ListBoxItem_Unselected"/>-->
|
||||
<!--<EventSetter Event="Unselected" Handler="Lbi_Unselected"/>-->
|
||||
<Style.Triggers>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
@@ -49,11 +50,7 @@
|
||||
</MultiTrigger>
|
||||
|
||||
|
||||
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="#ECECEC"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
</Trigger>
|
||||
<!--移到代码设置-->
|
||||
<!--<Trigger Property="IsSelected" Value="False">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
@@ -67,12 +64,10 @@
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
</Trigger>-->
|
||||
|
||||
<!--<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property=""></Condition>
|
||||
</MultiTrigger.Conditions>
|
||||
</MultiTrigger>-->
|
||||
<Trigger Property="IsMouseOver" Value="False">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
</Trigger>
|
||||
|
||||
|
||||
</Style.Triggers>
|
||||
@@ -82,10 +77,11 @@
|
||||
</UserControl.Resources>
|
||||
<!--左侧栏-->
|
||||
<hc:Card x:Name="MyCard"
|
||||
BorderThickness="1"
|
||||
Effect="{DynamicResource EffectShadow2}"
|
||||
Margin="5,0,0,5"
|
||||
>
|
||||
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}}">
|
||||
|
||||
@@ -135,7 +131,7 @@
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Tag="{Binding}">
|
||||
<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}"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using DraggAnimatedPanelExample;
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Control.Windows;
|
||||
using GeekDesk.MyThread;
|
||||
using GeekDesk.Util;
|
||||
@@ -9,7 +10,7 @@ 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;
|
||||
@@ -23,6 +24,8 @@ 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;
|
||||
@@ -30,17 +33,61 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
DelegateCommand<int[]> _swap;
|
||||
DelegateCommand<int[]> _swap;
|
||||
|
||||
public DelegateCommand<int[]> SwapCommand
|
||||
{
|
||||
@@ -65,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>
|
||||
/// 当修改菜单元素可见时 设置原菜单为不可见 并且不可选中
|
||||
@@ -82,13 +122,11 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
private void MenuWhenVisibilityChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
StackPanel sp = sender as StackPanel;
|
||||
|
||||
//ListBoxItem lbi = (sp.TemplatedParent as ContentPresenter).TemplatedParent as ListBoxItem;
|
||||
|
||||
ListBoxItem lbi = (sp.TemplatedParent as ContentPresenter).TemplatedParent as ListBoxItem;
|
||||
if (sp.Visibility == Visibility.Collapsed)
|
||||
{
|
||||
//SolidColorBrush scb = new SolidColorBrush(Colors.Red);
|
||||
//lbi.MouseEnter += Lbi_MouseEnter;
|
||||
|
||||
lbi.MouseEnter += Lbi_MouseEnter;
|
||||
if (MenuListBox.SelectedIndex != -1)
|
||||
{
|
||||
menuSelectIndexTemp = MenuListBox.SelectedIndex;
|
||||
@@ -98,32 +136,51 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
MenuListBox.SelectedIndex = menuSelectIndexTemp;
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
//SolidColorBrush bac = new SolidColorBrush(Color.FromRgb(236, 236, 236));
|
||||
//SolidColorBrush fontColor = new SolidColorBrush(Colors.Black);
|
||||
lbi.MouseEnter += (s, me) =>
|
||||
{
|
||||
lbi.Background = bac;
|
||||
};
|
||||
|
||||
//lbi.MouseEnter += (s, me) =>
|
||||
//{
|
||||
// lbi.Background = bac;
|
||||
//};
|
||||
|
||||
//lbi.MouseLeave += Lbi_MouseLeave;
|
||||
|
||||
//lbi.Selected += (s, me) =>
|
||||
//{
|
||||
// lbi.MouseLeave -= Lbi_MouseLeave;
|
||||
// lbi.Background = bac;
|
||||
// lbi.Foreground = fontColor;
|
||||
//};
|
||||
lbi.MouseLeave += Lbi_MouseLeave;
|
||||
lbi.Selected += Lbi_Selected;
|
||||
}
|
||||
}
|
||||
|
||||
//private void Lbi_MouseEnter(object sender, MouseEventArgs e)
|
||||
//{
|
||||
// ListBoxItem lbi = sender as ListBoxItem;
|
||||
// lbi.Background = Brushes.Transparent;
|
||||
//}
|
||||
#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>
|
||||
/// 新建菜单
|
||||
@@ -134,33 +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;
|
||||
|
||||
//ItemCollection ic = MenuListBox.Items;
|
||||
//SolidColorBrush bac = new SolidColorBrush(Color.FromRgb(236, 236, 236));
|
||||
//SolidColorBrush fontColor = new SolidColorBrush(Colors.Black);
|
||||
//foreach (var icItem in ic)
|
||||
//{
|
||||
// ListBoxItem lbi = icItem as ListBoxItem;
|
||||
// lbi.MouseEnter += (s, me) =>
|
||||
// {
|
||||
// lbi.Background = bac;
|
||||
// };
|
||||
|
||||
// lbi.MouseLeave += Lbi_MouseLeave;
|
||||
|
||||
// lbi.Selected += (s, me) =>
|
||||
// {
|
||||
// lbi.MouseLeave -= Lbi_MouseLeave;
|
||||
// lbi.Background = bac;
|
||||
// lbi.Foreground = fontColor;
|
||||
// };
|
||||
//}
|
||||
//首次触发不了Selected事件
|
||||
object obj = MenuListBox.ItemContainerGenerator.ContainerFromIndex(MenuListBox.SelectedIndex);
|
||||
SetListBoxItemEvent((ListBoxItem)obj);
|
||||
Lbi_Selected(obj, null);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重命名菜单 将textbox 设置为可见
|
||||
/// </summary>
|
||||
@@ -187,12 +227,13 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
CreateMenu(null, null);
|
||||
}
|
||||
int index = appData.MenuList.IndexOf(menuInfo);
|
||||
if(index == 0)
|
||||
if (index == 0)
|
||||
{
|
||||
index = 0;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
index = index - 1;
|
||||
index--;
|
||||
}
|
||||
|
||||
appData.MenuList.Remove(menuInfo);
|
||||
@@ -217,11 +258,13 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
if (eKey.Key == Key.Enter)
|
||||
{
|
||||
menuBox = ((TextBox)sender);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
done = false;
|
||||
}
|
||||
} else if (e.GetType() == typeof(RoutedEventArgs))
|
||||
}
|
||||
else if (e.GetType() == typeof(RoutedEventArgs))
|
||||
{
|
||||
menuBox = ((TextBox)sender);
|
||||
}
|
||||
@@ -280,19 +323,6 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
}
|
||||
}
|
||||
|
||||
//private void ListBoxItem_Unselected(object sender, RoutedEventArgs e)
|
||||
//{
|
||||
// //添加Leave效果
|
||||
// ListBoxItem lbi = sender as ListBoxItem;
|
||||
// //lbi.Background = Brushes.Transparent;
|
||||
// //lbi.MouseLeave += Lbi_MouseLeave;
|
||||
//}
|
||||
|
||||
//private void Lbi_MouseLeave(object sender, MouseEventArgs e)
|
||||
//{
|
||||
// ListBoxItem lbi = sender as ListBoxItem;
|
||||
// lbi.Background = Brushes.Transparent;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标悬停切换菜单
|
||||
@@ -319,6 +349,29 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,15 @@
|
||||
</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}"/>
|
||||
@@ -66,10 +74,10 @@
|
||||
<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.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"
|
||||
>
|
||||
@@ -107,26 +115,35 @@
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<hc:SimpleStackPanel Tag="{Binding}"
|
||||
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.Content="{Binding Content}"
|
||||
hc:Poptip.Placement="BottomLeft"
|
||||
Background="#00FFFFFF"
|
||||
MouseEnter="StackPanel_MouseEnter"
|
||||
MouseLeave="StackPanel_MouseLeave"
|
||||
>
|
||||
<Image Style="{StaticResource ImageStyle}" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
<TextBlock MaxWidth="80"
|
||||
Margin="0,5,0,0"
|
||||
MaxHeight="40"
|
||||
FontSize="13"
|
||||
TextWrapping="Wrap"
|
||||
TextTrimming="WordEllipsis"
|
||||
TextAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.TextColor}"
|
||||
Text="{Binding Name}"/>
|
||||
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.Content="{Binding Content}"
|
||||
hc:Poptip.Placement="BottomLeft"
|
||||
Background="#00FFFFFF"
|
||||
MouseEnter="StackPanel_MouseEnter"
|
||||
MouseLeave="StackPanel_MouseLeave"
|
||||
MouseLeftButtonDown="Icon_MouseLeftButtonDown"
|
||||
MouseLeftButtonUp="Icon_MouseLeftButtonUp"
|
||||
>
|
||||
<!--<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"
|
||||
FontSize="13"
|
||||
TextWrapping="Wrap"
|
||||
TextTrimming="WordEllipsis"
|
||||
TextAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.TextColor}"
|
||||
Text="{Binding Name}"/>
|
||||
<!--</StackPanel>-->
|
||||
|
||||
</hc:SimpleStackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
@@ -137,14 +154,17 @@
|
||||
</Grid>
|
||||
</hc:Card>
|
||||
|
||||
<hc:Card
|
||||
x:Name="VerticalCard"
|
||||
<hc:Card x:Name="VerticalCard"
|
||||
Visibility="Hidden"
|
||||
BorderThickness="1"
|
||||
Effect="{DynamicResource EffectShadow2}"
|
||||
Margin="5,0,5,5" Grid.ColumnSpan="2">
|
||||
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}}"/>
|
||||
<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"/>
|
||||
@@ -155,36 +175,45 @@
|
||||
VirtualizingPanel.IsVirtualizing="True"
|
||||
VirtualizingPanel.IsContainerVirtualizable="True"
|
||||
>
|
||||
<ListBox ItemsSource="{Binding Source={StaticResource SearchIconList},Path=IconList}"
|
||||
BorderThickness="0"
|
||||
Padding="0,10,0,0"
|
||||
>
|
||||
<ListBox.Background>
|
||||
<SolidColorBrush Opacity="0"/>
|
||||
</ListBox.Background>
|
||||
<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.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.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem" BasedOn="{StaticResource MyListBoxItemStyle}">
|
||||
<Setter Property="ContextMenu" Value="{StaticResource IconDialog}"/>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<WrapPanel Tag="{Binding}"
|
||||
<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}}"
|
||||
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}}"
|
||||
@@ -195,8 +224,8 @@
|
||||
MouseLeftButtonUp="Icon_MouseLeftButtonUp"
|
||||
Margin="25,20,0,0"
|
||||
>
|
||||
<Image Style="{StaticResource ImageStyle}" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
<TextBlock
|
||||
<Image Style="{StaticResource ImageStyle}" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
<TextBlock
|
||||
Margin="10,5,0,0"
|
||||
MaxHeight="40"
|
||||
FontSize="13"
|
||||
@@ -206,10 +235,12 @@
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.TextColor}"
|
||||
Text="{Binding Name}"/>
|
||||
</WrapPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</WrapPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</hc:TransitioningContentControl>
|
||||
|
||||
|
||||
</WrapPanel>
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
(indexes) =>
|
||||
{
|
||||
DROP_ICON = true;
|
||||
if (appData.AppConfig.IconSortType != SortType.CUSTOM
|
||||
if (appData.AppConfig.IconSortType != SortType.CUSTOM
|
||||
&& (dropCheckThread == null || !dropCheckThread.IsAlive))
|
||||
{
|
||||
dropCheckThread = new Thread(() =>
|
||||
@@ -117,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);
|
||||
@@ -129,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);
|
||||
@@ -261,6 +261,12 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
}
|
||||
}
|
||||
icon.Count++;
|
||||
|
||||
//隐藏搜索框
|
||||
if (RunTimeStatus.SEARCH_BOX_SHOW)
|
||||
{
|
||||
MainWindow.mainWindow.HidedSearchBox();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -577,11 +583,45 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
if (vb == Visibility.Visible)
|
||||
{
|
||||
WrapCard.Visibility = Visibility.Collapsed;
|
||||
} else
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ namespace GeekDesk.Control.UserControls.SystemItem
|
||||
iconInfo = CommonCode.GetIconInfoByPath(thisInfo.LnkPath_NoWrite);
|
||||
}
|
||||
menuInfo.IconList.Add(iconInfo);
|
||||
CommonCode.SortIconList();
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,16 @@ namespace GeekDesk.Converts
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
double menuLeftWidth = double.Parse(value.ToString());
|
||||
return MainWindow.mainWindow.Width - menuLeftWidth;
|
||||
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)
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Windows.Data;
|
||||
|
||||
namespace GeekDesk.Converts
|
||||
{
|
||||
public class SortTypeConvert : IValueConverter
|
||||
public class SortTypeConvert : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
|
||||
@@ -130,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" />
|
||||
@@ -190,10 +191,10 @@
|
||||
<Compile Include="Control\Windows\UpdateWindow.xaml.cs">
|
||||
<DependentUpon>UpdateWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Converts\SearchResWidth.cs" />
|
||||
<Compile Include="Converts\DoubleToGridLength.cs" />
|
||||
<Compile Include="Converts\SortTypeConvert.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" />
|
||||
@@ -209,18 +210,14 @@
|
||||
<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" />
|
||||
@@ -405,6 +402,5 @@
|
||||
<Resource Include="Resource\Image\SystemIcon\RecycleBin.png" />
|
||||
<Resource Include="Resource\Image\SystemIcon\Registry.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -21,6 +21,7 @@
|
||||
KeyDown="OnKeyDown"
|
||||
Focusable="True"
|
||||
MouseDown="MainWindow_MouseDown"
|
||||
MouseEnter="MainWindow_MouseEnter"
|
||||
>
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="0" ResizeBorderThickness="15"/>
|
||||
@@ -137,7 +138,6 @@
|
||||
<TextBox Panel.ZIndex="2" Grid.Row="0" Grid.Column="1"
|
||||
x:Name="SearchBox"
|
||||
Visibility="Collapsed"
|
||||
LostFocus="SearchBox_LostFocus"
|
||||
Margin="-100,5,0,0"
|
||||
Height="32"
|
||||
FontSize="16"
|
||||
@@ -145,7 +145,7 @@
|
||||
BorderThickness="0"
|
||||
TextChanged="SearchBox_TextChanged"
|
||||
/>
|
||||
|
||||
|
||||
|
||||
<uc:RightCardControl x:Name="RightCard" Grid.Row="1" Grid.Column="1"/>
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ using static GeekDesk.Util.ShowWindowFollowMouse;
|
||||
using System.Collections.ObjectModel;
|
||||
using NPinyin;
|
||||
using GeekDesk.ViewModel.Temp;
|
||||
using System.Threading;
|
||||
|
||||
namespace GeekDesk
|
||||
{
|
||||
@@ -58,6 +59,7 @@ namespace GeekDesk
|
||||
/// <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();
|
||||
@@ -80,26 +82,25 @@ namespace GeekDesk
|
||||
foreach (IconInfo icon in iconList)
|
||||
{
|
||||
string pyName = Pinyin.GetInitials(icon.Name).ToLower();
|
||||
if (icon.Name.Contains(inputText) || pyName.Contains(inputText)) {
|
||||
if (icon.Name.Contains(inputText) || pyName.Contains(inputText))
|
||||
{
|
||||
SearchIconList.IconList.Add(icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchIconList.IconList.Clear();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 隐藏搜索框
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SearchBox_LostFocus(object sender, RoutedEventArgs e)
|
||||
|
||||
public void HidedSearchBox()
|
||||
{
|
||||
RunTimeStatus.SEARCH_BOX_SHOW = false;
|
||||
SearchBox.Visibility = Visibility.Collapsed;
|
||||
SearchIconList.IconList.Clear();
|
||||
RightCard.VisibilitySearchCard(Visibility.Collapsed);
|
||||
SearchBox.Visibility = Visibility.Collapsed;
|
||||
SearchBox.Text = "";
|
||||
}
|
||||
|
||||
@@ -120,6 +121,7 @@ namespace GeekDesk
|
||||
this.Height = appData.AppConfig.WindowHeight;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 窗口加载完毕 执行方法
|
||||
/// </summary>
|
||||
@@ -338,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();
|
||||
}
|
||||
@@ -349,21 +351,53 @@ namespace GeekDesk
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
//修改贴边隐藏状态为未隐藏
|
||||
mainWindow.Activate();
|
||||
|
||||
MarginHide.IS_HIDE = false;
|
||||
//修改贴边隐藏状态为未隐藏
|
||||
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);
|
||||
mainWindow.Focus();
|
||||
|
||||
Keyboard.Focus(mainWindow.EmptyTextBox);
|
||||
}
|
||||
|
||||
public static void HideApp()
|
||||
{
|
||||
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
|
||||
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>
|
||||
@@ -582,5 +616,15 @@ namespace GeekDesk
|
||||
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>
|
||||
@@ -26,13 +26,13 @@ namespace GeekDesk.MyThread
|
||||
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,14 +42,14 @@ namespace GeekDesk.MyThread
|
||||
/// </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)
|
||||
{
|
||||
MainWindow.ShowApp();
|
||||
|
||||
@@ -49,5 +49,5 @@ using System.Windows;
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.4.1.3")]
|
||||
[assembly: AssemblyFileVersion("2.4.1.3")]
|
||||
[assembly: AssemblyVersion("2.4.1.4")]
|
||||
[assembly: AssemblyFileVersion("2.4.1.4")]
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
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
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
@@ -222,5 +222,34 @@ namespace GeekDesk.Util
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <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
|
||||
}
|
||||
@@ -30,6 +30,8 @@ namespace GeekDesk.Util
|
||||
|
||||
public static readonly int shadowWidth = 20;
|
||||
|
||||
public static bool ON_HIDE = false;
|
||||
|
||||
|
||||
private static double showMarginWidth = 1;
|
||||
|
||||
@@ -39,7 +41,7 @@ namespace GeekDesk.Util
|
||||
|
||||
public static void ReadyHide(Window window)
|
||||
{
|
||||
MarginHide.window = window;
|
||||
MarginHide.window = window;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +71,8 @@ namespace GeekDesk.Util
|
||||
#region 窗体贴边隐藏功能
|
||||
private static void HideWindow(object o, EventArgs e)
|
||||
{
|
||||
if (window.Visibility != Visibility.Visible) return;
|
||||
if (window.Visibility != Visibility.Visible
|
||||
|| RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW) return;
|
||||
|
||||
double screenLeft = SystemParameters.VirtualScreenLeft;
|
||||
double screenTop = SystemParameters.VirtualScreenTop;
|
||||
@@ -150,6 +153,7 @@ namespace GeekDesk.Util
|
||||
|
||||
public static void StartHide()
|
||||
{
|
||||
ON_HIDE = true;
|
||||
if (timer != null) return;
|
||||
timer = new Timer
|
||||
{
|
||||
@@ -161,6 +165,7 @@ namespace GeekDesk.Util
|
||||
|
||||
public static void StopHide()
|
||||
{
|
||||
ON_HIDE = false;
|
||||
if (timer == null) return;
|
||||
timer.Stop();
|
||||
timer.Dispose();
|
||||
@@ -295,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,8 +1,6 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Util;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
@@ -13,35 +11,17 @@ namespace GeekDesk.ViewModel
|
||||
[Serializable]
|
||||
public class MenuInfo : INotifyPropertyChanged
|
||||
{
|
||||
|
||||
|
||||
|
||||
private string menuName;
|
||||
private string menuId;
|
||||
private Visibility menuEdit = Visibility.Collapsed;
|
||||
private Visibility notMenuEdit = Visibility.Visible;
|
||||
private bool isEdit = false;
|
||||
private string menuGeometry; //菜单几何图标
|
||||
private string geometryColor; //几何图标颜色
|
||||
private ObservableCollection<IconInfo> iconList = new ObservableCollection<IconInfo>();
|
||||
|
||||
|
||||
|
||||
[field: NonSerializedAttribute()]
|
||||
private static string[] NO_WRITE_ARR = new string[] { "IsEdit"};
|
||||
|
||||
|
||||
public bool IsEdit
|
||||
{
|
||||
get
|
||||
{
|
||||
return isEdit;
|
||||
}
|
||||
set
|
||||
{
|
||||
isEdit = value;
|
||||
OnPropertyChanged("IsEdit");
|
||||
}
|
||||
}
|
||||
public string MenuGeometry
|
||||
{
|
||||
get
|
||||
@@ -85,7 +65,7 @@ namespace GeekDesk.ViewModel
|
||||
set
|
||||
{
|
||||
menuName = value;
|
||||
OnPropertyChanged("MenuName");
|
||||
OnPropertyChanged("MenuName");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,12 +93,9 @@ namespace GeekDesk.ViewModel
|
||||
menuEdit = value;
|
||||
if (menuEdit == Visibility.Visible)
|
||||
{
|
||||
IsEdit = true;
|
||||
NotMenuEdit = Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
IsEdit = false;
|
||||
NotMenuEdit = Visibility.Visible;
|
||||
}
|
||||
OnPropertyChanged("MenuEdit");
|
||||
@@ -151,24 +128,12 @@ namespace GeekDesk.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public override String ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
|
||||
[field: NonSerializedAttribute()]
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
foreach (string field in NO_WRITE_ARR)
|
||||
{
|
||||
if (field.Equals(propertyName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user