소스 검색

周五喽

liufei 4 년 전
부모
커밋
5faf6e11b2

+ 9 - 8
Control/ConfigWindow.xaml

@@ -12,7 +12,8 @@
            AllowsTransparency="True"
            AllowsTransparency="True"
            Background="Transparent"
            Background="Transparent"
            >
            >
-    <Border CornerRadius="8" BorderThickness="0">
+
+        <Border CornerRadius="8" BorderThickness="0">
         <Border.Background>
         <Border.Background>
             <SolidColorBrush Color="AliceBlue" Opacity="0.9"/>
             <SolidColorBrush Color="AliceBlue" Opacity="0.9"/>
         </Border.Background>
         </Border.Background>
@@ -56,13 +57,13 @@
                     </hc:SideMenuItem>
                     </hc:SideMenuItem>
                 </hc:SideMenu>
                 </hc:SideMenu>
             </hc:Card>
             </hc:Card>
-            <hc:Card x:Name="RightCard" Grid.Row="0" Grid.Column="1" MouseDown="DragMove">
-            </hc:Card>
-            <Button Width="22" Height="22" Click="Close_Button_Click" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" Grid.Column="1"/>
-        </Grid>
+            <hc:ScrollViewer  Grid.Row="0" Grid.Column="1">
+                <hc:Card x:Name="RightCard" Height="600"  MouseDown="DragMove">
+                </hc:Card>
+            </hc:ScrollViewer>
 
 
+        <Button Width="22" Height="22" Click="Close_Button_Click" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" Grid.Column="1"/>
+        </Grid>
     </Border>
     </Border>
-    
-    
-           
+
 </hc:Window>
 </hc:Window>

+ 138 - 0
Control/UserControls/LeftCardControl.xaml

@@ -0,0 +1,138 @@
+<UserControl x:Class="GeekDesk.Control.UserControls.LeftCardControl"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:GeekDesk.Control.UserControls"
+             xmlns:hc="https://handyorg.github.io/handycontrol"
+             xmlns:cvt="clr-namespace:GeekDesk.Converts"
+             xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
+    <UserControl.Resources>
+
+        <!--左侧栏样式动画-->
+        <Style x:Key="menuStyle" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItemBaseStyle}">
+            <Setter Property="FontSize" Value="15"/>
+            <Setter Property="Margin" Value="0,0,0,1"/>
+            <Setter Property="Background">
+                <Setter.Value>
+                    <SolidColorBrush Opacity="0"/>
+                </Setter.Value>
+            </Setter>
+
+            <Style.Triggers>
+                <MultiTrigger>
+                    <MultiTrigger.Conditions>
+                        <Condition Property="IsMouseOver" Value="False"/>
+                        <Condition Property="IsSelected" Value="False"/>
+                    </MultiTrigger.Conditions>
+                    <MultiTrigger.EnterActions>
+                        <BeginStoryboard>
+                            <Storyboard>
+                                <DoubleAnimation To="15" Duration="0:0:0.5" Storyboard.TargetProperty="FontSize"/>
+                            </Storyboard>
+                        </BeginStoryboard>
+                    </MultiTrigger.EnterActions>
+                    <MultiTrigger.ExitActions>
+                        <BeginStoryboard>
+                            <Storyboard Timeline.DesiredFrameRate="60">
+                                <DoubleAnimation To="18" Duration="0:0:0.001" Storyboard.TargetProperty="FontSize"/>
+                            </Storyboard>
+                        </BeginStoryboard>
+                    </MultiTrigger.ExitActions>
+                </MultiTrigger>
+                <Trigger Property="IsMouseOver" Value="True">
+                    <Setter Property="Background" Value="#FFE4DBDB"/>
+                </Trigger>
+                <Trigger Property="IsSelected" Value="true">
+                    <Setter Property="Background" Value="#FFECECEC"/>
+                    <Setter Property="Foreground" Value="Black"/>
+                </Trigger>
+            </Style.Triggers>
+        </Style>
+        <cvt:MenuWidthConvert x:Key="MenuWidthConvert"/>
+        <cvt:OpcityConvert x:Key="OpcityConvert"/>
+    </UserControl.Resources>
+        <!--左侧栏-->
+        <hc:Card 
+                 BorderThickness="1" 
+                 Effect="{DynamicResource EffectShadow2}" 
+                 Margin="5,0,0,5"
+                 >
+            <hc:Card.Background>
+                <SolidColorBrush Color="#FFFFFFFF" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"/>
+            </hc:Card.Background>
+            <hc:Card.BorderBrush>
+                <SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
+            </hc:Card.BorderBrush>
+            <hc:Card.ContextMenu>
+                <ContextMenu Width="200">
+                    <MenuItem Header="新建菜单" Click="CreateMenu"/>
+                </ContextMenu>
+            </hc:Card.ContextMenu>
+            <WrapPanel Orientation="Horizontal">
+                <ListBox x:Name="menus"
+                         ItemsSource="{Binding MenuList}"
+                         Tag="{Binding AppConfig.MenuCardWidth}"
+                         BorderThickness="0" Foreground="{x:Null}"
+                         SelectedIndex="{Binding AppConfig.SelectedMenuIndex}"
+                         VirtualizingPanel.VirtualizationMode="Recycling"
+                         >
+                    <ListBox.Resources>
+                        <ContextMenu x:Key="menuDialog" Width="200">
+                            <MenuItem Header="新建菜单" Click="CreateMenu"/>
+                            <MenuItem Header="重命名"  Click="RenameMenu" Tag="{Binding}"/>
+                            <MenuItem Header="删除" Click="DeleteMenu" Tag="{Binding}"/>
+                        </ContextMenu>
+                    </ListBox.Resources>
+
+                    <ListBox.ItemContainerStyle>
+                        <Style TargetType="ListBoxItem" BasedOn="{StaticResource menuStyle}">
+                            <Setter Property="ContextMenu" Value="{StaticResource menuDialog}"/>
+                        </Style>
+                    </ListBox.ItemContainerStyle>
+                    <ListBox.Background>
+                        <SolidColorBrush Color="AliceBlue" Opacity="0"/>
+                    </ListBox.Background>
+
+                    <ListBox.ItemsPanel>
+                        <ItemsPanelTemplate>
+                        <DraggAnimatedPanel:DraggAnimatedPanel ItemsHeight="30" ItemsWidth="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}}"   HorizontalAlignment="Center" VerticalAlignment="Top" SwapCommand="{Binding SwapCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
+                        </ItemsPanelTemplate>
+                    </ListBox.ItemsPanel>
+
+                    <ListBox.ItemTemplate>
+                        <DataTemplate>
+                            <StackPanel MouseLeftButtonDown="MenuClick" Tag="{Binding}">
+                                <TextBox Text="{Binding Path=MenuName, Mode=TwoWay}"
+                                     HorizontalAlignment="Left"
+                                     Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}}"
+                                     FontSize="15"
+                                     TextAlignment="Left"
+                                     LostFocus="LostFocusOrEnterDown"
+                                     KeyDown="LostFocusOrEnterDown"
+                                     Tag="{Binding}"
+                                     IsVisibleChanged="MenuEditWhenVisibilityChanged"
+                                     Visibility="{Binding MenuEdit}"/>
+                                <StackPanel Orientation="Horizontal">
+                                    <Button Background="Transparent" 
+                                        BorderThickness="0"
+                                        hc:IconElement.Geometry="M438.857143 548.571429a36.571429 36.571429 0 0 1 36.571428 36.571428v256a36.571429 36.571429 0 0 1-36.571428 36.571429H182.857143a36.571429 36.571429 0 0 1-36.571429-36.571429v-256a36.571429 36.571429 0 0 1 36.571429-36.571428h256z m402.285714 0a36.571429 36.571429 0 0 1 36.571429 36.571428v256a36.571429 36.571429 0 0 1-36.571429 36.571429h-256a36.571429 36.571429 0 0 1-36.571428-36.571429v-256a36.571429 36.571429 0 0 1 36.571428-36.571428h256z m-438.857143 73.142857H219.428571v182.857143h182.857143v-182.857143z m402.285715 0h-182.857143v182.857143h182.857143v-182.857143zM438.857143 146.285714a36.571429 36.571429 0 0 1 36.571428 36.571429v256a36.571429 36.571429 0 0 1-36.571428 36.571428H182.857143a36.571429 36.571429 0 0 1-36.571429-36.571428V182.857143a36.571429 36.571429 0 0 1 36.571429-36.571429h256z m402.285714 0a36.571429 36.571429 0 0 1 36.571429 36.571429v256a36.571429 36.571429 0 0 1-36.571429 36.571428h-256a36.571429 36.571429 0 0 1-36.571428-36.571428V182.857143a36.571429 36.571429 0 0 1 36.571428-36.571429h256zM402.285714 219.428571H219.428571v182.857143h182.857143V219.428571z m402.285715 0h-182.857143v182.857143h182.857143V219.428571z" 
+                                        hc:IconElement.Height="18"
+                                        hc:IconElement.Width="18"
+                                        />
+                                    <TextBlock Text="{Binding MenuName}"
+                                           VerticalAlignment="Center"
+                                           IsVisibleChanged="MenuWhenVisibilityChanged"
+                                           Visibility="{Binding NotMenuEdit}"
+                                           />
+                                </StackPanel>
+
+                            </StackPanel>
+                        </DataTemplate>
+                    </ListBox.ItemTemplate>
+                </ListBox>
+            </WrapPanel>
+        </hc:Card>
+</UserControl>

