增加添加系统应用功能

This commit is contained in:
liufei
2022-01-06 17:45:25 +08:00
parent 1125432c41
commit d092db8b5c
35 changed files with 950 additions and 293 deletions

View File

@@ -1,5 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section
name="SystemIcons"
type="System.Configuration.DictionarySectionHandler" />
</configSections>
<SystemIcons>
<add key="Calculator" value="计算器"/>
<add key="Computer" value="此电脑"/>
<add key="GroupPolicy" value="组策略"/>
<add key="Network" value="网络连接"/>
<add key="RecycleBin" value="回收站"/>
<add key="Registry" value="注册表编辑器"/>
<add key="Notepad" value="记事本"/>
<add key="Mstsc" value="远程桌面连接"/>
<add key="Control" value="控制面板"/>
<add key="CMD" value="命令行"/>
</SystemIcons>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
@@ -34,7 +51,9 @@
<add key="GitHubUpdateUrl" value="https://demo-liu.github.io/GeekDesk/Update.json" />
<add key="GiteeUpdateUrl" value="https://demo-liu.github.io/GeekDesk/Update.json" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
<add key="CustomIconTeachUrl" value="https://mp.weixin.qq.com/s/LxoHAekho9HBVl4FRw_Law"/>
</appSettings>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>

View File

@@ -5,8 +5,8 @@ namespace GeekDesk.Constant
{
public enum CommonEnum
{
WINDOW_WIDTH = 666, //默认窗体宽度
WINDOW_HEIGHT = 500, //默认窗体高度
WINDOW_WIDTH = 950, //默认窗体宽度
WINDOW_HEIGHT = 650, //默认窗体高度
MENU_CARD_WIDHT = 165, //默认菜单栏宽度
IMAGE_WIDTH = 45, //默认图标宽度
IMAGE_HEIGHT = 45, //默认图标高度

File diff suppressed because one or more lines are too long

View File

@@ -35,9 +35,11 @@
</hc:UniformSpacingPanel>
<TextBlock Text="注: 需配置正确的url方可加载远程图标!" Foreground="Red" Margin="10,95,-10,-92" />
<hc:UniformSpacingPanel Spacing="10" Margin="246.206,124.551,-246.206,-124.551">
<Button Content="取消" Command="hc:ControlCommands.Close"
<hc:UniformSpacingPanel Spacing="10" Margin="203,125,-203,-125">
<Button Content="取消" Command="hc:ControlCommands.Close" HorizontalAlignment="Stretch" Margin="-1,1,1,1" VerticalAlignment="Stretch"
/>
<Button Content="教程" Click="Teach_Click"
Style="{StaticResource Btn1}"/>
<Button Content="保存" Click="Confirm_Click"
Command="hc:ControlCommands.Close"
Style="{StaticResource Btn1}"/>

View File

@@ -3,6 +3,8 @@ using GeekDesk.Util;
using GeekDesk.ViewModel;
using Microsoft.Win32;
using System;
using System.Configuration;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
@@ -40,5 +42,12 @@ namespace GeekDesk.Control.Other
IconfontWindow.vm.IsSettingUrl = "false";
}
}
private void Teach_Click(object sender, RoutedEventArgs e)
{
string url = ConfigurationManager.AppSettings["CustomIconTeachUrl"];
Process.Start(url);
}
}
}

View File

@@ -3,13 +3,13 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
CornerRadius="4"
Width="300"
Height="340"
Width="350"
Height="450"
Style="{StaticResource BorderBG}"
>
<Border.Resources>
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
<Setter Property="Width" Value="40"/>
<Setter Property="Width" Value="75"/>
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center"/>
@@ -22,7 +22,7 @@
<Button Width="22" Height="22" Command="hc:ControlCommands.Close" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top"/>
<hc:UniformSpacingPanel Spacing="10">
<TextBlock Text="名称:" Style="{StaticResource LeftTB}"/>
<TextBox x:Name="IconName" Text="{Binding Name, Mode=OneWay}" Width="180" FontSize="14"/>
<TextBox x:Name="IconName" Text="{Binding Name, Mode=OneWay}" Width="230" FontSize="14"/>
</hc:UniformSpacingPanel>
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black"/>
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
@@ -42,8 +42,12 @@
</CheckBox>
</hc:UniformSpacingPanel>
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black" Grid.ColumnSpan="4"/>
<hc:UniformSpacingPanel Spacing="10">
<TextBlock Text="启动参数:" Style="{StaticResource LeftTB}"/>
<TextBox x:Name="StartArg" Text="{Binding StartArg, Mode=OneWay}" Width="230" Height="100" TextWrapping="Wrap" FontSize="14"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
<Button Content="保存" Style="{StaticResource Btn1}" Click="SaveProperty" Margin="208,0,0,0"/>
<Button Content="保存" Style="{StaticResource Btn1}" Click="SaveProperty" Margin="265,10,0,0"/>
</hc:UniformSpacingPanel>
</StackPanel>
</hc:SimplePanel>

View File

@@ -38,6 +38,7 @@ namespace GeekDesk.Control.Other
info.BitmapImage = IconImg.Source as BitmapImage;
info.Name = IconName.Text;
info.AdminStartUp = IconIsAdmin.IsChecked.Value;
info.StartArg = StartArg.Text;
CommonCode.SaveAppData(MainWindow.appData);
dialog.Close();
}

View File

