8
Constant/MenuTypeEnum.cs
Normal file
8
Constant/MenuTypeEnum.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace GeekDesk.Constant
|
||||
{
|
||||
public enum MenuTypeEnum
|
||||
{
|
||||
NORMAL = 0,
|
||||
RELATION_FOLDER = 1
|
||||
}
|
||||
}
|
||||
@@ -90,6 +90,7 @@ namespace GeekDesk.Control.Other
|
||||
= appData.MenuList[
|
||||
MainWindow.mainWindow.LeftCard.MenuListBox.SelectedIndex
|
||||
].IconList;
|
||||
MainWindow.mainWindow.LeftCard.BuildWatcher();
|
||||
//显示数据托盘
|
||||
MainWindow.mainWindow.RightCard.WrapUFG.Visibility = Visibility.Visible;
|
||||
//取消加密操作
|
||||
|
||||
@@ -234,6 +234,20 @@
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding TextColor}" Foreground="{Binding TextColor}" Width="100"/>
|
||||
<Button Content="选择" Margin="0,-10,0,0" Tag="Text" Click="ColorButton_Click"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black" Grid.ColumnSpan="4"/>
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
|
||||
<TextBlock VerticalAlignment="Center" Text="关联文件夹筛选后缀(以“|”分割):" />
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
|
||||
<hc:TextBox HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
IsReadOnlyCaretVisible="True"
|
||||
Width="300"
|
||||
Text="{Binding FilterExt}"
|
||||
InputMethod.IsInputMethodEnabled="False"
|
||||
/>
|
||||
</hc:UniformSpacingPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
|
||||
@@ -139,6 +139,7 @@
|
||||
<hc:Card.ContextMenu>
|
||||
<ContextMenu Width="200">
|
||||
<MenuItem Header="新建菜单" Click="CreateMenu"/>
|
||||
<MenuItem Header="新建关联菜单" Click="CreateFolderMenu"/>
|
||||
<MenuItem x:Name="AlterPW1" Header="修改密码" Click="AlterPassword"/>
|
||||
</ContextMenu>
|
||||
</hc:Card.ContextMenu>
|
||||
@@ -158,6 +159,7 @@
|
||||
<ListBox.Resources>
|
||||
<ContextMenu x:Key="MenuDialog" Width="200">
|
||||
<MenuItem Header="新建菜单" Click="CreateMenu"/>
|
||||
<MenuItem Header="新建关联菜单" Click="CreateFolderMenu"/>
|
||||
<MenuItem Header="重命名" Click="RenameMenu" Tag="{Binding}"/>
|
||||
<MenuItem Header="加密此列表" Click="EncryptMenu" Tag="{Binding}"/>
|
||||
<MenuItem x:Name="AlterPW2" Header="修改密码" Click="AlterPassword"/>
|
||||
|
||||
@@ -7,11 +7,19 @@ using GeekDesk.ViewModel;
|
||||
using System;
|
||||
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using DragEventArgs = System.Windows.DragEventArgs;
|
||||
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||
using MenuItem = System.Windows.Controls.MenuItem;
|
||||
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
||||
using TextBox = System.Windows.Controls.TextBox;
|
||||
using UserControl = System.Windows.Controls.UserControl;
|
||||
|
||||
namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
@@ -23,6 +31,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
private int menuSelectIndexTemp = -1;
|
||||
private AppData appData = MainWindow.appData;
|
||||
private SolidColorBrush bac = new SolidColorBrush(Color.FromRgb(236, 236, 236));
|
||||
private FileSystemWatcher Watcher = new FileSystemWatcher();
|
||||
|
||||
|
||||
public LeftCardControl()
|
||||
@@ -34,9 +43,33 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
SelectLastMenu();
|
||||
SetMenuListBoxItemEvent();
|
||||
BindWatcherEvent();
|
||||
BuildWatcher();
|
||||
};
|
||||
}
|
||||
|
||||
private void BindWatcherEvent()
|
||||
{
|
||||
Watcher.Created += WatcherEvent;
|
||||
Watcher.Renamed += WatcherEvent;
|
||||
Watcher.Deleted += WatcherEvent;
|
||||
}
|
||||
|
||||
public void BuildWatcher()
|
||||
{
|
||||
MenuInfo menuInfo = appData.MenuList[appData.AppConfig.SelectedMenuIndex];
|
||||
if (menuInfo.MenuType == MenuTypeEnum.RELATION_FOLDER)
|
||||
{
|
||||
Watcher.Path = menuInfo.RelationPath;
|
||||
}
|
||||
Watcher.EnableRaisingEvents = menuInfo.MenuType == MenuTypeEnum.RELATION_FOLDER;
|
||||
}
|
||||
|
||||
private void WatcherEvent(object sender, EventArgs e)
|
||||
{
|
||||
MenuInfo menuInfo = appData.MenuList[appData.AppConfig.SelectedMenuIndex];
|
||||
appData.AppConfig.SelectedMenuIcons = menuInfo.IconList;
|
||||
}
|
||||
|
||||
private void SetMenuListBoxItemEvent()
|
||||
{
|
||||
@@ -189,7 +222,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
/// <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" };
|
||||
MenuInfo info = new MenuInfo() { MenuEdit = Visibility.Collapsed, MenuId = System.Guid.NewGuid().ToString(), MenuName = "NewMenu", MenuType = MenuTypeEnum.NORMAL};
|
||||
appData.MenuList.Add(info);
|
||||
MenuListBox.SelectedIndex = appData.MenuList.Count - 1;
|
||||
appData.AppConfig.SelectedMenuIndex = MenuListBox.SelectedIndex;
|
||||
@@ -341,6 +374,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Collapsed;
|
||||
appData.AppConfig.SelectedMenuIcons = appData.MenuList[MenuListBox.SelectedIndex].IconList;
|
||||
BuildWatcher();
|
||||
}
|
||||
}
|
||||
MainWindow.mainWindow.RightCard.WrapUFG.Visibility = Visibility.Visible;
|
||||
@@ -628,5 +662,34 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建关联文件夹的菜单
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void CreateFolderMenu(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FolderBrowserDialog dialog = new FolderBrowserDialog();
|
||||
dialog.RootFolder = Environment.SpecialFolder.Desktop;
|
||||
if (dialog.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(dialog.SelectedPath))
|
||||
{
|
||||
MenuInfo info = new MenuInfo()
|
||||
{
|
||||
MenuEdit = Visibility.Collapsed, MenuId = System.Guid.NewGuid().ToString(), MenuName = new DirectoryInfo(dialog.SelectedPath).Name,
|
||||
|
||||
MenuType = MenuTypeEnum.RELATION_FOLDER, RelationPath = dialog.SelectedPath
|
||||
};
|
||||
|
||||
appData.MenuList.Add(info);
|
||||
MenuListBox.SelectedIndex = appData.MenuList.Count - 1;
|
||||
appData.AppConfig.SelectedMenuIndex = MenuListBox.SelectedIndex;
|
||||
appData.AppConfig.SelectedMenuIcons = info.IconList;
|
||||
//首次触发不了Selected事件
|
||||
object obj = MenuListBox.ItemContainerGenerator.ContainerFromIndex(MenuListBox.SelectedIndex);
|
||||
SetListBoxItemEvent((ListBoxItem)obj);
|
||||
Lbi_Selected(obj, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@
|
||||
<ContextMenu x:Key="IconDialog" Width="200">
|
||||
<MenuItem Header="管理员方式运行" Click="IconAdminStart" Tag="{Binding}"/>
|
||||
<MenuItem Header="打开文件所在位置" Click="ShowInExplore" Tag="{Binding}"/>
|
||||
<MenuItem Header="添加URL项目" Click="AddUrlIcon"/>
|
||||
<MenuItem Header="添加URL项目" Click="AddUrlIcon" />
|
||||
<MenuItem Header="添加系统项目" Click="AddSystemIcon"/>
|
||||
<MenuItem Header="资源管理器菜单" Click="SystemContextMenu" Tag="{Binding}"/>
|
||||
<MenuItem Header="属性" Click="PropertyConfig" Tag="{Binding}"/>
|
||||
|
||||
@@ -3,7 +3,6 @@ using GeekDesk.Util;
|
||||
using HandyControl.Controls;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
@@ -53,19 +52,39 @@ namespace GeekDesk.Control.Windows
|
||||
|
||||
this.WindowState = WindowState.Normal;//还原窗口(非最小化和最大化)
|
||||
|
||||
this.Width = SystemParameters.VirtualScreenWidth;
|
||||
this.Height = SystemParameters.VirtualScreenHeight;
|
||||
var screens = Screen.AllScreens;
|
||||
int allWidth = 0;
|
||||
int allHeight = 0;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
this.Left = SystemParameters.VirtualScreenLeft;
|
||||
this.Top = SystemParameters.VirtualScreenTop;
|
||||
//获取缩放比例
|
||||
double scale = ScreenUtil.GetScreenScalingFactor();
|
||||
|
||||
foreach (var screen in screens)
|
||||
{
|
||||
var rect = screen.Bounds;
|
||||
allWidth += rect.Width;
|
||||
allHeight += rect.Height;
|
||||
x = Math.Min(x, rect.X);
|
||||
y = Math.Min(y, rect.Y);
|
||||
}
|
||||
//如果主显示器是最左边和最上边,则显示主显示器的缩放比例,反之则缩放比例不添加缩放比例
|
||||
if (Screen.PrimaryScreen.Bounds.X != x || Screen.PrimaryScreen.Bounds.Y != y)
|
||||
{
|
||||
scale = 1;
|
||||
}
|
||||
|
||||
this.Width = allWidth;
|
||||
this.Height = allHeight;
|
||||
|
||||
this.Left = x;
|
||||
this.Top = y;
|
||||
|
||||
DesktopBG.Width = this.Width;
|
||||
DesktopBG.Height = this.Height;
|
||||
this.Topmost = true;
|
||||
|
||||
//获取缩放比例
|
||||
double scale = ScreenUtil.GetScreenScalingFactor();
|
||||
|
||||
bgBitmap = new System.Drawing.Bitmap(
|
||||
(int)(Width * scale),
|
||||
(int)(Height * scale),
|
||||
@@ -75,8 +94,8 @@ namespace GeekDesk.Control.Windows
|
||||
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bgBitmap))
|
||||
{
|
||||
g.CopyFromScreen(
|
||||
0,
|
||||
0,
|
||||
(int)this.Left,
|
||||
(int)this.Top,
|
||||
0,
|
||||
0,
|
||||
bgBitmap.Size
|
||||
@@ -88,7 +107,6 @@ namespace GeekDesk.Control.Windows
|
||||
Int32Rect.Empty,
|
||||
BitmapSizeOptions.FromEmptyOptions()
|
||||
);
|
||||
|
||||
DesktopBG.Source = bs;
|
||||
VisualBrush b = (VisualBrush)PixelBG.Fill;
|
||||
b.Visual = DesktopBG;
|
||||
|
||||
@@ -167,6 +167,7 @@
|
||||
<Compile Include="Constant\IconType.cs" />
|
||||
<Compile Include="Constant\CommonEnum.cs" />
|
||||
<Compile Include="Constant\IconStartType.cs" />
|
||||
<Compile Include="Constant\MenuTypeEnum.cs" />
|
||||
<Compile Include="Constant\PasswordType.cs" />
|
||||
<Compile Include="Constant\RunTimeStatus.cs" />
|
||||
<Compile Include="Constant\SearchType.cs" />
|
||||
|
||||
@@ -105,8 +105,27 @@ namespace GeekDesk.ViewModel
|
||||
|
||||
private bool? secondsWindow; //秒数窗口 默认打开
|
||||
|
||||
private string filterExt = "lnk|exe|cmd|vbs|bat|xls|xlsx|doc|docx|txt|pdf";
|
||||
|
||||
#region GetSet
|
||||
|
||||
public string FilterExt
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(filterExt))
|
||||
{
|
||||
FilterExt = "lnk|exe|cmd|vbs|bat|xls|xlsx|doc|docx|txt|pdf";
|
||||
}
|
||||
return filterExt;
|
||||
}
|
||||
set
|
||||
{
|
||||
filterExt = value;
|
||||
OnPropertyChanged("FilterExt");
|
||||
}
|
||||
}
|
||||
|
||||
public bool? SecondsWindow
|
||||
{
|
||||
get
|
||||
|
||||
@@ -3,6 +3,8 @@ using GeekDesk.Util;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace GeekDesk.ViewModel
|
||||
@@ -15,6 +17,8 @@ namespace GeekDesk.ViewModel
|
||||
|
||||
private string menuName;
|
||||
private string menuId;
|
||||
private MenuTypeEnum menuType = MenuTypeEnum.NORMAL;
|
||||
private string relationPath;
|
||||
private Visibility menuEdit = Visibility.Collapsed;
|
||||
private Visibility notMenuEdit = Visibility.Visible;
|
||||
private string menuGeometry; //菜单几何图标
|
||||
@@ -22,6 +26,25 @@ namespace GeekDesk.ViewModel
|
||||
private ObservableCollection<IconInfo> iconList = new ObservableCollection<IconInfo>();
|
||||
private bool isEncrypt; //是否加密
|
||||
|
||||
public string RelationPath
|
||||
{
|
||||
get => relationPath;
|
||||
set
|
||||
{
|
||||
relationPath = value;
|
||||
OnPropertyChanged("RelationPath");
|
||||
}
|
||||
}
|
||||
|
||||
public MenuTypeEnum MenuType
|
||||
{
|
||||
get => menuType;
|
||||
set
|
||||
{
|
||||
menuType = value;
|
||||
OnPropertyChanged("MenuType");
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEncrypt
|
||||
{
|
||||
@@ -134,6 +157,27 @@ namespace GeekDesk.ViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
//如果是关联文件夹类型,实时读取
|
||||
if (menuType == MenuTypeEnum.RELATION_FOLDER)
|
||||
{
|
||||
DirectoryInfo dir = new DirectoryInfo(RelationPath);
|
||||
if (dir.Exists)
|
||||
{
|
||||
ObservableCollection<IconInfo> relationIconInfo = new ObservableCollection<IconInfo>();
|
||||
var folders = dir.GetDirectories();
|
||||
foreach (var directoryInfo in folders)
|
||||
{
|
||||
relationIconInfo.Add(CommonCode.GetIconInfoByPath(directoryInfo.FullName));
|
||||
}
|
||||
var files = dir.EnumerateFiles().Where(f => MainWindow.appData.AppConfig.FilterExt.Contains(f.Extension.Replace(".", "")));
|
||||
foreach (var fileInfo in files)
|
||||
{
|
||||
relationIconInfo.Add(CommonCode.GetIconInfoByPath(fileInfo.FullName));
|
||||
}
|
||||
|
||||
return relationIconInfo;
|
||||
}
|
||||
}
|
||||
return iconList;
|
||||
}
|
||||
set
|
||||
|
||||
Reference in New Issue
Block a user