+ 176 - 0
Control/UserControls/LeftCardControl.xaml.cs

@@ -0,0 +1,176 @@
+using DraggAnimatedPanelExample;
+using GeekDesk.Util;
+using GeekDesk.ViewModel;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace GeekDesk.Control.UserControls
+{
+    /// <summary>
+    /// LeftCardControl.xaml 的交互逻辑
+    /// </summary>
+    public partial class LeftCardControl : UserControl
+    {
+        private int menuSelectIndexTemp = -1;
+        private AppData appData = MainWindow.appData;
+
+        public LeftCardControl()
+        {
+            InitializeComponent();
+            appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
+        }
+
+        DelegateCommand<int[]> _swap;
+
+        public DelegateCommand<int[]> SwapCommand
+        {
+            get
+            {
+                if (_swap == null)
+                    _swap = new DelegateCommand<int[]>(
+                        (indexes) =>
+                        {
+                            int fromS = indexes[0];
+                            int to = indexes[1];
+                            ObservableCollection<MenuInfo> menuList = MainWindow.appData.MenuList;
+                            var elementSource = menuList[to];
+                            var dragged = menuList[fromS];
+                            menuList.Remove(dragged);
+                            menuList.Insert(to, dragged);
+                            menus.SelectedIndex = to;
+                            MainWindow.appData.MenuList = menuList;
+                        }
+                    );
+                return _swap;
+            }
+        }
+
+            ////菜单点击事件
+        private void MenuClick(object sender, MouseButtonEventArgs e)
+        {
+            //设置对应菜单的图标列表
+            MenuInfo mi = (MenuInfo)(((StackPanel)sender).Tag);
+            appData.AppConfig.SelectedMenuIcons = mi.IconList;
+        }
+
+        /// <summary>
+        /// 当修改菜单元素可见时 设置原菜单为不可见 并且不可选中
+        /// 修改菜单元素不可见时  原菜单可见 并 选中
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void MenuWhenVisibilityChanged(object sender, DependencyPropertyChangedEventArgs e)
+        {
+            TextBlock tb = sender as TextBlock;
+            if (tb.Visibility == Visibility.Collapsed)
+            {
+                if (menus.SelectedIndex != -1)
+                {
+                    menuSelectIndexTemp = menus.SelectedIndex;
+                    menus.SelectedIndex = -1;
+                }
+                else
+                {
+                    menus.SelectedIndex = menuSelectIndexTemp;
+                }
+            }
+        }
+
+        /// <summary>
+        /// 新建菜单
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void CreateMenu(object sender, RoutedEventArgs e)
+        {
+            MenuInfo info = new MenuInfo() { MenuEdit = Visibility.Collapsed, MenuId = System.Guid.NewGuid().ToString(), MenuName = "NewMenu" };
+            appData.MenuList.Add(info);
+            menus.Items.Refresh();
+            menus.SelectedIndex = appData.MenuList.Count - 1;
+            appData.AppConfig.SelectedMenuIndex = menus.SelectedIndex;
+            appData.AppConfig.SelectedMenuIcons = info.IconList;
+        }
+
+        /// <summary>
+        /// 重命名菜单 将textbox 设置为可见
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void RenameMenu(object sender, RoutedEventArgs e)
+        {
+            MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo;
+            menuInfo.MenuEdit = (int)Visibility.Visible;
+        }
+
+        /// <summary>
+        /// 删除菜单
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void DeleteMenu(object sender, RoutedEventArgs e)
+        {
+            MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo;
+            appData.MenuList.Remove(menuInfo);
+        }
+
+        /// <summary>
+        /// 编辑菜单失焦或者敲下Enter键时保存修改后的菜单
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void LostFocusOrEnterDown(object sender, EventArgs e)
+        {
+            TextBox menuBox = null;
+            if (e.GetType() == typeof(KeyEventArgs))
+            {
+                KeyEventArgs eKey = e as KeyEventArgs;
+                if (eKey.Key == Key.Enter)
+                {
+                    menuBox = ((TextBox)sender);
+                }
+            }
+            else if (e.GetType() == typeof(RoutedEventArgs))
+            {
+                menuBox = ((TextBox)sender);
+            }
+
+            if (menuBox != null)
+            {
+                MenuInfo menuInfo = menuBox.Tag as MenuInfo;
+                string text = menuBox.Text;
+                menuInfo.MenuName = text;
+                menuInfo.MenuEdit = Visibility.Collapsed;
+            }
+        }
+
+        /// <summary>
+        /// 当修改菜单元素可见时 设置全选并获得焦点
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void MenuEditWhenVisibilityChanged(object sender, DependencyPropertyChangedEventArgs e)
+        {
+            TextBox box = sender as TextBox;
+            if (box.Visibility == Visibility.Visible)
+            {
+                Keyboard.Focus(box);
+                box.SelectAll();
+            }
+        }
+
+
+    }
+}

+ 117 - 0
Control/UserControls/RightCardControl.xaml

@@ -0,0 +1,117 @@
+<UserControl x:Class="GeekDesk.Control.UserControls.RightCardControl"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:GeekDesk.Control.UserControls"
+             xmlns:hc="https://handyorg.github.io/handycontrol"
+             xmlns:cvt="clr-namespace:GeekDesk.Converts"
+             xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
+    <UserControl.Resources>
+        <!--右侧栏样式动画-->
+        <Style x:Key="imageStyle" TargetType="Image">
+            <Setter Property="Width"  Value="{Binding ImageWidth}"/>
+            <Setter Property="Height" Value="{Binding ImageHeight}"/>
+            <Setter Property="Source" Value="{Binding BitmapImage}"/>
+            <Style.Triggers>
+                <MultiTrigger>
+                    <MultiTrigger.Conditions>
+                        <Condition Property="IsMouseOver" Value="True"/>
+                    </MultiTrigger.Conditions>
+                    <MultiTrigger.EnterActions>
+                        <BeginStoryboard>
+                            <Storyboard>
+                                <DoubleAnimation To="80" Duration="0:0:0.001" Storyboard.TargetProperty="Width"/>
+                                <DoubleAnimation To="80" Duration="0:0:0.001" Storyboard.TargetProperty="Height"/>
+                            </Storyboard>
+                        </BeginStoryboard>
+                    </MultiTrigger.EnterActions>
+                    <MultiTrigger.ExitActions>
+                        <BeginStoryboard>
+                            <Storyboard>
+                                <DoubleAnimation To="60" Duration="0:0:0.5" Storyboard.TargetProperty="Width"/>
+                                <DoubleAnimation To="60" Duration="0:0:0.5" Storyboard.TargetProperty="Height"/>
+                            </Storyboard>
+                        </BeginStoryboard>
+                    </MultiTrigger.ExitActions>
+                </MultiTrigger>
+            </Style.Triggers>
+        </Style>
+
+        <cvt:MenuWidthConvert x:Key="MenuWidthConvert"/>
+        <cvt:OpcityConvert x:Key="OpcityConvert"/>
+    </UserControl.Resources>
+
+    <!--右侧栏-->
+    <hc:Card AllowDrop="True" 
+             Drop="Wrap_Drop" 
+              
+             BorderThickness="1" 
+             Effect="{DynamicResource EffectShadow2}" 
+             Margin="5,0,5,5" Grid.ColumnSpan="2">
+        <hc:Card.Background>
+            <SolidColorBrush Color="#FFFFFFFF" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"/>
+        </hc:Card.Background>
+        <hc:Card.BorderBrush>
+            <SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
+        </hc:Card.BorderBrush>
+        <WrapPanel Orientation="Horizontal">
+            <ListBox x:Name="icons" ItemsSource="{Binding AppConfig.SelectedMenuIcons, Mode=TwoWay}" 
+                                 BorderThickness="0"
+                                 SelectionChanged="IconSelectionChanged "
+                                 VirtualizingPanel.VirtualizationMode="Recycling"
+                                 >
+                <ListBox.Background>
+                    <SolidColorBrush Opacity="0"/>
+                </ListBox.Background>
+                <ListBox.ItemsPanel>
+                    <ItemsPanelTemplate>
+                        <DraggAnimatedPanel:DraggAnimatedPanel ItemsHeight="115" ItemsWidth="100"  HorizontalAlignment="Center" SwapCommand="{Binding SwapCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
+                    </ItemsPanelTemplate>
+                </ListBox.ItemsPanel>
+
+                <ListBox.Resources>
+                    <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>
+                </ListBox.Resources>
+
+                <ListBox.ItemContainerStyle>
+                    <Style TargetType="ListBoxItem">
+                        <Setter Property="ContextMenu" Value="{StaticResource iconDialog}"/>
+                    </Style>
+                </ListBox.ItemContainerStyle>
+
+                <ListBox.ItemTemplate>
+                    <DataTemplate>
+                        <StackPanel Tag="{Binding}"
+                                        MouseLeftButtonUp="IconClick"
+                                        HorizontalAlignment="Center"
+                                        Margin="5,5,5,5"
+                                        hc:Poptip.HitMode="None" 
+                                        hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
+                                        hc:Poptip.Content="{Binding Content}" 
+                                        hc:Poptip.Placement="BottomLeft"
+                                        >
+                            <Image Style="{StaticResource imageStyle}" />
+                            <TextBlock MaxWidth="80"
+                                               MaxHeight="40"
+                                               TextWrapping="Wrap" 
+                                               TextTrimming="WordEllipsis"
+                                               TextAlignment="Center" 
+                                               VerticalAlignment="Center" 
+                                               Text="{Binding Name}"/>
+
+                        </StackPanel>
+                    </DataTemplate>
+                </ListBox.ItemTemplate>
+            </ListBox>
+        </WrapPanel>
+    </hc:Card>
+</UserControl>