@@ -9,7 +9,6 @@
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
>
<UserControl.Resources>
<!--右侧栏样式动画-->
@@ -48,6 +47,7 @@
<hc:Card.ContextMenu>
<ContextMenu Width="200">
<MenuItem Header="添加URL项目" Click="AddUrlIcon"/>
<MenuItem Header="添加系统项目" Click="AddSystemIcon"/>
</ContextMenu>
</hc:Card.ContextMenu>
<WrapPanel Orientation="Horizontal" VirtualizingPanel.VirtualizationMode="Recycling"
@@ -76,6 +76,7 @@
<MenuItem Header="管理员方式运行" Click="IconAdminStart" Tag="{Binding}"/>
<MenuItem Header="打开文件所在位置" Click="ShowInExplore" Tag="{Binding}"/>
<MenuItem Header="添加URL项目" Click="AddUrlIcon"/>
<MenuItem Header="添加系统项目" Click="AddSystemIcon"/>
<MenuItem Header="资源管理器菜单" Click="SystemContextMenu" Tag="{Binding}"/>
<MenuItem Header="属性" Click="PropertyConfig" Tag="{Binding}"/>
<MenuItem Header="从列表移除" Click="RemoveIcon" Tag="{Binding}"/>

View File

@@ -1,6 +1,7 @@
using DraggAnimatedPanelExample;
using GeekDesk.Constant;
using GeekDesk.Control.Other;
using GeekDesk.Control.Windows;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using HandyControl.Controls;
@@ -119,7 +120,19 @@ namespace GeekDesk.Control.UserControls.PannelCard
try
{
Process p = new Process();
string startArg = icon.StartArg;
if (Constants.SYSTEM_ICONS.ContainsKey(startArg))
{
StartSystemApp(startArg, type);
} else
{
p.StartInfo.FileName = icon.Path;
if (!StringUtil.IsEmpty(icon.StartArg))
{
p.StartInfo.Arguments = icon.StartArg;
}
if (icon.IconType == IconType.OTHER)
{
if (!File.Exists(icon.Path) && !Directory.Exists(icon.Path))
@@ -131,7 +144,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
switch (type)
{
case IconStartType.ADMIN_STARTUP:
p.StartInfo.Arguments = "1";//启动参数
//p.StartInfo.Arguments = "1";//启动参数
p.StartInfo.Verb = "runas";
p.StartInfo.CreateNoWindow = false; //设置显示窗口
p.StartInfo.UseShellExecute = false;//不使用操作系统外壳程序启动进程
@@ -163,7 +176,8 @@ namespace GeekDesk.Control.UserControls.PannelCard
{
MainWindow.HideApp();
}
} else
}
else
{
MainWindow.HideApp();
}
@@ -174,7 +188,8 @@ namespace GeekDesk.Control.UserControls.PannelCard
p.StartInfo.Arguments = "/e,/select," + icon.Path;
break;
}
} else
}
else
{
if (appData.AppConfig.AppHideType == AppHideType.START_EXE)
{
@@ -193,6 +208,8 @@ namespace GeekDesk.Control.UserControls.PannelCard
}
}
p.Start();
}
icon.Count++;
}
catch (Exception e)
@@ -204,7 +221,68 @@ namespace GeekDesk.Control.UserControls.PannelCard
private void StartSystemApp(string startArg, IconStartType type)
{
if (type == IconStartType.SHOW_IN_EXPLORE)
{
Growl.WarningGlobal("系统项目不支持打开文件位置操作!");
return;
}
switch (startArg)
{
case "Calculator":
Process.Start("calc.exe");
break;
case "Computer":
Process.Start("explorer.exe");
break;
case "GroupPolicy":
Process.Start("gpedit.msc");
break;
case "Notepad":
Process.Start("notepad");
break;
case "Network":
Process.Start("ncpa.cpl");
break;
case "RecycleBin":
Process.Start("shell:RecycleBinFolder");
break;
case "Registry":
Process.Start("regedit.exe");
break;
case "Mstsc":
if (type == IconStartType.ADMIN_STARTUP)
{
Process.Start("mstsc", "-admin");
} else
{
Process.Start("mstsc");
}
break;
case "Control":
Process.Start("Control");
break;
case "CMD":
if (type == IconStartType.ADMIN_STARTUP)
{
Process process = new Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Verb = "runas";
process.Start();
} else
{
Process.Start("cmd");
}
break;
}
}
/// <summary>
/// 拖动添加项目
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Wrap_Drop(object sender, DragEventArgs e)
{
Array dropObject = (System.Array)e.Data.GetData(DataFormats.FileDrop);
@@ -212,36 +290,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
foreach (object obj in dropObject)
{
string path = (string)obj;
string tempPath = path;
//string base64 = ImageUtil.FileImageToBase64(path, System.Drawing.Imaging.ImageFormat.Png);
string ext = "";
if (!ImageUtil.IsSystemItem(path))
{
ext = System.IO.Path.GetExtension(path).ToLower();
}
if (".lnk".Equals(ext))
{
string targetPath = FileUtil.GetTargetPathByLnk(path);
if (targetPath!=null)
{
path = targetPath;
}
}
BitmapImage bi = ImageUtil.GetBitmapIconByPath(path);
IconInfo iconInfo = new IconInfo
{
Path = path,
BitmapImage = bi
};
iconInfo.DefaultImage = iconInfo.ImageByteArr;
iconInfo.Name = System.IO.Path.GetFileNameWithoutExtension(tempPath);
if (StringUtil.IsEmpty(iconInfo.Name))
{
iconInfo.Name = path;
}
IconInfo iconInfo = CommonCode.GetIconInfoByPath(path);
MainWindow.appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList.Add(iconInfo);
CommonCode.SaveAppData(MainWindow.appData);
}
@@ -430,10 +479,25 @@ namespace GeekDesk.Control.UserControls.PannelCard
sb2.Remove();
}
/// <summary>
/// 添加URL项目
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void AddUrlIcon(object sender, RoutedEventArgs e)
{
IconInfoUrlDialog urlDialog = new IconInfoUrlDialog();
urlDialog.dialog = HandyControl.Controls.Dialog.Show(urlDialog, "IconInfoDialog");
}
/// <summary>
/// 添加系统项目
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void AddSystemIcon(object sender, RoutedEventArgs e)
{
SystemItemWindow.Show();
}
}
}

