diff --git a/Constant/AppHideType.cs b/Constant/AppHideType.cs
new file mode 100644
index 0000000..2ebeb0d
--- /dev/null
+++ b/Constant/AppHideType.cs
@@ -0,0 +1,14 @@
+
+
+///
+/// 面板隐藏方式
+///
+namespace GeekDesk.Constant
+{
+ public enum AppHideType
+ {
+ LOST_FOCUS = 1, // 失去焦点后
+ START_EXE = 2, //启动程序后
+ HANDLE = 3 //手动关闭
+ }
+}
diff --git a/Constant/DefaultConstant.cs b/Constant/DefaultConstant.cs
index 1804108..1b9f5da 100644
--- a/Constant/DefaultConstant.cs
+++ b/Constant/DefaultConstant.cs
@@ -3,7 +3,7 @@
///
namespace GeekDesk.Constant
{
- enum DefaultConstant
+ public enum DefaultConstant
{
WINDOW_WIDTH = 666, //默认窗体宽度
WINDOW_HEIGHT = 500, //默认窗体高度
diff --git a/Constant/IconStartType.cs b/Constant/IconStartType.cs
index f3398ec..1d94174 100644
--- a/Constant/IconStartType.cs
+++ b/Constant/IconStartType.cs
@@ -9,7 +9,7 @@ using System.Threading.Tasks;
///
namespace GeekDesk.Constant
{
- enum IconStartType
+ public enum IconStartType
{
DEFAULT_STARTUP = 1, //默认启动方式
ADMIN_STARTUP = 2, //管理员方式启动
diff --git a/Constant/SortType.cs b/Constant/SortType.cs
index 0255755..cace5e4 100644
--- a/Constant/SortType.cs
+++ b/Constant/SortType.cs
@@ -1,6 +1,6 @@
namespace GeekDesk.Constant
{
- enum SortType
+ public enum SortType
{
CUSTOM = 1, //自定义排序
NAME = 2, //按名称排序
diff --git a/Control/ConfigDialog.xaml b/Control/ConfigDialog.xaml
new file mode 100644
index 0000000..6f7aedc
--- /dev/null
+++ b/Control/ConfigDialog.xaml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Control/ConfigDialog.xaml.cs b/Control/ConfigDialog.xaml.cs
new file mode 100644
index 0000000..c9c22e0
--- /dev/null
+++ b/Control/ConfigDialog.xaml.cs
@@ -0,0 +1,14 @@
+
+namespace GeekDesk.Control
+{
+ ///
+ /// ConfigDialog.xaml 的交互逻辑
+ ///
+ public partial class ConfigDialog
+ {
+ public ConfigDialog()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/GeekDesk.csproj b/GeekDesk.csproj
index 2e11a81..f747356 100644
--- a/GeekDesk.csproj
+++ b/GeekDesk.csproj
@@ -71,10 +71,14 @@
+
+
+ ConfigDialog.xaml
+
IconInfoDialog.xaml
@@ -90,13 +94,18 @@
+
+
-
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/MainWindow.xaml b/MainWindow.xaml
index a0c6e6c..a7fa242 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -15,6 +15,9 @@
Background="Transparent"
OpacityMask ="White"
>
+
+
+
@@ -90,7 +93,6 @@
-
@@ -132,20 +134,29 @@
+ BorderThickness="0"
+ hc:IconElement.Geometry="M917.930667 512c0-57.6 36.181333-106.496 86.869333-125.952a505.429333 505.429333 0 0 0-55.210667-133.461333A134.826667 134.826667 0 0 1 771.413333 74.410667 507.733333 507.733333 0 0 0 637.952 19.2 135.168 135.168 0 0 1 512 106.069333 134.912 134.912 0 0 1 386.048 19.2 505.429333 505.429333 0 0 0 252.586667 74.410667c22.186667 49.749333 13.141333 109.824-27.562667 150.528a135.168 135.168 0 0 1-150.528 27.648 502.016 502.016 0 0 0-55.296 133.461333c50.688 19.626667 86.869333 68.437333 86.869333 125.952 0 57.6-36.181333 106.496-86.869333 125.952 12.117333 47.530667 30.72 92.330667 55.210667 133.461333a134.826667 134.826667 0 0 1 178.090666 178.176 507.733333 507.733333 0 0 0 133.546667 55.210667A135.168 135.168 0 0 1 512 917.930667c57.6 0 106.496 36.181333 125.952 86.869333a505.429333 505.429333 0 0 0 133.461333-55.210667 134.912 134.912 0 0 1 27.562667-150.528 135.168 135.168 0 0 1 150.528-27.648 502.016 502.016 0 0 0 55.296-133.461333A134.912 134.912 0 0 1 917.930667 512zM512 647.338667a135.338667 135.338667 0 1 1 0.085333-270.762667A135.338667 135.338667 0 0 1 512 647.338667z"
+ hc:IconElement.Height="18"
+ hc:IconElement.Width="18"
+ HorizontalAlignment="Right"
+ Click="ConfigButtonClick"
+ Initialized="SettingButton_Initialized"
+ x:Name="SettingButton"
+ >
+
+
+
+
+
+
+ BorderThickness="0"
+ hc:IconElement.Geometry="M828.770654 148.714771C641.293737-20.89959 354.184117-19.590868 168.245698 152.630946c-212.062907 196.418185-212.062907 522.329912 0 718.748098 185.93842 172.221815 473.048039 173.520546 660.524956 3.916176 219.435707-198.536117 219.435707-528.054322 0-726.580449z m-121.880976 569.643707c-11.708566 11.708566-30.680039 11.708566-42.388605 0L502.729054 556.586459c-0.659356-0.659356-1.728312-0.659356-2.397659 0L338.609327 718.318517c-11.708566 11.708566-30.680039 11.708566-42.388605 0l-0.039961-0.039961c-11.708566-11.708566-11.708566-30.680039 0-42.388605l161.732059-161.732058c0.659356-0.659356 0.659356-1.728312 0-2.397659L296.1408 350.008195c-11.708566-11.708566-11.708566-30.680039 0-42.388605l0.039961-0.039961c11.708566-11.708566 30.680039-11.708566 42.388605 0l161.772019 161.77202c0.659356 0.659356 1.728312 0.659356 2.397659 0L664.551024 307.539668c11.708566-11.708566 30.680039-11.708566 42.388605 0l0.039961 0.039961c11.708566 11.708566 11.708566 30.680039 0 42.388605L545.15762 511.770224c-0.659356 0.659356-0.659356 1.728312 0 2.397659L706.919649 675.939902c11.708566 11.708566 11.708566 30.680039 0 42.388605l-0.029971 0.029971z"
+ hc:IconElement.Height="18"
+ hc:IconElement.Width="18"
+ HorizontalAlignment="Right"
+ Click="CloseButtonClick"
+ />
@@ -209,7 +220,7 @@
KeyDown="LostFocusOrEnterDown"
Tag="{Binding}"
IsVisibleChanged="MenuEditWhenVisibilityChanged"
- Visibility="{Binding Path=MenuEdit, Converter={StaticResource VisibilityConvert}}"/>
+ Visibility="{Binding MenuEdit}"/>
@@ -267,6 +278,7 @@
+
@@ -304,7 +316,16 @@
-
+
+
+
+
+
+
+
+
+
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index f82626d..e45301b 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -10,9 +10,7 @@ using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Effects;
-using System.Windows.Media.Imaging;
+
namespace GeekDesk
{
@@ -29,23 +27,6 @@ namespace GeekDesk
{
InitializeComponent();
loadData();
- //Border border = new Border();
- //VisualBrush brush = new VisualBrush();
- //brush.Visual = test;
- //brush.Stretch = Stretch.Uniform;
- //border.Background = brush;
- //border.Effect = new BlurEffect()
- //{
- // Radius = 80,
- // RenderingBias = RenderingBias.Performance
- //};
- //border.Margin = new Thickness(-this.Margin.Left, -this.Margin.Top, 0, 0);
- //this.ClipToBounds = true;
- //this.Children.Clear();
- //this.Children.Add(border);
- //this.DataContext = mainModel;
- //menu.Items = mainModel;
- //System.Diagnostics.Process.Start(@"D:\SoftWare\WeGame\wegame.exe");
this.Loaded += Window_Loaded;
this.SizeChanged += MainWindow_Resize;
this.Topmost = true;
@@ -56,8 +37,9 @@ namespace GeekDesk
this.DataContext = appData;
if (appData.MenuList.Count == 0)
{
- appData.MenuList.Add(new MenuInfo() { MenuName = "NewMenu", MenuId = System.Guid.NewGuid().ToString(), MenuEdit = (int)Visibility.Collapsed});
+ appData.MenuList.Add(new MenuInfo() { MenuName = "NewMenu", MenuId = System.Guid.NewGuid().ToString(), MenuEdit = Visibility.Collapsed});
}
+ this.Visibility = appData.AppConfig.StartedShowPanel;
//窗体大小
LeftColumn.Width = new GridLength(appData.AppConfig.MenuCardWidth);
this.Width = appData.AppConfig.WindowWidth;
@@ -254,7 +236,7 @@ namespace GeekDesk
{
if (this.Visibility == Visibility.Collapsed)
{
- this.Visibility = Visibility.Visible;
+ ShowAppAndFollowMouse();
} else
{
this.Visibility = Visibility.Collapsed;
@@ -289,9 +271,33 @@ namespace GeekDesk
private void DragMove(object sender, MouseEventArgs e)
{
+ //if (e.LeftButton == MouseButtonState.Pressed)
+ //{
+ // this.DragMove();
+ //}
+
if (e.LeftButton == MouseButtonState.Pressed)
{
- this.DragMove();
+ var windowMode = this.ResizeMode;
+ if (this.ResizeMode != ResizeMode.NoResize)
+ {
+ this.ResizeMode = ResizeMode.NoResize;
+ }
+
+ this.UpdateLayout();
+
+
+ /* 当点击拖拽区域的时候,让窗口跟着移动
+ (When clicking the drag area, make the window follow) */
+ DragMove();
+
+
+ if (this.ResizeMode != windowMode)
+ {
+ this.ResizeMode = windowMode;
+ }
+
+ this.UpdateLayout();
}
}
@@ -332,7 +338,7 @@ namespace GeekDesk
MenuInfo menuInfo = menuBox.Tag as MenuInfo;
string text = menuBox.Text;
menuInfo.MenuName = text;
- menuInfo.MenuEdit = (int)Visibility.Collapsed;
+ menuInfo.MenuEdit = Visibility.Collapsed;
CommonCode.SaveAppData(appData);
}
}
@@ -381,7 +387,7 @@ namespace GeekDesk
///
private void CreateMenu(object sender, RoutedEventArgs e)
{
- appData.MenuList.Add(new MenuInfo() { MenuEdit = (int)Visibility.Collapsed, MenuId = System.Guid.NewGuid().ToString(), MenuName = "NewMenu" });
+ appData.MenuList.Add(new MenuInfo() { MenuEdit = Visibility.Collapsed, MenuId = System.Guid.NewGuid().ToString(), MenuName = "NewMenu" });
menus.SelectedIndex = appData.MenuList.Count - 1;
//appData.MenuList[appData.MenuList.Count - 1].MenuEdit = (int)Visibility.Visible;
CommonCode.SaveAppData(appData);
@@ -397,21 +403,7 @@ namespace GeekDesk
this.Visibility = Visibility.Collapsed;
}
- ///
- /// 图片图标单击事件
- ///
- ///
- ///
- private void NotifyIcon_Click(object sender, RoutedEventArgs e)
- {
- if (this.Visibility == Visibility.Collapsed)
- {
- this.Visibility = Visibility.Visible;
- } else
- {
- this.Visibility = Visibility.Collapsed;
- }
- }
+
///
/// 弹出Icon属性修改面板
@@ -444,6 +436,133 @@ namespace GeekDesk
appData.AppConfig.MenuCardWidth = LeftColumn.Width.Value;
CommonCode.SaveAppData(appData);
}
+
+ ///
+ /// 随鼠标位置显示面板 (鼠标始终在中间)
+ ///
+ private void ShowAppAndFollowMouse()
+ {
+ //获取鼠标位置
+ Point p = MouseUtil.GetMousePosition();
+ double left = SystemParameters.VirtualScreenLeft;
+ double top = SystemParameters.VirtualScreenTop;
+ double width = SystemParameters.VirtualScreenWidth;
+ double height = SystemParameters.VirtualScreenHeight;
+ double right = width - Math.Abs(left);
+ double bottom = height - Math.Abs(top);
+
+
+ if (p.X - this.Width / 2 < left)
+ {
+ //判断是否在最左边缘
+ this.Left = left;
+ } else if (p.X + this.Width / 2 > right)
+ {
+ //判断是否在最右边缘
+ this.Left = right - this.Width;
+ } else
+ {
+ this.Left = p.X - this.Width / 2;
+ }
+
+
+ if (p.Y - this.Height / 2 < top)
+ {
+ //判断是否在最上边缘
+ this.Top = top;
+ } else if (p.Y + this.Height/2 > bottom)
+ {
+ //判断是否在最下边缘
+ this.Top = bottom - this.Height;
+ } else
+ {
+ this.Top = p.Y - this.Height / 2;
+ }
+
+ this.Visibility = Visibility.Visible;
+ }
+
+ ///
+ /// 右键任务栏图标 显示主面板
+ ///
+ ///
+ ///
+ private void ShowApp(object sender, RoutedEventArgs e)
+ {
+ ShowApp();
+ }
+ private void ShowApp()
+ {
+ this.Visibility = Visibility.Visible;
+ ShowAppAndFollowMouse();
+ }
+
+ ///
+ /// 图片图标单击事件
+ ///
+ ///
+ ///
+ private void NotifyIcon_Click(object sender, RoutedEventArgs e)
+ {
+ if (this.Visibility == Visibility.Collapsed)
+ {
+ ShowApp();
+ }
+ else
+ {
+ this.Visibility = Visibility.Collapsed;
+ }
+ }
+
+ ///
+ /// 右键任务栏图标 设置
+ ///
+ ///
+ ///
+ private void ConfigApp(object sender, RoutedEventArgs e)
+ {
+ //MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo;
+ //appData.MenuList.Remove(menuInfo);
+
+
+
+ CommonCode.SaveAppData(appData);
+ }
+
+ ///
+ /// 右键任务栏图标退出
+ ///
+ ///
+ ///
+ private void ExitApp(object sender, RoutedEventArgs e)
+ {
+ Application.Current.Shutdown();
+ }
+
+ private void MenuItem_Click(object sender, RoutedEventArgs e)
+ {
+
+ }
+
+ ///
+ /// 设置按钮左键弹出菜单
+ ///
+ ///
+ ///
+ private void ConfigButtonClick(object sender, RoutedEventArgs e)
+ {
+ SettingMenu.IsOpen = true;
+ }
+
+ ///
+ /// 禁用设置按钮右键菜单
+ ///
+ ///
+ ///
+ private void SettingButton_Initialized(object sender, EventArgs e)
+ {
+ SettingButton.ContextMenu = null;
+ }
}
diff --git a/Util/HotKey.cs b/Util/HotKey.cs
index 34f51f2..8f37695 100644
--- a/Util/HotKey.cs
+++ b/Util/HotKey.cs
@@ -5,6 +5,10 @@ using System.Windows;
using System.Windows.Input;
using System.Windows.Interop;
+
+///
+/// 热键注册
+///
namespace GeekDesk.Util
{
diff --git a/Util/MouseUtil.cs b/Util/MouseUtil.cs
new file mode 100644
index 0000000..210e72d
--- /dev/null
+++ b/Util/MouseUtil.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace GeekDesk.Util
+{
+ class MouseUtil
+ {
+ [DllImport("user32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool GetCursorPos(ref Win32Point pt);
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct Win32Point
+ {
+ public Int32 X;
+ public Int32 Y;
+ };
+
+ ///
+ /// 获取鼠标坐标
+ ///
+ ///
+ public static Point GetMousePosition()
+ {
+ var w32Mouse = new Win32Point();
+ GetCursorPos(ref w32Mouse);
+ return new Point(w32Mouse.X, w32Mouse.Y);
+ }
+ }
+}
diff --git a/Util/ScreenUtil.cs b/Util/ScreenUtil.cs
new file mode 100644
index 0000000..ecaaa28
--- /dev/null
+++ b/Util/ScreenUtil.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GeekDesk.Util
+{
+ class ScreenUtil
+ {
+
+
+
+ }
+}
diff --git a/Util/VisibilityConvert.cs b/Util/VisibilityConvert.cs
deleted file mode 100644
index 0c5fe2d..0000000
--- a/Util/VisibilityConvert.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Data;
-
-namespace GeekDesk.Util
-{
- class VisibilityConvert : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- int v = (int)value;
-
- if (v == (int)Visibility.Visible)
- {
- return Visibility.Visible;
- } else if (v == (int)Visibility.Collapsed)
- {
- return Visibility.Collapsed;
- }
- return v;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/ViewModel/AppConfig.cs b/ViewModel/AppConfig.cs
index 4571668..1af16f8 100644
--- a/ViewModel/AppConfig.cs
+++ b/ViewModel/AppConfig.cs
@@ -2,23 +2,84 @@
using GeekDesk.Constant;
using System;
using System.ComponentModel;
+using System.Windows;
+///
+/// 程序设置
+///
namespace GeekDesk.ViewModel
{
[Serializable]
public class AppConfig : INotifyPropertyChanged
{
- private int menuSortType = (int)SortType.CUSTOM; //菜单排序类型
- private int iconSortType = (int)SortType.CUSTOM; //图表排序类型
+ private SortType menuSortType = SortType.CUSTOM; //菜单排序类型
+ private SortType iconSortType = SortType.CUSTOM; //图表排序类型
private double windowWidth = (double)DefaultConstant.WINDOW_WIDTH; //窗口宽度
private double windowHeight = (double)DefaultConstant.WINDOW_HEIGHT; //窗口高度
private double menuCardWidth = (double)DefaultConstant.MENU_CARD_WIDHT;//菜单栏宽度
private int selectedMenuIndex = 0; //上次选中菜单索引
-
+ private bool followMouse = true; //面板跟随鼠标 默认是
+ private Visibility configIconVisible = Visibility.Visible; // 设置按钮是否显示
+ private AppHideType appHideType = AppHideType.START_EXE; //面板关闭方式 (默认启动程序后)
+ private Visibility startedShowPanel = Visibility.Visible; //启动时是否显示主面板 默认显示
#region GetSet
+
+ public Visibility StartedShowPanel
+ {
+ get
+ {
+ return startedShowPanel;
+ }
+ set
+ {
+ startedShowPanel = value;
+ OnPropertyChanged("StartedShowPanel");
+ }
+ }
+
+ public AppHideType AppHideType
+ {
+ get
+ {
+ return appHideType;
+ }
+ set
+ {
+ appHideType = value;
+ OnPropertyChanged("AppHideType");
+ }
+ }
+
+ public Visibility ConfigIconVisible
+ {
+ get
+ {
+ return configIconVisible;
+ }
+ set
+ {
+ configIconVisible = value;
+ OnPropertyChanged("ConfigIconVisible");
+ }
+ }
+
+
+ public bool FollowMouse
+ {
+ get
+ {
+ return followMouse;
+ }
+ set
+ {
+ followMouse = value;
+ OnPropertyChanged("FollowMouse");
+ }
+ }
+
public int SelectedMenuIndex
{
get
@@ -32,7 +93,7 @@ namespace GeekDesk.ViewModel
}
}
- public int MenuSortType
+ public SortType MenuSortType
{
get
{
@@ -45,7 +106,7 @@ namespace GeekDesk.ViewModel
}
}
- public int IconSortType
+ public SortType IconSortType
{
get
{
diff --git a/ViewModel/AppData.cs b/ViewModel/AppData.cs
index 473e9c9..645ad64 100644
--- a/ViewModel/AppData.cs
+++ b/ViewModel/AppData.cs
@@ -3,6 +3,9 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
+///
+/// 程序数据
+///
namespace GeekDesk.ViewModel
{
[Serializable]
diff --git a/ViewModel/IconInfo.cs b/ViewModel/IconInfo.cs
index 51b7cc0..0582dd0 100644
--- a/ViewModel/IconInfo.cs
+++ b/ViewModel/IconInfo.cs
@@ -5,6 +5,9 @@ using System.ComponentModel;
using System.IO;
using System.Windows.Media.Imaging;
+///
+/// 图标信息
+///
namespace GeekDesk.ViewModel
{
[Serializable]
@@ -20,7 +23,7 @@ namespace GeekDesk.ViewModel
private int imageWidth = (int)DefaultConstant.IMAGE_WIDTH; //图片宽度
private int imageHeight = (int)DefaultConstant.IMAGE_HEIGHT; //图片高度
private bool adminStartUp = false; //始终管理员方式启动 默认否
- private byte[] defaultImage;
+ private byte[] defaultImage; //默认图标
diff --git a/ViewModel/MenuInfo.cs b/ViewModel/MenuInfo.cs
index 80adbcc..56c04b0 100644
--- a/ViewModel/MenuInfo.cs
+++ b/ViewModel/MenuInfo.cs
@@ -1,10 +1,6 @@
using System;
-using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows;
namespace GeekDesk.ViewModel
@@ -17,8 +13,8 @@ namespace GeekDesk.ViewModel
private string menuName;
private string menuId;
- private int menuEdit = (int)Visibility.Collapsed;
- private int notMenuEdit = (int)Visibility.Visible;
+ private Visibility menuEdit = Visibility.Collapsed;
+ private Visibility notMenuEdit = Visibility.Visible;
private ObservableCollection iconList = new ObservableCollection();
public string MenuName
@@ -47,7 +43,7 @@ namespace GeekDesk.ViewModel
}
}
- public int MenuEdit
+ public Visibility MenuEdit
{
get
{
@@ -56,18 +52,18 @@ namespace GeekDesk.ViewModel
set
{
menuEdit = value;
- if (menuEdit == (int)Visibility.Visible)
+ if (menuEdit == Visibility.Visible)
{
- NotMenuEdit = (int)Visibility.Collapsed;
+ NotMenuEdit = Visibility.Collapsed;
} else
{
- NotMenuEdit = (int)Visibility.Visible;
+ NotMenuEdit = Visibility.Visible;
}
OnPropertyChanged("MenuEdit");
}
}
- public int NotMenuEdit
+ public Visibility NotMenuEdit
{
get
{