+ 214 - 0
Control/UserControls/RightCardControl.xaml.cs

@@ -0,0 +1,214 @@
+using DraggAnimatedPanelExample;
+using GeekDesk.Constant;
+using GeekDesk.Util;
+using GeekDesk.ViewModel;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace GeekDesk.Control.UserControls
+{
+    /// <summary>
+    /// RightCardControl.xaml 的交互逻辑
+    /// </summary>
+    public partial class RightCardControl : UserControl
+    {
+        private AppData appData = MainWindow.appData;
+        public RightCardControl()
+        {
+            InitializeComponent();
+        }
+
+
+        #region 图标拖动
+        DelegateCommand<int[]> _swap;
+        public DelegateCommand<int[]> SwapCommand
+        {
+            get
+            {
+                if (_swap == null)
+                    _swap = new DelegateCommand<int[]>(
+                        (indexes) =>
+                        {
+                            int fromS = indexes[0];
+                            int to = indexes[1];
+                            ObservableCollection<IconInfo> iconList = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
+                            var elementSource = iconList[to];
+                            var dragged = iconList[fromS];
+
+                            iconList.Remove(dragged);
+                            iconList.Insert(to, dragged);
+                        }
+                    );
+                return _swap;
+            }
+        }
+
+        #endregion 图标拖动
+
+
+
+        /// <summary>
+        /// 图标点击事件
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void IconClick(object sender, MouseButtonEventArgs e)
+        {
+            IconInfo icon = (IconInfo)((StackPanel)sender).Tag;
+            if (icon.AdminStartUp)
+            {
+                StartIconApp(icon, IconStartType.ADMIN_STARTUP);
+            }
+            else
+            {
+                StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
+            }
+        }
+
+        /// <summary>
+        /// 管理员方式启动
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void IconAdminStart(object sender, RoutedEventArgs e)
+        {
+            IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
+            StartIconApp(icon, IconStartType.ADMIN_STARTUP);
+        }
+
+        /// <summary>
+        /// 打开文件所在位置
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ShowInExplore(object sender, RoutedEventArgs e)
+        {
+            IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
+            StartIconApp(icon, IconStartType.SHOW_IN_EXPLORE);
+        }
+
+        private void StartIconApp(IconInfo icon, IconStartType type)
+        {
+            try
+            {
+
+                if (!File.Exists(icon.Path) && !Directory.Exists(icon.Path))
+                {
+                    HandyControl.Controls.Growl.WarningGlobal("程序启动失败(文件路径不存在或已删除)!");
+                    return;
+                }
+
+                Process p = new Process();
+                p.StartInfo.FileName = icon.Path;
+
+                switch (type)
+                {
+                    case IconStartType.ADMIN_STARTUP:
+                        p.StartInfo.Arguments = "1";//启动参数
+                        p.StartInfo.Verb = "runas";
+                        p.StartInfo.CreateNoWindow = false; //设置显示窗口
+                        p.StartInfo.UseShellExecute = false;//不使用操作系统外壳程序启动进程
+                        p.StartInfo.ErrorDialog = false;
+                        if (appData.AppConfig.AppHideType == AppHideType.START_EXE)
+                        {
+                            this.Visibility = Visibility.Collapsed;
+                        }
+                        break;// c#好像不能case穿透
+                    case IconStartType.DEFAULT_STARTUP:
+                        if (appData.AppConfig.AppHideType == AppHideType.START_EXE)
+                        {
+                            this.Visibility = Visibility.Collapsed;
+                        }
+                        break;
+                    case IconStartType.SHOW_IN_EXPLORE:
+                        p.StartInfo.FileName = "Explorer.exe";
+                        p.StartInfo.Arguments = "/e,/select," + icon.Path;
+                        break;
+                }
+                p.Start();
+                icon.Count++;
+            }
+            catch (Exception)
+            {
+                HandyControl.Controls.Growl.WarningGlobal("程序启动失败(不支持的启动方式)!");
+            }
+        }
+
+
+        /// <summary>
+        /// data选中事件 设置不可选中
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void IconSelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            if (icons.SelectedIndex != -1) icons.SelectedIndex = -1;
+        }
+
+
+        private void Wrap_Drop(object sender, DragEventArgs e)
+        {
+            Array dropObject = (System.Array)e.Data.GetData(DataFormats.FileDrop);
+            if (dropObject == null) return;
+            foreach (object obj in dropObject)
+            {
+                string path = (string)obj;
+
+                //string base64 = ImageUtil.FileImageToBase64(path, ImageFormat.Jpeg);
+
+                IconInfo iconInfo = new IconInfo
+                {
+                    Path = path,
+                    BitmapImage = ImageUtil.GetBitmapIconByPath(path)
+                };
+                iconInfo.DefaultImage = iconInfo.ImageByteArr;
+                iconInfo.Name = System.IO.Path.GetFileNameWithoutExtension(path);
+                MainWindow.appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList.Add(iconInfo);
+            }
+        }
+
+        /// <summary>
+        /// 从列表删除图标
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void RemoveIcon(object sender, RoutedEventArgs e)
+        {
+            appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList.Remove((IconInfo)((MenuItem)sender).Tag);
+        }
+
+        private void MenuItem_Click(object sender, RoutedEventArgs e)
+        {
+
+            IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
+            System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("Explorer.exe");
+            psi.Arguments = "/e,/select," + icon.Path;
+            System.Diagnostics.Process.Start(psi);
+        }
+
+        /// <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));
+        }
+    }
+}

+ 111 - 48
Control/UserControls/SettingControl.xaml

@@ -3,7 +3,7 @@
              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:util="clr-namespace:GeekDesk.Util"
+             xmlns:cvt="clr-namespace:GeekDesk.Converts"
              xmlns:local="clr-namespace:GeekDesk.Control.UserControls"
              xmlns:local="clr-namespace:GeekDesk.Control.UserControls"
              xmlns:hc="https://handyorg.github.io/handycontrol"
              xmlns:hc="https://handyorg.github.io/handycontrol"
              mc:Ignorable="d" 
              mc:Ignorable="d" 
@@ -11,61 +11,124 @@
              d:DesignHeight="450" d:DesignWidth="800">
              d:DesignHeight="450" d:DesignWidth="800">
 
 
     <UserControl.Resources>
     <UserControl.Resources>
-        <util:HideTypeConvert x:Key="HideTypeConvert"/>
+        <cvt:HideTypeConvert x:Key="HideTypeConvert"/>
     </UserControl.Resources>
     </UserControl.Resources>
-    <hc:SimplePanel Margin="10">
-        <hc:SimplePanel.Background>
-            <SolidColorBrush Opacity="0.9"/>
-        </hc:SimplePanel.Background>
-        <hc:UniformSpacingPanel Spacing="10" Margin="0,0,0,10" Grid.ColumnSpan="4">
-            <TextBlock Text="主面板设置" VerticalAlignment="Center"/>
-        </hc:UniformSpacingPanel>
-        <hc:Divider LineStrokeDashArray="3,3" Margin="30,22,450,119" LineStroke="Black" Grid.ColumnSpan="4"/>
-        <hc:UniformSpacingPanel Spacing="10" Margin="30,26.394,0,-16.394" Grid.ColumnSpan="4">
-            <CheckBox x:Name="IconIsAdmin" Content="启动时显示主面板" IsChecked="{Binding StartedShowPanel}">
-                <CheckBox.Background>
-                    <LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
-                        <GradientStop Color="#FF9EA3A6"/>
-                    </LinearGradientBrush>
-                </CheckBox.Background>
-            </CheckBox>
-        </hc:UniformSpacingPanel>
+        <hc:SimplePanel Margin="10">
+            <hc:SimplePanel.Background>
+                <SolidColorBrush Opacity="0.9"/>
+            </hc:SimplePanel.Background>
 
 
-        <hc:UniformSpacingPanel Spacing="10" Margin="30,50,0,-102.337" Grid.ColumnSpan="4">
-            <CheckBox  Content="显示时追随鼠标位置" IsChecked="{Binding FollowMouse}" Unchecked="CheckBox_Unchecked">
-                <CheckBox.Background>
-                    <LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
-                        <GradientStop Color="#FF9EA3A6"/>
-                    </LinearGradientBrush>
-                </CheckBox.Background>
-            </CheckBox>
-        </hc:UniformSpacingPanel>
-        <hc:UniformSpacingPanel Spacing="10" Margin="30,89.49,-30,-79.49" Grid.ColumnSpan="4">
-            <TextBlock Text="面板关闭方式" VerticalAlignment="Center"/>
-        </hc:UniformSpacingPanel>
-        <hc:Divider LineStrokeDashArray="3,3" Margin="30,109,450,26.208" LineStroke="Black" Grid.ColumnSpan="4"/>
-        <hc:UniformSpacingPanel Spacing="10" Margin="40,115,-10,-102.337" Grid.ColumnSpan="4">
-            <RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}" 
+            <hc:UniformSpacingPanel Spacing="10" Margin="0,0,0,10" Grid.ColumnSpan="4">
+                <TextBlock Text="主面板设置" VerticalAlignment="Center"/>
+            </hc:UniformSpacingPanel>
+            <hc:Divider LineStrokeDashArray="3,3" Margin="30,22,450,119" LineStroke="Black" Grid.ColumnSpan="4"/>
+            <hc:UniformSpacingPanel Spacing="10" Margin="30,26.394,0,-16.394" Grid.ColumnSpan="4">
+                <CheckBox x:Name="IconIsAdmin" Content="启动时显示主面板" IsChecked="{Binding StartedShowPanel}">
+                    <CheckBox.Background>
+                        <LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
+                            <GradientStop Color="#FF9EA3A6"/>
+                        </LinearGradientBrush>
+                    </CheckBox.Background>
+                </CheckBox>
+            </hc:UniformSpacingPanel>
+
+            <hc:UniformSpacingPanel Spacing="10" Margin="30,50,0,-102.337" Grid.ColumnSpan="4">
+                <CheckBox  Content="显示时追随鼠标位置" IsChecked="{Binding FollowMouse}" Unchecked="CheckBox_Unchecked">
+                    <CheckBox.Background>
+                        <LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
+                            <GradientStop Color="#FF9EA3A6"/>
+                        </LinearGradientBrush>
+                    </CheckBox.Background>
+                </CheckBox>
+            </hc:UniformSpacingPanel>
+            <hc:UniformSpacingPanel Spacing="10" Margin="30,89.49,-30,-79.49" Grid.ColumnSpan="4">
+                <TextBlock Text="面板关闭方式" VerticalAlignment="Center"/>
+            </hc:UniformSpacingPanel>
+            <hc:Divider LineStrokeDashArray="3,3" Margin="30,109,450,26.208" LineStroke="Black" Grid.ColumnSpan="4"/>
+            <hc:UniformSpacingPanel Spacing="10" Margin="40,115,-10,-102.337" Grid.ColumnSpan="4">
+                <RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}" 
                          Style="{StaticResource RadioButtonIcon}" Content="失去焦点后"
                          Style="{StaticResource RadioButtonIcon}" Content="失去焦点后"
                          IsChecked="{Binding AppHideType, Mode=TwoWay, Converter={StaticResource HideTypeConvert}, ConverterParameter=1}"/>
                          IsChecked="{Binding AppHideType, Mode=TwoWay, Converter={StaticResource HideTypeConvert}, ConverterParameter=1}"/>