View File

@@ -0,0 +1,57 @@
<UserControl x:Class="GeekDesk.Control.UserControls.SystemItem.SystemItem"
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:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.IconFont"
mc:Ignorable="d"
Background="#00FFFFFF"
>
<WrapPanel HorizontalAlignment="Center" VerticalAlignment="Top" Background="Transparent">
<ListBox x:Name="ItemListBox" ItemsSource="{Binding IconInfos}" BorderThickness="0"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.IsContainerVirtualizable="True"
>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" Background="#00FFFFFF"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.Background>
<SolidColorBrush Opacity="0"/>
</ListBox.Background>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Width="80" Height="80" HorizontalAlignment="Center"
Background="#00FFFFFF"
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
hc:Poptip.Content="{Binding Content_NoWrite, Mode=OneWay}"
Tag="{Binding}"
MouseLeftButtonDown="Icon_MouseLeftButtonDown"
hc:Poptip.Placement="BottomLeft"
hc:Poptip.HitMode="None"
>
<Image Source="{Binding BitmapImage_NoWrite, Mode=OneWay}" Width="45" Height="45" RenderOptions.BitmapScalingMode="HighQuality" />
<TextBlock TextAlignment="Center"
HorizontalAlignment="Center"
VerticalAlignment="Center"
TextWrapping="Wrap"
MaxHeight="40"
FontSize="13"
TextTrimming="WordEllipsis"
Width="65" Text="{Binding Name_NoWrite, Mode=OneWay}"
/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</WrapPanel>
</UserControl>

View File

@@ -0,0 +1,59 @@
using GeekDesk.Constant;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using System;
using System.Collections.Generic;
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.SystemItem
{
/// <summary>
/// IconPannel.xaml 的交互逻辑
/// </summary>
public partial class SystemItem : UserControl
{
public SystemItem()
{
InitializeComponent();
}
private void Icon_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
IconInfo thisInfo = (sender as StackPanel).Tag as IconInfo;
MenuInfo menuInfo = MainWindow.appData.MenuList[MainWindow.appData.AppConfig.SelectedMenuIndex];
string startArg = thisInfo.StartArg;
IconInfo iconInfo;
if (Constants.SYSTEM_ICONS.ContainsKey(startArg))
{
//系统项
iconInfo = new IconInfo
{
Name_NoWrite = thisInfo.Name_NoWrite,
Path_NoWrite = thisInfo.Path_NoWrite,
StartArg_NoWrite = thisInfo.StartArg_NoWrite,
BitmapImage_NoWrite = thisInfo.BitmapImage_NoWrite
};
iconInfo.Content_NoWrite = iconInfo.Name_NoWrite
+ "\n使用次数:" + iconInfo.Count;
} else
{
//startupMenu or Store
iconInfo = CommonCode.GetIconInfoByPath(thisInfo.LnkPath_NoWrite);
}
menuInfo.IconList.Add(iconInfo);
CommonCode.SaveAppData(MainWindow.appData);
}
}
}

View File

@@ -5,7 +5,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GeekDesk.Control.Windows"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:uc="clr-namespace:GeekDesk.Control.UserControls.IconFont"
xmlns:uc="clr-namespace:GeekDesk.Control.UserControls.SystemItem"
xmlns:cvt="clr-namespace:GeekDesk.Converts"
mc:Ignorable="d"
Title="Svg"
Height="520" Width="700"
@@ -33,6 +34,7 @@
</Setter>
</Style.Setters>
</Style>
<cvt:MenuInfoConvert x:Key="MenuInfoConvert"/>
</Window.Resources>
<Grid Margin="20">
@@ -43,38 +45,52 @@
<Border MouseDown="DragMove" Style="{StaticResource BorderBG}" hc:Dialog.Token="IconUrlDialog">
<hc:DialogContainer>
<Grid MouseDown="DragMove">
<TextBox x:Name="CheckSettingUrl" Visibility="Collapsed" Text="{Binding IsSettingUrl}" TextChanged="CheckSettingUrl_TextChanged"/>
<StackPanel HorizontalAlignment="Center" Margin="10">
<Border CornerRadius="8" Height="30" Width="150">
<Border.Background>
<SolidColorBrush Color="White" Opacity="0.7"/>
</Border.Background>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button Background="Transparent"
BorderThickness="0"
hc:IconElement.Geometry="{Binding AppConfig.SelectedMenuIndex, Mode=OneWay, Converter={StaticResource MenuInfoConvert}, ConverterParameter=1}"
hc:IconElement.Height="18"
hc:IconElement.Width="18"
IsEnabled="False"
Opacity="1"
>
</Button>
<TextBlock x:Name="MenuName" Text="{Binding AppConfig.SelectedMenuIndex, Mode=OneWay, Converter={StaticResource MenuInfoConvert}, ConverterParameter=2}" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
</Border>
</StackPanel>
<hc:TabControl x:Name="MyTabControl"
IsAnimationEnabled="True"
SelectionChanged="TabControl_SelectionChanged"
ShowContextMenu="True"
IsTabFillEnabled="True"
Margin="20,30,20,20"
Margin="20,60,20,20"
Height="350"
VerticalAlignment="Top"
Style="{StaticResource HcTabControl}">
<hc:TabItem Tag="System" IsSelected="True" Header="系统应用" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource SystemIcon}" Style="{StaticResource TabTitle}">
<hc:SimplePanel>
<uc:IconPannel x:Name="SystemItem"/>
<uc:SystemItem x:Name="SystemItem"/>
</hc:SimplePanel>
</hc:TabItem>
<hc:TabItem Tag="System" IsSelected="True" Header="开始菜单应用" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource SystemIcon}" Style="{StaticResource TabTitle}">
<hc:TabItem x:Name="StartMenu" Tag="StartMenu" Header="开始菜单应用" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource SystemIcon}" Style="{StaticResource TabTitle}">
<hc:SimplePanel>
<uc:IconPannel x:Name="StartMenuItem"/>
<uc:SystemItem x:Name="StartMenuItem"/>
<hc:LoadingCircle x:Name="StartMenuLoading"/>
</hc:SimplePanel>
</hc:TabItem>
<hc:TabItem Tag="Custom" Header="商店应用" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource CustomIcon}" Style="{StaticResource TabTitle}">
<!--<hc:TabItem Tag="Store" Header="商店应用(未开放)" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource CustomIcon}" Style="{StaticResource TabTitle}">
<hc:SimplePanel>
<uc:IconPannel x:Name="CustomIcon"/>
<hc:LoadingCircle x:Name="LoadingEle"/>
<uc:SystemItem x:Name="StoreItem"/>
</hc:SimplePanel>
</hc:TabItem>
</hc:TabItem>-->
</hc:TabControl>
<Button Content="取消" Click="Close_Click" Margin="391,397.5,163,22.5"/>
<Button Content="自定义设置" Click="CustomButton_Click" IsEnabled="False" Name="CustomButton" Style="{StaticResource Btn1}" Margin="447,397.5,71,22.5"/>
<Button Content="确定" Click="Confirm_Click" Style="{StaticResource Btn1}" Margin="534,397.5,20,22.5" />
<Button Content="关闭" Click="Close_Click" Margin="594,420,20,31.5"/>
</Grid>
</hc:DialogContainer>
</Border>

