liufei 4 роки тому
батько
коміт
4701ecc781

+ 14 - 0
Constant/AppHideType.cs

@@ -0,0 +1,14 @@
+
+
+/// <summary>
+/// 面板隐藏方式
+/// </summary>
+namespace GeekDesk.Constant
+{
+    public enum AppHideType
+    {
+        LOST_FOCUS = 1, // 失去焦点后
+        START_EXE = 2,   //启动程序后
+        HANDLE = 3   //手动关闭
+    }
+}

+ 1 - 1
Constant/DefaultConstant.cs

@@ -3,7 +3,7 @@
 /// </summary>
 namespace GeekDesk.Constant
 {
-    enum DefaultConstant
+    public enum DefaultConstant
     {
         WINDOW_WIDTH = 666, //默认窗体宽度
         WINDOW_HEIGHT = 500, //默认窗体高度

+ 1 - 1
Constant/IconStartType.cs

@@ -9,7 +9,7 @@ using System.Threading.Tasks;
 /// </summary>
 namespace GeekDesk.Constant
 {
-    enum IconStartType
+    public enum IconStartType
     {
         DEFAULT_STARTUP = 1, //默认启动方式
         ADMIN_STARTUP = 2,  //管理员方式启动

+ 1 - 1
Constant/SortType.cs

@@ -1,6 +1,6 @@
 namespace GeekDesk.Constant
 {
-    enum SortType
+    public enum SortType
     {
         CUSTOM = 1, //自定义排序
         NAME = 2, //按名称排序

+ 35 - 0
Control/ConfigDialog.xaml

@@ -0,0 +1,35 @@
+<hc:Window x:Class="GeekDesk.Control.ConfigDialog"
+           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+           xmlns:hc="https://handyorg.github.io/handycontrol"
+           mc:Ignorable="d"
+           WindowStartupLocation="CenterScreen"
+           Height="450" 
+           Width="800" 
+           WindowStyle="None"
+           AllowsTransparency="True"
+           Opacity="0.9"
+           >
+    <hc:Window.Background>
+        <SolidColorBrush Color="AliceBlue" Opacity="0.9"/>
+    </hc:Window.Background>
+
+    <Grid>
+        <hc:SideMenu BorderThickness="1" Width="200" Margin="32">
+            <hc:Interaction.Triggers>
+                <hc:EventTrigger EventName="SelectionChanged">
+                    <hc:EventToCommand Command="{Binding SwitchItemCmd}" PassEventArgsToCommand="True" />
+                </hc:EventTrigger>
+            </hc:Interaction.Triggers>
+
+            <hc:SideMenuItem Header="Work Items">
+                <hc:SideMenuItem.Icon>
+                    <TextBlock Text="&#xf314;" Style="{StaticResource TextBlockFabricIcons}"/>
+                </hc:SideMenuItem.Icon>
+            </hc:SideMenuItem>
+        </hc:SideMenu>
+    </Grid>
+           
+</hc:Window>

+ 14 - 0
Control/ConfigDialog.xaml.cs

@@ -0,0 +1,14 @@
+
+namespace GeekDesk.Control
+{
+    /// <summary>
+    /// ConfigDialog.xaml 的交互逻辑
+    /// </summary>
+    public partial class ConfigDialog
+    {
+        public ConfigDialog()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 10 - 1
GeekDesk.csproj

@@ -71,10 +71,14 @@
     <Compile Include="Command\DelegateCommand.cs" />
     <Compile Include="Command\DelegateCommandBase.cs" />
     <Compile Include="Constant\AppConstant.cs" />
+    <Compile Include="Constant\AppHideType.cs" />
     <Compile Include="Constant\Constants.cs" />
     <Compile Include="Constant\DefaultConstant.cs" />
     <Compile Include="Constant\IconStartType.cs" />
     <Compile Include="Constant\SortType.cs" />
+    <Compile Include="Control\ConfigDialog.xaml.cs">
+      <DependentUpon>ConfigDialog.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Control\IconInfoDialog.xaml.cs">
       <DependentUpon>IconInfoDialog.xaml</DependentUpon>
     </Compile>
@@ -90,13 +94,18 @@
     <Compile Include="Util\ImageUtil.cs" />
     <Compile Include="Util\ListViewDragDropManager.cs" />
     <Compile Include="Util\MenuWidthConvert.cs" />
+    <Compile Include="Util\MouseUtil.cs" />
     <Compile Include="Util\MouseUtilities.cs" />
+    <Compile Include="Util\ScreenUtil.cs" />
     <Compile Include="Util\SystemIcon.cs" />
-    <Compile Include="Util\VisibilityConvert.cs" />
     <Compile Include="ViewModel\AppConfig.cs" />
     <Compile Include="ViewModel\AppData.cs" />
     <Compile Include="ViewModel\IconInfo.cs" />
     <Compile Include="ViewModel\MenuInfo.cs" />
+    <Page Include="Control\ConfigDialog.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Control\IconInfoDialog.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 38 - 17
MainWindow.xaml

@@ -15,6 +15,9 @@
         Background="Transparent"
         OpacityMask ="White"
         >
+    <WindowChrome.WindowChrome>
+        <WindowChrome CaptionHeight="0" ResizeBorderThickness="10"/>
+    </WindowChrome.WindowChrome>
     <Window.Resources>
 
         <!--左侧栏样式动画-->
@@ -90,7 +93,6 @@
         </Style>
 
         <util:MenuWidthConvert x:Key="MenuWidthConvert"/>
-        <util:VisibilityConvert x:Key="VisibilityConvert"/>
 
     </Window.Resources>
 
@@ -132,20 +134,29 @@
                     </DockPanel.Background>
                     <hc:UniformSpacingPanel Spacing="0" Grid.ColumnSpan="4" HorizontalAlignment="Right" VerticalAlignment="Center">
                         <Button Background="Transparent" 
-                    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"
-                    />
+                                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"
+                                >
+                            <Button.ContextMenu>
+                                <ContextMenu Width="200" x:Name="SettingMenu">
+                                    <MenuItem Header="设置" Click="ConfigApp"/>
+                                </ContextMenu>
+                            </Button.ContextMenu>
+                        </Button>
                         <Button Background="Transparent" 
-                    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"
-                    />
+                                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"
+                                />
                     </hc:UniformSpacingPanel>
 
                 </DockPanel>
@@ -209,7 +220,7 @@
                                      KeyDown="LostFocusOrEnterDown"
                                      Tag="{Binding}"
                                      IsVisibleChanged="MenuEditWhenVisibilityChanged"
-                                     Visibility="{Binding Path=MenuEdit, Converter={StaticResource VisibilityConvert}}"/>
+                                     Visibility="{Binding MenuEdit}"/>
                                         <StackPanel Orientation="Horizontal">
                                             <Button Background="Transparent" 
                                         BorderThickness="0"
@@ -220,7 +231,7 @@
                                             <TextBlock Text="{Binding MenuName}"
                                            VerticalAlignment="Center"
                                            IsVisibleChanged="MenuWhenVisibilityChanged"
-                                           Visibility="{Binding Path=NotMenuEdit, Converter={StaticResource VisibilityConvert}}"
+                                           Visibility="{Binding NotMenuEdit}"
                                            />
                                         </StackPanel>
 
@@ -267,6 +278,7 @@
                                 <ContextMenu x:Key="iconDialog" Width="200">
                                     <MenuItem Header="管理员方式运行" Click="IconAdminStart" Tag="{Binding}"/>
                                     <MenuItem Header="打开文件所在位置" Click="ShowInExplore" Tag="{Binding}"/>
+                                    <MenuItem Header="资源管理器菜单" Click="MenuItem_Click" Tag="{Binding}"/>
                                     <MenuItem Header="属性" Click="PropertyConfig" Tag="{Binding}"/>
                                     <MenuItem Header="从列表移除" Click="RemoveIcon" Tag="{Binding}"/>
                                 </ContextMenu>
@@ -304,7 +316,16 @@
                         </ListBox>
                     </WrapPanel>
                 </hc:Card>
-                <hc:NotifyIcon Icon="/Resource/Image/Ico.png" Text="GeekDesk" Click="NotifyIcon_Click"/>
+                <hc:NotifyIcon Icon="/Resource/Image/Ico.png" Text="GeekDesk" Click="NotifyIcon_Click">
+                    <hc:NotifyIcon.ContextMenu>
+                        <ContextMenu Width="200">
+                            <MenuItem Header="打开面板" Click="ShowApp"/>
+                            <MenuItem Header="设置"  Click="ConfigApp"/>
+                            <MenuItem Header="退出" Click="ExitApp"/>
+                        </ContextMenu>
+                    </hc:NotifyIcon.ContextMenu>
+                    
+                </hc:NotifyIcon>
                 <StackPanel hc:Growl.GrowlParent="True" VerticalAlignment="Top" Margin="0,10,10,0"/>
             </Grid>
         </Border>

+ 157 - 38
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
         /// <param name="e"></param>
         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,6 +403,100 @@ namespace GeekDesk
             this.Visibility = Visibility.Collapsed;
         }
 
+       
+
+        /// <summary>
+        /// 弹出Icon属性修改面板
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void PropertyConfig(object sender, RoutedEventArgs e)
+        {
+            HandyControl.Controls.Dialog.Show(new IconInfoDialog((IconInfo)((MenuItem)sender).Tag));
+        }
+
+        /// <summary>
+        /// 从列表删除图标
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void RemoveIcon(object sender, RoutedEventArgs e)
+        {
+            appData.MenuList[menus.SelectedIndex].IconList.Remove((IconInfo)((MenuItem)sender).Tag);
+            CommonCode.SaveAppData(appData);
+        }
+
+        /// <summary>
+        /// 左侧栏宽度改变 持久化
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void LeftCardResize(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
+        {
+            appData.AppConfig.MenuCardWidth = LeftColumn.Width.Value;
+            CommonCode.SaveAppData(appData);
+        }
+
+        /// <summary>
+        /// 随鼠标位置显示面板 (鼠标始终在中间)
+        /// </summary>
+        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;
+        }
+
+        /// <summary>
+        /// 右键任务栏图标 显示主面板
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ShowApp(object sender, RoutedEventArgs e)
+        {
+            ShowApp();
+        }
+        private void ShowApp()
+        {
+            this.Visibility = Visibility.Visible;
+            ShowAppAndFollowMouse();
+        }
+
         /// <summary>
         /// 图片图标单击事件
         /// </summary>
@@ -406,43 +506,62 @@ namespace GeekDesk
         {
             if (this.Visibility == Visibility.Collapsed)
             {
-                this.Visibility = Visibility.Visible;
-            } else
+                ShowApp();
+            }
+            else
             {
                 this.Visibility = Visibility.Collapsed;
             }
         }
 
         /// <summary>
-        /// 弹出Icon属性修改面板
+        /// 右键任务栏图标 设置
         /// </summary>
         /// <param name="sender"></param>
         /// <param name="e"></param>
-        private void PropertyConfig(object sender, RoutedEventArgs e)
+        private void ConfigApp(object sender, RoutedEventArgs e)
         {
-            HandyControl.Controls.Dialog.Show(new IconInfoDialog((IconInfo)((MenuItem)sender).Tag));
+            //MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo;
+            //appData.MenuList.Remove(menuInfo);
+
+
+
+            CommonCode.SaveAppData(appData);
         }
 
         /// <summary>
-        /// 从列表删除图标
+        /// 右键任务栏图标退出
         /// </summary>
         /// <param name="sender"></param>
         /// <param name="e"></param>
-        private void RemoveIcon(object sender, RoutedEventArgs e)
+        private void ExitApp(object sender, RoutedEventArgs e)
         {
-            appData.MenuList[menus.SelectedIndex].IconList.Remove((IconInfo)((MenuItem)sender).Tag);
-            CommonCode.SaveAppData(appData);
+            Application.Current.Shutdown();
+        }
+
+        private void MenuItem_Click(object sender, RoutedEventArgs e)
+        {
+
         }
 
         /// <summary>
-        /// 左侧栏宽度改变 持久化
+        /// 设置按钮左键弹出菜单
         /// </summary>
         /// <param name="sender"></param>
         /// <param name="e"></param>
-        private void LeftCardResize(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
+        private void ConfigButtonClick(object sender, RoutedEventArgs e)
         {
-            appData.AppConfig.MenuCardWidth = LeftColumn.Width.Value;
-            CommonCode.SaveAppData(appData);
+            SettingMenu.IsOpen = true;
+        }
+
+        /// <summary>
+        /// 禁用设置按钮右键菜单
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void SettingButton_Initialized(object sender, EventArgs e)
+        {
+            SettingButton.ContextMenu = null;
         }
     }
 

+ 4 - 0
Util/HotKey.cs

@@ -5,6 +5,10 @@ using System.Windows;
 using System.Windows.Input;
 using System.Windows.Interop;
 
+
+/// <summary>
+/// 热键注册
+/// </summary>
 namespace GeekDesk.Util
 {
 

+ 35 - 0
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;
+        };
+
+        /// <summary>
+        /// 获取鼠标坐标
+        /// </summary>
+        /// <returns></returns>
+        public static Point GetMousePosition()
+        {
+            var w32Mouse = new Win32Point();
+            GetCursorPos(ref w32Mouse);
+            return new Point(w32Mouse.X, w32Mouse.Y);
+        }
+    }
+}

+ 15 - 0
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
+    {
+
+
+
+    }
+}

+ 0 - 33
Util/VisibilityConvert.cs

@@ -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();
-        }
-    }
-}

+ 66 - 5
ViewModel/AppConfig.cs

@@ -2,23 +2,84 @@
 using GeekDesk.Constant;
 using System;
 using System.ComponentModel;
+using System.Windows;
 
+/// <summary>
+/// 程序设置
+/// </summary>
 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
             {

+ 3 - 0
ViewModel/AppData.cs

@@ -3,6 +3,9 @@ using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.ComponentModel;
 
+/// <summary>
+/// 程序数据
+/// </summary>
 namespace GeekDesk.ViewModel
 {
     [Serializable]

+ 4 - 1
ViewModel/IconInfo.cs

@@ -5,6 +5,9 @@ using System.ComponentModel;
 using System.IO;
 using System.Windows.Media.Imaging;
 
+/// <summary>
+/// 图标信息
+/// </summary>
 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; //默认图标
 
 
 

+ 7 - 11
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<IconInfo> iconList = new ObservableCollection<IconInfo>();
 
         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
             {