-            <RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
+                <RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}"
                          Style="{StaticResource RadioButtonIcon}" Content="运行项目后" 
                          Style="{StaticResource RadioButtonIcon}" Content="运行项目后" 
                          IsChecked="{Binding AppHideType, Mode=TwoWay, Converter={StaticResource HideTypeConvert}, ConverterParameter=2}"/>
                          IsChecked="{Binding AppHideType, Mode=TwoWay, Converter={StaticResource HideTypeConvert}, ConverterParameter=2}"/>
-            <RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}" 
+                <RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}" 
                          Style="{StaticResource RadioButtonIcon}" Content="手动关闭"
                          Style="{StaticResource RadioButtonIcon}" Content="手动关闭"
                          IsChecked="{Binding AppHideType, Mode=TwoWay, Converter={StaticResource HideTypeConvert}, ConverterParameter=3}"/>
                          IsChecked="{Binding AppHideType, Mode=TwoWay, Converter={StaticResource HideTypeConvert}, ConverterParameter=3}"/>
-        </hc:UniformSpacingPanel>
-        <hc:UniformSpacingPanel Spacing="10" Margin="30,160.5,-30,-150.5" Grid.ColumnSpan="4">
-            <TextBlock Text="背景图片" VerticalAlignment="Center"/>
-        </hc:UniformSpacingPanel>
-        <hc:UniformSpacingPanel Spacing="10" Margin="40,199.5,-40,-189.5" Grid.ColumnSpan="4">
-            <TextBlock Text="图片路径:" VerticalAlignment="Center"/>
-            <TextBlock Text="{Binding BacImgName}" Width="200" VerticalAlignment="Center"/>
-            <Button Content="修改" Click="BGButton_Click"/>
-        </hc:UniformSpacingPanel>
-        <hc:Divider LineStrokeDashArray="3,3" Margin="30,22,450,119" LineStroke="Black" Grid.ColumnSpan="4"/>
+            </hc:UniformSpacingPanel>
+            <hc:UniformSpacingPanel Spacing="10" Margin="30,160.5,-30,-150.5" Grid.ColumnSpan="4">
+                <TextBlock Text="背景图片" VerticalAlignment="Center"/>
+            </hc:UniformSpacingPanel>
+            <hc:UniformSpacingPanel Spacing="10" Margin="40,183,-40,-173" Grid.ColumnSpan="4">
+                <TextBlock Text="图片路径:" VerticalAlignment="Center"/>
+                <TextBlock Text="{Binding BacImgName}" Width="200" 
+                       VerticalAlignment="Center"
+                       hc:Poptip.HitMode="None" 
+                       hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
+                       hc:Poptip.Content="{Binding BacImgName}" 
+                       hc:Poptip.Placement="TopLeft"
+                       />
+                <Button Content="修改" Click="BGButton_Click"/>
+            </hc:UniformSpacingPanel>
+            <hc:Divider LineStrokeDashArray="3,3" Margin="30,22,450,119" LineStroke="Black" Grid.ColumnSpan="4"/>
+
+            <hc:Divider LineStrokeDashArray="3,3" Margin="10,217.235,-10,-66.235" LineStroke="Black" Grid.ColumnSpan="4"/>
+            <hc:UniformSpacingPanel Spacing="10" Margin="30,240,-30,-230" Grid.ColumnSpan="4">
+                <TextBlock Text="托盘不透明度" VerticalAlignment="Center"/>
+            </hc:UniformSpacingPanel>
+            <hc:UniformSpacingPanel Spacing="10" Margin="40,267,-40,-257" Grid.ColumnSpan="4">
+                <hc:PreviewSlider Value="{Binding CardOpacity}"
+                              Maximum="100"
+                              Margin="0,0,-313.5,7.5"
+                              >
+                    <hc:PreviewSlider.PreviewContent>
+                        <Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
+                    </hc:PreviewSlider.PreviewContent>
+                </hc:PreviewSlider>
+            </hc:UniformSpacingPanel>
+
+            <hc:UniformSpacingPanel Spacing="10" Margin="30,298.813,-30,-288.813" Grid.ColumnSpan="4">
+                <TextBlock Text="背景图片不透明度" VerticalAlignment="Center"/>
+            </hc:UniformSpacingPanel>
+            <hc:UniformSpacingPanel Spacing="10" Margin="40,330,-40,-320" Grid.ColumnSpan="4">
+                <hc:PreviewSlider Value="{Binding BgOpacity}"
+                              Maximum="100"
+                              Margin="0,0,-313.5,7.5"
+                              >
+                    <hc:PreviewSlider.PreviewContent>
+                        <Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
+                    </hc:PreviewSlider.PreviewContent>
+                </hc:PreviewSlider>
+            </hc:UniformSpacingPanel>
 
 
-        <!--<hc:Divider LineStrokeDashArray="3,3" Margin="10,242.735,-10,-91.735" LineStroke="Black" Grid.ColumnSpan="4"/>-->
+            <hc:UniformSpacingPanel Spacing="10" Margin="30,370.813,-30,-360.813" Grid.ColumnSpan="4">
+                <TextBlock Text="主面板不透明度" VerticalAlignment="Center"/>
+            </hc:UniformSpacingPanel>
+            <hc:UniformSpacingPanel Spacing="10" Margin="40,399,-40,-389" Grid.ColumnSpan="4">
+                <hc:PreviewSlider Value="{Binding PannelOpacity}"
+                              Minimum="50"
+                              Maximum="100"
+                              Margin="0,0,-313.5,7.5"
+                              >
+                    <hc:PreviewSlider.PreviewContent>
+                        <Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
+                    </hc:PreviewSlider.PreviewContent>
+                </hc:PreviewSlider>
+            </hc:UniformSpacingPanel>
 
 
-    </hc:SimplePanel>
+            <hc:UniformSpacingPanel Spacing="10" Margin="30,429.313,-30,-419.313" Grid.ColumnSpan="4">
+                <TextBlock Text="主面板圆角大小" VerticalAlignment="Center"/>
+            </hc:UniformSpacingPanel>
+            <hc:UniformSpacingPanel Spacing="10" Margin="40,463.5,-40,-453.5" Grid.ColumnSpan="4">
+                <hc:PreviewSlider Value="{Binding PannelCornerRadius}"
+                              Maximum="25"
+                              Margin="0,0,-313.5,7.5"
+                              >
+                    <hc:PreviewSlider.PreviewContent>
+                        <Label Style="{StaticResource LabelPrimary}" Content="{Binding Path=(hc:PreviewSlider.PreviewPosition),RelativeSource={RelativeSource Self}}" ContentStringFormat="#0"/>
+                    </hc:PreviewSlider.PreviewContent>
+                </hc:PreviewSlider>
+            </hc:UniformSpacingPanel>
+        </hc:SimplePanel>
+   
 </UserControl>
 </UserControl>

+ 1 - 5
Control/UserControls/SettingControl.xaml.cs

@@ -28,11 +28,6 @@ namespace GeekDesk.Control.UserControls
             InitializeComponent();
             InitializeComponent();
         }
         }
 
 