View File

@@ -1,16 +1,22 @@
using GeekDesk.Control.Other;
using GeekDesk.Constant;
using GeekDesk.Control.Other;
using GeekDesk.Interface;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Resources;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using static GeekDesk.Util.ShowWindowFollowMouse;
namespace GeekDesk.Control.Windows
@@ -22,27 +28,19 @@ namespace GeekDesk.Control.Windows
public partial class SystemItemWindow : Window, IWindowCommon
{
private static AppConfig appConfig = MainWindow.appData.AppConfig;
private static MenuInfo menuInfo;
private static List<IconfontInfo> systemIcons;
private static List<IconfontInfo> customIcons;
public static IconfontViewModel vm;
private SystemItemWindow(List<IconfontInfo> icons, MenuInfo menuInfo)
{
private static SystemItemViewModel vm;
private static List<IconInfo> systemIcons;
private static List<IconInfo> startMenuIcons;
private static List<IconInfo> storeIcons;
InitializeComponent();
systemIcons = icons;
this.Topmost = true;
SystemItemWindow.menuInfo = menuInfo;
vm = new IconfontViewModel
private SystemItemWindow()
{
Iconfonts = systemIcons
};
vm = new SystemItemViewModel();
this.DataContext = vm;
InitializeComponent();
this.Topmost = true;
}
/// <summary>
/// 移动窗口
/// </summary>
@@ -61,157 +59,186 @@ namespace GeekDesk.Control.Windows
this.Close();
}
/// <summary>
/// 切换选项卡
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
TabItem ti = this.MyTabControl.SelectedItem as TabItem;
List<IconInfo> systemInfos = vm.IconInfos;
if (systemInfos == null)
{
systemInfos = new List<IconInfo>();
}
switch (ti.Tag.ToString())
{
case "Custom":
CustomButton.IsEnabled = true;
if (StringUtil.IsEmpty(appConfig.CustomIconUrl) || StringUtil.IsEmpty(appConfig.CustomIconJsonUrl))
case "StartMenu": //开始菜单
if (startMenuIcons == null)
{
LoadingEle.Visibility = Visibility.Visible;
CustomIcon.Visibility = Visibility.Collapsed;
HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig), "IconUrlDialog");
vm.IconInfos = null;
System.Threading.Thread t = new System.Threading.Thread(new ThreadStart(GetStartMenuInfos))
{
IsBackground = true
};
t.Start();
} else
{
if (customIcons == null)
StartMenuLoading.Visibility = Visibility.Collapsed;
vm.IconInfos = startMenuIcons;
}
break;
case "Store": //应用商店
if (storeIcons == null)
{
vm.Iconfonts = null;
LoadingOnlineIcon();
vm.IconInfos = null;
storeIcons = new List<IconInfo>();
vm.IconInfos = storeIcons;
}
else
{
vm.IconInfos = storeIcons;
}
break;
default: //默认系统项
if (systemIcons == null)
{
vm.IconInfos = null;
systemIcons = GetSysteIconInfos();
vm.IconInfos = systemIcons;
} else
{
vm.Iconfonts = customIcons;
LoadingEle.Visibility = Visibility.Collapsed;
CustomIcon.Visibility = Visibility.Visible;
}
}
break;
default:
if (CustomButton != null)
{
CustomButton.IsEnabled = false;
}
if (vm != null)
{
vm.Iconfonts = systemIcons;
vm.IconInfos = systemIcons;
}
break;
}
}
private void Confirm_Click(object sender, RoutedEventArgs e)
/// <summary>
/// 获取开始菜单路径下项目
/// </summary>
/// <returns></returns>
private void GetStartMenuInfos()
{
TabItem ti = this.MyTabControl.SelectedItem as TabItem;
int index;
switch (ti.Tag.ToString())
App.Current.Dispatcher.Invoke((Action)(() =>
{
case "Custom":
index = this.CustomIcon.IconListBox.SelectedIndex;
if (index != -1)
StartMenuLoading.Visibility = Visibility.Visible;
}));
List<IconInfo> infos = new List<IconInfo>();
//获取开始菜单路径
string path = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\Programs";
//递归获取信息
GetInfos(path, infos);
App.Current.Dispatcher.Invoke((Action)(() =>
{
menuInfo.MenuGeometry = customIcons[index].Text;
if (StartMenu.IsSelected)
{
startMenuIcons = infos;
vm.IconInfos = startMenuIcons;
}
break;
default:
index = this.CustomIcon.IconListBox.SelectedIndex;
if (index != -1)
{
menuInfo.MenuGeometry = systemIcons[index].Text;
}
break;
}
this.Close();
StartMenuLoading.Visibility = Visibility.Collapsed;
}));
}
private static System.Windows.Window window = null;
public static void Show(List<IconfontInfo> listInfo, MenuInfo menuInfo)
/// <summary>
/// 递归获取文件信息
/// </summary>
/// <param name="path"></param>
/// <param name="listInfos"></param>
private void GetInfos(string path, List<IconInfo> listInfos)
{
if (window == null || !window.Activate())
DirectoryInfo di = new DirectoryInfo(path);
FileSystemInfo[] fileInfoArr = di.GetFileSystemInfos();
foreach(FileSystemInfo fi in fileInfoArr)
{
window = new SystemItemWindow(listInfo, menuInfo);
}
window.Show();
Keyboard.Focus(window);
ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0, false);
}
private void CustomButton_Click(object sender, RoutedEventArgs e)
path = fi.FullName;
if (File.Exists(path))
{
HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig));
}
private void CheckSettingUrl_TextChanged(object sender, TextChangedEventArgs e)
{
if (CheckSettingUrl.Text == "true")
{
LoadingOnlineIcon();
} else
{
LoadingEle.IsRunning = true;
CustomIcon.Visibility = Visibility.Collapsed;
}
}
private void LoadingOnlineIcon()
string ext = Path.GetExtension(path).ToLower();
if (".exe".Equals(ext) || ".lnk".Equals(ext))
{
try
{
string svgJsStr = HttpUtil.Get(appConfig.CustomIconUrl);
string jsonStr = HttpUtil.Get(appConfig.CustomIconJsonUrl);
List<IconfontInfo> icons = SvgToGeometry.GetIconfonts(svgJsStr, jsonStr);
customIcons = icons;
vm.Iconfonts = customIcons;
LoadingEle.Visibility = Visibility.Collapsed;
CustomIcon.Visibility = Visibility.Visible;
}
catch (Exception e)
IconInfo iconInfo = CommonCode.GetIconInfoByPath_NoWrite(path);
if (iconInfo.Path_NoWrite != null)
{
HandyControl.Controls.Growl.WarningGlobal("加载远程图标异常!");
LogUtil.WriteErrorLog(e, "加载远程图标异常!");
iconInfo.Content_NoWrite = iconInfo.Path_NoWrite + "\n" + iconInfo.Name_NoWrite;
listInfos.Add(iconInfo);
}
}
catch (Exception) { }
}
}
else if (Directory.Exists(path))
{
GetInfos(path, listInfos);
}
}
}
public void OnKeyDown(object sender, KeyEventArgs e)
/// <summary>
/// 获取系统项目
/// </summary>
/// <returns></returns>
private List<IconInfo> GetSysteIconInfos()
{
if (e.Key == Key.Escape)
List<IconInfo> iconInfos = new List<IconInfo>();
Hashtable systemIcons = Constants.SYSTEM_ICONS;
IconInfo iconInfo;
foreach (object key in systemIcons.Keys)
{
this.Close();
string keyStr = key.ToString();
iconInfo = new IconInfo
{
Name_NoWrite = systemIcons[key].ToString()
};
iconInfo.BitmapImage_NoWrite = new BitmapImage(
new Uri("pack://application:,,,/GeekDesk;component/Resource/Image/SystemIcon/" + keyStr + ".png"
, UriKind.RelativeOrAbsolute));
iconInfo.StartArg = keyStr;
iconInfo.Content_NoWrite = iconInfo.Name_NoWrite;
iconInfos.Add(iconInfo);
}
return iconInfos;
}
public class IconfontViewModel : INotifyPropertyChanged
public class SystemItemViewModel : INotifyPropertyChanged
{
private List<IconfontInfo> iconfonts;
private string isSettingUrl;
private List<IconInfo> iconInfos;
private AppConfig appConfig;
public List<IconfontInfo> Iconfonts
public SystemItemViewModel()
{
this.AppConfig = MainWindow.appData.AppConfig;
}
public AppConfig AppConfig
{
get
{
return iconfonts;
return appConfig;
}
set
{
iconfonts = value;
OnPropertyChanged("Iconfonts");
appConfig = value;
OnPropertyChanged("AppConfig");
}
}
public string IsSettingUrl
public List<IconInfo> IconInfos
{
get
{
return isSettingUrl;
return iconInfos;
}
set
{
isSettingUrl = value;
OnPropertyChanged("IsSettingUrl");
iconInfos = value;
OnPropertyChanged("IconInfos");
}
}
@@ -223,5 +250,32 @@ namespace GeekDesk.Control.Windows
}
}
private static System.Windows.Window window = null;
public static void Show()
{
if (window == null || !window.Activate())
{
window = new SystemItemWindow();
}
window.Show();
Keyboard.Focus(window);
ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0, false);
}
public void OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
this.Close();
}
}
}
}

