Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28ebb48983 | ||
|
|
74e36cc68a | ||
|
|
9f60f1be63 | ||
|
|
e9dbc3e5b9 | ||
|
|
e9a3726bb4 | ||
|
|
58c67a0497 | ||
|
|
5ff3f04da6 | ||
|
|
14aa73f504 | ||
|
|
5c10b5f59e | ||
|
|
d092db8b5c | ||
|
|
1125432c41 | ||
|
|
e99eee08ff | ||
|
|
fb26834938 | ||
|
|
e9063a176e | ||
|
|
6038eee680 | ||
|
|
19c8ff9d8d | ||
|
|
e3a85e42fa | ||
|
|
09d3a520b4 | ||
|
|
7f585dd095 | ||
|
|
353acec75e | ||
|
|
8d4201f5ba | ||
|
|
0453cdad66 | ||
|
|
88af8324b9 | ||
|
|
8ee27e247b | ||
|
|
cf8f983f1a | ||
|
|
37e8631f73 | ||
|
|
0f6119c0ba | ||
|
|
caf75e2427 | ||
|
|
c13593bdf4 | ||
|
|
e6a95c4668 |
21
App.config
@@ -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>
|
||||
@@ -28,13 +45,15 @@
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<appSettings>
|
||||
<add key="Version" value="2.3.20" />
|
||||
<add key="Version" value="2.4.10" />
|
||||
<add key="GitHubUrl" value="https://github.com/Demo-Liu/GeekDesk" />
|
||||
<add key="GiteeUrl" value="https://gitee.com/demo_liu/GeekDesk/tree/master" />
|
||||
<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>
|
||||
|
||||
65
App.xaml.cs
@@ -1,7 +1,9 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Util;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Threading;
|
||||
@@ -19,6 +21,8 @@ namespace GeekDesk
|
||||
public App()
|
||||
{
|
||||
this.Startup += new StartupEventHandler(App_Startup);
|
||||
Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
|
||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||
}
|
||||
|
||||
private void App_Startup(object sender, StartupEventArgs e)
|
||||
@@ -35,47 +39,24 @@ namespace GeekDesk
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
|
||||
{
|
||||
e.Handled = true;//使用这一行代码告诉运行时,该异常被处理了,不再作为UnhandledException抛出了。
|
||||
LogUtil.WriteErrorLog(e, "未捕获异常!");
|
||||
if (Constants.DEV)
|
||||
{
|
||||
MessageBox.Show("GeekDesk遇到一个问题, 不用担心, 这不影响其它操作!");
|
||||
}
|
||||
}
|
||||
|
||||
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
LogUtil.WriteErrorLog(e, "严重异常!");
|
||||
MessageBox.Show("GeekDesk遇到未知问题崩溃!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// private void WriteLog(object exception)
|
||||
// {
|
||||
// Exception ex = exception as Exception;
|
||||
|
||||
// using (FileStream fs = File.Open(".//ErrorLog.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite))
|
||||
// {
|
||||
// fs.Seek(0, SeekOrigin.End);
|
||||
// byte[] buffer = Encoding.Default.GetBytes("-------------------------------------------------------\r\n");
|
||||
// fs.Write(buffer, 0, buffer.Length);
|
||||
|
||||
// buffer = Encoding.Default.GetBytes(DateTime.Now.ToString() + "\r\n");
|
||||
// fs.Write(buffer, 0, buffer.Length);
|
||||
|
||||
// if (ex != null)
|
||||
// {
|
||||
// buffer = Encoding.Default.GetBytes("成员名: " + ex.TargetSite + "\r\n");
|
||||
// fs.Write(buffer, 0, buffer.Length);
|
||||
|
||||
// buffer = Encoding.Default.GetBytes("引发异常的类: " + ex.TargetSite.DeclaringType + "\r\n");
|
||||
// fs.Write(buffer, 0, buffer.Length);
|
||||
|
||||
// buffer = Encoding.Default.GetBytes("异常信息: " + ex.Message + "\r\n");
|
||||
// fs.Write(buffer, 0, buffer.Length);
|
||||
|
||||
// buffer = Encoding.Default.GetBytes("引发异常的程序集或对象: " + ex.Source + "\r\n");
|
||||
// fs.Write(buffer, 0, buffer.Length);
|
||||
|
||||
// buffer = Encoding.Default.GetBytes("栈:" + ex.StackTrace + "\r\n");
|
||||
// fs.Write(buffer, 0, buffer.Length);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// buffer = Encoding.Default.GetBytes("应用程序错误: " + exception.ToString() + "\r\n");
|
||||
// fs.Write(buffer, 0, buffer.Length);
|
||||
// }
|
||||
// }
|
||||
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
@@ -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, //默认图标高度
|
||||
|
||||
@@ -40,13 +40,15 @@ namespace GeekDesk.Control.Other
|
||||
if (info.ExecType == TodoTaskExecType.CRON)
|
||||
{
|
||||
CronExpression exp = new CronExpression(info.Cron);
|
||||
DateTime dtNow = DateTime.Now;
|
||||
DateTimeOffset ddo = DateTime.SpecifyKind(dtNow, DateTimeKind.Local);
|
||||
string nextExecTime = ddo.LocalDateTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
info.ExeTime = nextExecTime;
|
||||
DateTime nowTime = DateTime.Now;
|
||||
|
||||
DateTime nextTime = ddo.LocalDateTime;
|
||||
TimeSpan ts = nextTime.Subtract(dtNow);
|
||||
//计算下次执行时间
|
||||
DateTime nextTime = DateTime.SpecifyKind(exp.GetNextValidTimeAfter(nowTime).Value.LocalDateTime, DateTimeKind.Local);
|
||||
|
||||
string nextTimeStr = nextTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
info.ExeTime = nextTimeStr;
|
||||
|
||||
TimeSpan ts = nextTime.Subtract(nowTime);
|
||||
int minutes = (int)Math.Ceiling(ts.TotalMinutes);
|
||||
if (minutes < 0)
|
||||
{
|
||||
|
||||
@@ -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}"/>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -74,9 +75,10 @@ namespace GeekDesk.Control.Other
|
||||
info.BitmapImage = ImageUtil.GetBitmapIconByPath(ofd.FileName);
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
}
|
||||
} catch (Exception)
|
||||
} catch (Exception e1)
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("修改图标失败,已重置为默认图标!");
|
||||
LogUtil.WriteErrorLog(e1, "修改图标失败!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -89,9 +89,10 @@ namespace GeekDesk.Control.Other
|
||||
info.BitmapImage = ImageUtil.GetBitmapIconByPath(ofd.FileName);
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
}
|
||||
} catch (Exception)
|
||||
} catch (Exception e1)
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("修改图标失败,已重置为默认图标!");
|
||||
LogUtil.WriteErrorLog(e1, "修改图标失败!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,14 +22,14 @@
|
||||
<hc:Shield Subject=".net" Status=">=4.72" Margin="0,0,10,0" Color="#1182c3"/>
|
||||
<hc:Shield Subject="IDE" Status="VS2019" Margin="0,0,10,0" Color="#1182c3"/>
|
||||
|
||||
<hc:Shield Subject="GitHub" Visibility="Visible" Status="Demo-liu"
|
||||
<hc:Shield Subject="GitHub" Visibility="Visible" Status="Star"
|
||||
Command="hc:ControlCommands.OpenLink"
|
||||
CommandParameter="https://github.com/Demo-Liu/GeekDesk"
|
||||
Margin="0,0,10,0" Color="#24292F"/>
|
||||
<hc:Shield Subject="Gitee" Visibility="Visible" Status="Demo-liu"
|
||||
<hc:Shield Subject="Gitee" Visibility="Visible" Status="Star"
|
||||
Command="hc:ControlCommands.OpenLink"
|
||||
CommandParameter="https://gitee.com/demo_liu/GeekDesk"
|
||||
Margin="0,5,10,0" Color="#C71D23"/>
|
||||
Margin="0,0,10,0" Color="#C71D23"/>
|
||||
|
||||
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
@@ -41,7 +41,17 @@
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox Content="鼠标中间呼出" Checked="MouseMiddle_Changed" IsChecked="{Binding MouseMiddleShow}">
|
||||
<CheckBox Content="鼠标中间呼出" Click="MouseMiddle_Changed" IsChecked="{Binding MouseMiddleShow}">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
</LinearGradientBrush>
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox Content="双击启动" IsChecked="{Binding DoubleOpen}">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
@@ -51,7 +61,7 @@
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox Content="贴边隐藏" IsChecked="{Binding MarginHide}" Checked="MarginHide_Changed" Unchecked="MarginHide_Changed">
|
||||
<CheckBox Content="贴边隐藏" IsChecked="{Binding MarginHide}" Click="MarginHide_Changed">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
@@ -61,7 +71,7 @@
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox Content="主窗口动画效果" IsChecked="{Binding AppAnimation}" Checked="Animation_Checked">
|
||||
<CheckBox Content="主窗口动画效果" IsChecked="{Binding AppAnimation}" Click="Animation_Checked">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Control.Windows;
|
||||
using GeekDesk.Thread;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using HandyControl.Data;
|
||||
@@ -252,13 +253,10 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
{
|
||||
if (appConfig.MarginHide)
|
||||
{
|
||||
MainWindow.hide.TimerSet();
|
||||
MarginHide.StartHide();
|
||||
} else
|
||||
{
|
||||
if (MainWindow.hide.timer != null)
|
||||
{
|
||||
MainWindow.hide.TimerStop();
|
||||
}
|
||||
MarginHide.StopHide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,12 +278,14 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
/// <param name="e"></param>
|
||||
private void MouseMiddle_Changed(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
if (appConfig.MouseMiddleShow)
|
||||
{
|
||||
MouseHookThread.MiddleHook();
|
||||
} else
|
||||
{
|
||||
MouseHookThread.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void HookListener_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
|
||||
{
|
||||
Console.WriteLine(e.KeyChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,9 +53,10 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
appConfig.BacImgName = ofd.FileName;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception e1)
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("修改背景失败,已重置为默认背景!");
|
||||
LogUtil.WriteErrorLog(e1, "修改背景失败!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -69,9 +70,10 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
appConfig.BitmapImage = ImageUtil.Base64ToBitmapImage(Constants.DEFAULT_BAC_IMAGE_BASE64);
|
||||
appConfig.BacImgName = "系统默认";
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception e1)
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("修改背景失败,已重置为默认背景!");
|
||||
LogUtil.WriteErrorLog(e1, "修改默认背景失败!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<SolidColorBrush Opacity="0"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<EventSetter Event="MouseLeftButtonDown" Handler="MenuClick"/>
|
||||
<EventSetter Event="MouseRightButtonDown" Handler="MenuClick"/>
|
||||
<Style.Triggers>
|
||||
@@ -43,13 +44,24 @@
|
||||
</BeginStoryboard>
|
||||
</MultiTrigger.ExitActions>
|
||||
</MultiTrigger>
|
||||
<!--<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#FFE4DBDB"/>
|
||||
</Trigger>-->
|
||||
<Trigger Property="IsSelected" Value="true">
|
||||
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#FFECECEC"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="#FFECECEC"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
</Trigger>
|
||||
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsEdit}" Value="True"/>
|
||||
</MultiDataTrigger.Conditions>
|
||||
<MultiDataTrigger.Setters>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
</MultiDataTrigger.Setters>
|
||||
</MultiDataTrigger>
|
||||
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<cvt:MenuWidthConvert x:Key="MenuWidthConvert"/>
|
||||
@@ -57,7 +69,7 @@
|
||||
</UserControl.Resources>
|
||||
<!--左侧栏-->
|
||||
<hc:Card x:Name="MyCard"
|
||||
BorderThickness="1"
|
||||
BorderThickness="1"
|
||||
Effect="{DynamicResource EffectShadow2}"
|
||||
Margin="5,0,0,5"
|
||||
>
|
||||
@@ -76,6 +88,7 @@
|
||||
</hc:Card.ContextMenu>
|
||||
<WrapPanel Orientation="Horizontal">
|
||||
<ListBox x:Name="MenuListBox"
|
||||
Padding="2,3,0,2"
|
||||
ItemsSource="{Binding MenuList}"
|
||||
Tag="{Binding AppConfig.MenuCardWidth}"
|
||||
BorderThickness="0" Foreground="{x:Null}"
|
||||
@@ -89,7 +102,7 @@
|
||||
<MenuItem Header="重命名" Click="RenameMenu" Tag="{Binding}"/>
|
||||
<MenuItem Header="修改图标" Click="EditMenuGeometry" Tag="{Binding}"/>
|
||||
<MenuItem Header="删除" Click="DeleteMenu" Tag="{Binding}"/>
|
||||
</ContextMenu>
|
||||
</ContextMenu>
|
||||
</ListBox.Resources>
|
||||
|
||||
<ListBox.ItemContainerStyle>
|
||||
@@ -103,27 +116,28 @@
|
||||
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<DraggAnimatedPanel:DraggAnimatedPanel ItemsHeight="33" ItemsWidth="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}, ConverterParameter=10}" HorizontalAlignment="Center" VerticalAlignment="Top" SwapCommand="{Binding SwapCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
|
||||
<DraggAnimatedPanel:DraggAnimatedPanel ItemsHeight="33" ItemsWidth="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}, ConverterParameter=10}" HorizontalAlignment="Center" VerticalAlignment="Top" SwapCommand="{Binding SwapCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel MouseLeftButtonDown="MenuClick" MouseRightButtonDown="MenuClick" Tag="{Binding}">
|
||||
<hc:TextBox Text="{Binding Path=MenuName, Mode=TwoWay}"
|
||||
<StackPanel MouseLeftButtonDown="MenuClick" MouseRightButtonDown="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}, ConverterParameter=35}"
|
||||
FontSize="16"
|
||||
Height="25"
|
||||
Height="28"
|
||||
VerticalAlignment="Center"
|
||||
TextAlignment="Left"
|
||||
LostFocus="LostFocusOrEnterDown"
|
||||
KeyDown="LostFocusOrEnterDown"
|
||||
Tag="{Binding}"
|
||||
Margin="2"
|
||||
Padding="2"
|
||||
BorderThickness="0"
|
||||
IsVisibleChanged="MenuEditWhenVisibilityChanged"
|
||||
Visibility="{Binding MenuEdit}"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button Background="Transparent"
|
||||
BorderThickness="0"
|
||||
hc:IconElement.Geometry="{Binding MenuGeometry}"
|
||||
|
||||
@@ -28,11 +28,11 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
if (appData.AppConfig.SelectedMenuIndex >= appData.MenuList.Count || appData.AppConfig.SelectedMenuIndex == -1)
|
||||
{
|
||||
appData.AppConfig.SelectedMenuIcons = appData.MenuList[0].IconList;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DelegateCommand<int[]> _swap;
|
||||
@@ -204,11 +204,13 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
|
||||
private void menus_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
appData.AppConfig.SelectedMenuIcons = null;
|
||||
//设置对应菜单的图标列表
|
||||
if (MenuListBox.SelectedIndex == -1)
|
||||
{
|
||||
appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.MenuList.Count-1].IconList;
|
||||
} else
|
||||
appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.MenuList.Count - 1].IconList;
|
||||
}
|
||||
else
|
||||
{
|
||||
appData.AppConfig.SelectedMenuIcons = appData.MenuList[MenuListBox.SelectedIndex].IconList;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
|
||||
>
|
||||
<UserControl.Resources>
|
||||
<!--右侧栏样式动画-->
|
||||
@@ -19,6 +18,7 @@
|
||||
<Setter Property="Source" Value="{Binding BitmapImage}"/>
|
||||
</Style>
|
||||
<Style x:Key="MyListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ListBoxItem}">
|
||||
@@ -47,11 +47,16 @@
|
||||
<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" VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.IsContainerVirtualizable="True">
|
||||
<WrapPanel Orientation="Horizontal" VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
VirtualizingPanel.IsVirtualizing="True"
|
||||
VirtualizingPanel.IsContainerVirtualizable="True"
|
||||
>
|
||||
<ListBox x:Name="IconListBox" ItemsSource="{Binding AppConfig.SelectedMenuIcons, Mode=TwoWay}"
|
||||
BorderThickness="0"
|
||||
Padding="0,10,0,0"
|
||||
>
|
||||
<ListBox.Background>
|
||||
<SolidColorBrush Opacity="0"/>
|
||||
@@ -71,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}"/>
|
||||
@@ -98,7 +104,7 @@
|
||||
hc:Poptip.Content="{Binding Content}"
|
||||
hc:Poptip.Placement="BottomLeft"
|
||||
Background="#00FFFFFF"
|
||||
MouseLeftButtonUp="IconClick"
|
||||
MouseLeftButtonDown="IconClick"
|
||||
MouseEnter="StackPanel_MouseEnter"
|
||||
MouseLeave="StackPanel_MouseLeave"
|
||||
>
|
||||
|
||||
@@ -1,29 +1,21 @@
|
||||
using DraggAnimatedPanelExample;
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Control.Other;
|
||||
using GeekDesk.Control.Windows;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using HandyControl.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
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.Animation;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
@@ -75,15 +67,30 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
/// <param name="e"></param>
|
||||
private void IconClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
IconInfo icon = (IconInfo)((SimpleStackPanel)sender).Tag;
|
||||
if (icon.AdminStartUp)
|
||||
if (appData.AppConfig.DoubleOpen && e.ClickCount >= 2)
|
||||
{
|
||||
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
||||
}
|
||||
else
|
||||
IconInfo icon = (IconInfo)((SimpleStackPanel)sender).Tag;
|
||||
if (icon.AdminStartUp)
|
||||
{
|
||||
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
|
||||
}
|
||||
} else if (!appData.AppConfig.DoubleOpen && e.ClickCount == 1)
|
||||
{
|
||||
StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
|
||||
IconInfo icon = (IconInfo)((SimpleStackPanel)sender).Tag;
|
||||
if (icon.AdminStartUp)
|
||||
{
|
||||
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -113,74 +120,181 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
try
|
||||
{
|
||||
Process p = new Process();
|
||||
p.StartInfo.FileName = icon.Path;
|
||||
if (icon.IconType == IconType.OTHER)
|
||||
{
|
||||
if (!File.Exists(icon.Path) && !Directory.Exists(icon.Path))
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(文件路径不存在或已删除)!");
|
||||
return;
|
||||
}
|
||||
p.StartInfo.WorkingDirectory = icon.Path.Substring(0, icon.Path.LastIndexOf("\\"));
|
||||
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)
|
||||
{
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (appData.AppConfig.MarginHide)
|
||||
{
|
||||
if (!MainWindow.hide.IsMargin())
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
|
||||
}
|
||||
break;// c#好像不能case穿透
|
||||
case IconStartType.DEFAULT_STARTUP:
|
||||
if (appData.AppConfig.AppHideType == AppHideType.START_EXE)
|
||||
{
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (appData.AppConfig.MarginHide)
|
||||
string startArg = icon.StartArg;
|
||||
|
||||
if (startArg!=null && Constants.SYSTEM_ICONS.ContainsKey(startArg))
|
||||
{
|
||||
StartSystemApp(startArg, type);
|
||||
} else
|
||||
{
|
||||
p.StartInfo.FileName = icon.Path;
|
||||
if (!StringUtil.IsEmpty(startArg))
|
||||
{
|
||||
p.StartInfo.Arguments = startArg;
|
||||
}
|
||||
if (icon.IconType == IconType.OTHER)
|
||||
{
|
||||
if (!File.Exists(icon.Path) && !Directory.Exists(icon.Path))
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(文件路径不存在或已删除)!");
|
||||
return;
|
||||
}
|
||||
p.StartInfo.WorkingDirectory = icon.Path.Substring(0, icon.Path.LastIndexOf("\\"));
|
||||
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)
|
||||
{
|
||||
if (!MainWindow.hide.IsMargin())
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (appData.AppConfig.MarginHide)
|
||||
{
|
||||
if (!MarginHide.IS_HIDE)
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
} else
|
||||
|
||||
}
|
||||
break;// c#好像不能case穿透
|
||||
case IconStartType.DEFAULT_STARTUP:
|
||||
if (appData.AppConfig.AppHideType == AppHideType.START_EXE)
|
||||
{
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (appData.AppConfig.MarginHide)
|
||||
{
|
||||
if (!MarginHide.IS_HIDE)
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IconStartType.SHOW_IN_EXPLORE:
|
||||
p.StartInfo.FileName = "Explorer.exe";
|
||||
p.StartInfo.Arguments = "/e,/select," + icon.Path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (appData.AppConfig.AppHideType == AppHideType.START_EXE)
|
||||
{
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (appData.AppConfig.MarginHide)
|
||||
{
|
||||
if (!MarginHide.IS_HIDE)
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IconStartType.SHOW_IN_EXPLORE:
|
||||
p.StartInfo.FileName = "Explorer.exe";
|
||||
p.StartInfo.Arguments = "/e,/select," + icon.Path;
|
||||
break;
|
||||
else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
}
|
||||
p.Start();
|
||||
}
|
||||
p.Start();
|
||||
|
||||
icon.Count++;
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception e)
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("程序启动失败(不支持的启动方式)!");
|
||||
LogUtil.WriteErrorLog(e, "程序启动失败:path=" + icon.Path + ",type=" + type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (appData.AppConfig.MarginHide)
|
||||
{
|
||||
if (!MarginHide.IS_HIDE)
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
|
||||
/// <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);
|
||||
@@ -188,32 +302,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
foreach (object obj in dropObject)
|
||||
{
|
||||
string path = (string)obj;
|
||||
|
||||
//string base64 = ImageUtil.FileImageToBase64(path, ImageFormat.Png);
|
||||
|
||||
string 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(path);
|
||||
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);
|
||||
}
|
||||
@@ -402,10 +491,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
57
Control/UserControls/SystemItem/SystemItem.xaml
Normal 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>
|
||||
59
Control/UserControls/SystemItem/SystemItem.xaml.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,11 +27,10 @@
|
||||
<DataGrid.RowStyle>
|
||||
<Style TargetType="DataGridRow" BasedOn="{StaticResource DataGridRowStyle}">
|
||||
<EventSetter Event="MouseRightButtonDown" Handler="DataGridRow_MouseRightButtonDown" />
|
||||
<EventSetter Event="Selected" Handler="DataGridRow_Selected"/>
|
||||
<Setter Property="Background" Value="White"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="#5BC0DE"/>
|
||||
<Setter Property="Background" Value="{StaticResource BtnBG}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="False">
|
||||
<Setter Property="Background" Value="White"/>
|
||||
|
||||
@@ -84,20 +84,5 @@ namespace GeekDesk.Control.UserControls.Backlog
|
||||
Menu.IsOpen = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 选中时颜色变化
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void DataGridRow_Selected(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Color c = Color.FromRgb(91, 192, 222);
|
||||
SolidColorBrush b = new SolidColorBrush
|
||||
{
|
||||
Color = c,
|
||||
Opacity = 0.9
|
||||
};
|
||||
((DataGridRow)sender).Background = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
AllowsTransparency="True"
|
||||
Background="#00FFFFFF" ShowInTaskbar="False"
|
||||
BorderThickness="0"
|
||||
Focusable="True"
|
||||
KeyDown="OnKeyDown"
|
||||
>
|
||||
|
||||
<Grid Margin="30">
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Control.UserControls;
|
||||
using GeekDesk.Control.UserControls.Config;
|
||||
using GeekDesk.Interface;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using HandyControl.Controls;
|
||||
@@ -15,7 +16,7 @@ namespace GeekDesk.Control.Windows
|
||||
/// <summary>
|
||||
/// ConfigDialog.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ConfigWindow
|
||||
public partial class ConfigWindow : IWindowCommon
|
||||
{
|
||||
private static readonly AboutControl about = new AboutControl();
|
||||
private static readonly ThemeControl theme = new ThemeControl();
|
||||
@@ -87,6 +88,15 @@ namespace GeekDesk.Control.Windows
|
||||
window = new ConfigWindow(appConfig, mainWindow);
|
||||
}
|
||||
window.Show();
|
||||
Keyboard.Focus(window);
|
||||
}
|
||||
|
||||
public void OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent" ShowInTaskbar="False"
|
||||
BorderThickness="0"
|
||||
Focusable="True"
|
||||
KeyDown="OnKeyDown"
|
||||
>
|
||||
|
||||
<Window.Resources>
|
||||
@@ -39,7 +41,7 @@
|
||||
<DropShadowEffect BlurRadius="30" Direction="-90" Color="Gray"
|
||||
RenderingBias="Quality" ShadowDepth="2"/>
|
||||
</Grid.Effect>
|
||||
<Border MouseDown="DragMove" Style="{StaticResource BorderBG}">
|
||||
<Border MouseDown="DragMove" Style="{StaticResource BorderBG}" hc:Dialog.Token="IconUrlDialog">
|
||||
<!--<Border.Background>
|
||||
--><!--<SolidColorBrush Color="AliceBlue" Opacity="0.9"/>--><!--
|
||||
<LinearGradientBrush Opacity="0.97">
|
||||
@@ -47,9 +49,10 @@
|
||||
<GradientStop Color="#97D282" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</Border.Background>-->
|
||||
<Grid MouseDown="DragMove">
|
||||
<TextBox x:Name="CheckSettingUrl" Visibility="Collapsed" Text="{Binding IsSettingUrl}" TextChanged="CheckSettingUrl_TextChanged"/>
|
||||
<hc:TabControl x:Name="MyTabControl"
|
||||
<hc:DialogContainer>
|
||||
<Grid MouseDown="DragMove">
|
||||
<TextBox x:Name="CheckSettingUrl" Visibility="Collapsed" Text="{Binding IsSettingUrl}" TextChanged="CheckSettingUrl_TextChanged"/>
|
||||
<hc:TabControl x:Name="MyTabControl"
|
||||
IsAnimationEnabled="True"
|
||||
SelectionChanged="TabControl_SelectionChanged"
|
||||
ShowContextMenu="True"
|
||||
@@ -58,24 +61,25 @@
|
||||
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="SystemIcon"/>
|
||||
</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:SimplePanel>
|
||||
<uc:IconPannel x:Name="CustomIcon"/>
|
||||
<hc:LoadingCircle x:Name="LoadingEle"/>
|
||||
</hc:SimplePanel>
|
||||
</hc:TabItem>
|
||||
</hc:TabControl>
|
||||
<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="SystemIcon"/>
|
||||
</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:SimplePanel>
|
||||
<uc:IconPannel x:Name="CustomIcon"/>
|
||||
<hc:LoadingCircle x:Name="LoadingEle"/>
|
||||
</hc:SimplePanel>
|
||||
</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" />
|
||||
</Grid>
|
||||
<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" />
|
||||
</Grid>
|
||||
</hc:DialogContainer>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using GeekDesk.Control.Other;
|
||||
using GeekDesk.Interface;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
|
||||
@@ -17,7 +18,7 @@ namespace GeekDesk.Control.Windows
|
||||
/// <summary>
|
||||
/// IconfontWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class IconfontWindow : Window
|
||||
public partial class IconfontWindow : Window, IWindowCommon
|
||||
{
|
||||
private static AppConfig appConfig = MainWindow.appData.AppConfig;
|
||||
private static MenuInfo menuInfo;
|
||||
@@ -71,7 +72,7 @@ namespace GeekDesk.Control.Windows
|
||||
{
|
||||
LoadingEle.Visibility = Visibility.Visible;
|
||||
CustomIcon.Visibility = Visibility.Collapsed;
|
||||
HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig));
|
||||
HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig), "IconUrlDialog");
|
||||
} else
|
||||
{
|
||||
if (customIcons == null)
|
||||
@@ -132,12 +133,13 @@ namespace GeekDesk.Control.Windows
|
||||
window = new IconfontWindow(listInfo, menuInfo);
|
||||
}
|
||||
window.Show();
|
||||
Keyboard.Focus(window);
|
||||
ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0, false);
|
||||
}
|
||||
|
||||
private void CustomButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig));
|
||||
HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig), "IconUrlDialog");
|
||||
}
|
||||
|
||||
|
||||
@@ -166,12 +168,20 @@ namespace GeekDesk.Control.Windows
|
||||
LoadingEle.Visibility = Visibility.Collapsed;
|
||||
CustomIcon.Visibility = Visibility.Visible;
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception e)
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("加载远程图标异常!");
|
||||
LogUtil.WriteErrorLog(e, "加载远程图标异常!");
|
||||
}
|
||||
}
|
||||
|
||||
public void OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public class IconfontViewModel : INotifyPropertyChanged
|
||||
{
|
||||
|
||||
100
Control/Windows/SystemItemWindow.xaml
Normal file
@@ -0,0 +1,100 @@
|
||||
<Window x:Class="GeekDesk.Control.Windows.SystemItemWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:GeekDesk.Control.Windows"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:uc="clr-namespace:GeekDesk.Control.UserControls.SystemItem"
|
||||
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
||||
mc:Ignorable="d"
|
||||
Title="Svg"
|
||||
Height="520" Width="700"
|
||||
WindowStyle="None"
|
||||
ResizeMode="NoResize"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent" ShowInTaskbar="False"
|
||||
BorderThickness="0"
|
||||
Focusable="True"
|
||||
KeyDown="OnKeyDown"
|
||||
>
|
||||
<Window.Resources>
|
||||
<Style x:Key="HcTabControl" TargetType="hc:TabControl" BasedOn="{StaticResource TabControlInLine}">
|
||||
<Style.Setters>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
</Style.Setters>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="TabTitle" TargetType="hc:TabItem" BasedOn="{StaticResource TabItemInLine}">
|
||||
<Style.Setters>
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="White" Opacity="0.68"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style.Setters>
|
||||
</Style>
|
||||
<cvt:MenuInfoConvert x:Key="MenuInfoConvert"/>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid Margin="20">
|
||||
<Grid.Effect>
|
||||
<DropShadowEffect BlurRadius="30" Direction="-90" Color="Gray"
|
||||
RenderingBias="Quality" ShadowDepth="2"/>
|
||||
</Grid.Effect>
|
||||
<Border MouseDown="DragMove" Style="{StaticResource BorderBG}" hc:Dialog.Token="IconUrlDialog">
|
||||
<hc:DialogContainer>
|
||||
<Grid MouseDown="DragMove">
|
||||
<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,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:SystemItem x:Name="SystemItem"/>
|
||||
</hc:SimplePanel>
|
||||
</hc:TabItem>
|
||||
<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:SystemItem x:Name="StartMenuItem"/>
|
||||
<hc:LoadingCircle x:Name="StartMenuLoading"/>
|
||||
</hc:SimplePanel>
|
||||
</hc:TabItem>
|
||||
<!--<hc:TabItem Tag="Store" Header="商店应用(未开放)" hc:IconElement.Height="16" hc:IconElement.Width="16" hc:IconElement.Geometry="{StaticResource CustomIcon}" Style="{StaticResource TabTitle}">
|
||||
<hc:SimplePanel>
|
||||
<uc:SystemItem x:Name="StoreItem"/>
|
||||
</hc:SimplePanel>
|
||||
</hc:TabItem>-->
|
||||
</hc:TabControl>
|
||||
<Button Content="关闭" Click="Close_Click" Margin="594,420,20,31.5"/>
|
||||
</Grid>
|
||||
</hc:DialogContainer>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
|
||||
</Window>
|
||||
281
Control/Windows/SystemItemWindow.xaml.cs
Normal file
@@ -0,0 +1,281 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// SystemItemWindow.xaml 的交互逻辑
|
||||
/// 添加系统项目到对应菜单
|
||||
/// </summary>
|
||||
public partial class SystemItemWindow : Window, IWindowCommon
|
||||
{
|
||||
private static AppConfig appConfig = MainWindow.appData.AppConfig;
|
||||
private static SystemItemViewModel vm;
|
||||
private static List<IconInfo> systemIcons;
|
||||
private static List<IconInfo> startMenuIcons;
|
||||
private static List<IconInfo> storeIcons;
|
||||
|
||||
private SystemItemWindow()
|
||||
{
|
||||
vm = new SystemItemViewModel();
|
||||
this.DataContext = vm;
|
||||
InitializeComponent();
|
||||
this.Topmost = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移动窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
DragMove();
|
||||
}
|
||||
}
|
||||
|
||||
private void Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
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 "StartMenu": //开始菜单
|
||||
if (startMenuIcons == null)
|
||||
{
|
||||
vm.IconInfos = null;
|
||||
System.Threading.Thread t = new System.Threading.Thread(new ThreadStart(GetStartMenuInfos))
|
||||
{
|
||||
IsBackground = true
|
||||
};
|
||||
t.Start();
|
||||
} else
|
||||
{
|
||||
StartMenuLoading.Visibility = Visibility.Collapsed;
|
||||
vm.IconInfos = startMenuIcons;
|
||||
}
|
||||
break;
|
||||
case "Store": //应用商店
|
||||
if (storeIcons == null)
|
||||
{
|
||||
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.IconInfos = systemIcons;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取开始菜单路径下项目
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private void GetStartMenuInfos()
|
||||
{
|
||||
App.Current.Dispatcher.Invoke((Action)(() =>
|
||||
{
|
||||
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)(() =>
|
||||
{
|
||||
if (StartMenu.IsSelected)
|
||||
{
|
||||
startMenuIcons = infos;
|
||||
vm.IconInfos = startMenuIcons;
|
||||
}
|
||||
StartMenuLoading.Visibility = Visibility.Collapsed;
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 递归获取文件信息
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="listInfos"></param>
|
||||
private void GetInfos(string path, List<IconInfo> listInfos)
|
||||
{
|
||||
DirectoryInfo di = new DirectoryInfo(path);
|
||||
FileSystemInfo[] fileInfoArr = di.GetFileSystemInfos();
|
||||
foreach(FileSystemInfo fi in fileInfoArr)
|
||||
{
|
||||
path = fi.FullName;
|
||||
if (File.Exists(path))
|
||||
{
|
||||
string ext = Path.GetExtension(path).ToLower();
|
||||
if (".exe".Equals(ext) || ".lnk".Equals(ext))
|
||||
{
|
||||
try
|
||||
{
|
||||
IconInfo iconInfo = CommonCode.GetIconInfoByPath_NoWrite(path);
|
||||
if (iconInfo.Path_NoWrite != null)
|
||||
{
|
||||
iconInfo.Content_NoWrite = iconInfo.Path_NoWrite + "\n" + iconInfo.Name_NoWrite;
|
||||
listInfos.Add(iconInfo);
|
||||
}
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
}
|
||||
else if (Directory.Exists(path))
|
||||
{
|
||||
GetInfos(path, listInfos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取系统项目
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private List<IconInfo> GetSysteIconInfos()
|
||||
{
|
||||
List<IconInfo> iconInfos = new List<IconInfo>();
|
||||
|
||||
Hashtable systemIcons = Constants.SYSTEM_ICONS;
|
||||
IconInfo iconInfo;
|
||||
foreach (object key in systemIcons.Keys)
|
||||
{
|
||||
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 SystemItemViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private List<IconInfo> iconInfos;
|
||||
private AppConfig appConfig;
|
||||
|
||||
public SystemItemViewModel()
|
||||
{
|
||||
this.AppConfig = MainWindow.appData.AppConfig;
|
||||
}
|
||||
|
||||
public AppConfig AppConfig
|
||||
{
|
||||
get
|
||||
{
|
||||
return appConfig;
|
||||
}
|
||||
set
|
||||
{
|
||||
appConfig = value;
|
||||
OnPropertyChanged("AppConfig");
|
||||
}
|
||||
}
|
||||
public List<IconInfo> IconInfos
|
||||
{
|
||||
get
|
||||
{
|
||||
return iconInfos;
|
||||
}
|
||||
set
|
||||
{
|
||||
iconInfos = value;
|
||||
OnPropertyChanged("IconInfos");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,12 @@
|
||||
Height="450"
|
||||
Width="510"
|
||||
WindowStyle="None"
|
||||
Title=""
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent" ShowInTaskbar="False"
|
||||
>
|
||||
Focusable="True"
|
||||
KeyDown="OnKeyDown"
|
||||
>
|
||||
<Window.Resources>
|
||||
<cvt:TodoTaskExecConvert x:Key="TodoTaskExecConvert"/>
|
||||
</Window.Resources>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Interface;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using HandyControl.Controls;
|
||||
@@ -22,7 +23,7 @@ namespace GeekDesk.Control.Windows
|
||||
/// <summary>
|
||||
/// BacklogInfoWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ToDoInfoWindow
|
||||
public partial class ToDoInfoWindow : IWindowCommon
|
||||
{
|
||||
|
||||
private static int windowType = -1;
|
||||
@@ -207,6 +208,7 @@ namespace GeekDesk.Control.Windows
|
||||
{
|
||||
window = new ToDoInfoWindow();
|
||||
window.Show();
|
||||
Keyboard.Focus(window);
|
||||
}
|
||||
window.Visibility = Visibility.Collapsed;
|
||||
windowType = NEW_TODO;
|
||||
@@ -222,6 +224,7 @@ namespace GeekDesk.Control.Windows
|
||||
}
|
||||
windowType = DETAIL_TODO;
|
||||
window2.Show();
|
||||
Keyboard.Focus(window2);
|
||||
}
|
||||
|
||||
private void ExecType_Checked(object sender, RoutedEventArgs e)
|
||||
@@ -239,5 +242,13 @@ namespace GeekDesk.Control.Windows
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent" ShowInTaskbar="False"
|
||||
Focusable="True"
|
||||
KeyDown="OnKeyDown"
|
||||
>
|
||||
|
||||
<Grid Margin="50">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using GeekDesk.Control.UserControls.Backlog;
|
||||
using GeekDesk.Interface;
|
||||
using GeekDesk.ViewModel;
|
||||
using HandyControl.Controls;
|
||||
using System;
|
||||
@@ -21,7 +22,7 @@ namespace GeekDesk.Control.Windows
|
||||
/// <summary>
|
||||
/// BacklogWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ToDoWindow
|
||||
public partial class ToDoWindow : IWindowCommon
|
||||
{
|
||||
private static TodoControl backlog = new TodoControl();
|
||||
private AppData appData = MainWindow.appData;
|
||||
@@ -94,8 +95,15 @@ namespace GeekDesk.Control.Windows
|
||||
window = new ToDoWindow();
|
||||
}
|
||||
window.Show();
|
||||
Keyboard.Focus(window);
|
||||
}
|
||||
|
||||
|
||||
public void OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,10 @@
|
||||
Height="460" Width="610"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent" ShowInTaskbar="False">
|
||||
Title=""
|
||||
Background="Transparent" ShowInTaskbar="False"
|
||||
Focusable="True"
|
||||
KeyDown="OnKeyDown">
|
||||
<Grid Margin="20">
|
||||
<Grid.Effect>
|
||||
<DropShadowEffect BlurRadius="30" Direction="-90" Color="Gray"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Interface;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -23,7 +24,7 @@ namespace GeekDesk.Control.Windows
|
||||
/// <summary>
|
||||
/// UpdateWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class UpdateWindow : Window
|
||||
public partial class UpdateWindow : Window, IWindowCommon
|
||||
{
|
||||
private static AppConfig appConfig = MainWindow.appData.AppConfig;
|
||||
private static string githubUrl = "";
|
||||
@@ -37,9 +38,9 @@ namespace GeekDesk.Control.Windows
|
||||
InitializeComponent();
|
||||
DataHandle(jo);
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
LogUtil.WriteErrorLog(e, "更新信息格式化失败!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -103,6 +104,15 @@ namespace GeekDesk.Control.Windows
|
||||
window = new UpdateWindow(jo);
|
||||
}
|
||||
window.Show();
|
||||
Keyboard.Focus(window);
|
||||
}
|
||||
|
||||
public void OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
45
Converts/MenuInfoConvert.cs
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -142,12 +143,18 @@
|
||||
<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>
|
||||
<Compile Include="Control\UserControls\IconFont\IconPannel.xaml.cs">
|
||||
<DependentUpon>IconPannel.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Control\Windows\SystemItemWindow.xaml.cs">
|
||||
<DependentUpon>SystemItemWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Control\Windows\ToDoInfoWindow.xaml.cs">
|
||||
<DependentUpon>ToDoInfoWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -182,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" />
|
||||
@@ -189,6 +197,7 @@
|
||||
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.cs" />
|
||||
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.Drag.cs" />
|
||||
<Compile Include="Converts\HideTypeConvert.cs" />
|
||||
<Compile Include="Interface\IWindowCommon.cs" />
|
||||
<Compile Include="Task\ToDoTask.cs" />
|
||||
<Compile Include="Thread\MouseHookThread.cs" />
|
||||
<Compile Include="Thread\DispatcherBuild.cs" />
|
||||
@@ -200,6 +209,7 @@
|
||||
<Compile Include="Util\DragAdorner.cs" />
|
||||
<Compile Include="Util\FileIcon.cs" />
|
||||
<Compile Include="Util\FileUtil.cs" />
|
||||
<Compile Include="Util\LogUtil.cs" />
|
||||
<Compile Include="Util\MarginHide.cs" />
|
||||
<Compile Include="Util\HttpUtil.cs" />
|
||||
<Compile Include="Util\ImageUtil.cs" />
|
||||
@@ -212,6 +222,7 @@
|
||||
<Compile Include="Util\ShowWindowFollowMouse.cs" />
|
||||
<Compile Include="Util\StringUtil.cs" />
|
||||
<Compile Include="Util\SvgToGeometry.cs" />
|
||||
<Compile Include="Util\SystemIcon.cs" />
|
||||
<Compile Include="ViewModel\AppConfig.cs" />
|
||||
<Compile Include="ViewModel\AppData.cs" />
|
||||
<Compile Include="ViewModel\ToDoInfo.cs" />
|
||||
@@ -234,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>
|
||||
@@ -242,6 +257,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Control\Windows\SystemItemWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Control\Windows\ToDoInfoWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -366,6 +385,35 @@
|
||||
<Isolated>False</Isolated>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
<COMReference Include="Shell32">
|
||||
<Guid>{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
<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>
|
||||
15
Interface/IWindowCommon.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace GeekDesk.Interface
|
||||
{
|
||||
public interface IWindowCommon
|
||||
{
|
||||
void OnKeyDown(object sender, KeyEventArgs e);
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,10 @@
|
||||
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" 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"
|
||||
@@ -19,6 +20,8 @@
|
||||
Opacity="0"
|
||||
Deactivated="Window_Deactivated"
|
||||
SizeChanged="Window_SizeChanged"
|
||||
KeyDown="OnKeyDown"
|
||||
Focusable="True"
|
||||
>
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="0" ResizeBorderThickness="15"/>
|
||||
@@ -92,6 +95,7 @@
|
||||
Click="ConfigButtonClick"
|
||||
Initialized="SettingButton_Initialized"
|
||||
x:Name="SettingButton"
|
||||
FocusVisualStyle="{x:Null}"
|
||||
>
|
||||
<Button.ContextMenu>
|
||||
<ContextMenu x:Name="SettingMenus" Width="130">
|
||||
@@ -107,13 +111,15 @@
|
||||
hc:IconElement.Width="18"
|
||||
HorizontalAlignment="Right"
|
||||
Click="CloseButtonClick"
|
||||
FocusVisualStyle="{x:Null}"
|
||||
/>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
</DockPanel>
|
||||
|
||||
|
||||
<uc:LeftCardControl Grid.Row="1" Grid.Column="0"/>
|
||||
<uc:LeftCardControl Grid.Row="1" Grid.Column="0"/>
|
||||
|
||||
<!--分割线-->
|
||||
<GridSplitter Opacity="0" Grid.Row="1" Grid.Column="0" Width="1" VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
|
||||
|
||||
@@ -124,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"/>
|
||||
|
||||
@@ -3,6 +3,7 @@ using GeekDesk.Constant;
|
||||
using GeekDesk.Control;
|
||||
using GeekDesk.Control.UserControls.Config;
|
||||
using GeekDesk.Control.Windows;
|
||||
using GeekDesk.Interface;
|
||||
using GeekDesk.Task;
|
||||
using GeekDesk.Thread;
|
||||
using GeekDesk.Util;
|
||||
@@ -29,18 +30,14 @@ namespace GeekDesk
|
||||
/// MainWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
///
|
||||
public partial class MainWindow : Window
|
||||
public partial class MainWindow : Window, IWindowCommon
|
||||
{
|
||||
|
||||
//public IKeyboardMouseEvents m_GlobalHook = Hook.GlobalEvents();
|
||||
|
||||
public static AppData appData = CommonCode.GetAppDataByFile();
|
||||
//public static ToDoInfoWindow toDoInfoWindow = (ToDoInfoWindow)ToDoInfoWindow.GetThis();
|
||||
public static ToDoInfoWindow toDoInfoWindow;
|
||||
public static int hotKeyId = -1;
|
||||
public static int toDoHotKeyId = -1;
|
||||
public static MainWindow mainWindow;
|
||||
public static MarginHide hide;
|
||||
public MainWindow()
|
||||
{
|
||||
LoadData();
|
||||
@@ -52,10 +49,10 @@ namespace GeekDesk
|
||||
ToDoTask.BackLogCheck();
|
||||
|
||||
////实例化隐藏 Hide类,进行时间timer设置
|
||||
hide = new MarginHide(this);
|
||||
MarginHide.ReadyHide(this);
|
||||
if (appData.AppConfig.MarginHide)
|
||||
{
|
||||
hide.TimerSet();
|
||||
MarginHide.StartHide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,6 +92,7 @@ namespace GeekDesk
|
||||
ShowApp();
|
||||
}
|
||||
|
||||
//给任务栏图标一个名字
|
||||
BarIcon.Text = Constants.MY_NAME;
|
||||
|
||||
//注册热键
|
||||
@@ -108,36 +106,15 @@ namespace GeekDesk
|
||||
}
|
||||
|
||||
//注册鼠标中键监听事件
|
||||
//m_GlobalHook.MouseUpExt += M_GlobalHook_MouseUpExt;
|
||||
MouseHookThread.MiddleHook();
|
||||
if (appData.AppConfig.MouseMiddleShow)
|
||||
{
|
||||
MouseHookThread.MiddleHook();
|
||||
}
|
||||
|
||||
//更新线程开启 检测更新
|
||||
UpdateThread.Update();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标中键呼出
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
//private void M_GlobalHook_MouseUpExt(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
//{
|
||||
// if (appData.AppConfig.MouseMiddleShow && e.Button == System.Windows.Forms.MouseButtons.Middle)
|
||||
// {
|
||||
// if (MotionControl.hotkeyFinished)
|
||||
// {
|
||||
// if (mainWindow.Visibility == Visibility.Collapsed || mainWindow.Opacity == 0)
|
||||
// {
|
||||
// ShowApp();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// HideApp();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 注册当前窗口的热键
|
||||
/// </summary>
|
||||
@@ -152,7 +129,7 @@ namespace GeekDesk
|
||||
{
|
||||
if (MotionControl.hotkeyFinished)
|
||||
{
|
||||
if (mainWindow.Visibility == Visibility.Collapsed || mainWindow.Opacity == 0)
|
||||
if (mainWindow.Visibility == Visibility.Collapsed || mainWindow.Opacity == 0 || MarginHide.IS_HIDE)
|
||||
{
|
||||
ShowApp();
|
||||
}
|
||||
@@ -209,7 +186,7 @@ namespace GeekDesk
|
||||
mainWindow.Opacity = 0;
|
||||
}
|
||||
};
|
||||
Timeline.SetDesiredFrameRate(opacityAnimation, 30);
|
||||
Timeline.SetDesiredFrameRate(opacityAnimation, 60);
|
||||
mainWindow.BeginAnimation(OpacityProperty, opacityAnimation);
|
||||
} else
|
||||
{
|
||||
@@ -283,10 +260,6 @@ namespace GeekDesk
|
||||
/// <param name="e"></param>
|
||||
private void DragMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
//if (e.LeftButton == MouseButtonState.Pressed)
|
||||
//{
|
||||
// this.DragMove();
|
||||
//}
|
||||
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
@@ -303,7 +276,6 @@ namespace GeekDesk
|
||||
(When clicking the drag area, make the window follow) */
|
||||
DragMove();
|
||||
|
||||
|
||||
if (this.ResizeMode != windowMode)
|
||||
{
|
||||
this.ResizeMode = windowMode;
|
||||
@@ -362,6 +334,8 @@ namespace GeekDesk
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
//修改贴边隐藏状态为未隐藏
|
||||
MarginHide.IS_HIDE = false;
|
||||
if (appData.AppConfig.FollowMouse)
|
||||
{
|
||||
ShowWindowFollowMouse.Show(mainWindow, MousePosition.CENTER, 0, 0, false);
|
||||
@@ -419,16 +393,6 @@ namespace GeekDesk
|
||||
p.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 右键任务栏图标退出
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ExitApp(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MouseHookThread.Dispose();
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -475,7 +439,7 @@ namespace GeekDesk
|
||||
if (appData.AppConfig.AppHideType == AppHideType.LOST_FOCUS)
|
||||
{
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (appData.AppConfig.MarginHide && !hide.IsMargin())
|
||||
if (appData.AppConfig.MarginHide && !MarginHide.IS_HIDE)
|
||||
{
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
@@ -500,6 +464,21 @@ namespace GeekDesk
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 右键任务栏图标退出
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ExitApp(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (appData.AppConfig.MouseMiddleShow)
|
||||
{
|
||||
MouseHookThread.Dispose();
|
||||
}
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
/// <summary>
|
||||
/// 重启
|
||||
/// </summary>
|
||||
@@ -507,10 +486,13 @@ namespace GeekDesk
|
||||
/// <param name="e"></param>
|
||||
private void ReStartApp(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MouseHookThread.Dispose();
|
||||
if (appData.AppConfig.MouseMiddleShow)
|
||||
{
|
||||
MouseHookThread.Dispose();
|
||||
}
|
||||
|
||||
Process p = new Process();
|
||||
p.StartInfo.FileName = Constants.APP_DIR + Constants.MY_NAME + ".exe";
|
||||
p.StartInfo.FileName = Constants.APP_DIR + "GeekDesk.exe";
|
||||
p.StartInfo.WorkingDirectory = Constants.APP_DIR;
|
||||
p.Start();
|
||||
|
||||
@@ -526,6 +508,15 @@ namespace GeekDesk
|
||||
{
|
||||
appData.AppConfig.ShowBarIcon = false;
|
||||
}
|
||||
|
||||
|
||||
public void OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
HideApp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -49,5 +49,5 @@ using System.Windows;
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.3.2.0")]
|
||||
[assembly: AssemblyFileVersion("2.3.2.0")]
|
||||
[assembly: AssemblyVersion("2.4.1.0")]
|
||||
[assembly: AssemblyFileVersion("2.4.1.0")]
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol">
|
||||
|
||||
|
||||
<!--整体样式-->
|
||||
<Style x:Key="BorderBG" TargetType="Border">
|
||||
<Style.Setters>
|
||||
<Setter Property="Background">
|
||||
@@ -18,18 +19,29 @@
|
||||
</Style.Setters>
|
||||
</Style>
|
||||
|
||||
<LinearGradientBrush x:Key="BtnBG" Opacity="0.97">
|
||||
<GradientStop Color="White" Offset="0"/>
|
||||
<GradientStop Color="White" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
|
||||
<!--按钮样式-->
|
||||
<Style x:Key="Btn1" TargetType="Button" BasedOn="{StaticResource ButtonInfo}">
|
||||
<Setter Property="Background">
|
||||
<Setter Property="Background" Value="{StaticResource BtnBG}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="BorderBrush">
|
||||
<Setter.Value>
|
||||
<LinearGradientBrush Opacity="0.97">
|
||||
<GradientStop Color="#5BC0DE" Offset="0"/>
|
||||
<GradientStop Color="#5BC0DE" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
<SolidColorBrush Color="#E5E5E2"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#E5E5E2"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<!--菜单样式-->
|
||||
<Style x:Key="MyMenuStyle" TargetType="hc:SideMenuItem" BasedOn="{StaticResource SideMenuItemBaseStyle}">
|
||||
<Style.Setters>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
|
||||
BIN
Resource/Image/SystemIcon/CMD.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
Resource/Image/SystemIcon/Calculator.png
Normal file
|
After Width: | Height: | Size: 8.7 KiB |
BIN
Resource/Image/SystemIcon/Computer.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
Resource/Image/SystemIcon/Control.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
Resource/Image/SystemIcon/GroupPolicy.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
Resource/Image/SystemIcon/Mstsc.png
Normal file
|
After Width: | Height: | Size: 47 KiB |
BIN
Resource/Image/SystemIcon/Network.png
Normal file
|
After Width: | Height: | Size: 61 KiB |
BIN
Resource/Image/SystemIcon/Notepad.png
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
BIN
Resource/Image/SystemIcon/RecycleBin.png
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
Resource/Image/SystemIcon/Registry.png
Normal file
|
After Width: | Height: | Size: 7.2 KiB |
@@ -1,4 +1,5 @@
|
||||
using GeekDesk.Control.UserControls.Config;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using Gma.System.MouseKeyHook;
|
||||
using System;
|
||||
@@ -15,7 +16,7 @@ namespace GeekDesk.Thread
|
||||
public class MouseHookThread
|
||||
{
|
||||
private static AppConfig appConfig = MainWindow.appData.AppConfig;
|
||||
private static IKeyboardMouseEvents m_GlobalHook = Hook.GlobalEvents();
|
||||
private static IKeyboardMouseEvents m_GlobalHook = null;
|
||||
private static Dispatcher dispatcher;
|
||||
|
||||
|
||||
@@ -23,7 +24,9 @@ namespace GeekDesk.Thread
|
||||
public static void MiddleHook()
|
||||
{
|
||||
//使用dispatcher来单独监听UI线程 防止程序卡顿
|
||||
if (dispatcher != null) return;
|
||||
dispatcher = DispatcherBuild.Build();
|
||||
m_GlobalHook = Hook.GlobalEvents();
|
||||
dispatcher.Invoke((Action)(() =>
|
||||
{
|
||||
m_GlobalHook.MouseDownExt += M_GlobalHook_MouseDownExt;
|
||||
@@ -32,9 +35,16 @@ namespace GeekDesk.Thread
|
||||
|
||||
public static void Dispose()
|
||||
{
|
||||
m_GlobalHook.MouseDownExt -= M_GlobalHook_MouseDownExt;
|
||||
m_GlobalHook.Dispose();
|
||||
dispatcher.InvokeShutdown();
|
||||
try
|
||||
{
|
||||
m_GlobalHook.MouseDownExt -= M_GlobalHook_MouseDownExt;
|
||||
m_GlobalHook.Dispose();
|
||||
m_GlobalHook = null;
|
||||
dispatcher.InvokeShutdown();
|
||||
dispatcher = null;
|
||||
}
|
||||
catch { }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -50,7 +60,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.IS_HIDE)
|
||||
{
|
||||
MainWindow.ShowApp();
|
||||
}
|
||||
|
||||
@@ -59,12 +59,9 @@ namespace GeekDesk.Thread
|
||||
}));
|
||||
}
|
||||
}
|
||||
#pragma warning disable CS0168 // 声明了变量“e”,但从未使用过
|
||||
} catch (Exception e)
|
||||
#pragma warning restore CS0168 // 声明了变量“e”,但从未使用过
|
||||
{
|
||||
//不做处理
|
||||
//MessageBox.Show(e.Message);
|
||||
LogUtil.WriteErrorLog(e, "检测更新失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10
Update.json
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"title": "<EFBFBD>汾<EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
||||
"subTitle": "V2.3.20 <20><>ʽ<EFBFBD><CABD>",
|
||||
"msgTitle": "<EFBFBD><EFBFBD><EFBFBD>θ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
||||
"msg": "['һ<EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><EFBFBD><DEB8><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>bug<75><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><CBB2>ֹ<EFBFBD><D6B9><EFBFBD>','<27><EFBFBD><DEB8><EFBFBD><DEB7>IJ˵<C4B2>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>bug','<27><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״bug','<27><EFBFBD><DEB8>ȼ<EFBFBD><C8BC><EFBFBD>֧<EFBFBD><D6A7>Alt<6C><74>bug','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>깦<EFBFBD><EAB9A6>','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>star<61><72>']",
|
||||
"title": "GeekDesk版本更新",
|
||||
"subTitle": "V2.4.10",
|
||||
"msgTitle": "本次更新内容如下",
|
||||
"msg": "['各位兄弟去给我点个免费Star呗','增加添加系统和开始菜单应用功能','增加项目启动参数','优化贴边隐藏动画效果(可能现在并不完美)','增加双击打开功能','其它已知问题修复(如果有人发现)']",
|
||||
"githubUrl": "https://github.com/Demo-Liu/GeekDesk/releases",
|
||||
"giteeUrl": "https://gitee.com/demo_liu/GeekDesk/releases",
|
||||
"version": "2.3.20"
|
||||
"version": "2.4.10"
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"title": "版本更新",
|
||||
"subTitle": "V2.3.20 正式版",
|
||||
"msgTitle": "本次更新内容如下",
|
||||
"msg": "['一个小更新, 修复了一部分bug并增加了部分功能','修复无法修改菜单图标的bug','修复图标锯齿状bug','修复热键不支持Alt的bug','增加鼠标中键呼出功能','增加隐藏托盘图标功能','界面美化等','最后去给我点个star呗']",
|
||||
"title": "GeekDesk<EFBFBD>汾<EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
||||
"subTitle": "V2.3.21",
|
||||
"msgTitle": "<EFBFBD><EFBFBD><EFBFBD>θ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
||||
"msg": "['<EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD>ڿ<EFBFBD>Esc<EFBFBD>˳<EFBFBD>','<27><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>BUG,<2C><><EFBFBD><EFBFBD>û<EFBFBD><C3BB>D<EFBFBD>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ','<27><EFBFBD><DEB8><EFBFBD>֪<EFBFBD><D6AA><EFBFBD><EFBFBD>']",
|
||||
"githubUrl": "https://github.com/Demo-Liu/GeekDesk/releases",
|
||||
"giteeUrl": "https://gitee.com/demo_liu/GeekDesk/releases",
|
||||
"version": "2.3.20"
|
||||
"version": "2.3.21"
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -32,11 +32,11 @@ namespace GeekDesk.Util
|
||||
int nIcons, //指定获取的图标数量,仅当文件类型为.exe 和 .dll时候可用
|
||||
int flags //标志,默认0就可以,具体可以看LoadImage函数
|
||||
);
|
||||
|
||||
|
||||
|
||||
public static BitmapImage GetBitmapImage(string filePath)
|
||||
{
|
||||
Icon ico;
|
||||
Icon ico = null;
|
||||
//选中文件中的图标总数
|
||||
var iconTotalCount = PrivateExtractIcons(filePath, 0, 0, 0, null, null, 0, 0);
|
||||
//用于接收获取到的图标指针
|
||||
@@ -53,18 +53,31 @@ namespace GeekDesk.Util
|
||||
{
|
||||
ip = hIcons[0];
|
||||
ico = Icon.FromHandle(ip);
|
||||
if (IsMinOrTransparent(ico))
|
||||
{
|
||||
ico = null;
|
||||
}
|
||||
}
|
||||
else if (GetBlurExts().Contains(ext))
|
||||
if (ico == null && GetBlurExts().Contains(ext))
|
||||
{
|
||||
ico = Icon.ExtractAssociatedIcon(filePath);
|
||||
if (IsMinOrTransparent(ico))
|
||||
{
|
||||
ico = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (ico == null)
|
||||
{
|
||||
ip = GetJumboIcon(GetIconIndex(filePath));
|
||||
ico = Icon.FromHandle(ip);
|
||||
}
|
||||
|
||||
return IconToBitmapImage(ico, ip);
|
||||
}
|
||||
|
||||
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");
|
||||
@@ -73,20 +86,51 @@ namespace GeekDesk.Util
|
||||
EncoderParameters myEncoderParameters = new EncoderParameters(1);
|
||||
myEncoderParameters.Param[0] = myEncoderParameter;
|
||||
|
||||
//bmp.Save("d:\\test.png");
|
||||
|
||||
bmp.Save(strm, myImageCodecInfo, myEncoderParameters);
|
||||
bmp.Save("d:\\test.png", 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();
|
||||
}
|
||||
|
||||
|
||||
private static bool IsMinOrTransparent(Icon ico)
|
||||
{
|
||||
Bitmap bm = ico.ToBitmap();
|
||||
double w = bm.Width;
|
||||
double h = bm.Height;
|
||||
|
||||
Color middleColor = bm.GetPixel((int)(w * 0.50), (int)(h * 0.50));
|
||||
Color transparent = Color.FromArgb(0, 0, 0, 0);
|
||||
|
||||
//如果中间像素不为空 直接判断此icon不为空
|
||||
if (middleColor != Color.Transparent && middleColor != transparent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//判断中间一条横线像素 有不透明元素即判断 icon不为空
|
||||
Color c;
|
||||
int h2 = (int)h / 2;
|
||||
for (int i=0; i<(int)w; i++)
|
||||
{
|
||||
c = bm.GetPixel(i, h2);
|
||||
if (c!= Color.Transparent && c != transparent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static ImageCodecInfo GetEncoderInfo(String mimeType)
|
||||
{
|
||||
int j;
|
||||
@@ -417,7 +461,6 @@ namespace GeekDesk.Util
|
||||
int iOverlay,
|
||||
ref int piIndex);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
136
Util/FileUtil.cs
@@ -2,7 +2,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
@@ -10,25 +12,151 @@ namespace GeekDesk.Util
|
||||
public class FileUtil
|
||||
{
|
||||
|
||||
private static readonly string NO_PATH = "{(.*)}";
|
||||
private static readonly string NO_ICO = "^,(.*)";
|
||||
private static readonly string HAVE_ICO = "(.*),(.*)";
|
||||
|
||||
public static string GetTargetPathByLnk(string filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
WshShell shell = new WshShell();
|
||||
IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath);
|
||||
|
||||
if (StringUtil.IsEmpty(shortcut.TargetPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return shortcut.TargetPath;
|
||||
string path = shortcut.TargetPath;
|
||||
if (path==null || Regex.IsMatch(path, NO_PATH))
|
||||
{
|
||||
path = ParseShortcut(filePath);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
#pragma warning disable CS0168 // 声明了变量“e”,但从未使用过
|
||||
catch (Exception e)
|
||||
#pragma warning restore CS0168 // 声明了变量“e”,但从未使用过
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
UINT MsiGetShortcutTarget(
|
||||
LPCTSTR szShortcutTarget,
|
||||
LPTSTR szProductCode,
|
||||
LPTSTR szFeatureId,
|
||||
LPTSTR szComponentCode
|
||||
);
|
||||
*/
|
||||
[DllImport("msi.dll", CharSet = CharSet.Auto)]
|
||||
static extern int MsiGetShortcutTarget(string targetFile, StringBuilder productCode, StringBuilder featureID, StringBuilder componentCode);
|
||||
|
||||
public enum InstallState
|
||||
{
|
||||
NotUsed = -7,
|
||||
BadConfig = -6,
|
||||
Incomplete = -5,
|
||||
SourceAbsent = -4,
|
||||
MoreData = -3,
|
||||
InvalidArg = -2,
|
||||
Unknown = -1,
|
||||
Broken = 0,
|
||||
Advertised = 1,
|
||||
Removed = 1,
|
||||
Absent = 2,
|
||||
Local = 3,
|
||||
Source = 4,
|
||||
Default = 5
|
||||
}
|
||||
|
||||
public const int MaxFeatureLength = 38;
|
||||
public const int MaxGuidLength = 38;
|
||||
public const int MaxPathLength = 1024;
|
||||
|
||||
/*
|
||||
INSTALLSTATE MsiGetComponentPath(
|
||||
LPCTSTR szProduct,
|
||||
LPCTSTR szComponent,
|
||||
LPTSTR lpPathBuf,
|
||||
DWORD* pcchBuf
|
||||
);
|
||||
*/
|
||||
[DllImport("msi.dll", CharSet = CharSet.Auto)]
|
||||
static extern InstallState MsiGetComponentPath(string productCode, string componentCode, StringBuilder componentPath, ref int componentPathBufferSize);
|
||||
|
||||
public static string ParseShortcut(string file)
|
||||
{
|
||||
StringBuilder product = new StringBuilder(MaxGuidLength + 1);
|
||||
StringBuilder feature = new StringBuilder(MaxFeatureLength + 1);
|
||||
StringBuilder component = new StringBuilder(MaxGuidLength + 1);
|
||||
|
||||
MsiGetShortcutTarget(file, product, feature, component);
|
||||
|
||||
int pathLength = MaxPathLength;
|
||||
StringBuilder path = new StringBuilder(pathLength);
|
||||
|
||||
InstallState installState = MsiGetComponentPath(product.ToString(), component.ToString(), path, ref pathLength);
|
||||
if (installState == InstallState.Local)
|
||||
{
|
||||
return path.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,9 +53,10 @@ namespace GeekDesk.Util
|
||||
UnregisterHotKey(handleTemp[id].Handle, id);
|
||||
GlobalHotKey.handleTemp[id].Dispose();
|
||||
GlobalHotKey.handleTemp.Remove(id);
|
||||
} catch
|
||||
} catch (Exception e)
|
||||
{
|
||||
//nothing
|
||||
LogUtil.WriteErrorLog(e, "取消注册热键异常!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
@@ -13,6 +14,7 @@ namespace GeekDesk.Util
|
||||
{
|
||||
class ImageUtil
|
||||
{
|
||||
private static readonly string SYSTEM_ITEM = "::{.*}";
|
||||
|
||||
/// <summary>
|
||||
/// 图片数组转 BitmapImage
|
||||
@@ -84,7 +86,12 @@ namespace GeekDesk.Util
|
||||
/// <returns></returns>
|
||||
public static BitmapImage GetBitmapIconByPath(string filePath)
|
||||
{
|
||||
if (File.Exists(filePath))
|
||||
if (filePath.Contains("%windir%"))
|
||||
{
|
||||
filePath = filePath.Replace("%windir%", System.Environment.GetEnvironmentVariable("windir"));
|
||||
}
|
||||
|
||||
if (File.Exists(filePath) || IsSystemItem(filePath))
|
||||
{
|
||||
if (IsImage(filePath)) {
|
||||
//图片
|
||||
@@ -94,8 +101,17 @@ namespace GeekDesk.Util
|
||||
return FileIcon.GetBitmapImage(filePath);
|
||||
}
|
||||
} else if(Directory.Exists(filePath)) {
|
||||
//文件夹
|
||||
return ImageUtil.Base64ToBitmapImage(Constants.DEFAULT_DIR_IMAGE_BASE64);
|
||||
|
||||
if ((filePath.IndexOf("\\") == filePath.LastIndexOf("\\")) && filePath.IndexOf("\\") == filePath.Length - 1)
|
||||
{
|
||||
//磁盘
|
||||
return ImageUtil.Base64ToBitmapImage(Constants.DEFAULT_DISK_IMAGE_BASE64);
|
||||
} else
|
||||
{
|
||||
//文件夹
|
||||
return ImageUtil.Base64ToBitmapImage(Constants.DEFAULT_DIR_IMAGE_BASE64);
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -200,8 +216,9 @@ namespace GeekDesk.Util
|
||||
return bm;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception e)
|
||||
{
|
||||
LogUtil.WriteErrorLog(e, "获取文件缩略图失败!filePath="+filePath);
|
||||
return Base64ToBitmapImage(Constants.DEFAULT_IMG_IMAGE_BASE64);
|
||||
}
|
||||
|
||||
@@ -300,8 +317,9 @@ namespace GeekDesk.Util
|
||||
ms.Close();
|
||||
return Convert.ToBase64String(arr);
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception e)
|
||||
{
|
||||
LogUtil.WriteErrorLog(e, "图片文件转base64失败!Imagefilename=" + Imagefilename + ",ImageFormat="+format);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -334,5 +352,15 @@ namespace GeekDesk.Util
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否为系统项
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool IsSystemItem(string path)
|
||||
{
|
||||
return Regex.IsMatch(path, SYSTEM_ITEM);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
76
Util/LogUtil.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using GeekDesk.Constant;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class LogUtil
|
||||
{
|
||||
public static void WriteErrorLog(object exception, string msg = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
Exception ex = exception as Exception;
|
||||
|
||||
using (FileStream fs = File.Open(Constants.ERROR_FILE_PATH, FileMode.OpenOrCreate, FileAccess.ReadWrite))
|
||||
{
|
||||
fs.Seek(0, SeekOrigin.End);
|
||||
byte[] buffer = Encoding.Default.GetBytes("-------------------------------------------------------\r\n");
|
||||
fs.Write(buffer, 0, buffer.Length);
|
||||
|
||||
buffer = Encoding.Default.GetBytes(DateTime.Now.ToString() + msg + "\r\n");
|
||||
fs.Write(buffer, 0, buffer.Length);
|
||||
|
||||
if (ex != null)
|
||||
{
|
||||
buffer = Encoding.Default.GetBytes("成员名: " + ex.TargetSite + "\r\n");
|
||||
fs.Write(buffer, 0, buffer.Length);
|
||||
|
||||
buffer = Encoding.Default.GetBytes("引发异常的类: " + ex.TargetSite.DeclaringType + "\r\n");
|
||||
fs.Write(buffer, 0, buffer.Length);
|
||||
|
||||
buffer = Encoding.Default.GetBytes("异常信息: " + ex.Message + "\r\n");
|
||||
fs.Write(buffer, 0, buffer.Length);
|
||||
|
||||
buffer = Encoding.Default.GetBytes("引发异常的程序集或对象: " + ex.Source + "\r\n");
|
||||
fs.Write(buffer, 0, buffer.Length);
|
||||
|
||||
buffer = Encoding.Default.GetBytes("栈:" + ex.StackTrace + "\r\n");
|
||||
fs.Write(buffer, 0, buffer.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer = Encoding.Default.GetBytes("应用程序错误: " + exception.ToString() + "\r\n");
|
||||
fs.Write(buffer, 0, buffer.Length);
|
||||
}
|
||||
}
|
||||
} catch
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void WriteLog(string msg)
|
||||
{
|
||||
try {
|
||||
using (FileStream fs = File.Open(Constants.LOG_FILE_PATH, FileMode.OpenOrCreate, FileAccess.ReadWrite))
|
||||
{
|
||||
fs.Seek(0, SeekOrigin.End);
|
||||
byte[] buffer = Encoding.Default.GetBytes("-------------------------------------------------------\r\n");
|
||||
fs.Write(buffer, 0, buffer.Length);
|
||||
|
||||
buffer = Encoding.Default.GetBytes(DateTime.Now.ToString() + msg + "\r\n" );
|
||||
fs.Write(buffer, 0, buffer.Length);
|
||||
}
|
||||
} catch { }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,8 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using System.Drawing; //添加引用
|
||||
using System.Windows.Forms;//添加引用
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Animation;
|
||||
@@ -14,32 +14,40 @@ using System.Windows.Media;
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
|
||||
enum HidePosition
|
||||
enum HideType
|
||||
{
|
||||
TOP = 1,
|
||||
LEFT = 2,
|
||||
RIGHT = 3
|
||||
TOP_SHOW = 1,
|
||||
LEFT_SHOW = 2,
|
||||
RIGHT_SHOW = 3,
|
||||
TOP_HIDE = 4,
|
||||
LEFT_HIDE = 5,
|
||||
RIGHT_HIDE = 6
|
||||
}
|
||||
|
||||
public class MarginHide
|
||||
{
|
||||
readonly Window window;//定义使用该方法的窗体
|
||||
private static Window window;//定义使用该方法的窗体
|
||||
|
||||
private readonly int hideTime = 80;
|
||||
private static readonly int hideTime = 200;
|
||||
private static readonly int fadeHideTime = 180;
|
||||
private static readonly int fadeShowTime = 200;
|
||||
private static readonly int taskTime = 250;
|
||||
|
||||
private readonly int taskTime = 200;
|
||||
private static double showMarginWidth = 1;
|
||||
|
||||
private double showMarginWidth = 1;
|
||||
public static bool IS_RUN = false;
|
||||
public static bool IS_HIDE = false;
|
||||
|
||||
#pragma warning disable CS0414 // 字段“MarginHide.isHide”已被赋值,但从未使用过它的值
|
||||
private bool isHide;
|
||||
#pragma warning restore CS0414 // 字段“MarginHide.isHide”已被赋值,但从未使用过它的值
|
||||
private static Timer timer = null;
|
||||
|
||||
public Timer timer;
|
||||
//构造函数,传入将要匹配的窗体
|
||||
public MarginHide(Window window)
|
||||
public static void ReadyHide(Window window)
|
||||
{
|
||||
this.window = window;
|
||||
MarginHide.window = window;
|
||||
if (timer != null) return;
|
||||
timer = new Timer();//添加timer计时器,隐藏功能
|
||||
timer.Interval = taskTime;
|
||||
timer.Tick += HideWindow;
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +55,7 @@ namespace GeekDesk.Util
|
||||
/// 窗体是否贴边
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsMargin()
|
||||
public static bool IsMargin()
|
||||
{
|
||||
double screenLeft = SystemParameters.VirtualScreenLeft;
|
||||
double screenTop = SystemParameters.VirtualScreenTop;
|
||||
@@ -67,9 +75,9 @@ namespace GeekDesk.Util
|
||||
|
||||
|
||||
#region 窗体贴边隐藏功能
|
||||
private void TimerDealy(object o, EventArgs e)
|
||||
private static void HideWindow(object o, EventArgs e)
|
||||
{
|
||||
if (window.Visibility != Visibility.Visible) return;
|
||||
if (window.Visibility != Visibility.Visible || !IS_RUN) return;
|
||||
|
||||
double screenLeft = SystemParameters.VirtualScreenLeft;
|
||||
double screenTop = SystemParameters.VirtualScreenTop;
|
||||
@@ -87,47 +95,58 @@ namespace GeekDesk.Util
|
||||
double mouseY = p.Y;
|
||||
|
||||
//鼠标不在窗口上
|
||||
if (mouseX < windowLeft || mouseX > windowLeft + windowWidth
|
||||
|| mouseY < windowTop || mouseY > windowTop + windowHeight)
|
||||
if ((mouseX < windowLeft || mouseX > windowLeft + windowWidth
|
||||
|| mouseY < windowTop || mouseY > windowTop + windowHeight) && !IS_HIDE)
|
||||
{
|
||||
//上方隐藏条件
|
||||
if (windowTop <= screenTop)
|
||||
{
|
||||
HideAnimation(windowTop, screenTop - windowHeight + showMarginWidth, Window.TopProperty);
|
||||
isHide = true;
|
||||
IS_HIDE = true;
|
||||
FadeAnimation(1, 0);
|
||||
HideAnimation(windowTop, screenTop - windowHeight + showMarginWidth, Window.TopProperty, HideType.TOP_HIDE);
|
||||
return;
|
||||
}
|
||||
//左侧隐藏条件
|
||||
if (windowLeft <= screenLeft)
|
||||
{
|
||||
HideAnimation(windowLeft, screenLeft - windowWidth + showMarginWidth, Window.LeftProperty);
|
||||
IS_HIDE = true;
|
||||
FadeAnimation(1, 0);
|
||||
HideAnimation(windowLeft, screenLeft - windowWidth + showMarginWidth, Window.LeftProperty, HideType.LEFT_HIDE);
|
||||
return;
|
||||
}
|
||||
//右侧隐藏条件
|
||||
if (windowLeft + windowWidth + Math.Abs(screenLeft) >= screenWidth)
|
||||
{
|
||||
HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - showMarginWidth, Window.LeftProperty);
|
||||
IS_HIDE = true;
|
||||
FadeAnimation(1, 0);
|
||||
HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - showMarginWidth, Window.LeftProperty, HideType.RIGHT_HIDE);
|
||||
return;
|
||||
}
|
||||
} else if (mouseX >= windowLeft && mouseX <= windowLeft + windowWidth
|
||||
&& mouseY >= windowTop && mouseY <= windowTop + windowHeight)
|
||||
&& mouseY >= windowTop && mouseY <= windowTop + windowHeight && IS_HIDE)
|
||||
{
|
||||
//上方显示
|
||||
if (windowTop <= screenTop - showMarginWidth)
|
||||
{
|
||||
HideAnimation(windowTop, screenTop, Window.TopProperty);
|
||||
IS_HIDE = false;
|
||||
HideAnimation(windowTop, screenTop, Window.TopProperty, HideType.TOP_SHOW);
|
||||
FadeAnimation(0, 1);
|
||||
return;
|
||||
}
|
||||
//左侧显示
|
||||
if (windowLeft <= screenLeft - showMarginWidth)
|
||||
{
|
||||
HideAnimation(windowLeft, screenLeft, Window.LeftProperty);
|
||||
IS_HIDE = false;
|
||||
HideAnimation(windowLeft, screenLeft, Window.LeftProperty, HideType.LEFT_SHOW);
|
||||
FadeAnimation(0, 1);
|
||||
return;
|
||||
}
|
||||
//右侧显示
|
||||
if (windowLeft + Math.Abs(screenLeft) == screenWidth - showMarginWidth)
|
||||
{
|
||||
HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - windowWidth, Window.LeftProperty);
|
||||
IS_HIDE = false;
|
||||
HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - windowWidth, Window.LeftProperty, HideType.RIGHT_SHOW);
|
||||
FadeAnimation(0, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -136,58 +155,83 @@ namespace GeekDesk.Util
|
||||
#endregion
|
||||
|
||||
|
||||
public void TimerSet()
|
||||
public static void StartHide()
|
||||
{
|
||||
if (timer != null) return;
|
||||
timer = new Timer();//添加timer计时器,隐藏功能
|
||||
#region 计时器设置,隐藏功能
|
||||
timer.Interval = taskTime;
|
||||
timer.Tick += TimerDealy;
|
||||
timer.Start();
|
||||
#endregion
|
||||
IS_RUN = true;
|
||||
}
|
||||
|
||||
public void TimerStop()
|
||||
public static void StopHide()
|
||||
{
|
||||
timer.Stop();
|
||||
timer.Dispose();
|
||||
timer = null;
|
||||
IS_RUN = false;
|
||||
//功能关闭 如果界面是隐藏状态 那么要显示界面 ↓
|
||||
|
||||
double screenLeft = SystemParameters.VirtualScreenLeft;
|
||||
double screenTop = SystemParameters.VirtualScreenTop;
|
||||
double screenWidth = SystemParameters.VirtualScreenWidth;
|
||||
|
||||
double windowWidth = window.Width;
|
||||
|
||||
double windowTop = window.Top;
|
||||
double windowLeft = window.Left;
|
||||
|
||||
//左侧显示
|
||||
if (windowLeft <= screenLeft - showMarginWidth)
|
||||
if (IS_HIDE)
|
||||
{
|
||||
HideAnimation(windowLeft, screenLeft, Window.LeftProperty);
|
||||
return;
|
||||
}
|
||||
double screenLeft = SystemParameters.VirtualScreenLeft;
|
||||
double screenTop = SystemParameters.VirtualScreenTop;
|
||||
double screenWidth = SystemParameters.VirtualScreenWidth;
|
||||
|
||||
//上方显示
|
||||
if (windowTop <= screenTop - showMarginWidth)
|
||||
{
|
||||
HideAnimation(windowTop, screenTop, Window.TopProperty);
|
||||
return;
|
||||
}
|
||||
double windowWidth = window.Width;
|
||||
|
||||
//右侧显示
|
||||
if (windowLeft + Math.Abs(screenLeft) == screenWidth - showMarginWidth)
|
||||
{
|
||||
HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - windowWidth, Window.LeftProperty);
|
||||
return;
|
||||
double windowTop = window.Top;
|
||||
double windowLeft = window.Left;
|
||||
|
||||
//左侧显示
|
||||
if (windowLeft <= screenLeft - showMarginWidth)
|
||||
{
|
||||
IS_HIDE = false;
|
||||
FadeAnimation(0, 1);
|
||||
HideAnimation(windowLeft, screenLeft, Window.LeftProperty, HideType.LEFT_SHOW);
|
||||
return;
|
||||
}
|
||||
|
||||
//上方显示
|
||||
if (windowTop <= screenTop - showMarginWidth)
|
||||
{
|
||||
IS_HIDE = false;
|
||||
FadeAnimation(0, 1);
|
||||
HideAnimation(windowTop, screenTop, Window.TopProperty, HideType.TOP_SHOW);
|
||||
return;
|
||||
}
|
||||
|
||||
//右侧显示
|
||||
if (windowLeft + Math.Abs(screenLeft) == screenWidth - showMarginWidth)
|
||||
{
|
||||
IS_HIDE = false;
|
||||
FadeAnimation(0, 1);
|
||||
HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - windowWidth, Window.LeftProperty, HideType.RIGHT_SHOW);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void HideAnimation(double from, double to, DependencyProperty property)
|
||||
private static void HideAnimation(double from, double to, DependencyProperty property, HideType hideType)
|
||||
{
|
||||
|
||||
double toTemp = to;
|
||||
double leftT = window.Width / 4 * 3;
|
||||
double topT = window.Height / 4 * 3;
|
||||
switch (hideType)
|
||||
{
|
||||
case HideType.LEFT_HIDE:
|
||||
to += leftT;
|
||||
break;
|
||||
case HideType.LEFT_SHOW:
|
||||
to -= leftT;
|
||||
break;
|
||||
case HideType.RIGHT_HIDE:
|
||||
to -= leftT;
|
||||
break;
|
||||
case HideType.RIGHT_SHOW:
|
||||
to += leftT;
|
||||
break;
|
||||
case HideType.TOP_HIDE:
|
||||
to += topT;
|
||||
break;
|
||||
case HideType.TOP_SHOW:
|
||||
to -= topT;
|
||||
break;
|
||||
}
|
||||
DoubleAnimation da = new DoubleAnimation
|
||||
{
|
||||
From = from,
|
||||
@@ -196,11 +240,47 @@ namespace GeekDesk.Util
|
||||
};
|
||||
da.Completed += (s, e) =>
|
||||
{
|
||||
if ("Top".Equals(property.Name))
|
||||
{
|
||||
window.Top = toTemp;
|
||||
}
|
||||
else
|
||||
{
|
||||
window.Left = toTemp;
|
||||
}
|
||||
window.BeginAnimation(property, null);
|
||||
};
|
||||
|
||||
Timeline.SetDesiredFrameRate(da, 60);
|
||||
window.BeginAnimation(property, da);
|
||||
}
|
||||
|
||||
private static void FadeAnimation(double from, double to)
|
||||
{
|
||||
double time;
|
||||
if (to == 0D)
|
||||
{
|
||||
time = fadeHideTime;
|
||||
} else
|
||||
{
|
||||
time = fadeShowTime;
|
||||
}
|
||||
DoubleAnimation opacityAnimation = new DoubleAnimation
|
||||
{
|
||||
From = from,
|
||||
To = to,
|
||||
Duration = new Duration(TimeSpan.FromMilliseconds(time))
|
||||
};
|
||||
opacityAnimation.Completed += (s, e) =>
|
||||
{
|
||||
//window.Opacity = to;
|
||||
window.BeginAnimation(Window.OpacityProperty, null);
|
||||
};
|
||||
Timeline.SetDesiredFrameRate(opacityAnimation, 60);
|
||||
window.BeginAnimation(Window.OpacityProperty, opacityAnimation);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace GeekDesk.Util
|
||||
catch (Exception ex)
|
||||
#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过
|
||||
{
|
||||
LogUtil.WriteErrorLog(ex, "注册启动Error1!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -66,6 +67,7 @@ namespace GeekDesk.Util
|
||||
catch (Exception ex)
|
||||
#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过
|
||||
{
|
||||
LogUtil.WriteErrorLog(ex, "注册启动Error2!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -79,6 +81,7 @@ namespace GeekDesk.Util
|
||||
{
|
||||
key.Close();
|
||||
}
|
||||
LogUtil.WriteErrorLog(ex, "注册启动Error3!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace GeekDesk.Util
|
||||
double left = SystemParameters.VirtualScreenLeft;
|
||||
double top = SystemParameters.VirtualScreenTop;
|
||||
double width = SystemParameters.VirtualScreenWidth;
|
||||
double height = SystemParameters.VirtualScreenHeight;
|
||||
double height = SystemParameters.WorkArea.Height + 20; // 不遮挡任务栏
|
||||
double right = width - Math.Abs(left);
|
||||
double bottom = height - Math.Abs(top);
|
||||
|
||||
@@ -36,7 +36,6 @@ namespace GeekDesk.Util
|
||||
|
||||
switch (position)
|
||||
{
|
||||
|
||||
case MousePosition.LEFT_BOTTOM:
|
||||
afterWidth = 0;
|
||||
afterHeight = window.Height;
|
||||
|
||||
@@ -21,14 +21,17 @@ namespace GeekDesk.Util
|
||||
string svgPath = "/GeekDesk;component/Resource/Iconfont/iconfont.js";
|
||||
string jsonPath = "/GeekDesk;component/Resource/Iconfont/iconfont.json";
|
||||
|
||||
Stream svgStream = Application.GetResourceStream(new Uri(svgPath, UriKind.Relative)).Stream;
|
||||
Stream jsonStream = Application.GetResourceStream(new Uri(jsonPath, UriKind.Relative)).Stream;
|
||||
|
||||
StreamReader streamReader = new StreamReader(svgStream);
|
||||
string svgJsStr = streamReader.ReadToEnd();
|
||||
JObject jo = ReadJson(jsonStream);
|
||||
|
||||
return GetIconfonts(svgJsStr, jo);
|
||||
using (Stream svgStream = Application.GetResourceStream(new Uri(svgPath, UriKind.Relative)).Stream,
|
||||
jsonStream = Application.GetResourceStream(new Uri(jsonPath, UriKind.Relative)).Stream)
|
||||
{
|
||||
using (StreamReader streamReader = new StreamReader(svgStream))
|
||||
{
|
||||
string svgJsStr = streamReader.ReadToEnd();
|
||||
JObject jo = ReadJson(jsonStream);
|
||||
return GetIconfonts(svgJsStr, jo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static List<IconfontInfo> GetIconfonts(string svgJsStr, string jsonStr)
|
||||
|
||||
34
Util/SystemIcon.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class SystemIcon
|
||||
{
|
||||
[DllImport("Shell32.dll")]
|
||||
public static extern int ExtractIcon(IntPtr h, string strx, int ii);
|
||||
|
||||
public static Icon MyExtractIcon(string FileName, int iIndex, IntPtr h)
|
||||
{
|
||||
try
|
||||
{
|
||||
IntPtr hIcon = (IntPtr)ExtractIcon(h, FileName, iIndex);
|
||||
if (!hIcon.Equals(null))
|
||||
{
|
||||
Icon icon = Icon.FromHandle(hIcon);
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Util;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
@@ -70,7 +71,22 @@ namespace GeekDesk.ViewModel
|
||||
|
||||
private bool showBarIcon = true; //显示托盘图标 默认显示
|
||||
|
||||
private bool doubleOpen = false; //双击打开项目 默认关闭
|
||||
|
||||
#region GetSet
|
||||
public bool DoubleOpen
|
||||
{
|
||||
get
|
||||
{
|
||||
return doubleOpen;
|
||||
}
|
||||
set
|
||||
{
|
||||
doubleOpen = value;
|
||||
OnPropertyChanged("DoubleOpen");
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowBarIcon
|
||||
{
|
||||
get
|
||||
@@ -707,5 +723,9 @@ namespace GeekDesk.ViewModel
|
||||
|
||||
#endregion
|
||||
|
||||
public override String ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using GeekDesk.Util;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -84,6 +85,11 @@ namespace GeekDesk.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public override String ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
|
||||
[field: NonSerializedAttribute()]
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Util;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
/// <summary>
|
||||
@@ -22,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
|
||||
@@ -53,6 +106,18 @@ namespace GeekDesk.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] DefaultImage_NoWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultImage;
|
||||
}
|
||||
set
|
||||
{
|
||||
defaultImage = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool AdminStartUp
|
||||
{
|
||||
get
|
||||
@@ -75,7 +140,13 @@ namespace GeekDesk.ViewModel
|
||||
set
|
||||
{
|
||||
count = value;
|
||||
Content = Path + "\n" + Name + "\n使用次数: " + Count;
|
||||
if (StringUtil.IsEmpty(Path))
|
||||
{
|
||||
Content = Name + "\n使用次数: " + Count;
|
||||
} else
|
||||
{
|
||||
Content = Path + "\n" + Name + "\n使用次数: " + Count;
|
||||
}
|
||||
OnPropertyChanged("Count");
|
||||
}
|
||||
}
|
||||
@@ -89,11 +160,30 @@ namespace GeekDesk.ViewModel
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
Content = Path + "\n" + Name + "\n使用次数: " + Count;
|
||||
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
|
||||
@@ -103,11 +193,31 @@ namespace GeekDesk.ViewModel
|
||||
set
|
||||
{
|
||||
path = value;
|
||||
Content = Path + "\n" + Name + "\n使用次数: " + Count;
|
||||
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
|
||||
@@ -123,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
|
||||
@@ -137,6 +261,19 @@ namespace GeekDesk.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] ImageByteArr_NoWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return imageByteArr;
|
||||
}
|
||||
set
|
||||
{
|
||||
imageByteArr = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Content
|
||||
{
|
||||
get
|
||||
@@ -150,10 +287,18 @@ namespace GeekDesk.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public string Content_NoWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
return content;
|
||||
}
|
||||
set
|
||||
{
|
||||
content = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[field: NonSerializedAttribute()]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -36,5 +37,11 @@ namespace GeekDesk.ViewModel
|
||||
name = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override String ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Util;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
@@ -17,11 +18,23 @@ namespace GeekDesk.ViewModel
|
||||
private string menuId;
|
||||
private Visibility menuEdit = Visibility.Collapsed;
|
||||
private Visibility notMenuEdit = Visibility.Visible;
|
||||
private bool isEdit = false;
|
||||
private string menuGeometry; //菜单几何图标
|
||||
private string geometryColor; //几何图标颜色
|
||||
private ObservableCollection<IconInfo> iconList = new ObservableCollection<IconInfo>();
|
||||
|
||||
|
||||
public bool IsEdit
|
||||
{
|
||||
get
|
||||
{
|
||||
return isEdit;
|
||||
}
|
||||
set
|
||||
{
|
||||
isEdit = value;
|
||||
OnPropertyChanged("IsEdit");
|
||||
}
|
||||
}
|
||||
public string MenuGeometry
|
||||
{
|
||||
get
|
||||
@@ -93,9 +106,11 @@ namespace GeekDesk.ViewModel
|
||||
menuEdit = value;
|
||||
if (menuEdit == Visibility.Visible)
|
||||
{
|
||||
IsEdit = true;
|
||||
NotMenuEdit = Visibility.Collapsed;
|
||||
} else
|
||||
{
|
||||
IsEdit = false;
|
||||
NotMenuEdit = Visibility.Visible;
|
||||
}
|
||||
OnPropertyChanged("MenuEdit");
|
||||
@@ -128,6 +143,11 @@ namespace GeekDesk.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public override String ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
|
||||
[field: NonSerializedAttribute()]
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Util;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -129,7 +130,10 @@ namespace GeekDesk.ViewModel
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
public override String ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
|
||||
|
||||
[field: NonSerializedAttribute()]
|
||||
|
||||