-        private void SimplePanel_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
-        {
-            CommonCode.SaveAppData(MainWindow.appData);
-        }
-
         private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
         private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
         {
         {
 
 
@@ -57,6 +52,7 @@ namespace GeekDesk.Control.UserControls
                 if (ofd.ShowDialog() == true)
                 if (ofd.ShowDialog() == true)
                 {
                 {
                     appConfig.BitmapImage = ImageUtil.GetBitmapImageByFile(ofd.FileName);
                     appConfig.BitmapImage = ImageUtil.GetBitmapImageByFile(ofd.FileName);
+                    appConfig.BacImgName = ofd.FileName;
                 }
                 }
             } catch (Exception)
             } catch (Exception)
             {
             {

+ 26 - 0
Converts/DoubleToGridLength.cs

@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Data;
+
+namespace GeekDesk.Converts
+{
+    class DoubleToGridLength : IValueConverter
+    {
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            double val = double.Parse(value.ToString());
+            return new GridLength(val);
+        }
+
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            GridLength val = (GridLength)value;
+            return double.Parse(val.ToString());
+        }
+    }
+}

+ 1 - 1
Util/HideTypeConvert.cs → Converts/HideTypeConvert.cs

@@ -7,7 +7,7 @@ using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using System.Windows.Data;
 using System.Windows.Data;
 
 