View File

@@ -0,0 +1,45 @@
using GeekDesk.Constant;
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 MenuInfoConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
int menuIndex = MainWindow.appData.AppConfig.SelectedMenuIndex;
if (menuIndex == -1)
{
return "";
} else
{
string type = parameter.ToString();
if ("1".Equals(type))
{
return MainWindow.appData.MenuList[menuIndex].MenuGeometry;
}
else
{
return MainWindow.appData.MenuList[menuIndex].MenuName;
}
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
//bool isChecked = (bool)value;
//if (!isChecked)
//{
// return null;
//}
//return (AppHideType)int.Parse(parameter.ToString());
}
}
}

View File

@@ -143,6 +143,9 @@
<Compile Include="Control\UserControls\Config\OtherControl.xaml.cs">
<DependentUpon>OtherControl.xaml</DependentUpon>
</Compile>
<Compile Include="Control\UserControls\SystemItem\SystemItem.xaml.cs">
<DependentUpon>SystemItem.xaml</DependentUpon>
</Compile>
<Compile Include="Control\UserControls\ToDo\TodoControl.xaml.cs">
<DependentUpon>TodoControl.xaml</DependentUpon>
</Compile>
@@ -186,6 +189,7 @@
<DependentUpon>UpdateWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Converts\DoubleToGridLength.cs" />
<Compile Include="Converts\MenuInfoConvert.cs" />
<Compile Include="Converts\TodoTaskExecConvert.cs" />
<Compile Include="Converts\IntToCornerRadius.cs" />
<Compile Include="Converts\OpcityConvert.cs" />
@@ -241,6 +245,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\UserControls\SystemItem\SystemItem.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Control\UserControls\ToDo\TodoControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -387,5 +395,25 @@
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<Resource Include="Resource\Image\SystemIcon\Calculator.png" />
<Resource Include="Resource\Image\SystemIcon\Computer.png" />
<Resource Include="Resource\Image\SystemIcon\GroupPolicy.png" />
<Resource Include="Resource\Image\SystemIcon\Network.png" />
<Resource Include="Resource\Image\SystemIcon\RecycleBin.png" />
<Resource Include="Resource\Image\SystemIcon\Registry.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resource\Image\SystemIcon\Notepad.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resource\Image\SystemIcon\Mstsc.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resource\Image\SystemIcon\Control.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resource\Image\SystemIcon\CMD.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -11,7 +11,8 @@
x:Name="window"
xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:AppData}"
Title="GeekDesk"
d:DesignHeight="500" d:DesignWidth="700"
MinWidth="600"
MinHeight="400"
WindowStyle="None"
AllowsTransparency="True"
Background="Transparent"
@@ -129,7 +130,7 @@
<hc:NotifyIcon.ContextMenu>
<ContextMenu Width="130">
<MenuItem Header="打开面板" Click="ShowApp"/>
<MenuItem Header="关闭图标" Click="CloseBarIcon"/>
<MenuItem Header="隐藏图标" Click="CloseBarIcon"/>
<MenuItem Header="待办" Click="BacklogMenuClick"/>
<MenuItem Header="程序目录" Click="OpenThisDir"/>
<MenuItem Header="设置" Click="ConfigApp"/>

