19
App.config
@@ -1,5 +1,21 @@
|
||||
<?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="命令行" />
|
||||
<add key="Services" value="服务" />
|
||||
</SystemIcons>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
@@ -28,12 +44,13 @@
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<appSettings>
|
||||
<add key="Version" value="2.3.21" />
|
||||
<add key="Version" value="2.4.11" />
|
||||
<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">
|
||||
|
||||
59
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);
|
||||
// }
|
||||
// }
|
||||
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
@@ -62,7 +64,8 @@ namespace GeekDesk.Control.Other
|
||||
{
|
||||
Growl.SuccessGlobal("下次任务将在 " + minutes + " 分钟后提醒您!");
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
appData.ToDoList.Remove(info); //执行任务删除
|
||||
appData.HiToDoList.Add(info); //添加历史任务
|
||||
@@ -120,7 +123,7 @@ namespace GeekDesk.Control.Other
|
||||
ToDoInfo info = this.DataContext as ToDoInfo;
|
||||
int time = int.Parse(DelayTime.Text);
|
||||
string type = DelayType.Text;
|
||||
switch(type)
|
||||
switch (type)
|
||||
{
|
||||
case "分":
|
||||
info.ExeTime = DateTime.Now.AddMinutes(time).ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@@ -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;
|
||||
@@ -35,10 +37,18 @@ namespace GeekDesk.Control.Other
|
||||
if (!StringUtil.IsEmpty(IconUrl.Text) && !StringUtil.IsEmpty(JsonUrl.Text))
|
||||
{
|
||||
IconfontWindow.vm.IsSettingUrl = "true";
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
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,11 @@ 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 ex)
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("修改图标失败,已重置为默认图标!");
|
||||
LogUtil.WriteErrorLog(ex, "修改图标失败!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<hc:Shield Subject="Gitee" Visibility="Visible" Status="Demo-liu"
|
||||
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,7 @@
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
|
||||
<CheckBox Content="鼠标中间呼出" Checked="MouseMiddle_Changed" Unchecked="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"/>
|
||||
@@ -51,7 +51,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 DoubleOpen}">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
@@ -61,7 +61,17 @@
|
||||
</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 MarginHide}" Click="MarginHide_Changed">
|
||||
<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 AppAnimation}" Click="Animation_Checked">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
main = true;
|
||||
}
|
||||
|
||||
if (prevKeyTemp == Key.None || prevKeyTemp!=downKey)
|
||||
if (prevKeyTemp == Key.None || prevKeyTemp != downKey)
|
||||
{
|
||||
if (hotkeyFinished)
|
||||
{
|
||||
@@ -71,7 +71,8 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
appConfig.Hotkey = 0;
|
||||
appConfig.HotkeyStr = "";
|
||||
appConfig.HotkeyModifiers = 0;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
appConfig.ToDoHotkey = 0;
|
||||
appConfig.ToDoHotkeyStr = "";
|
||||
@@ -90,7 +91,8 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
{
|
||||
appConfig.HotkeyStr = GetKeyName(downKey);
|
||||
appConfig.HotkeyModifiers = GetModifierKeys(downKey);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
appConfig.ToDoHotkeyStr = GetKeyName(downKey);
|
||||
appConfig.ToDoHotkeyModifiers = GetModifierKeys(downKey);
|
||||
@@ -111,7 +113,8 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
{
|
||||
appConfig.Hotkey = downKey;
|
||||
appConfig.HotkeyStr += downKey.ToString();
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
appConfig.ToDoHotkey = downKey;
|
||||
appConfig.ToDoHotkeyStr += downKey.ToString();
|
||||
@@ -125,7 +128,8 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
{
|
||||
appConfig.HotkeyStr += GetKeyName(downKey);
|
||||
appConfig.HotkeyModifiers |= GetModifierKeys(downKey);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
appConfig.ToDoHotkeyStr += GetKeyName(downKey);
|
||||
appConfig.ToDoHotkeyModifiers |= GetModifierKeys(downKey);
|
||||
@@ -143,7 +147,8 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
if (key == Key.LeftCtrl || key == Key.RightCtrl)
|
||||
{
|
||||
return "Ctrl + ";
|
||||
} else if (key == Key.LWin || key == Key.RWin)
|
||||
}
|
||||
else if (key == Key.LWin || key == Key.RWin)
|
||||
{
|
||||
return "Win + ";
|
||||
}
|
||||
@@ -195,7 +200,7 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
{
|
||||
main = true;
|
||||
}
|
||||
lock(this)
|
||||
lock (this)
|
||||
{
|
||||
bool allKeyUp = true;
|
||||
//判断所有键是否都松开
|
||||
@@ -221,7 +226,8 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
GlobalHotKey.Dispose(MainWindow.hotKeyId);
|
||||
}
|
||||
MainWindow.RegisterHotKey(false);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MainWindow.toDoHotKeyId != -1)
|
||||
{
|
||||
@@ -253,13 +259,11 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
{
|
||||
if (appConfig.MarginHide)
|
||||
{
|
||||
MainWindow.hide.TimerSet();
|
||||
} else
|
||||
{
|
||||
if (MainWindow.hide.timer != null)
|
||||
{
|
||||
MainWindow.hide.TimerStop();
|
||||
MarginHide.StartHide();
|
||||
}
|
||||
else
|
||||
{
|
||||
MarginHide.StopHide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,7 +288,8 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
if (appConfig.MouseMiddleShow)
|
||||
{
|
||||
MouseHookThread.MiddleHook();
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
MouseHookThread.Dispose();
|
||||
}
|
||||
|
||||
@@ -53,8 +53,9 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
appConfig.BacImgName = ofd.FileName;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogUtil.WriteErrorLog(ex, "修改背景失败,已重置为默认背景!");
|
||||
HandyControl.Controls.Growl.WarningGlobal("修改背景失败,已重置为默认背景!");
|
||||
}
|
||||
|
||||
@@ -69,8 +70,9 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
appConfig.BitmapImage = ImageUtil.Base64ToBitmapImage(Constants.DEFAULT_BAC_IMAGE_BASE64);
|
||||
appConfig.BacImgName = "系统默认";
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogUtil.WriteErrorLog(ex, "修改背景失败2,已重置为默认背景!");
|
||||
HandyControl.Controls.Growl.WarningGlobal("修改背景失败,已重置为默认背景!");
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
|
||||
>
|
||||
<UserControl.Resources>
|
||||
<!--右侧栏样式动画-->
|
||||
@@ -48,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"/>
|
||||
@@ -72,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}"/>
|
||||
@@ -99,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,6 +1,7 @@
|
||||
using DraggAnimatedPanelExample;
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Control.Other;
|
||||
using GeekDesk.Control.Windows;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using HandyControl.Controls;
|
||||
@@ -65,6 +66,8 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void IconClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (appData.AppConfig.DoubleOpen && e.ClickCount >= 2)
|
||||
{
|
||||
IconInfo icon = (IconInfo)((SimpleStackPanel)sender).Tag;
|
||||
if (icon.AdminStartUp)
|
||||
@@ -76,6 +79,20 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
|
||||
}
|
||||
}
|
||||
else if (!appData.AppConfig.DoubleOpen && e.ClickCount == 1)
|
||||
{
|
||||
IconInfo icon = (IconInfo)((SimpleStackPanel)sender).Tag;
|
||||
if (icon.AdminStartUp)
|
||||
{
|
||||
StartIconApp(icon, IconStartType.ADMIN_STARTUP);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 管理员方式启动
|
||||
@@ -103,8 +120,21 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
try
|
||||
{
|
||||
Process p = new Process();
|
||||
using (Process p = new Process())
|
||||
{
|
||||
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))
|
||||
@@ -116,7 +146,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
switch (type)
|
||||
{
|
||||
case IconStartType.ADMIN_STARTUP:
|
||||
p.StartInfo.Arguments = "1";//启动参数
|
||||
//p.StartInfo.Arguments = "1";//启动参数
|
||||
p.StartInfo.Verb = "runas";
|
||||
p.StartInfo.CreateNoWindow = false; //设置显示窗口
|
||||
p.StartInfo.UseShellExecute = false;//不使用操作系统外壳程序启动进程
|
||||
@@ -126,7 +156,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (appData.AppConfig.MarginHide)
|
||||
{
|
||||
if (!MainWindow.hide.IsMargin())
|
||||
if (!MarginHide.IS_HIDE)
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
@@ -144,11 +174,12 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (appData.AppConfig.MarginHide)
|
||||
{
|
||||
if (!MainWindow.hide.IsMargin())
|
||||
if (!MarginHide.IS_HIDE)
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
@@ -160,18 +191,119 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (appData.AppConfig.AppHideType == AppHideType.START_EXE)
|
||||
{
|
||||
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
||||
if (appData.AppConfig.MarginHide)
|
||||
{
|
||||
if (!MarginHide.IS_HIDE)
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
using (Process process = new Process())
|
||||
{
|
||||
process.StartInfo.FileName = "cmd.exe";
|
||||
process.StartInfo.Verb = "runas";
|
||||
process.Start();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Process.Start("cmd");
|
||||
}
|
||||
break;
|
||||
case "Services":
|
||||
Process.Start("services.msc");
|
||||
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);
|
||||
@@ -179,35 +311,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
foreach (object obj in dropObject)
|
||||
{
|
||||
string path = (string)obj;
|
||||
|
||||
//string base64 = ImageUtil.FileImageToBase64(path, ImageFormat.Png);
|
||||
string ext = "";
|
||||
if (!ImageUtil.IsSystemItem(path))
|
||||
{
|
||||
ext = System.IO.Path.GetExtension(path).ToLower();
|
||||
}
|
||||
|
||||
if (".lnk".Equals(ext))
|
||||
{
|
||||
string targetPath = FileUtil.GetTargetPathByLnk(path);
|
||||
if (targetPath!=null)
|
||||
{
|
||||
path = targetPath;
|
||||
}
|
||||
}
|
||||
|
||||
BitmapImage bi = ImageUtil.GetBitmapIconByPath(path);
|
||||
IconInfo iconInfo = new IconInfo
|
||||
{
|
||||
Path = path,
|
||||
BitmapImage = bi
|
||||
};
|
||||
iconInfo.DefaultImage = iconInfo.ImageByteArr;
|
||||
iconInfo.Name = System.IO.Path.GetFileNameWithoutExtension(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);
|
||||
}
|
||||
@@ -333,7 +437,8 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
ThreadStart ts = new ThreadStart(crs.Remove);
|
||||
System.Threading.Thread t = new System.Threading.Thread(ts);
|
||||
t.Start();
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
img.BeginAnimation(WidthProperty, null);
|
||||
img.BeginAnimation(HeightProperty, null);
|
||||
@@ -396,10 +501,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"/>
|
||||
|
||||
@@ -95,6 +95,7 @@ namespace GeekDesk.Control.Windows
|
||||
{
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
this.DataContext = null;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace GeekDesk.Control.Windows
|
||||
|
||||
private void Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.DataContext = null;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
@@ -73,13 +74,15 @@ namespace GeekDesk.Control.Windows
|
||||
LoadingEle.Visibility = Visibility.Visible;
|
||||
CustomIcon.Visibility = Visibility.Collapsed;
|
||||
HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig), "IconUrlDialog");
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (customIcons == null)
|
||||
{
|
||||
vm.Iconfonts = null;
|
||||
LoadingOnlineIcon();
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
vm.Iconfonts = customIcons;
|
||||
LoadingEle.Visibility = Visibility.Collapsed;
|
||||
@@ -121,6 +124,7 @@ namespace GeekDesk.Control.Windows
|
||||
}
|
||||
break;
|
||||
}
|
||||
this.DataContext = null;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
@@ -139,7 +143,7 @@ namespace GeekDesk.Control.Windows
|
||||
|
||||
private void CustomButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig));
|
||||
HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig), "IconUrlDialog");
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +152,8 @@ namespace GeekDesk.Control.Windows
|
||||
if (CheckSettingUrl.Text == "true")
|
||||
{
|
||||
LoadingOnlineIcon();
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadingEle.IsRunning = true;
|
||||
CustomIcon.Visibility = Visibility.Collapsed;
|
||||
@@ -168,9 +173,10 @@ namespace GeekDesk.Control.Windows
|
||||
LoadingEle.Visibility = Visibility.Collapsed;
|
||||
CustomIcon.Visibility = Visibility.Visible;
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception e)
|
||||
{
|
||||
HandyControl.Controls.Growl.WarningGlobal("加载远程图标异常!");
|
||||
LogUtil.WriteErrorLog(e, "加载远程图标异常!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,6 +184,7 @@ namespace GeekDesk.Control.Windows
|
||||
{
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
this.DataContext = null;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
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>
|
||||
301
Control/Windows/SystemItemWindow.xaml.cs
Normal file
@@ -0,0 +1,301 @@
|
||||
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 List<IconInfo> systemIcons;
|
||||
private List<IconInfo> startMenuIcons;
|
||||
private 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.DataContext = null;
|
||||
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 filePath, List<IconInfo> listInfos)
|
||||
{
|
||||
DirectoryInfo di = new DirectoryInfo(filePath);
|
||||
string[] filePaths = Directory.GetFiles(filePath);
|
||||
string[] dirPaths = Directory.GetDirectories(filePath);
|
||||
|
||||
string[] paths = new string[filePaths.Length + dirPaths.Length];
|
||||
filePaths.CopyTo(paths, 0);
|
||||
if (filePaths == null || filePaths.Length == 0)
|
||||
{
|
||||
dirPaths.CopyTo(paths, 0);
|
||||
} else
|
||||
{
|
||||
dirPaths.CopyTo(paths, filePaths.Length - 1);
|
||||
}
|
||||
|
||||
foreach (string path in paths)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
//FileSystemInfo[] fileInfoArr = di.GetFileSystemInfos();
|
||||
//foreach(FileSystemInfo fi in fileInfoArr)
|
||||
//{
|
||||
// string path = fi.FullName;
|
||||
|
||||
//}
|
||||
}
|
||||
|
||||
/// <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.DataContext = null;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@
|
||||
<Border.Resources>
|
||||
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
|
||||
<Setter Property="Width" Value="67"/>
|
||||
<Setter Property="Margin" Value="0,5,0,0"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="TextAlignment" Value="Center"/>
|
||||
@@ -67,13 +68,15 @@
|
||||
IsChecked="{Binding ExecType, Mode=OneWay, Converter={StaticResource TodoTaskExecConvert}, ConverterParameter=2}"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel x:Name="SetTimePanel" Visibility="Visible" Spacing="10" Grid.ColumnSpan="4" Margin="0,10,0,0">
|
||||
<hc:UniformSpacingPanel x:Name="SetTimePanel" Height="30" Visibility="Visible" Spacing="10" Grid.ColumnSpan="4" Margin="0,10,0,0">
|
||||
<WrapPanel VerticalAlignment="Center">
|
||||
<TextBlock Text="指定时间:" Style="{StaticResource LeftTB}"/>
|
||||
<TextBlock Text="*" Foreground="Red" Margin="-10,0,0,0"/>
|
||||
<hc:DateTimePicker x:Name="ExeTime" Text="{Binding ExeTime, Mode=OneWay}" ErrorStr="Error!" Width="200" Margin="-5.2,0,0,0"/>
|
||||
<TextBlock Text="*" Foreground="Red"/>
|
||||
</WrapPanel>
|
||||
<hc:DateTimePicker x:Name="ExeTime" Text="{Binding ExeTime, Mode=OneWay}" ErrorStr="Error!" Width="200" Margin="1.6,0,0,0"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<hc:UniformSpacingPanel x:Name="CronPanel" Visibility="Collapsed" Spacing="10" Grid.ColumnSpan="4" Margin="0,10,0,0">
|
||||
<hc:UniformSpacingPanel x:Name="CronPanel" Height="30" Visibility="Collapsed" Spacing="10" Grid.ColumnSpan="4" Margin="0,10,0,0">
|
||||
<WrapPanel VerticalAlignment="Center">
|
||||
<TextBlock Text="CRON:" Style="{StaticResource LeftTB}"/>
|
||||
<TextBlock Text="*" Foreground="Red" />
|
||||
@@ -84,8 +87,10 @@
|
||||
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4" Margin="0,10,0,0">
|
||||
<WrapPanel VerticalAlignment="Center">
|
||||
<TextBlock Text="完成时间:" Style="{StaticResource LeftTB}"/>
|
||||
<TextBlock x:Name="DoneTime" Text="{Binding DoneTime, Mode=OneWay}" Width="200"/>
|
||||
</WrapPanel>
|
||||
<TextBlock x:Name="DoneTime" VerticalAlignment="Center" Margin="5,6,0,0" Text="{Binding DoneTime, Mode=OneWay}" Width="200"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
|
||||
|
||||
@@ -151,7 +151,14 @@ namespace GeekDesk.Control.Windows
|
||||
};
|
||||
if (windowType != NEW_TODO)
|
||||
{
|
||||
appData.HiToDoList.Remove(this.DataContext as ToDoInfo);
|
||||
ToDoInfo tdi = this.DataContext as ToDoInfo;
|
||||
if (appData.HiToDoList.Contains(tdi))
|
||||
{
|
||||
appData.HiToDoList.Remove(tdi);
|
||||
} else if (appData.ToDoList.Contains(tdi))
|
||||
{
|
||||
appData.ToDoList.Remove(tdi);
|
||||
}
|
||||
}
|
||||
appData.ToDoList.Add(info);
|
||||
|
||||
@@ -247,6 +254,7 @@ namespace GeekDesk.Control.Windows
|
||||
{
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
this.DataContext = null;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +102,7 @@ namespace GeekDesk.Control.Windows
|
||||
{
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
this.DataContext = null;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,6 +111,7 @@ namespace GeekDesk.Control.Windows
|
||||
{
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
this.DataContext = null;
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,12 +142,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 +188,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" />
|
||||
@@ -201,6 +208,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" />
|
||||
@@ -235,6 +243,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>
|
||||
@@ -243,6 +255,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>
|
||||
@@ -368,5 +384,20 @@
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resource\Image\SystemIcon\Services.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resource\Image\SystemIcon\Calculator.png" />
|
||||
<Resource Include="Resource\Image\SystemIcon\CMD.png" />
|
||||
<Resource Include="Resource\Image\SystemIcon\Computer.png" />
|
||||
<Resource Include="Resource\Image\SystemIcon\Control.png" />
|
||||
<Resource Include="Resource\Image\SystemIcon\GroupPolicy.png" />
|
||||
<Resource Include="Resource\Image\SystemIcon\Mstsc.png" />
|
||||
<Resource Include="Resource\Image\SystemIcon\Network.png" />
|
||||
<Resource Include="Resource\Image\SystemIcon\Notepad.png" />
|
||||
<Resource Include="Resource\Image\SystemIcon\RecycleBin.png" />
|
||||
<Resource Include="Resource\Image\SystemIcon\Registry.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -11,7 +11,8 @@
|
||||
x:Name="window"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:AppData}"
|
||||
Title="GeekDesk"
|
||||
d:DesignHeight="500" d:DesignWidth="700"
|
||||
MinWidth="600"
|
||||
MinHeight="400"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
@@ -129,7 +130,7 @@
|
||||
<hc:NotifyIcon.ContextMenu>
|
||||
<ContextMenu Width="130">
|
||||
<MenuItem Header="打开面板" Click="ShowApp"/>
|
||||
<MenuItem Header="关闭图标" Click="CloseBarIcon"/>
|
||||
<MenuItem Header="隐藏图标" Click="CloseBarIcon"/>
|
||||
<MenuItem Header="待办" Click="BacklogMenuClick"/>
|
||||
<MenuItem Header="程序目录" Click="OpenThisDir"/>
|
||||
<MenuItem Header="设置" Click="ConfigApp"/>
|
||||
|
||||
@@ -38,7 +38,6 @@ namespace GeekDesk
|
||||
public static int hotKeyId = -1;
|
||||
public static int toDoHotKeyId = -1;
|
||||
public static MainWindow mainWindow;
|
||||
public static MarginHide hide;
|
||||
public MainWindow()
|
||||
{
|
||||
LoadData();
|
||||
@@ -50,10 +49,10 @@ namespace GeekDesk
|
||||
ToDoTask.BackLogCheck();
|
||||
|
||||
////实例化隐藏 Hide类,进行时间timer设置
|
||||
hide = new MarginHide(this);
|
||||
MarginHide.ReadyHide(this);
|
||||
if (appData.AppConfig.MarginHide)
|
||||
{
|
||||
hide.TimerSet();
|
||||
MarginHide.StartHide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,10 +61,11 @@ namespace GeekDesk
|
||||
/// </summary>
|
||||
private void LoadData()
|
||||
{
|
||||
GC.KeepAlive(appData); // 持活
|
||||
this.DataContext = appData;
|
||||
if (appData.MenuList.Count == 0)
|
||||
{
|
||||
appData.MenuList.Add(new MenuInfo() { MenuName = "NewMenu", MenuId = System.Guid.NewGuid().ToString(), MenuEdit = Visibility.Collapsed});
|
||||
appData.MenuList.Add(new MenuInfo() { MenuName = "NewMenu", MenuId = System.Guid.NewGuid().ToString(), MenuEdit = Visibility.Collapsed });
|
||||
}
|
||||
|
||||
this.Width = appData.AppConfig.WindowWidth;
|
||||
@@ -84,11 +84,13 @@ namespace GeekDesk
|
||||
if (appData.AppConfig.AppAnimation)
|
||||
{
|
||||
this.Opacity = 0;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowApp();
|
||||
}
|
||||
@@ -130,7 +132,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();
|
||||
}
|
||||
@@ -160,45 +162,8 @@ namespace GeekDesk
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 淡入淡出效果
|
||||
/// </summary>
|
||||
/// <param name="opacity"></param>
|
||||
/// <param name="milliseconds"></param>
|
||||
/// <param name="visibility"></param>
|
||||
public static void FadeStoryBoard(int opacity, int milliseconds, Visibility visibility)
|
||||
{
|
||||
if (appData.AppConfig.AppAnimation)
|
||||
{
|
||||
DoubleAnimation opacityAnimation = new DoubleAnimation
|
||||
{
|
||||
From = mainWindow.Opacity,
|
||||
To = opacity,
|
||||
Duration = new Duration(TimeSpan.FromMilliseconds(milliseconds))
|
||||
};
|
||||
opacityAnimation.Completed += (s, e) =>
|
||||
{
|
||||
mainWindow.BeginAnimation(OpacityProperty, null);
|
||||
if (visibility == Visibility.Visible)
|
||||
{
|
||||
mainWindow.Opacity = 1;
|
||||
} else
|
||||
{
|
||||
mainWindow.Opacity = 0;
|
||||
}
|
||||
};
|
||||
Timeline.SetDesiredFrameRate(opacityAnimation, 30);
|
||||
mainWindow.BeginAnimation(OpacityProperty, opacityAnimation);
|
||||
} else
|
||||
{
|
||||
//防止关闭动画后 窗体仍是0透明度
|
||||
mainWindow.Opacity = 1;
|
||||
mainWindow.Visibility = visibility;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册新建待办的热键
|
||||
/// </summary>
|
||||
@@ -207,7 +172,7 @@ namespace GeekDesk
|
||||
try
|
||||
{
|
||||
|
||||
if (appData.AppConfig.ToDoHotkeyModifiers!=0)
|
||||
if (appData.AppConfig.ToDoHotkeyModifiers != 0)
|
||||
{
|
||||
//加载完毕注册热键
|
||||
toDoHotKeyId = GlobalHotKey.RegisterHotKey(appData.AppConfig.ToDoHotkeyModifiers, appData.AppConfig.ToDoHotkey, () =>
|
||||
@@ -299,7 +264,8 @@ namespace GeekDesk
|
||||
if (appData.AppConfig.AppAnimation)
|
||||
{
|
||||
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
@@ -335,6 +301,8 @@ namespace GeekDesk
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
//修改贴边隐藏状态为未隐藏
|
||||
MarginHide.IS_HIDE = false;
|
||||
if (appData.AppConfig.FollowMouse)
|
||||
{
|
||||
ShowWindowFollowMouse.Show(mainWindow, MousePosition.CENTER, 0, 0, false);
|
||||
@@ -348,6 +316,45 @@ namespace GeekDesk
|
||||
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 淡入淡出效果
|
||||
/// </summary>
|
||||
/// <param name="opacity"></param>
|
||||
/// <param name="milliseconds"></param>
|
||||
/// <param name="visibility"></param>
|
||||
public static void FadeStoryBoard(int opacity, int milliseconds, Visibility visibility)
|
||||
{
|
||||
if (appData.AppConfig.AppAnimation)
|
||||
{
|
||||
DoubleAnimation opacityAnimation = new DoubleAnimation
|
||||
{
|
||||
From = mainWindow.Opacity,
|
||||
To = opacity,
|
||||
Duration = new Duration(TimeSpan.FromMilliseconds(milliseconds))
|
||||
};
|
||||
opacityAnimation.Completed += (s, e) =>
|
||||
{
|
||||
mainWindow.BeginAnimation(OpacityProperty, null);
|
||||
if (visibility == Visibility.Visible)
|
||||
{
|
||||
mainWindow.Opacity = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
mainWindow.Opacity = 0;
|
||||
}
|
||||
};
|
||||
Timeline.SetDesiredFrameRate(opacityAnimation, 60);
|
||||
mainWindow.BeginAnimation(OpacityProperty, opacityAnimation);
|
||||
}
|
||||
else
|
||||
{
|
||||
//防止关闭动画后 窗体仍是0透明度
|
||||
mainWindow.Opacity = 1;
|
||||
mainWindow.Visibility = visibility;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -392,19 +399,6 @@ namespace GeekDesk
|
||||
p.Start();
|
||||
}
|
||||
|
||||
/// <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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -451,7 +445,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;
|
||||
}
|
||||
@@ -476,17 +470,35 @@ 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>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ReStartApp(object sender, RoutedEventArgs e)
|
||||
{
|
||||
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();
|
||||
|
||||
|
||||
@@ -49,5 +49,5 @@ using System.Windows;
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.3.2.1")]
|
||||
[assembly: AssemblyFileVersion("2.3.2.1")]
|
||||
[assembly: AssemblyVersion("2.4.1.1")]
|
||||
[assembly: AssemblyFileVersion("2.4.1.1")]
|
||||
|
||||
@@ -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>
|
||||
|
||||
<Style x:Key="Btn1" TargetType="Button" BasedOn="{StaticResource ButtonInfo}">
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<LinearGradientBrush Opacity="0.97">
|
||||
<GradientStop Color="#5BC0DE" Offset="0"/>
|
||||
<GradientStop Color="#5BC0DE" Offset="1"/>
|
||||
<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" Value="{StaticResource BtnBG}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="BorderBrush">
|
||||
<Setter.Value>
|
||||
<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 |
BIN
Resource/Image/SystemIcon/Services.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
@@ -59,12 +59,9 @@ namespace GeekDesk.Thread
|
||||
}));
|
||||
}
|
||||
}
|
||||
#pragma warning disable CS0168 // 声明了变量“e”,但从未使用过
|
||||
} catch (Exception e)
|
||||
#pragma warning restore CS0168 // 声明了变量“e”,但从未使用过
|
||||
} catch (Exception ex)
|
||||
{
|
||||
//不做处理
|
||||
//MessageBox.Show(e.Message);
|
||||
LogUtil.WriteErrorLog(ex, "获取更新失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"title": "GeekDesk版本更新",
|
||||
"subTitle": "V2.3.21",
|
||||
"subTitle": "V2.4.11",
|
||||
"msgTitle": "本次更新内容如下",
|
||||
"msg": "['所有窗口可Esc退出','修复一个测试遗留BUG,导致没有D盘的情况下无法添加项目','修复已知问题']",
|
||||
"msg": "['各位兄弟去给我点个免费Star呗','增加添加系统和开始菜单应用功能','增加项目启动参数','优化贴边隐藏动画效果(可能现在并不完美)','增加双击打开功能','修复cron表达式任务无限重启','其它已知问题修复(如果有人发现)']",
|
||||
"githubUrl": "https://github.com/Demo-Liu/GeekDesk/releases",
|
||||
"giteeUrl": "https://gitee.com/demo_liu/GeekDesk/releases",
|
||||
"version": "2.3.21"
|
||||
"version": "2.4.11"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"title": "GeekDesk<73>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD>",
|
||||
"subTitle": "V2.3.21",
|
||||
"msgTitle": "<22><><EFBFBD>θ<EFBFBD><CEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
||||
"msg": "['<27><><EFBFBD>д<EFBFBD><D0B4>ڿ<EFBFBD>Esc<73>˳<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.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
|
||||
|
||||
137
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,152 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,19 +86,38 @@ namespace GeekDesk.Util
|
||||
/// <returns></returns>
|
||||
public static BitmapImage GetBitmapIconByPath(string filePath)
|
||||
{
|
||||
if (filePath.Contains("%windir%"))
|
||||
{
|
||||
filePath = filePath.Replace("%windir%", System.Environment.GetEnvironmentVariable("windir"));
|
||||
}
|
||||
|
||||
if (File.Exists(filePath) || IsSystemItem(filePath))
|
||||
{
|
||||
if (IsImage(filePath)) {
|
||||
if (IsImage(filePath))
|
||||
{
|
||||
//图片
|
||||
return GetThumbnailByFile(filePath, 256, 256);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{ //其它文件
|
||||
return FileIcon.GetBitmapImage(filePath);
|
||||
}
|
||||
} else if(Directory.Exists(filePath)) {
|
||||
}
|
||||
else if (Directory.Exists(filePath))
|
||||
{
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -202,8 +221,9 @@ namespace GeekDesk.Util
|
||||
return bm;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception e)
|
||||
{
|
||||
LogUtil.WriteErrorLog(e, "获取文件缩略图失败!filePath=" + filePath);
|
||||
return Base64ToBitmapImage(Constants.DEFAULT_IMG_IMAGE_BASE64);
|
||||
}
|
||||
|
||||
@@ -302,8 +322,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;
|
||||
}
|
||||
}
|
||||
|
||||
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,59 @@ 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)
|
||||
}
|
||||
else if (mouseX >= windowLeft && mouseX <= windowLeft + windowWidth
|
||||
&& 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,24 +156,17 @@ 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;
|
||||
//功能关闭 如果界面是隐藏状态 那么要显示界面 ↓
|
||||
|
||||
if (IS_HIDE)
|
||||
{
|
||||
double screenLeft = SystemParameters.VirtualScreenLeft;
|
||||
double screenTop = SystemParameters.VirtualScreenTop;
|
||||
double screenWidth = SystemParameters.VirtualScreenWidth;
|
||||
@@ -166,28 +179,60 @@ namespace GeekDesk.Util
|
||||
//左侧显示
|
||||
if (windowLeft <= screenLeft - showMarginWidth)
|
||||
{
|
||||
HideAnimation(windowLeft, screenLeft, Window.LeftProperty);
|
||||
IS_HIDE = false;
|
||||
FadeAnimation(0, 1);
|
||||
HideAnimation(windowLeft, screenLeft, Window.LeftProperty, HideType.LEFT_SHOW);
|
||||
return;
|
||||
}
|
||||
|
||||
//上方显示
|
||||
if (windowTop <= screenTop - showMarginWidth)
|
||||
{
|
||||
HideAnimation(windowTop, screenTop, Window.TopProperty);
|
||||
IS_HIDE = false;
|
||||
FadeAnimation(0, 1);
|
||||
HideAnimation(windowTop, screenTop, Window.TopProperty, HideType.TOP_SHOW);
|
||||
return;
|
||||
}
|
||||
|
||||
//右侧显示
|
||||
if (windowLeft + Math.Abs(screenLeft) == screenWidth - showMarginWidth)
|
||||
{
|
||||
HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - windowWidth, Window.LeftProperty);
|
||||
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 +241,48 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,10 +48,9 @@ namespace GeekDesk.Util
|
||||
key.Close();
|
||||
|
||||
}
|
||||
#pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过
|
||||
catch (Exception ex)
|
||||
#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过
|
||||
{
|
||||
LogUtil.WriteErrorLog(ex, "设置开机/取消失败!started=" + started);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -62,19 +61,17 @@ namespace GeekDesk.Util
|
||||
key.DeleteValue(exeName);//取消开机启动
|
||||
key.Close();
|
||||
}
|
||||
#pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过
|
||||
catch (Exception ex)
|
||||
#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过
|
||||
{
|
||||
LogUtil.WriteErrorLog(ex, "取消开机启动失败!started=" + started);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过
|
||||
catch (Exception ex)
|
||||
#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过
|
||||
{
|
||||
LogUtil.WriteErrorLog(ex, "取消/开机/失败!started=" + started);
|
||||
if (key != null)
|
||||
{
|
||||
key.Close();
|
||||
|
||||
@@ -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
|
||||
@@ -105,7 +121,8 @@ namespace GeekDesk.ViewModel
|
||||
if (imageWidth == 0)
|
||||
{
|
||||
return (int)CommonEnum.IMAGE_WIDTH;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
return imageWidth;
|
||||
}
|
||||
@@ -380,7 +397,8 @@ namespace GeekDesk.ViewModel
|
||||
if (blurEffect)
|
||||
{
|
||||
BlurValue = 100;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
BlurValue = 0;
|
||||
}
|
||||
@@ -552,7 +570,8 @@ namespace GeekDesk.ViewModel
|
||||
bacImgName = "系统默认";
|
||||
//Image image = ImageUtil.ByteArrayToImage(Convert.FromBase64String(Constants.DEFAULT_BAC_IMAGE_BASE64));
|
||||
return ImageUtil.ByteArrToImage(Convert.FromBase64String(Constants.DEFAULT_BAC_IMAGE_BASE64));
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
return ImageUtil.ByteArrToImage(ImageByteArr);
|
||||
}
|
||||
@@ -707,5 +726,9 @@ namespace GeekDesk.ViewModel
|
||||
|
||||
#endregion
|
||||
|
||||
public override String ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,14 @@ namespace GeekDesk.ViewModel
|
||||
set
|
||||
{
|
||||
count = value;
|
||||
if (StringUtil.IsEmpty(Path))
|
||||
{
|
||||
Content = Name + "\n使用次数: " + Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
Content = Path + "\n" + Name + "\n使用次数: " + Count;
|
||||
}
|
||||
OnPropertyChanged("Count");
|
||||
}
|
||||
}
|
||||
@@ -89,11 +161,30 @@ namespace GeekDesk.ViewModel
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
if (StringUtil.IsEmpty(Path))
|
||||
{
|
||||
Content = Name + "\n使用次数: " + Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
Content = Path + "\n" + Name + "\n使用次数: " + Count;
|
||||
}
|
||||
OnPropertyChanged("Name");
|
||||
}
|
||||
}
|
||||
|
||||
public string Name_NoWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
return name;
|
||||
}
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Path
|
||||
{
|
||||
get
|
||||
@@ -103,11 +194,31 @@ namespace GeekDesk.ViewModel
|
||||
set
|
||||
{
|
||||
path = value;
|
||||
if (StringUtil.IsEmpty(Path))
|
||||
{
|
||||
Content = Name + "\n使用次数: " + Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
Content = Path + "\n" + Name + "\n使用次数: " + Count;
|
||||
}
|
||||
OnPropertyChanged("Path");
|
||||
}
|
||||
}
|
||||
|
||||
public string Path_NoWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
return path;
|
||||
}
|
||||
set
|
||||
{
|
||||
path = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public BitmapImage BitmapImage
|
||||
{
|
||||
get
|
||||
@@ -123,6 +234,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 +262,19 @@ namespace GeekDesk.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] ImageByteArr_NoWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return imageByteArr;
|
||||
}
|
||||
set
|
||||
{
|
||||
imageByteArr = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Content
|
||||
{
|
||||
get
|
||||
@@ -151,9 +289,17 @@ namespace GeekDesk.ViewModel
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public string Content_NoWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
return content;
|
||||
}
|
||||
set
|
||||
{
|
||||
content = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[field: NonSerializedAttribute()]
|
||||
|
||||