-namespace GeekDesk.Util
+namespace GeekDesk.Converts
 {
 {
    public class HideTypeConvert : IValueConverter
    public class HideTypeConvert : IValueConverter
     {
     {

+ 25 - 0
Converts/IntToCornerRadius.cs

@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Data;
+
+namespace GeekDesk.Converts
+{
+    class IntToCornerRadius : IValueConverter
+    {
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            int val = int.Parse(value.ToString());
+            return new CornerRadius(val);
+        }
+
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 2 - 2
Util/MenuWidthConvert.cs → Converts/MenuWidthConvert.cs

@@ -2,9 +2,9 @@
 using System.Globalization;
 using System.Globalization;
 using System.Windows.Data;
 using System.Windows.Data;
 
 
-namespace GeekDesk.Util
+namespace GeekDesk.Converts
 {
 {
-    class MenuWidthConvert : IValueConverter
+    public class MenuWidthConvert : IValueConverter
     {
     {
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         {
         {

+ 24 - 0
Converts/OpcityConvert.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace GeekDesk.Converts
+{
+    public class OpcityConvert : IValueConverter
+    {
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            double val = double.Parse(value.ToString());
+            return (double)(Math.Round((decimal)(val / 100.00), 2));
+        }
+
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 19 - 2
GeekDesk.csproj

@@ -107,14 +107,23 @@
     <Compile Include="Control\IconInfoDialog.xaml.cs">
     <Compile Include="Control\IconInfoDialog.xaml.cs">
       <DependentUpon>IconInfoDialog.xaml</DependentUpon>
       <DependentUpon>IconInfoDialog.xaml</DependentUpon>
     </Compile>
     </Compile>
+    <Compile Include="Control\UserControls\LeftCardControl.xaml.cs">
+      <DependentUpon>LeftCardControl.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Control\UserControls\RightCardControl.xaml.cs">
+      <DependentUpon>RightCardControl.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Control\UserControls\SettingControl.xaml.cs">
     <Compile Include="Control\UserControls\SettingControl.xaml.cs">
       <DependentUpon>SettingControl.xaml</DependentUpon>
       <DependentUpon>SettingControl.xaml</DependentUpon>
     </Compile>
     </Compile>
+    <Compile Include="Converts\DoubleToGridLength.cs" />
+    <Compile Include="Converts\IntToCornerRadius.cs" />
+    <Compile Include="Converts\OpcityConvert.cs" />
     <Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.cs" />
     <Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.cs" />
     <Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.Drag.cs" />
     <Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.Drag.cs" />
     <Compile Include="EditTextBlock\EditableTextBlock.cs" />
     <Compile Include="EditTextBlock\EditableTextBlock.cs" />
     <Compile Include="EditTextBlock\EditableTextBlockAdorner.cs" />
     <Compile Include="EditTextBlock\EditableTextBlockAdorner.cs" />
-    <Compile Include="Util\HideTypeConvert.cs" />
+    <Compile Include="Converts\HideTypeConvert.cs" />
     <Compile Include="Util\CommonCode.cs" />
     <Compile Include="Util\CommonCode.cs" />
     <Compile Include="Util\ConsoleManager.cs" />
     <Compile Include="Util\ConsoleManager.cs" />
     <Compile Include="Util\DragAdorner.cs" />
     <Compile Include="Util\DragAdorner.cs" />
@@ -122,7 +131,7 @@
     <Compile Include="Util\HotKey.cs" />
     <Compile Include="Util\HotKey.cs" />
     <Compile Include="Util\ImageUtil.cs" />
     <Compile Include="Util\ImageUtil.cs" />
     <Compile Include="Util\ListViewDragDropManager.cs" />
     <Compile Include="Util\ListViewDragDropManager.cs" />
-    <Compile Include="Util\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\MouseUtilities.cs" />
     <Compile Include="Util\ScreenUtil.cs" />
     <Compile Include="Util\ScreenUtil.cs" />
@@ -140,6 +149,14 @@
       <SubType>Designer</SubType>
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
       <Generator>MSBuild:Compile</Generator>
     </Page>
     </Page>
+    <Page Include="Control\UserControls\LeftCardControl.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Control\UserControls\RightCardControl.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Control\UserControls\SettingControl.xaml">
     <Page Include="Control\UserControls\SettingControl.xaml">
       <SubType>Designer</SubType>
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
       <Generator>MSBuild:Compile</Generator>

+ 20 - 239
MainWindow.xaml

@@ -5,9 +5,11 @@
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:GeekDesk"
         xmlns:local="clr-namespace:GeekDesk"
         xmlns:tp="clr-namespace:GeekDesk.EditTextBlock"
         xmlns:tp="clr-namespace:GeekDesk.EditTextBlock"
+        xmlns:uc="clr-namespace:GeekDesk.Control.UserControls"
         mc:Ignorable="d"
         mc:Ignorable="d"
-        xmlns:util="clr-namespace:GeekDesk.Util"
-        xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel" x:Name="window"
+        xmlns:cvt="clr-namespace:GeekDesk.Converts"
+        xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
+        x:Name="window"
         xmlns:hc="https://handyorg.github.io/handycontrol"
         xmlns:hc="https://handyorg.github.io/handycontrol"
         Title="MainWindow" Height="500" Width="600"
         Title="MainWindow" Height="500" Width="600"
         WindowStyle="None"
         WindowStyle="None"
@@ -21,88 +23,21 @@
     </WindowChrome.WindowChrome>
     </WindowChrome.WindowChrome>
     <Window.Resources>
     <Window.Resources>
 
 
-        <!--左侧栏样式动画-->
-        <Style x:Key="menuStyle" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItemBaseStyle}">
-            <Setter Property="FontSize" Value="15"/>
-            <Setter Property="Margin" Value="0,0,0,1"/>
-            <Setter Property="Background">
-                <Setter.Value>
-                    <SolidColorBrush Opacity="0"/>
-                </Setter.Value>
-            </Setter>
-
-            <Style.Triggers>
-                <MultiTrigger>
-                    <MultiTrigger.Conditions>
-                        <Condition Property="IsMouseOver" Value="False"/>
-                        <Condition Property="IsSelected" Value="False"/>
-                    </MultiTrigger.Conditions>
-                    <MultiTrigger.EnterActions>
-                        <BeginStoryboard>
-                            <Storyboard>
-                                <DoubleAnimation To="15" Duration="0:0:0.5" Storyboard.TargetProperty="FontSize"/>
-                            </Storyboard>
-                        </BeginStoryboard>
-                    </MultiTrigger.EnterActions>
-                    <MultiTrigger.ExitActions>
-                        <BeginStoryboard>
-                            <Storyboard Timeline.DesiredFrameRate="60">
-                                <DoubleAnimation To="18" Duration="0:0:0.001" Storyboard.TargetProperty="FontSize"/>
-                            </Storyboard>
-                        </BeginStoryboard>
-                    </MultiTrigger.ExitActions>
-                </MultiTrigger>
-                <Trigger Property="IsMouseOver" Value="True">
-                    <Setter Property="Background" Value="#FFE4DBDB"/>
-                </Trigger>
-                <Trigger Property="IsSelected" Value="true">
-                    <Setter Property="Background" Value="#FFECECEC"/>
-                    <Setter Property="Foreground" Value="Black"/>
-                </Trigger>
-            </Style.Triggers>
-        </Style>
-
-
-        <!--右侧栏样式动画-->
-        <Style x:Key="imageStyle" TargetType="Image">
-            <Setter Property="Width"  Value="{Binding ImageWidth}"/>
-            <Setter Property="Height" Value="{Binding ImageHeight}"/>
-            <Setter Property="Source" Value="{Binding BitmapImage}"/>
-            <Style.Triggers>
-                <MultiTrigger>
-                    <MultiTrigger.Conditions>
-                        <Condition Property="IsMouseOver" Value="True"/>
-                    </MultiTrigger.Conditions>
-                    <MultiTrigger.EnterActions>
-                        <BeginStoryboard>
-                            <Storyboard>
-                                <DoubleAnimation To="80" Duration="0:0:0.001" Storyboard.TargetProperty="Width"/>
-                                <DoubleAnimation To="80" Duration="0:0:0.001" Storyboard.TargetProperty="Height"/>
-                            </Storyboard>
-                        </BeginStoryboard>
-                    </MultiTrigger.EnterActions>
-                    <MultiTrigger.ExitActions>
-                        <BeginStoryboard>
-                            <Storyboard>
-                                <DoubleAnimation To="60" Duration="0:0:0.5" Storyboard.TargetProperty="Width"/>
-                                <DoubleAnimation To="60" Duration="0:0:0.5" Storyboard.TargetProperty="Height"/>
-                            </Storyboard>
-                        </BeginStoryboard>
-                    </MultiTrigger.ExitActions>
-                </MultiTrigger>
-            </Style.Triggers>
-        </Style>
-
-        <util:MenuWidthConvert x:Key="MenuWidthConvert"/>
-
+       
+        <cvt:MenuWidthConvert x:Key="MenuWidthConvert"/>
+        <cvt:OpcityConvert x:Key="OpcityConvert"/>
+        <cvt:IntToCornerRadius x:Key="IntToCornerRadius"/>
+        <cvt:DoubleToGridLength x:Key="DoubleToGridLength"/>
     </Window.Resources>
     </Window.Resources>
 
 
 
 
-    <Border CornerRadius="5"  BorderThickness="0" Background="White" LostFocus="App_LostFocus">
-        <Border CornerRadius="5"  BorderThickness="0">
+    <Border CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}"  BorderThickness="0"
+            Background="AliceBlue" LostFocus="App_LostFocus"
+            Opacity="{Binding AppConfig.PannelOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}">
+        <Border CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}"  BorderThickness="0">
             <!--背景图片-->
             <!--背景图片-->
             <Border.Background>
             <Border.Background>
-                <ImageBrush ImageSource="{Binding AppConfig.BitmapImage}" Opacity="1"></ImageBrush>
+                <ImageBrush ImageSource="{Binding AppConfig.BitmapImage}" Opacity="{Binding AppConfig.BgOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"></ImageBrush>
             </Border.Background>
             </Border.Background>
             <Grid>
             <Grid>
                 <Grid.RowDefinitions>
                 <Grid.RowDefinitions>
@@ -110,9 +45,8 @@
                     <RowDefinition Height="*"></RowDefinition>
                     <RowDefinition Height="*"></RowDefinition>
                 </Grid.RowDefinitions>
                 </Grid.RowDefinitions>
                 <Grid.ColumnDefinitions>
                 <Grid.ColumnDefinitions>
-                    <ColumnDefinition x:Name="LeftColumn" MinWidth="80" Width="165" MaxWidth="200"></ColumnDefinition>
-                    <ColumnDefinition Width="45*"></ColumnDefinition>
-                    <ColumnDefinition Width="382*"/>
+                    <ColumnDefinition x:Name="LeftColumn" MinWidth="80" Width="{Binding AppConfig.MenuCardWidth, Mode=TwoWay, Converter={StaticResource DoubleToGridLength}}" MaxWidth="200"></ColumnDefinition>
+                    <ColumnDefinition Width="*"></ColumnDefinition>
                 </Grid.ColumnDefinitions>
                 </Grid.ColumnDefinitions>
 
 
 
 
@@ -138,11 +72,6 @@
                                 Initialized="SettingButton_Initialized"
                                 Initialized="SettingButton_Initialized"
                                 x:Name="SettingButton"
                                 x:Name="SettingButton"
                                 >
                                 >
-                            <!--<Button.ContextMenu>
-                                <ContextMenu Width="200" x:Name="SettingMenu">
-                                    <MenuItem Header="设置" Click="ConfigApp"/>
-                                </ContextMenu>
-                            </Button.ContextMenu>-->
                         </Button>
                         </Button>
                         <Button Background="Transparent" 
                         <Button Background="Transparent" 
                                 BorderThickness="0"
                                 BorderThickness="0"
@@ -156,161 +85,13 @@
 
 
                 </DockPanel>
                 </DockPanel>
 
 
-                <!--左侧栏-->
-                <hc:Card x:Name="leftCard" Grid.Row="1" Grid.Column="0"
-                 BorderThickness="1" 
-                 Effect="{DynamicResource EffectShadow2}" 
-                 Margin="5,0,0,5"
-                 >
-                    <hc:Card.Background>
-                        <SolidColorBrush Color="#FFFFFFFF" Opacity="0.1"/>
-                    </hc:Card.Background>
-                    <hc:Card.BorderBrush>
-                        <SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
-                    </hc:Card.BorderBrush>
-                    <hc:Card.ContextMenu>
-                        <ContextMenu Width="200">
-                            <MenuItem Header="新建菜单" Click="CreateMenu"/>
-                        </ContextMenu>
-                    </hc:Card.ContextMenu>
-                    <WrapPanel Orientation="Horizontal">
-                        <ListBox x:Name="menus"  
-                                 ItemsSource="{Binding MenuList}"
-                                 BorderThickness="0" Foreground="{x:Null}"
-                                 VirtualizingPanel.VirtualizationMode="Recycling"
-                                >
-                            <ListBox.Resources>
-                                <ContextMenu x:Key="menuDialog" Width="200">
-                                    <MenuItem Header="新建菜单" Click="CreateMenu"/>
-                                    <MenuItem Header="重命名"  Click="RenameMenu" Tag="{Binding}"/>
-                                    <MenuItem Header="删除" Click="DeleteMenu" Tag="{Binding}"/>
-                                </ContextMenu>
-                            </ListBox.Resources>
-
-                            <ListBox.ItemContainerStyle>
-                                <Style TargetType="ListBoxItem" BasedOn="{StaticResource menuStyle}">
-                                    <Setter Property="ContextMenu" Value="{StaticResource menuDialog}"/>
-                                </Style>
-                            </ListBox.ItemContainerStyle>
-                            <ListBox.Background>
-                                <SolidColorBrush Color="AliceBlue" Opacity="0"/>
-                            </ListBox.Background>
-
-                            <ListBox.ItemsPanel>
-                                <ItemsPanelTemplate>
-                                    <DraggAnimatedPanel:DraggAnimatedPanel ItemsHeight="30" ItemsWidth="{Binding ElementName=LeftColumn, Path=Width, Converter={StaticResource MenuWidthConvert}}"   HorizontalAlignment="Center" VerticalAlignment="Top" SwapCommand="{Binding SwapCommand2, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"/>
-                                </ItemsPanelTemplate>
-                            </ListBox.ItemsPanel>
-
-                            <ListBox.ItemTemplate>
-                                <DataTemplate>
-                                    <StackPanel MouseLeftButtonDown="MenuClick" Tag="{Binding}">
-                                        <TextBox Text="{Binding Path=MenuName, Mode=TwoWay}"
-                                     HorizontalAlignment="Left"
-                                     Width="{Binding ElementName=LeftColumn, Path=Width, Converter={StaticResource MenuWidthConvert}}"
-                                     FontSize="15"
-                                     TextAlignment="Left"
-                                     LostFocus="LostFocusOrEnterDown"
-                                     KeyDown="LostFocusOrEnterDown"
-                                     Tag="{Binding}"
-                                     IsVisibleChanged="MenuEditWhenVisibilityChanged"
-                                     Visibility="{Binding MenuEdit}"/>
-                                        <StackPanel Orientation="Horizontal">
-                                            <Button Background="Transparent" 
-                                        BorderThickness="0"
-                                        hc:IconElement.Geometry="M438.857143 548.571429a36.571429 36.571429 0 0 1 36.571428 36.571428v256a36.571429 36.571429 0 0 1-36.571428 36.571429H182.857143a36.571429 36.571429 0 0 1-36.571429-36.571429v-256a36.571429 36.571429 0 0 1 36.571429-36.571428h256z m402.285714 0a36.571429 36.571429 0 0 1 36.571429 36.571428v256a36.571429 36.571429 0 0 1-36.571429 36.571429h-256a36.571429 36.571429 0 0 1-36.571428-36.571429v-256a36.571429 36.571429 0 0 1 36.571428-36.571428h256z m-438.857143 73.142857H219.428571v182.857143h182.857143v-182.857143z m402.285715 0h-182.857143v182.857143h182.857143v-182.857143zM438.857143 146.285714a36.571429 36.571429 0 0 1 36.571428 36.571429v256a36.571429 36.571429 0 0 1-36.571428 36.571428H182.857143a36.571429 36.571429 0 0 1-36.571429-36.571428V182.857143a36.571429 36.571429 0 0 1 36.571429-36.571429h256z m402.285714 0a36.571429 36.571429 0 0 1 36.571429 36.571429v256a36.571429 36.571429 0 0 1-36.571429 36.571428h-256a36.571429 36.571429 0 0 1-36.571428-36.571428V182.857143a36.571429 36.571429 0 0 1 36.571428-36.571429h256zM402.285714 219.428571H219.428571v182.857143h182.857143V219.428571z m402.285715 0h-182.857143v182.857143h182.857143V219.428571z" 
-                                        hc:IconElement.Height="18"
-                                        hc:IconElement.Width="18"
-                                        />
-                                            <TextBlock Text="{Binding MenuName}"
-                                           VerticalAlignment="Center"
-                                           IsVisibleChanged="MenuWhenVisibilityChanged"
-                                           Visibility="{Binding NotMenuEdit}"
-                                           />
-                                        </StackPanel>
-
-                                    </StackPanel>
-                                </DataTemplate>
-                            </ListBox.ItemTemplate>
-                        </ListBox>
-                    </WrapPanel>
-                </hc:Card>
 
 
+                <uc:LeftCardControl  Grid.Row="1" Grid.Column="0"/>
                 <!--分割线-->
                 <!--分割线-->
-                <GridSplitter DragCompleted="LeftCardResize" Opacity="0" Grid.Row="1" Grid.Column="0" Width="1"  VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
-
-                <!--右侧栏-->
-                <hc:Card AllowDrop="True" 
-                 Drop="Wrap_Drop" 
-                 x:Name="rightCard" 
-                 Grid.Row="1" 
-                 Grid.Column="1"  
-                 BorderThickness="1" 
-                 Effect="{DynamicResource EffectShadow2}" 
-                 Margin="5,0,5,5" Grid.ColumnSpan="2">
-                    <hc:Card.Background>
-                        <SolidColorBrush Color="#FFFFFFFF" Opacity="0.1"/>
-                    </hc:Card.Background>
-                    <hc:Card.BorderBrush>
-                        <SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
-                    </hc:Card.BorderBrush>
-                    <WrapPanel Orientation="Horizontal">
-                        <ListBox x:Name="icons" ItemsSource="{Binding}" 
-                                 BorderThickness="0"
-                                 SelectionChanged="IconSelectionChanged"
-                                 VirtualizingPanel.VirtualizationMode="Recycling"
-                                 >
-                            <ListBox.Background>
-                                <SolidColorBrush Opacity="0"/>
-                            </ListBox.Background>
-                            <ListBox.ItemsPanel>
-                                <ItemsPanelTemplate>
-                                    <DraggAnimatedPanel:DraggAnimatedPanel ItemsHeight="115" ItemsWidth="100"  HorizontalAlignment="Center" SwapCommand="{Binding SwapCommand, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"/>
-                                </ItemsPanelTemplate>
-                            </ListBox.ItemsPanel>
-
-                            <ListBox.Resources>
-                                <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>
-                            </ListBox.Resources>
-
-                            <ListBox.ItemContainerStyle>
-                                <Style TargetType="ListBoxItem">
-                                    <Setter Property="ContextMenu" Value="{StaticResource iconDialog}"/>
-                                </Style>
-                            </ListBox.ItemContainerStyle>
-
-                            <ListBox.ItemTemplate>
-                                <DataTemplate>
-                                    <StackPanel Tag="{Binding}"
-                                        MouseLeftButtonUp="IconClick"
-                                        HorizontalAlignment="Center"
-                                        Margin="5,5,5,5"
-                                        hc:Poptip.HitMode="None" 
-                                        hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
-                                        hc:Poptip.Content="{Binding Content}" 
-                                        hc:Poptip.Placement="BottomLeft"
-                                        >
-                                        <Image Style="{StaticResource imageStyle}" />
-                                        <TextBlock MaxWidth="80"
-                                               MaxHeight="40"
-                                               TextWrapping="Wrap" 
-                                               TextTrimming="WordEllipsis"
-                                               TextAlignment="Center" 
-                                               VerticalAlignment="Center" 
-                                               Text="{Binding Name}"/>
+                <GridSplitter Opacity="0" Grid.Row="1" Grid.Column="0" Width="1"  VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
 
 
-                                    </StackPanel>
-                                </DataTemplate>
-                            </ListBox.ItemTemplate>
-                        </ListBox>
-                    </WrapPanel>
-                </hc:Card>
+                <uc:RightCardControl Grid.Row="1" Grid.Column="1"/>
+                
                 <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>
                     <hc:NotifyIcon.ContextMenu>
                         <ContextMenu Width="200">
                         <ContextMenu Width="200">

+ 29 - 319
MainWindow.xaml.cs

@@ -12,6 +12,7 @@ using System.IO;
 using System.Windows;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Controls;
 using System.Windows.Input;
 using System.Windows.Input;
+using System.Windows.Interop;
 using System.Windows.Media;
 using System.Windows.Media;
 
 
 namespace GeekDesk
 namespace GeekDesk
@@ -24,7 +25,6 @@ namespace GeekDesk
     {
     {
 
 
         public static AppData appData = CommonCode.GetAppDataByFile();
         public static AppData appData = CommonCode.GetAppDataByFile();
-        private int menuSelectIndexTemp = -1;
         public MainWindow()
         public MainWindow()
         {
         {
             InitializeComponent();
             InitializeComponent();
@@ -41,196 +41,9 @@ namespace GeekDesk
             {
             {
                 appData.MenuList.Add(new MenuInfo() { MenuName = "NewMenu", MenuId = System.Guid.NewGuid().ToString(), MenuEdit = Visibility.Collapsed});
                 appData.MenuList.Add(new MenuInfo() { MenuName = "NewMenu", MenuId = System.Guid.NewGuid().ToString(), MenuEdit = Visibility.Collapsed});
             }
             }
-           
-            
-            //窗体大小
-            LeftColumn.Width = new GridLength(appData.AppConfig.MenuCardWidth);
+
             this.Width = appData.AppConfig.WindowWidth;
             this.Width = appData.AppConfig.WindowWidth;
             this.Height = appData.AppConfig.WindowHeight;
             this.Height = appData.AppConfig.WindowHeight;
-            //选中 菜单
-            menus.SelectedIndex = appData.AppConfig.SelectedMenuIndex;
-            //图标数据
-            icons.ItemsSource = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
-        }
-
-
-        #region 图标拖动
-        DelegateCommand<int[]> _swap;
-        public DelegateCommand<int[]> SwapCommand
-        {
-            get
-            {
-                if (_swap == null)
-                    _swap = new DelegateCommand<int[]>(
-                        (indexes) =>
-                        {
-                            int fromS = indexes[0];
-                            int to = indexes[1];
-                            ObservableCollection<IconInfo> iconList = appData.MenuList[menus.SelectedIndex].IconList;
-                            var elementSource = iconList[to];
-                            var dragged = iconList[fromS];
-
-                            iconList.Remove(dragged);
-                            iconList.Insert(to, dragged);
-                        }
-                    );
-                return _swap;
-            }
-        }
-        DelegateCommand<int[]> _swap2;
-
-        public DelegateCommand<int[]> SwapCommand2
-        {
-            get
-            {
-                if (_swap2 == null)
-                    _swap2 = new DelegateCommand<int[]>(
-                        (indexes) =>
-                        {
-                            int fromS = indexes[0];
-                            int to = indexes[1];
-                            ObservableCollection<MenuInfo> menuList = appData.MenuList;
-                            var elementSource = menuList[to];
-                            var dragged = menuList[fromS];
-                            menuList.Remove(dragged);
-                            menuList.Insert(to, dragged);
-                            menus.SelectedIndex = to;
-                            appData.MenuList = menuList;
-                        }
-                    );
-                return _swap2;
-            }
-        }
-        #endregion 图标拖动
-
-
-        private void Wrap_Drop(object sender, DragEventArgs e)
-        {
-            Array dropObject = (System.Array)e.Data.GetData(DataFormats.FileDrop);
-            if (dropObject == null) return;
-            foreach (object obj in dropObject)
-            {
-                string path = (string)obj;
-
-                //string base64 = ImageUtil.FileImageToBase64(path, ImageFormat.Jpeg);
-
-                IconInfo iconInfo = new IconInfo
-                {
-                    Path = path,
-                    BitmapImage = ImageUtil.GetBitmapIconByPath(path)
-                };
-                iconInfo.DefaultImage = iconInfo.ImageByteArr;
-                iconInfo.Name = Path.GetFileNameWithoutExtension(path);
-                appData.MenuList[menus.SelectedIndex].IconList.Add(iconInfo);
-            }
-        }
-
-   
-        ////菜单点击事件
-        private void MenuClick(object sender, MouseButtonEventArgs e)
-        {
-            //设置对应菜单的图标列表
-            MenuInfo mi = (MenuInfo)(((StackPanel)sender).Tag);
-            icons.ItemsSource = mi.IconList;
-            appData.AppConfig.SelectedMenuIndex = menus.Items.IndexOf(mi);
-        }
-
-
-
-        /// <summary>
-        /// 图标点击事件
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void IconClick(object sender, MouseButtonEventArgs e)
-        {
-            IconInfo icon = (IconInfo)((StackPanel)sender).Tag;
-            if (icon.AdminStartUp)
-            {
-                StartIconApp(icon, IconStartType.ADMIN_STARTUP);
-            }
-            else
-            {
-                StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
-            }
-        }
-
-        /// <summary>
-        /// 管理员方式启动
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void IconAdminStart(object sender, RoutedEventArgs e)
-        {
-            IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
-            StartIconApp(icon, IconStartType.ADMIN_STARTUP);
-        }
-
-        /// <summary>
-        /// 打开文件所在位置
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void ShowInExplore(object sender, RoutedEventArgs e)
-        {
-            IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
-            StartIconApp(icon, IconStartType.SHOW_IN_EXPLORE);
-        }
-
-        private void StartIconApp(IconInfo icon, IconStartType type)
-        {
-            try
-            {
-
-                if (!File.Exists(icon.Path) && !Directory.Exists(icon.Path))
-                {
-                    HandyControl.Controls.Growl.WarningGlobal("程序启动失败(文件路径不存在或已删除)!");
-                    return;
-                }
-
-                Process p = new Process();
-                p.StartInfo.FileName = icon.Path;
-
-                switch (type) {
-                    case IconStartType.ADMIN_STARTUP:
-                        p.StartInfo.Arguments = "1";//启动参数
-                        p.StartInfo.Verb = "runas";
-                        p.StartInfo.CreateNoWindow = false; //设置显示窗口
-                        p.StartInfo.UseShellExecute = false;//不使用操作系统外壳程序启动进程
-                        p.StartInfo.ErrorDialog = false;
-                        if (appData.AppConfig.AppHideType == AppHideType.START_EXE)
-                        {
-                            this.Visibility = Visibility.Collapsed;
-                        }
-                        break;// c#好像不能case穿透
-                    case IconStartType.DEFAULT_STARTUP:
-                        if (appData.AppConfig.AppHideType == AppHideType.START_EXE)
-                        {
-                            this.Visibility = Visibility.Collapsed;
-                        }
-                        break;
-                    case IconStartType.SHOW_IN_EXPLORE:
-                        p.StartInfo.FileName = "Explorer.exe";
-                        p.StartInfo.Arguments = "/e,/select," + icon.Path;
-                        break;
-                }
-                p.Start();
-                icon.Count++;
-            } catch (Exception)
-            { 
-                HandyControl.Controls.Growl.WarningGlobal("程序启动失败(不支持的启动方式)!");
-            }
-        }
-        
-
-        /// <summary>
-        /// data选中事件 设置不可选中
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void IconSelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            if (icons.SelectedIndex != -1) icons.SelectedIndex = -1;
         }
         }
 
 
         void Window_Loaded(object sender, RoutedEventArgs e)
         void Window_Loaded(object sender, RoutedEventArgs e)
@@ -264,16 +77,7 @@ namespace GeekDesk
         }
         }
 
 
 
 
-        /// <summary>
-        /// 删除菜单
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void DeleteMenu(object sender, RoutedEventArgs e)
-        {
-            MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo;
-            appData.MenuList.Remove(menuInfo);
-        }
+       
 
 
         private void DragMove(object sender, MouseEventArgs e)
         private void DragMove(object sender, MouseEventArgs e)
         {
         {
@@ -307,97 +111,14 @@ namespace GeekDesk
             }
             }
         }
         }
 
 
-        /// <summary>
-        /// 重命名菜单 将textbox 设置为可见
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void RenameMenu(object sender, RoutedEventArgs e)
-        {
-            MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo;
-            menuInfo.MenuEdit = (int)Visibility.Visible;
-        }
 
 
-        /// <summary>
-        /// 编辑菜单失焦或者敲下Enter键时保存修改后的菜单
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void LostFocusOrEnterDown(object sender, EventArgs e)
-        {
-            TextBox menuBox = null;
-            if (e.GetType() == typeof(KeyEventArgs))
-            {
-                KeyEventArgs eKey = e as KeyEventArgs;
-                if (eKey.Key == Key.Enter)
-                {
-                    menuBox = ((TextBox)sender);
-                }
-            } else if(e.GetType() == typeof(RoutedEventArgs))
-            {
-                menuBox = ((TextBox)sender);
-            }
 
 
-            if (menuBox != null)
-            {
-                MenuInfo menuInfo = menuBox.Tag as MenuInfo;
-                string text = menuBox.Text;
-                menuInfo.MenuName = text;
-                menuInfo.MenuEdit = Visibility.Collapsed;
-            }
-        }
 
 
-        /// <summary>
-        /// 当修改菜单元素可见时 设置全选并获得焦点
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void MenuEditWhenVisibilityChanged(object sender, DependencyPropertyChangedEventArgs e)
-        {
-            TextBox box = sender as TextBox;
-            if (box.Visibility == Visibility.Visible)
-            {
-                Keyboard.Focus(box);
-                box.SelectAll();
-            }
-        }
 
 
-        /// <summary>
-        /// 当修改菜单元素可见时 设置原菜单为不可见 并且不可选中
-        /// 修改菜单元素不可见时  原菜单可见 并 选中
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void MenuWhenVisibilityChanged(object sender, DependencyPropertyChangedEventArgs e)
-        {
-            TextBlock tb = sender as TextBlock;
-            if (tb.Visibility == Visibility.Collapsed)
-            {
-                if (menus.SelectedIndex != -1)
-                {
-                    menuSelectIndexTemp = menus.SelectedIndex;
-                    menus.SelectedIndex = -1;
-                } else
-                {
-                    menus.SelectedIndex = menuSelectIndexTemp;
-                }
-            }
-        }
 
 
-        /// <summary>
-        /// 新建菜单
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void CreateMenu(object sender, RoutedEventArgs e)
-        {
-            MenuInfo info = new MenuInfo() { MenuEdit = Visibility.Collapsed, MenuId = System.Guid.NewGuid().ToString(), MenuName = "NewMenu" };
-            appData.MenuList.Add(info);
-            menus.Items.Refresh();
-            menus.SelectedIndex = appData.MenuList.Count - 1;
-            appData.AppConfig.SelectedMenuIndex = menus.SelectedIndex;
-            icons.ItemsSource = info.IconList;
-        }
+
+
+
 
 
         /// <summary>
         /// <summary>
         /// 关闭按钮单击事件
         /// 关闭按钮单击事件
@@ -411,35 +132,19 @@ namespace GeekDesk
 
 
        
        
 
 
-        /// <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);
-        }
+       
 
 
-        /// <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;
-        }
+        ///// <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;
+        //}
 
 
         /// <summary>
         /// <summary>
         /// 随鼠标位置显示面板 (鼠标始终在中间)
         /// 随鼠标位置显示面板 (鼠标始终在中间)
@@ -549,13 +254,18 @@ namespace GeekDesk
             Application.Current.Shutdown();
             Application.Current.Shutdown();
         }
         }
 
 
-        private void MenuItem_Click(object sender, RoutedEventArgs e)
-        {
-            IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
-            System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("Explorer.exe");
-            psi.Arguments = "/e,/select," + icon.Path;
-            System.Diagnostics.Process.Start(psi);
-        }
+        
+
+        //public static void ShowContextMenu(IntPtr hAppWnd, Window taskBar, System.Windows.Point pt)
+        //{
+        //    WindowInteropHelper helper = new WindowInteropHelper(taskBar);
+        //    IntPtr callingTaskBarWindow = helper.Handle;
+        //    IntPtr wMenu = GetSystemMenu(hAppWnd, false);
+        //    // Display the menu 
+        //    uint command = TrackPopupMenuEx(wMenu, TPM.LEFTBUTTON | TPM.RETURNCMD, (int) pt.X, (int) pt.Y, callingTaskBarWindow, IntPtr.Zero);
+        //    if (command == 0) return; 
+        //    PostMessage(hAppWnd, WM.SYSCOMMAND, new IntPtr(command), IntPtr.Zero);
+        //}
 
 
         /// <summary>
         /// <summary>
         /// 设置按钮左键弹出菜单
         /// 设置按钮左键弹出菜单

+ 70 - 1
ViewModel/AppConfig.cs

@@ -2,6 +2,7 @@
 using GeekDesk.Constant;
 using GeekDesk.Constant;
 using GeekDesk.Util;
 using GeekDesk.Util;
 using System;
 using System;
+using System.Collections.ObjectModel;
 using System.ComponentModel;
 using System.ComponentModel;
 using System.Windows;
 using System.Windows;
 using System.Windows.Media.Imaging;
 using System.Windows.Media.Imaging;
@@ -29,10 +30,77 @@ namespace GeekDesk.ViewModel
         private BitmapImage bitmapImage; //位图
         private BitmapImage bitmapImage; //位图
         private byte[] imageByteArr; //背景图片 byte数组
         private byte[] imageByteArr; //背景图片 byte数组
         private string bacImgName = "系统默认";
         private string bacImgName = "系统默认";
+        private int cardOpacity = 10;  //默认0.1的不透明度  此处显示数值 * 100
+        private int bgOpacity = 100; // 背景图片不透明度 此处显示数值 * 100
+        private int pannelOpacity = 100; //主面板不透明度 此处显示数值 * 100
+        private int pannelCornerRadius = 4;  //面板圆角 默认4
+        [field: NonSerialized]
+        private ObservableCollection<IconInfo> selectedMenuIcons;
 
 
+        #region GetSet
+        public ObservableCollection<IconInfo> SelectedMenuIcons
+        {
+            get
+            {
+                return selectedMenuIcons;
+            }
+            set
+            {
+                selectedMenuIcons = value;
+                OnPropertyChanged("SelectedMenuIcons");
+            }
+        }
 
 
+        public int PannelCornerRadius
+        {
+            get
+            {
+                return pannelCornerRadius;
+            }
+            set
+            {
+                pannelCornerRadius = value;
+                OnPropertyChanged("pannelCornerRadius");
+            }
+        }
 
 
-        #region GetSet
+        public int PannelOpacity
+        {
+            get
+            {
+                return pannelOpacity;
+            }
+            set
+            {
+                pannelOpacity = value;
+                OnPropertyChanged("PannelOpacity");
+            }
+        }
+        public int BgOpacity
+        {
+            get
+            {
+                return bgOpacity;
+            }
+            set
+            {
+                bgOpacity = value;
+                OnPropertyChanged("BgOpacity");
+            }
+        }
+
+        public int CardOpacity
+        {
+            get
+            {
+                return cardOpacity;
+            }
+            set
+            {
+                cardOpacity = value;
+                OnPropertyChanged("CardOpacity");
+            }
+        }
 
 
         public string BacImgName
         public string BacImgName
         {
         {
@@ -67,6 +135,7 @@ namespace GeekDesk.ViewModel
             {
             {
                 if (imageByteArr == null || imageByteArr.Length == 0)
                 if (imageByteArr == null || imageByteArr.Length == 0)
                 {
                 {
+                    bacImgName = "系统默认";
                     return ImageUtil.ByteArrToImage(Convert.FromBase64String(Constants.DEFAULT_BAC_IMAGE_BASE64));
                     return ImageUtil.ByteArrToImage(Convert.FromBase64String(Constants.DEFAULT_BAC_IMAGE_BASE64));
                 } else
                 } else
                 {
                 {