View File

@@ -62,6 +62,7 @@ namespace GeekDesk
/// </summary>
private void LoadData()
{
GC.KeepAlive(MainWindow.appData); // 持活
this.DataContext = appData;
if (appData.MenuList.Count == 0)
{
@@ -130,7 +131,7 @@ namespace GeekDesk
{
if (MotionControl.hotkeyFinished)
{
if (mainWindow.Visibility == Visibility.Collapsed || mainWindow.Opacity == 0)
if (mainWindow.Visibility == Visibility.Collapsed || mainWindow.Opacity == 0 || MarginHide.isHide)
{
ShowApp();
}
@@ -187,7 +188,7 @@ namespace GeekDesk
mainWindow.Opacity = 0;
}
};
Timeline.SetDesiredFrameRate(opacityAnimation, 30);
Timeline.SetDesiredFrameRate(opacityAnimation, 60);
mainWindow.BeginAnimation(OpacityProperty, opacityAnimation);
} else
{
@@ -335,6 +336,8 @@ namespace GeekDesk
//{
// return;
//}
//修改贴边隐藏状态为未隐藏
MarginHide.isHide = false;
if (appData.AppConfig.FollowMouse)
{
ShowWindowFollowMouse.Show(mainWindow, MousePosition.CENTER, 0, 0, false);

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@@ -1,4 +1,5 @@
using GeekDesk.Control.UserControls.Config;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using Gma.System.MouseKeyHook;
using System;
@@ -51,7 +52,9 @@ namespace GeekDesk.Thread
{
MainWindow.mainWindow.Dispatcher.Invoke((Action)(() =>
{
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed || MainWindow.mainWindow.Opacity == 0)
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed
|| MainWindow.mainWindow.Opacity == 0
|| MarginHide.isHide)
{
MainWindow.ShowApp();
}

View File

@@ -2,7 +2,7 @@
"title": "GeekDesk版本更新",
"subTitle": "V2.4.10",
"msgTitle": "本次更新内容如下",
"msg": "['']",
"msg": "['各位兄弟去给我点个免费Star呗','增加添加系统和开始菜单应用功能','增加项目启动参数','优化贴边隐藏动画效果','增加双击打开功能','其它已知问题修复']",
"githubUrl": "https://github.com/Demo-Liu/GeekDesk/releases",
"giteeUrl": "https://gitee.com/demo_liu/GeekDesk/releases",
"version": "2.4.10"

View File

@@ -5,6 +5,7 @@ using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Windows;
using System.Windows.Media.Imaging;
/// <summary>
/// 提取一些代码
@@ -45,7 +46,6 @@ namespace GeekDesk.Util
/// <param name="appData"></param>
public static void SaveAppData(AppData appData)
{
using (FileStream fs = new FileStream(Constants.DATA_FILE_PATH, FileMode.Create))
{
BinaryFormatter bf = new BinaryFormatter();
@@ -74,6 +74,100 @@ namespace GeekDesk.Util
return false;
}
/// <summary>
/// 根据路径获取文件图标等信息
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public static IconInfo GetIconInfoByPath(string path)
{
string tempPath = path;
//string base64 = ImageUtil.FileImageToBase64(path, System.Drawing.Imaging.ImageFormat.Png);
//string ext = "";
//if (!ImageUtil.IsSystemItem(path))
//{
// ext = System.IO.Path.GetExtension(path).ToLower();
//}
string iconPath = null;
//if (".lnk".Equals(ext))
//{
string targetPath = FileUtil.GetTargetPathByLnk(path);
iconPath = FileUtil.GetIconPathByLnk(path);
if (targetPath != null)
{
path = targetPath;
}
//}
if (StringUtil.IsEmpty(iconPath))
{
iconPath = path;
}
BitmapImage bi = ImageUtil.GetBitmapIconByPath(iconPath);
IconInfo iconInfo = new IconInfo
{
Path = path,
LnkPath = tempPath,
BitmapImage = bi,
StartArg = FileUtil.GetArgByLnk(tempPath)
};
iconInfo.DefaultImage = iconInfo.ImageByteArr;
iconInfo.Name = System.IO.Path.GetFileNameWithoutExtension(tempPath);
if (StringUtil.IsEmpty(iconInfo.Name))
{
iconInfo.Name = path;
}
return iconInfo;
}
public static IconInfo GetIconInfoByPath_NoWrite(string path)
{
string tempPath = path;
//string base64 = ImageUtil.FileImageToBase64(path, System.Drawing.Imaging.ImageFormat.Png);
string ext = "";
if (!ImageUtil.IsSystemItem(path))
{
ext = System.IO.Path.GetExtension(path).ToLower();
}
string iconPath = null;
if (".lnk".Equals(ext))
{
string targetPath = FileUtil.GetTargetPathByLnk(path);
iconPath = FileUtil.GetIconPathByLnk(path);
if (targetPath != null)
{
path = targetPath;
}
}
if (StringUtil.IsEmpty(iconPath))
{
iconPath = path;
}
BitmapImage bi = ImageUtil.GetBitmapIconByPath(iconPath);
IconInfo iconInfo = new IconInfo
{
Path_NoWrite = path,
LnkPath_NoWrite = tempPath,
BitmapImage_NoWrite = bi,
StartArg_NoWrite = FileUtil.GetArgByLnk(tempPath)
};
iconInfo.DefaultImage_NoWrite = iconInfo.ImageByteArr;
iconInfo.Name = System.IO.Path.GetFileNameWithoutExtension(tempPath);
if (StringUtil.IsEmpty(iconInfo.Name))
{
iconInfo.Name_NoWrite = path;
}
return iconInfo;
}
[StructLayout(LayoutKind.Sequential)]
private struct RECT

View File

@@ -72,23 +72,12 @@ namespace GeekDesk.Util
ico = Icon.FromHandle(ip);
}
IntPtr hIcon2 = IntPtr.Zero;
//TODO
for (int i=0; i<=1000; i++)
{
try
{
ico = SystemIcon.MyExtractIcon("%SystemRoot%\\system32\\shell32.dll", i, hIcon2);
Bitmap bmp2 = ico.ToBitmap();
bmp2.Save("d:\\test\\" + i + ".png");
} catch
{
return IconToBitmapImage(ico, ip);
}
}
ico = SystemIcon.MyExtractIcon("%SystemRoot%\\system32\\shell32.dll", 16, hIcon2);
Bitmap bmp = ico.ToBitmap();
private static BitmapImage IconToBitmapImage(Icon icon, IntPtr iconIP)
{
Bitmap bmp = icon.ToBitmap();
MemoryStream strm = new MemoryStream();
ImageCodecInfo myImageCodecInfo = GetEncoderInfo("image/png");
@@ -96,16 +85,18 @@ namespace GeekDesk.Util
EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 75L);
EncoderParameters myEncoderParameters = new EncoderParameters(1);
myEncoderParameters.Param[0] = myEncoderParameter;
bmp.Save("d:\\test.png");
//bmp.Save("d:\\test.png");
bmp.Save(strm, myImageCodecInfo, myEncoderParameters);
BitmapImage bmpImage = new BitmapImage();
bmpImage.BeginInit();
strm.Seek(0, SeekOrigin.Begin);
bmpImage.StreamSource = strm;
bmpImage.EndInit();
if (ip != IntPtr.Zero)
if (iconIP != IntPtr.Zero)
{
Shell32.DestroyIcon(ip);
Shell32.DestroyIcon(iconIP);
}
return bmpImage.Clone();
}

View File

@@ -12,7 +12,9 @@ namespace GeekDesk.Util
public class FileUtil
{
private static readonly string NO_PATH = ".*{.*}.*";
private static readonly string NO_PATH = "{(.*)}";
private static readonly string NO_ICO = "^,(.*)";
private static readonly string HAVE_ICO = "(.*),(.*)";
public static string GetTargetPathByLnk(string filePath)
{
@@ -20,7 +22,6 @@ namespace GeekDesk.Util
{
WshShell shell = new WshShell();
IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath);
if (StringUtil.IsEmpty(shortcut.TargetPath))
{
return null;
@@ -32,11 +33,60 @@ namespace GeekDesk.Util
}
return path;
}
#pragma warning disable CS0168 // 声明了变量“e”但从未使用过
catch (Exception e)
#pragma warning restore CS0168 // 声明了变量“e”但从未使用过
{
LogUtil.WriteErrorLog(e, "获取文件图标失败! filePath=" + filePath);
LogUtil.WriteErrorLog(e, "获取目标路径失败! filePath=" + filePath);
return null;
}
}
/// <summary>
/// 获取启动参数
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public static string GetArgByLnk(string filePath)
{
try
{
WshShell shell = new WshShell();
IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath);
return shortcut.Arguments;
}
catch (Exception e)
{
LogUtil.WriteErrorLog(e, "获取启动参数失败! filePath=" + filePath);
return "";
}
}
/// <summary>
/// 获取iconpath
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public static string GetIconPathByLnk(string filePath)
{
try
{
WshShell shell = new WshShell();
IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath);
var iconPath = shortcut.IconLocation;
if (StringUtil.IsEmpty(iconPath)
|| Regex.IsMatch(iconPath, NO_ICO)
|| Regex.IsMatch(iconPath, NO_PATH)
|| !Regex.IsMatch(iconPath, HAVE_ICO))
{
return null;
} else
{
return iconPath.Split(',')[0];
}
}
catch (Exception e)
{
LogUtil.WriteErrorLog(e, "获取图标路径失败! filePath=" + filePath);
return null;
}
}

View File

@@ -86,6 +86,11 @@ namespace GeekDesk.Util
/// <returns></returns>
public static BitmapImage GetBitmapIconByPath(string filePath)
{
if (filePath.Contains("%windir%"))
{
filePath = filePath.Replace("%windir%", System.Environment.GetEnvironmentVariable("windir"));
}
if (File.Exists(filePath) || IsSystemItem(filePath))
{
if (IsImage(filePath)) {

View File

@@ -27,7 +27,7 @@ namespace GeekDesk.Util
double left = SystemParameters.VirtualScreenLeft;
double top = SystemParameters.VirtualScreenTop;
double width = SystemParameters.VirtualScreenWidth;
double height = SystemParameters.WorkArea.Height + 20;
double height = SystemParameters.WorkArea.Height + 20; // 不遮挡任务栏
double right = width - Math.Abs(left);
double bottom = height - Math.Abs(top);

View File

@@ -25,10 +25,60 @@ namespace GeekDesk.ViewModel
private string content; //显示信息
private bool adminStartUp = false; //始终管理员方式启动 默认否
private byte[] defaultImage; //默认图标
private string startArg; //启动参数
private string lnkPath;
private IconType iconType = IconType.OTHER;
public string LnkPath_NoWrite
{
get
{
return lnkPath;
}
set
{
lnkPath = value;
}
}
public string LnkPath
{
get
{
return lnkPath;
}
set
{
lnkPath = value;
OnPropertyChanged("LnkPath");
}
}
public string StartArg
{
get
{
return startArg;
}
set
{
startArg = value;
OnPropertyChanged("StartArg");
}
}
public string StartArg_NoWrite
{
get
{
return startArg;
}
set
{
startArg = value;
}
}
public IconType IconType
{
get
@@ -56,6 +106,18 @@ namespace GeekDesk.ViewModel
}
}
public byte[] DefaultImage_NoWrite
{
get
{
return defaultImage;
}
set
{
defaultImage = value;
}
}
public bool AdminStartUp
{
get
@@ -78,7 +140,13 @@ namespace GeekDesk.ViewModel
set
{
count = value;
if (StringUtil.IsEmpty(Path))
{
Content = Name + "\n使用次数: " + Count;
} else
{
Content = Path + "\n" + Name + "\n使用次数: " + Count;
}
OnPropertyChanged("Count");
}
}
@@ -92,11 +160,30 @@ namespace GeekDesk.ViewModel
set
{
name = value;
if (StringUtil.IsEmpty(Path))
{
Content = Name + "\n使用次数: " + Count;
}
else
{
Content = Path + "\n" + Name + "\n使用次数: " + Count;
}
OnPropertyChanged("Name");
}
}
public string Name_NoWrite
{
get
{
return name;
}
set
{
name = value;
}
}
public string Path
{
get
@@ -106,11 +193,31 @@ namespace GeekDesk.ViewModel
set
{
path = value;
if (StringUtil.IsEmpty(Path))
{
Content = Name + "\n使用次数: " + Count;
}
else
{
Content = Path + "\n" + Name + "\n使用次数: " + Count;
}
OnPropertyChanged("Path");
}
}
public string Path_NoWrite
{
get
{
return path;
}
set
{
path = value;
}
}
public BitmapImage BitmapImage
{
get
@@ -126,6 +233,20 @@ namespace GeekDesk.ViewModel
}
}
public BitmapImage BitmapImage_NoWrite
{
get
{
return ImageUtil.ByteArrToImage(ImageByteArr_NoWrite);
}
set
{
bitmapImage = value;
ImageByteArr_NoWrite = ImageUtil.BitmapImageToByte(bitmapImage);
}
}
public byte[] ImageByteArr
{
get
@@ -140,6 +261,19 @@ namespace GeekDesk.ViewModel
}
}
public byte[] ImageByteArr_NoWrite
{
get
{
return imageByteArr;
}
set
{
imageByteArr = value;
}
}
public string Content
{
get
@@ -153,9 +287,17 @@ namespace GeekDesk.ViewModel
}
}
public override String ToString()
public string Content_NoWrite
{
return JsonConvert.SerializeObject(this);
get
{
return content;
}
set
{
content = value;
}
}