Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56584e1c99 | ||
|
|
05b63d107d | ||
|
|
eaa37aacae | ||
|
|
0c9cd85b82 | ||
|
|
3e0d0c502b | ||
|
|
5a89b40244 | ||
|
|
0495b8a121 | ||
|
|
1ef3129017 | ||
|
|
ca3d6b50e3 | ||
|
|
683b4bc870 | ||
|
|
abdc4b6046 | ||
|
|
ff2a103682 | ||
|
|
9c687117f9 |
@@ -44,7 +44,7 @@
|
|||||||
</assemblyBinding>
|
</assemblyBinding>
|
||||||
</runtime>
|
</runtime>
|
||||||
<appSettings>
|
<appSettings>
|
||||||
<add key="Version" value="2.4.14" />
|
<add key="Version" value="2.4.13" />
|
||||||
<add key="GitHubUrl" value="https://github.com/Demo-Liu/GeekDesk" />
|
<add key="GitHubUrl" value="https://github.com/Demo-Liu/GeekDesk" />
|
||||||
<add key="GiteeUrl" value="https://gitee.com/demo_liu/GeekDesk/tree/master" />
|
<add key="GiteeUrl" value="https://gitee.com/demo_liu/GeekDesk/tree/master" />
|
||||||
<add key="GitHubUpdateUrl" value="https://demo-liu.github.io/GeekDesk/Update.json" />
|
<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 string APP_DIR = AppDomain.CurrentDomain.BaseDirectory.Trim();
|
||||||
|
|
||||||
// 是否为开发模式
|
// 是否为开发模式
|
||||||
public static bool DEV = false;
|
public static bool DEV = true;
|
||||||
|
|
||||||
public static string MY_NAME = DEV ? "GeekDesk-D" : "GeekDesk";
|
public static string MY_NAME = DEV ? "GeekDesk-D" : "GeekDesk";
|
||||||
|
|
||||||
@@ -26,7 +26,8 @@ namespace GeekDesk.Constant
|
|||||||
|
|
||||||
public static string ERROR_FILE_PATH = APP_DIR + "Error.log";
|
public static string ERROR_FILE_PATH = APP_DIR + "Error.log";
|
||||||
|
|
||||||
public static int SHADOW_WIDTH = 20;
|
//阴影宽度
|
||||||
|
public static readonly int SHADOW_WIDTH = 20;
|
||||||
|
|
||||||
//系统图标
|
//系统图标
|
||||||
public static Hashtable SYSTEM_ICONS = (Hashtable)ConfigurationManager.GetSection("SystemIcons");
|
public static Hashtable SYSTEM_ICONS = (Hashtable)ConfigurationManager.GetSection("SystemIcons");
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
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,7 +4,6 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
||||||
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
|
|
||||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
@@ -22,11 +21,11 @@
|
|||||||
<hc:Shield Subject=".net" Status=">=4.72" Margin="0,0,10,0" Color="#1182c3"/>
|
<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="IDE" Status="VS2019" Margin="0,0,10,0" Color="#1182c3"/>
|
||||||
|
|
||||||
<hc:Shield Subject="GitHub" Visibility="Visible" Status="Demo-liu"
|
<hc:Shield Subject="GitHub" Visibility="Visible" Status="Star"
|
||||||
Command="hc:ControlCommands.OpenLink"
|
Command="hc:ControlCommands.OpenLink"
|
||||||
CommandParameter="https://github.com/Demo-Liu/GeekDesk"
|
CommandParameter="https://github.com/Demo-Liu/GeekDesk"
|
||||||
Margin="0,0,10,0" Color="#24292F"/>
|
Margin="0,0,10,0" Color="#24292F"/>
|
||||||
<hc:Shield Subject="Gitee" Visibility="Visible" Status="Demo-liu"
|
<hc:Shield Subject="Gitee" Visibility="Visible" Status="Star"
|
||||||
Command="hc:ControlCommands.OpenLink"
|
Command="hc:ControlCommands.OpenLink"
|
||||||
CommandParameter="https://gitee.com/demo_liu/GeekDesk"
|
CommandParameter="https://gitee.com/demo_liu/GeekDesk"
|
||||||
Margin="0,0,10,0" Color="#C71D23"/>
|
Margin="0,0,10,0" Color="#C71D23"/>
|
||||||
@@ -62,17 +61,9 @@
|
|||||||
</hc:Poptip.Instance>
|
</hc:Poptip.Instance>
|
||||||
</hc:Shield>
|
</hc:Shield>
|
||||||
</hc:UniformSpacingPanel>
|
</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>
|
</StackPanel>
|
||||||
</hc:SimplePanel>
|
</hc:SimplePanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
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:hc="https://handyorg.github.io/handycontrol"
|
||||||
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
||||||
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
|
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
|
||||||
@@ -22,7 +21,7 @@
|
|||||||
</Setter>
|
</Setter>
|
||||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||||
<EventSetter Event="MouseEnter" Handler="Menu_MouseEnter"/>
|
<EventSetter Event="MouseEnter" Handler="Menu_MouseEnter"/>
|
||||||
<!--<EventSetter Event="Unselected" Handler="Lbi_Unselected"/>-->
|
<!--<EventSetter Event="Unselected" Handler="ListBoxItem_Unselected"/>-->
|
||||||
<Style.Triggers>
|
<Style.Triggers>
|
||||||
<MultiTrigger>
|
<MultiTrigger>
|
||||||
<MultiTrigger.Conditions>
|
<MultiTrigger.Conditions>
|
||||||
@@ -50,7 +49,11 @@
|
|||||||
</MultiTrigger>
|
</MultiTrigger>
|
||||||
|
|
||||||
|
|
||||||
<!--移到代码设置-->
|
|
||||||
|
<Trigger Property="IsSelected" Value="True">
|
||||||
|
<Setter Property="Background" Value="#ECECEC"/>
|
||||||
|
<Setter Property="Foreground" Value="Black"/>
|
||||||
|
</Trigger>
|
||||||
<!--<Trigger Property="IsSelected" Value="False">
|
<!--<Trigger Property="IsSelected" Value="False">
|
||||||
<Setter Property="Background" Value="Transparent"/>
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
<Setter Property="Foreground" Value="Black"/>
|
<Setter Property="Foreground" Value="Black"/>
|
||||||
@@ -64,10 +67,12 @@
|
|||||||
<Setter Property="Background" Value="Transparent"/>
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
<Setter Property="Foreground" Value="Black"/>
|
<Setter Property="Foreground" Value="Black"/>
|
||||||
</Trigger>-->
|
</Trigger>-->
|
||||||
<Trigger Property="IsMouseOver" Value="False">
|
|
||||||
<Setter Property="Background" Value="Transparent"/>
|
<!--<MultiTrigger>
|
||||||
<Setter Property="Foreground" Value="Black"/>
|
<MultiTrigger.Conditions>
|
||||||
</Trigger>
|
<Condition Property=""></Condition>
|
||||||
|
</MultiTrigger.Conditions>
|
||||||
|
</MultiTrigger>-->
|
||||||
|
|
||||||
|
|
||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
@@ -80,7 +85,6 @@
|
|||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
Effect="{DynamicResource EffectShadow2}"
|
Effect="{DynamicResource EffectShadow2}"
|
||||||
Margin="5,0,0,5"
|
Margin="5,0,0,5"
|
||||||
MouseDown="MyCard_MouseDown"
|
|
||||||
>
|
>
|
||||||
<hc:Card.Background>
|
<hc:Card.Background>
|
||||||
<SolidColorBrush Color="#FFFFFFFF" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}">
|
<SolidColorBrush Color="#FFFFFFFF" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}">
|
||||||
@@ -131,7 +135,7 @@
|
|||||||
|
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel Tag="{Binding}" MouseDown="ListBoxItem_MouseDown">
|
<StackPanel Tag="{Binding}">
|
||||||
<TextBox Text="{Binding Path=MenuName, Mode=TwoWay}"
|
<TextBox Text="{Binding Path=MenuName, Mode=TwoWay}"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}, ConverterParameter=35}"
|
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}, ConverterParameter=35}"
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using DraggAnimatedPanelExample;
|
using DraggAnimatedPanelExample;
|
||||||
using GeekDesk.Constant;
|
|
||||||
using GeekDesk.Control.Windows;
|
using GeekDesk.Control.Windows;
|
||||||
using GeekDesk.MyThread;
|
using GeekDesk.MyThread;
|
||||||
using GeekDesk.Util;
|
using GeekDesk.Util;
|
||||||
@@ -10,7 +9,7 @@ using System.Collections.ObjectModel;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Data;
|
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
@@ -24,8 +23,6 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
|||||||
{
|
{
|
||||||
private int menuSelectIndexTemp = -1;
|
private int menuSelectIndexTemp = -1;
|
||||||
private AppData appData = MainWindow.appData;
|
private AppData appData = MainWindow.appData;
|
||||||
private SolidColorBrush bac = new SolidColorBrush(Color.FromRgb(236, 236, 236));
|
|
||||||
|
|
||||||
|
|
||||||
//是否正在修改菜单
|
//是否正在修改菜单
|
||||||
private static bool IS_EDIT = false;
|
private static bool IS_EDIT = false;
|
||||||
@@ -33,56 +30,12 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
|||||||
public LeftCardControl()
|
public LeftCardControl()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
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)
|
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;
|
appData.AppConfig.SelectedMenuIcons = appData.MenuList[0].IconList;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MenuListBox.SelectedIndex = appData.AppConfig.SelectedMenuIndex;
|
|
||||||
appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
|
appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,6 +65,13 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////菜单点击事件
|
||||||
|
//private void MenuClick(object sender, MouseButtonEventArgs e)
|
||||||
|
//{
|
||||||
|
// //设置对应菜单的图标列表
|
||||||
|
// MenuInfo mi = (MenuInfo)(((StackPanel)sender).Tag);
|
||||||
|
// appData.AppConfig.SelectedMenuIcons = mi.IconList;
|
||||||
|
//}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当修改菜单元素可见时 设置原菜单为不可见 并且不可选中
|
/// 当修改菜单元素可见时 设置原菜单为不可见 并且不可选中
|
||||||
@@ -123,10 +83,12 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
|||||||
{
|
{
|
||||||
StackPanel sp = sender as StackPanel;
|
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)
|
if (sp.Visibility == Visibility.Collapsed)
|
||||||
{
|
{
|
||||||
lbi.MouseEnter += Lbi_MouseEnter;
|
//SolidColorBrush scb = new SolidColorBrush(Colors.Red);
|
||||||
|
//lbi.MouseEnter += Lbi_MouseEnter;
|
||||||
|
|
||||||
if (MenuListBox.SelectedIndex != -1)
|
if (MenuListBox.SelectedIndex != -1)
|
||||||
{
|
{
|
||||||
menuSelectIndexTemp = MenuListBox.SelectedIndex;
|
menuSelectIndexTemp = MenuListBox.SelectedIndex;
|
||||||
@@ -136,51 +98,32 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
|||||||
{
|
{
|
||||||
MenuListBox.SelectedIndex = menuSelectIndexTemp;
|
MenuListBox.SelectedIndex = menuSelectIndexTemp;
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
lbi.MouseEnter += (s, me) =>
|
//SolidColorBrush bac = new SolidColorBrush(Color.FromRgb(236, 236, 236));
|
||||||
{
|
//SolidColorBrush fontColor = new SolidColorBrush(Colors.Black);
|
||||||
lbi.Background = bac;
|
|
||||||
};
|
|
||||||
|
|
||||||
lbi.MouseLeave += Lbi_MouseLeave;
|
//lbi.MouseEnter += (s, me) =>
|
||||||
lbi.Selected += Lbi_Selected;
|
//{
|
||||||
|
// lbi.Background = bac;
|
||||||
|
//};
|
||||||
|
|
||||||
|
//lbi.MouseLeave += Lbi_MouseLeave;
|
||||||
|
|
||||||
|
//lbi.Selected += (s, me) =>
|
||||||
|
//{
|
||||||
|
// lbi.MouseLeave -= Lbi_MouseLeave;
|
||||||
|
// lbi.Background = bac;
|
||||||
|
// lbi.Foreground = fontColor;
|
||||||
|
//};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 设置菜单触发事件
|
//private void Lbi_MouseEnter(object sender, MouseEventArgs e)
|
||||||
private void Lbi_MouseEnter(object sender, MouseEventArgs e)
|
//{
|
||||||
{
|
// ListBoxItem lbi = sender as ListBoxItem;
|
||||||
ListBoxItem lbi = sender as ListBoxItem;
|
// lbi.Background = Brushes.Transparent;
|
||||||
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>
|
/// <summary>
|
||||||
/// 新建菜单
|
/// 新建菜单
|
||||||
@@ -191,15 +134,32 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
|||||||
{
|
{
|
||||||
MenuInfo info = new MenuInfo() { MenuEdit = Visibility.Collapsed, MenuId = System.Guid.NewGuid().ToString(), MenuName = "NewMenu" };
|
MenuInfo info = new MenuInfo() { MenuEdit = Visibility.Collapsed, MenuId = System.Guid.NewGuid().ToString(), MenuName = "NewMenu" };
|
||||||
appData.MenuList.Add(info);
|
appData.MenuList.Add(info);
|
||||||
|
MenuListBox.Items.Refresh();
|
||||||
MenuListBox.SelectedIndex = appData.MenuList.Count - 1;
|
MenuListBox.SelectedIndex = appData.MenuList.Count - 1;
|
||||||
appData.AppConfig.SelectedMenuIndex = MenuListBox.SelectedIndex;
|
appData.AppConfig.SelectedMenuIndex = MenuListBox.SelectedIndex;
|
||||||
appData.AppConfig.SelectedMenuIcons = info.IconList;
|
appData.AppConfig.SelectedMenuIcons = info.IconList;
|
||||||
//首次触发不了Selected事件
|
|
||||||
object obj = MenuListBox.ItemContainerGenerator.ContainerFromIndex(MenuListBox.SelectedIndex);
|
|
||||||
SetListBoxItemEvent((ListBoxItem)obj);
|
|
||||||
Lbi_Selected(obj, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//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;
|
||||||
|
// };
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 重命名菜单 将textbox 设置为可见
|
/// 重命名菜单 将textbox 设置为可见
|
||||||
@@ -230,10 +190,9 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
|||||||
if(index == 0)
|
if(index == 0)
|
||||||
{
|
{
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
index--;
|
index = index - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
appData.MenuList.Remove(menuInfo);
|
appData.MenuList.Remove(menuInfo);
|
||||||
@@ -258,13 +217,11 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
|||||||
if (eKey.Key == Key.Enter)
|
if (eKey.Key == Key.Enter)
|
||||||
{
|
{
|
||||||
menuBox = ((TextBox)sender);
|
menuBox = ((TextBox)sender);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
}
|
} else if (e.GetType() == typeof(RoutedEventArgs))
|
||||||
else if (e.GetType() == typeof(RoutedEventArgs))
|
|
||||||
{
|
{
|
||||||
menuBox = ((TextBox)sender);
|
menuBox = ((TextBox)sender);
|
||||||
}
|
}
|
||||||
@@ -323,6 +280,19 @@ 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>
|
/// <summary>
|
||||||
/// 鼠标悬停切换菜单
|
/// 鼠标悬停切换菜单
|
||||||
@@ -349,29 +319,6 @@ 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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,14 +20,6 @@
|
|||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
</Style>-->
|
</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">
|
<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="Width" Value="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageWidth, Mode=OneWay}"/>
|
||||||
<Setter Property="Height" Value="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageHeight, Mode=OneWay}"/>
|
<Setter Property="Height" Value="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageHeight, Mode=OneWay}"/>
|
||||||
@@ -77,7 +69,7 @@
|
|||||||
VirtualizingPanel.IsVirtualizing="True"
|
VirtualizingPanel.IsVirtualizing="True"
|
||||||
VirtualizingPanel.IsContainerVirtualizable="True"
|
VirtualizingPanel.IsContainerVirtualizable="True"
|
||||||
>
|
>
|
||||||
<ListBox x:Name="IconListBox" ItemsSource="{Binding AppConfig.SelectedMenuIcons, Mode=OneWay}"
|
<ListBox x:Name="IconListBox" ItemsSource="{Binding AppConfig.SelectedMenuIcons, Mode=TwoWay}"
|
||||||
BorderThickness="0"
|
BorderThickness="0"
|
||||||
Padding="0,10,0,0"
|
Padding="0,10,0,0"
|
||||||
>
|
>
|
||||||
@@ -123,15 +115,8 @@
|
|||||||
Background="#00FFFFFF"
|
Background="#00FFFFFF"
|
||||||
MouseEnter="StackPanel_MouseEnter"
|
MouseEnter="StackPanel_MouseEnter"
|
||||||
MouseLeave="StackPanel_MouseLeave"
|
MouseLeave="StackPanel_MouseLeave"
|
||||||
MouseLeftButtonDown="Icon_MouseLeftButtonDown"
|
|
||||||
MouseLeftButtonUp="Icon_MouseLeftButtonUp"
|
|
||||||
>
|
>
|
||||||
<!--<StackPanel Background="#00FFFFFF"
|
<Image Style="{StaticResource ImageStyle}" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||||
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"
|
<TextBlock MaxWidth="80"
|
||||||
Margin="0,5,0,0"
|
Margin="0,5,0,0"
|
||||||
MaxHeight="40"
|
MaxHeight="40"
|
||||||
@@ -142,8 +127,6 @@
|
|||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Foreground="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.TextColor}"
|
Foreground="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.TextColor}"
|
||||||
Text="{Binding Name}"/>
|
Text="{Binding Name}"/>
|
||||||
<!--</StackPanel>-->
|
|
||||||
|
|
||||||
</hc:SimpleStackPanel>
|
</hc:SimpleStackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListBox.ItemTemplate>
|
</ListBox.ItemTemplate>
|
||||||
@@ -154,17 +137,14 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</hc:Card>
|
</hc:Card>
|
||||||
|
|
||||||
<hc:Card x:Name="VerticalCard"
|
<hc:Card
|
||||||
|
x:Name="VerticalCard"
|
||||||
Visibility="Hidden"
|
Visibility="Hidden"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
Effect="{DynamicResource EffectShadow2}"
|
Effect="{DynamicResource EffectShadow2}"
|
||||||
Margin="5,0,5,5" Grid.ColumnSpan="2"
|
Margin="5,0,5,5" Grid.ColumnSpan="2">
|
||||||
MouseLeftButtonDown="VerticalCard_MouseLeftButtonDown"
|
|
||||||
>
|
|
||||||
<hc:Card.Background>
|
<hc:Card.Background>
|
||||||
<SolidColorBrush Color="AliceBlue"
|
<SolidColorBrush Color="AliceBlue" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"/>
|
||||||
hc:GeometryEffect.GeometryEffect="20"
|
|
||||||
Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"/>
|
|
||||||
</hc:Card.Background>
|
</hc:Card.Background>
|
||||||
<hc:Card.BorderBrush>
|
<hc:Card.BorderBrush>
|
||||||
<SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
|
<SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
|
||||||
@@ -175,7 +155,6 @@
|
|||||||
VirtualizingPanel.IsVirtualizing="True"
|
VirtualizingPanel.IsVirtualizing="True"
|
||||||
VirtualizingPanel.IsContainerVirtualizable="True"
|
VirtualizingPanel.IsContainerVirtualizable="True"
|
||||||
>
|
>
|
||||||
<hc:TransitioningContentControl TransitionStoryboard="{StaticResource Custom1Transition}">
|
|
||||||
<ListBox ItemsSource="{Binding Source={StaticResource SearchIconList},Path=IconList}"
|
<ListBox ItemsSource="{Binding Source={StaticResource SearchIconList},Path=IconList}"
|
||||||
BorderThickness="0"
|
BorderThickness="0"
|
||||||
Padding="0,10,0,0"
|
Padding="0,10,0,0"
|
||||||
@@ -201,19 +180,11 @@
|
|||||||
</Style>
|
</Style>
|
||||||
</ListBox.ItemContainerStyle>
|
</ListBox.ItemContainerStyle>
|
||||||
|
|
||||||
<ListBox.ItemsPanel>
|
|
||||||
<ItemsPanelTemplate>
|
|
||||||
<StackPanel Background="#00FFFFFF"
|
|
||||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.MenuCardWidth, Mode=OneWay, Converter={StaticResource SearchResWidth}, ConverterParameter=1}"
|
|
||||||
/>
|
|
||||||
</ItemsPanelTemplate>
|
|
||||||
</ListBox.ItemsPanel>
|
|
||||||
|
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<WrapPanel Tag="{Binding}"
|
<WrapPanel Tag="{Binding}"
|
||||||
Height="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageHeight, Mode=OneWay}"
|
Height="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImageHeight, Mode=OneWay}"
|
||||||
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.MenuCardWidth, Mode=OneWay, Converter={StaticResource SearchResWidth}, ConverterParameter=2}"
|
Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.MenuCardWidth, Mode=OneWay, Converter={StaticResource SearchResWidth}}"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
hc:Poptip.HitMode="None"
|
hc:Poptip.HitMode="None"
|
||||||
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
|
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
|
||||||
@@ -239,8 +210,6 @@
|
|||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListBox.ItemTemplate>
|
</ListBox.ItemTemplate>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
</hc:TransitioningContentControl>
|
|
||||||
|
|
||||||
|
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
|||||||
{
|
{
|
||||||
if (appData.AppConfig.DoubleOpen && e.ClickCount >= 2)
|
if (appData.AppConfig.DoubleOpen && e.ClickCount >= 2)
|
||||||
{
|
{
|
||||||
IconInfo icon = (IconInfo)((Panel)sender).Tag;
|
IconInfo icon = (IconInfo)((SimpleStackPanel)sender).Tag;
|
||||||
if (icon.AdminStartUp)
|
if (icon.AdminStartUp)
|
||||||
{
|
{
|
||||||
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
||||||
@@ -129,7 +129,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
|||||||
}
|
}
|
||||||
else if (!appData.AppConfig.DoubleOpen && e.ClickCount == 1)
|
else if (!appData.AppConfig.DoubleOpen && e.ClickCount == 1)
|
||||||
{
|
{
|
||||||
IconInfo icon = (IconInfo)((Panel)sender).Tag;
|
IconInfo icon = (IconInfo)((SimpleStackPanel)sender).Tag;
|
||||||
if (icon.AdminStartUp)
|
if (icon.AdminStartUp)
|
||||||
{
|
{
|
||||||
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
||||||
@@ -261,12 +261,6 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
icon.Count++;
|
icon.Count++;
|
||||||
|
|
||||||
//隐藏搜索框
|
|
||||||
if (RunTimeStatus.SEARCH_BOX_SHOW)
|
|
||||||
{
|
|
||||||
MainWindow.mainWindow.HidedSearchBox();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -583,45 +577,11 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
|||||||
if (vb == Visibility.Visible)
|
if (vb == Visibility.Visible)
|
||||||
{
|
{
|
||||||
WrapCard.Visibility = Visibility.Collapsed;
|
WrapCard.Visibility = Visibility.Collapsed;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
WrapCard.Visibility = Visibility.Visible;
|
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,6 +53,7 @@ namespace GeekDesk.Control.UserControls.SystemItem
|
|||||||
iconInfo = CommonCode.GetIconInfoByPath(thisInfo.LnkPath_NoWrite);
|
iconInfo = CommonCode.GetIconInfoByPath(thisInfo.LnkPath_NoWrite);
|
||||||
}
|
}
|
||||||
menuInfo.IconList.Add(iconInfo);
|
menuInfo.IconList.Add(iconInfo);
|
||||||
|
CommonCode.SortIconList();
|
||||||
CommonCode.SaveAppData(MainWindow.appData);
|
CommonCode.SaveAppData(MainWindow.appData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,17 +12,9 @@ namespace GeekDesk.Converts
|
|||||||
class SearchResWidth : IValueConverter
|
class SearchResWidth : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
{
|
|
||||||
string param = parameter as string;
|
|
||||||
if ("1".Equals(param))
|
|
||||||
{
|
{
|
||||||
double menuLeftWidth = double.Parse(value.ToString());
|
double menuLeftWidth = double.Parse(value.ToString());
|
||||||
return MainWindow.mainWindow.Width - menuLeftWidth;
|
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)
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
|||||||
@@ -130,7 +130,6 @@
|
|||||||
<Compile Include="Constant\IconType.cs" />
|
<Compile Include="Constant\IconType.cs" />
|
||||||
<Compile Include="Constant\CommonEnum.cs" />
|
<Compile Include="Constant\CommonEnum.cs" />
|
||||||
<Compile Include="Constant\IconStartType.cs" />
|
<Compile Include="Constant\IconStartType.cs" />
|
||||||
<Compile Include="Constant\RunTimeStatus.cs" />
|
|
||||||
<Compile Include="Constant\SortType.cs" />
|
<Compile Include="Constant\SortType.cs" />
|
||||||
<Compile Include="Constant\TodoTaskExecType.cs" />
|
<Compile Include="Constant\TodoTaskExecType.cs" />
|
||||||
<Compile Include="Constant\UpdateType.cs" />
|
<Compile Include="Constant\UpdateType.cs" />
|
||||||
@@ -191,10 +190,10 @@
|
|||||||
<Compile Include="Control\Windows\UpdateWindow.xaml.cs">
|
<Compile Include="Control\Windows\UpdateWindow.xaml.cs">
|
||||||
<DependentUpon>UpdateWindow.xaml</DependentUpon>
|
<DependentUpon>UpdateWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Converts\DoubleToGridLength.cs" />
|
|
||||||
<Compile Include="Converts\MenuInfoConvert.cs" />
|
|
||||||
<Compile Include="Converts\SearchResWidth.cs" />
|
<Compile Include="Converts\SearchResWidth.cs" />
|
||||||
|
<Compile Include="Converts\DoubleToGridLength.cs" />
|
||||||
<Compile Include="Converts\SortTypeConvert.cs" />
|
<Compile Include="Converts\SortTypeConvert.cs" />
|
||||||
|
<Compile Include="Converts\MenuInfoConvert.cs" />
|
||||||
<Compile Include="Converts\TodoTaskExecConvert.cs" />
|
<Compile Include="Converts\TodoTaskExecConvert.cs" />
|
||||||
<Compile Include="Converts\IntToCornerRadius.cs" />
|
<Compile Include="Converts\IntToCornerRadius.cs" />
|
||||||
<Compile Include="Converts\OpcityConvert.cs" />
|
<Compile Include="Converts\OpcityConvert.cs" />
|
||||||
@@ -210,14 +209,18 @@
|
|||||||
<Compile Include="Util\AeroGlassHelper.cs" />
|
<Compile Include="Util\AeroGlassHelper.cs" />
|
||||||
<Compile Include="Util\GlobalHotKey.cs" />
|
<Compile Include="Util\GlobalHotKey.cs" />
|
||||||
<Compile Include="Util\CommonCode.cs" />
|
<Compile Include="Util\CommonCode.cs" />
|
||||||
|
<Compile Include="Util\ConsoleManager.cs" />
|
||||||
|
<Compile Include="Util\DragAdorner.cs" />
|
||||||
<Compile Include="Util\FileIcon.cs" />
|
<Compile Include="Util\FileIcon.cs" />
|
||||||
<Compile Include="Util\FileUtil.cs" />
|
<Compile Include="Util\FileUtil.cs" />
|
||||||
<Compile Include="Util\LogUtil.cs" />
|
<Compile Include="Util\LogUtil.cs" />
|
||||||
<Compile Include="Util\MarginHide.cs" />
|
<Compile Include="Util\MarginHide.cs" />
|
||||||
<Compile Include="Util\HttpUtil.cs" />
|
<Compile Include="Util\HttpUtil.cs" />
|
||||||
<Compile Include="Util\ImageUtil.cs" />
|
<Compile Include="Util\ImageUtil.cs" />
|
||||||
|
<Compile Include="Util\ListViewDragDropManager.cs" />
|
||||||
<Compile Include="Converts\MenuWidthConvert.cs" />
|
<Compile Include="Converts\MenuWidthConvert.cs" />
|
||||||
<Compile Include="Util\MouseUtil.cs" />
|
<Compile Include="Util\MouseUtil.cs" />
|
||||||
|
<Compile Include="Util\MouseUtilities.cs" />
|
||||||
<Compile Include="Util\RegisterUtil.cs" />
|
<Compile Include="Util\RegisterUtil.cs" />
|
||||||
<Compile Include="Util\ShellContextMenu.cs" />
|
<Compile Include="Util\ShellContextMenu.cs" />
|
||||||
<Compile Include="Util\ShowWindowFollowMouse.cs" />
|
<Compile Include="Util\ShowWindowFollowMouse.cs" />
|
||||||
@@ -402,5 +405,6 @@
|
|||||||
<Resource Include="Resource\Image\SystemIcon\RecycleBin.png" />
|
<Resource Include="Resource\Image\SystemIcon\RecycleBin.png" />
|
||||||
<Resource Include="Resource\Image\SystemIcon\Registry.png" />
|
<Resource Include="Resource\Image\SystemIcon\Registry.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
@@ -21,7 +21,6 @@
|
|||||||
KeyDown="OnKeyDown"
|
KeyDown="OnKeyDown"
|
||||||
Focusable="True"
|
Focusable="True"
|
||||||
MouseDown="MainWindow_MouseDown"
|
MouseDown="MainWindow_MouseDown"
|
||||||
MouseEnter="MainWindow_MouseEnter"
|
|
||||||
>
|
>
|
||||||
<WindowChrome.WindowChrome>
|
<WindowChrome.WindowChrome>
|
||||||
<WindowChrome CaptionHeight="0" ResizeBorderThickness="15"/>
|
<WindowChrome CaptionHeight="0" ResizeBorderThickness="15"/>
|
||||||
@@ -138,6 +137,7 @@
|
|||||||
<TextBox Panel.ZIndex="2" Grid.Row="0" Grid.Column="1"
|
<TextBox Panel.ZIndex="2" Grid.Row="0" Grid.Column="1"
|
||||||
x:Name="SearchBox"
|
x:Name="SearchBox"
|
||||||
Visibility="Collapsed"
|
Visibility="Collapsed"
|
||||||
|
LostFocus="SearchBox_LostFocus"
|
||||||
Margin="-100,5,0,0"
|
Margin="-100,5,0,0"
|
||||||
Height="32"
|
Height="32"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ using static GeekDesk.Util.ShowWindowFollowMouse;
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using NPinyin;
|
using NPinyin;
|
||||||
using GeekDesk.ViewModel.Temp;
|
using GeekDesk.ViewModel.Temp;
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace GeekDesk
|
namespace GeekDesk
|
||||||
{
|
{
|
||||||
@@ -59,7 +58,6 @@ namespace GeekDesk
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void SearchItem(object sender, CanExecuteRoutedEventArgs e)
|
private void SearchItem(object sender, CanExecuteRoutedEventArgs e)
|
||||||
{
|
{
|
||||||
RunTimeStatus.SEARCH_BOX_SHOW = true;
|
|
||||||
RightCard.VisibilitySearchCard(Visibility.Visible);
|
RightCard.VisibilitySearchCard(Visibility.Visible);
|
||||||
SearchBox.Visibility = Visibility.Visible;
|
SearchBox.Visibility = Visibility.Visible;
|
||||||
SearchBox.Focus();
|
SearchBox.Focus();
|
||||||
@@ -82,25 +80,26 @@ namespace GeekDesk
|
|||||||
foreach (IconInfo icon in iconList)
|
foreach (IconInfo icon in iconList)
|
||||||
{
|
{
|
||||||
string pyName = Pinyin.GetInitials(icon.Name).ToLower();
|
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);
|
SearchIconList.IconList.Add(icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
SearchIconList.IconList.Clear();
|
SearchIconList.IconList.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
public void HidedSearchBox()
|
/// 隐藏搜索框
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void SearchBox_LostFocus(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
RunTimeStatus.SEARCH_BOX_SHOW = false;
|
|
||||||
SearchBox.Visibility = Visibility.Collapsed;
|
|
||||||
SearchIconList.IconList.Clear();
|
SearchIconList.IconList.Clear();
|
||||||
RightCard.VisibilitySearchCard(Visibility.Collapsed);
|
RightCard.VisibilitySearchCard(Visibility.Collapsed);
|
||||||
|
SearchBox.Visibility = Visibility.Collapsed;
|
||||||
SearchBox.Text = "";
|
SearchBox.Text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +120,6 @@ namespace GeekDesk
|
|||||||
this.Height = appData.AppConfig.WindowHeight;
|
this.Height = appData.AppConfig.WindowHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 窗口加载完毕 执行方法
|
/// 窗口加载完毕 执行方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -340,7 +338,7 @@ namespace GeekDesk
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
public void ShowApp(object sender, RoutedEventArgs e)
|
private void ShowApp(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ShowApp();
|
ShowApp();
|
||||||
}
|
}
|
||||||
@@ -351,53 +349,21 @@ namespace GeekDesk
|
|||||||
//{
|
//{
|
||||||
// return;
|
// return;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//修改贴边隐藏状态为未隐藏
|
//修改贴边隐藏状态为未隐藏
|
||||||
if (MarginHide.ON_HIDE)
|
mainWindow.Activate();
|
||||||
{
|
|
||||||
MarginHide.IS_HIDE = false;
|
|
||||||
if (!CommonCode.MouseInWindow(mainWindow))
|
|
||||||
{
|
|
||||||
RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW = true;
|
|
||||||
MarginHide.WaitHide(3000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
MarginHide.IS_HIDE = false;
|
||||||
if (appData.AppConfig.FollowMouse)
|
if (appData.AppConfig.FollowMouse)
|
||||||
{
|
{
|
||||||
ShowWindowFollowMouse.Show(mainWindow, MousePosition.CENTER, 0, 0, false);
|
ShowWindowFollowMouse.Show(mainWindow, MousePosition.CENTER, 0, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
FadeStoryBoard(1, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Visible);
|
FadeStoryBoard(1, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Visible);
|
||||||
|
mainWindow.Focus();
|
||||||
Keyboard.Focus(mainWindow.EmptyTextBox);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void HideApp()
|
public static void HideApp()
|
||||||
{
|
|
||||||
if (!MarginHide.IS_HIDE)
|
|
||||||
{
|
|
||||||
if (RunTimeStatus.SEARCH_BOX_SHOW)
|
|
||||||
{
|
|
||||||
mainWindow.HidedSearchBox();
|
|
||||||
new Thread(() =>
|
|
||||||
{
|
|
||||||
Thread.Sleep(100);
|
|
||||||
App.Current.Dispatcher.BeginInvoke(new Action(() =>
|
|
||||||
{
|
{
|
||||||
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
|
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
|
||||||
}));
|
|
||||||
}).Start();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
ShowApp();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -616,15 +582,5 @@ namespace GeekDesk
|
|||||||
EmptyTextBox.Focus();
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
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 = DispatcherBuild.Build();
|
||||||
dispatcher.Invoke((Action)(() =>
|
dispatcher.Invoke((Action)(() =>
|
||||||
{
|
{
|
||||||
m_GlobalHook.MouseUpExt += M_GlobalHook_MouseUpExt;
|
m_GlobalHook.MouseDownExt += M_GlobalHook_MouseDownExt;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Dispose()
|
public static void Dispose()
|
||||||
{
|
{
|
||||||
m_GlobalHook.MouseUpExt -= M_GlobalHook_MouseUpExt;
|
m_GlobalHook.MouseDownExt -= M_GlobalHook_MouseDownExt;
|
||||||
m_GlobalHook.Dispose();
|
m_GlobalHook.Dispose();
|
||||||
dispatcher.InvokeShutdown();
|
dispatcher.InvokeShutdown();
|
||||||
}
|
}
|
||||||
@@ -42,13 +42,13 @@ namespace GeekDesk.MyThread
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private static void M_GlobalHook_MouseUpExt(object sender, System.Windows.Forms.MouseEventArgs e)
|
private static void M_GlobalHook_MouseDownExt(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||||
{
|
{
|
||||||
if (appConfig.MouseMiddleShow && e.Button == System.Windows.Forms.MouseButtons.Middle)
|
if (appConfig.MouseMiddleShow && e.Button == System.Windows.Forms.MouseButtons.Middle)
|
||||||
{
|
{
|
||||||
if (MotionControl.hotkeyFinished)
|
if (MotionControl.hotkeyFinished)
|
||||||
{
|
{
|
||||||
App.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() =>
|
MainWindow.mainWindow.Dispatcher.Invoke((Action)(() =>
|
||||||
{
|
{
|
||||||
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed || MainWindow.mainWindow.Opacity == 0)
|
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed || MainWindow.mainWindow.Opacity == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,5 +49,5 @@ using System.Windows;
|
|||||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||||
//通过使用 "*",如下所示:
|
//通过使用 "*",如下所示:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("2.4.1.4")]
|
[assembly: AssemblyVersion("2.4.1.3")]
|
||||||
[assembly: AssemblyFileVersion("2.4.1.4")]
|
[assembly: AssemblyFileVersion("2.4.1.3")]
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"title": "GeekDesk版本更新",
|
"title": "GeekDesk版本更新",
|
||||||
"subTitle": "V2.4.14",
|
"subTitle": "V2.4.12",
|
||||||
"msgTitle": "本次更新内容如下",
|
"msgTitle": "本次更新内容如下",
|
||||||
"msg": "['这次更新间隔比较久, 一个是工作比较忙, 另一个是因为老毛病颈椎病犯了, 但新版本总归是来了','增加图标排序功能','增加鼠标悬停切换菜单','增加搜索功能,显示界面后按下Ctrl+F','其它已知问题修复','老规矩兄弟萌, 我用爱发电, 你们点免费Star']",
|
"msg": "['各位兄弟去给我点个免费Star呗','这是个修复版本,主要修复上个版本的bug','修复图标无法拖动','修复界面遮挡任务栏']",
|
||||||
"githubUrl": "https://github.com/Demo-Liu/GeekDesk/releases",
|
"githubUrl": "https://github.com/Demo-Liu/GeekDesk/releases",
|
||||||
"giteeUrl": "https://gitee.com/demo_liu/GeekDesk/releases",
|
"giteeUrl": "https://gitee.com/demo_liu/GeekDesk/releases",
|
||||||
"version": "2.4.14"
|
"version": "2.4.12"
|
||||||
}
|
}
|
||||||
@@ -222,34 +222,5 @@ 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
101
Util/ConsoleManager.cs
Normal file
101
Util/ConsoleManager.cs
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
170
Util/DragAdorner.cs
Normal file
170
Util/DragAdorner.cs
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
// 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
|
||||||
|
}
|
||||||
|
}
|
||||||
862
Util/ListViewDragDropManager.cs
Normal file
862
Util/ListViewDragDropManager.cs
Normal file
@@ -0,0 +1,862 @@
|
|||||||
|
// 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,8 +30,6 @@ namespace GeekDesk.Util
|
|||||||
|
|
||||||
public static readonly int shadowWidth = 20;
|
public static readonly int shadowWidth = 20;
|
||||||
|
|
||||||
public static bool ON_HIDE = false;
|
|
||||||
|
|
||||||
|
|
||||||
private static double showMarginWidth = 1;
|
private static double showMarginWidth = 1;
|
||||||
|
|
||||||
@@ -71,8 +69,7 @@ namespace GeekDesk.Util
|
|||||||
#region 窗体贴边隐藏功能
|
#region 窗体贴边隐藏功能
|
||||||
private static void HideWindow(object o, EventArgs e)
|
private static void HideWindow(object o, EventArgs e)
|
||||||
{
|
{
|
||||||
if (window.Visibility != Visibility.Visible
|
if (window.Visibility != Visibility.Visible) return;
|
||||||
|| RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW) return;
|
|
||||||
|
|
||||||
double screenLeft = SystemParameters.VirtualScreenLeft;
|
double screenLeft = SystemParameters.VirtualScreenLeft;
|
||||||
double screenTop = SystemParameters.VirtualScreenTop;
|
double screenTop = SystemParameters.VirtualScreenTop;
|
||||||
@@ -153,7 +150,6 @@ namespace GeekDesk.Util
|
|||||||
|
|
||||||
public static void StartHide()
|
public static void StartHide()
|
||||||
{
|
{
|
||||||
ON_HIDE = true;
|
|
||||||
if (timer != null) return;
|
if (timer != null) return;
|
||||||
timer = new Timer
|
timer = new Timer
|
||||||
{
|
{
|
||||||
@@ -165,7 +161,6 @@ namespace GeekDesk.Util
|
|||||||
|
|
||||||
public static void StopHide()
|
public static void StopHide()
|
||||||
{
|
{
|
||||||
ON_HIDE = false;
|
|
||||||
if (timer == null) return;
|
if (timer == null) return;
|
||||||
timer.Stop();
|
timer.Stop();
|
||||||
timer.Dispose();
|
timer.Dispose();
|
||||||
@@ -300,20 +295,6 @@ 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
56
Util/MouseUtilities.cs
Normal file
56
Util/MouseUtilities.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
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,6 +1,8 @@
|
|||||||
using GeekDesk.Constant;
|
using GeekDesk.Constant;
|
||||||
using GeekDesk.Util;
|
using GeekDesk.Util;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@@ -17,11 +19,29 @@ namespace GeekDesk.ViewModel
|
|||||||
private string menuId;
|
private string menuId;
|
||||||
private Visibility menuEdit = Visibility.Collapsed;
|
private Visibility menuEdit = Visibility.Collapsed;
|
||||||
private Visibility notMenuEdit = Visibility.Visible;
|
private Visibility notMenuEdit = Visibility.Visible;
|
||||||
|
private bool isEdit = false;
|
||||||
private string menuGeometry; //菜单几何图标
|
private string menuGeometry; //菜单几何图标
|
||||||
private string geometryColor; //几何图标颜色
|
private string geometryColor; //几何图标颜色
|
||||||
private ObservableCollection<IconInfo> iconList = new ObservableCollection<IconInfo>();
|
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
|
public string MenuGeometry
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -93,9 +113,12 @@ namespace GeekDesk.ViewModel
|
|||||||
menuEdit = value;
|
menuEdit = value;
|
||||||
if (menuEdit == Visibility.Visible)
|
if (menuEdit == Visibility.Visible)
|
||||||
{
|
{
|
||||||
|
IsEdit = true;
|
||||||
NotMenuEdit = Visibility.Collapsed;
|
NotMenuEdit = Visibility.Collapsed;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
|
IsEdit = false;
|
||||||
NotMenuEdit = Visibility.Visible;
|
NotMenuEdit = Visibility.Visible;
|
||||||
}
|
}
|
||||||
OnPropertyChanged("MenuEdit");
|
OnPropertyChanged("MenuEdit");
|
||||||
@@ -128,11 +151,23 @@ namespace GeekDesk.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override String ToString()
|
||||||
|
{
|
||||||
|
return JsonConvert.SerializeObject(this);
|
||||||
|
}
|
||||||
|
|
||||||
[field: NonSerializedAttribute()]
|
[field: NonSerializedAttribute()]
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
private void OnPropertyChanged(string propertyName)
|
private void OnPropertyChanged(string propertyName)
|
||||||
{
|
{
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
foreach (string field in NO_WRITE_ARR)
|
||||||
|
{
|
||||||
|
if (field.Equals(propertyName))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
CommonCode.SaveAppData(MainWindow.appData);
|
CommonCode.SaveAppData(MainWindow.appData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user