🎉 增加了相对路径
This commit is contained in:
@@ -61,7 +61,7 @@
|
||||
<add key="GiteeUpdateUrl" value="https://gitee.com/BookerLiu/GeekDesk/raw/master/Update.json" />
|
||||
<!--<add key="GiteeUpdateUrl" value="file:///C:/Users/Fei/Desktop/GeekDesk/Update.json" />-->
|
||||
<add key="ClientSettingsProvider.ServiceUri" value="" />
|
||||
<add key="CustomIconTeachUrl" value="https://mp.weixin.qq.com/s/LxoHAekho9HBVl4FRw_Law" />
|
||||
<add key="CustomIconTeachUrl" value="https://mp.weixin.qq.com/s/LxoHAekho9HBVl4FRw_Law" />
|
||||
</appSettings>
|
||||
<system.web>
|
||||
<membership defaultProvider="ClientAuthenticationMembershipProvider">
|
||||
|
||||
@@ -257,6 +257,7 @@
|
||||
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.Drag.cs" />
|
||||
<Compile Include="Converts\HideTypeConvert.cs" />
|
||||
<Compile Include="Interface\IWindowCommon.cs" />
|
||||
<Compile Include="MyThread\RelativePathThread.cs" />
|
||||
<Compile Include="Task\ToDoTask.cs" />
|
||||
<Compile Include="MyThread\MouseHookThread.cs" />
|
||||
<Compile Include="MyThread\DispatcherBuild.cs" />
|
||||
|
||||
@@ -227,13 +227,11 @@ namespace GeekDesk
|
||||
//更新线程开启 检测更新
|
||||
UpdateThread.Update();
|
||||
|
||||
//自动备份一次数据
|
||||
appData.AppConfig.SysBakTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
CommonCode.SaveAppData(appData, Constants.DATA_FILE_BAK_PATH);
|
||||
//建立相对路径
|
||||
RelativePathThread.MakeRelativePath();
|
||||
|
||||
//毛玻璃 暂时未解决阴影问题
|
||||
//BlurGlassUtil.EnableBlur(this);
|
||||
AeroGlassUtil.GlassWindow(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
39
MyThread/RelativePathThread.cs
Normal file
39
MyThread/RelativePathThread.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.MyThread
|
||||
{
|
||||
public class RelativePathThread
|
||||
{
|
||||
public static void MakeRelativePath()
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
|
||||
ObservableCollection<MenuInfo> menuList = MainWindow.appData.MenuList;
|
||||
|
||||
string myExePath = Constants.APP_DIR + "GeekDesk.exe";
|
||||
foreach (MenuInfo mi in menuList)
|
||||
{
|
||||
ObservableCollection<IconInfo> iconList = mi.IconList;
|
||||
foreach (IconInfo icon in iconList)
|
||||
{
|
||||
icon.RelativePath_NoWrite = FileUtil.MakeRelativePath(myExePath, icon.Path);
|
||||
}
|
||||
}
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_BAK_PATH);
|
||||
}).Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,6 +94,7 @@ namespace GeekDesk.Util
|
||||
/// <param name="appData"></param>
|
||||
public static void SaveAppData(AppData appData, string filePath)
|
||||
{
|
||||
appData.AppConfig.SysBakTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
if (!Directory.Exists(filePath.Substring(0, filePath.LastIndexOf("\\"))))
|
||||
{
|
||||
Directory.CreateDirectory(filePath.Substring(0, filePath.LastIndexOf("\\")));
|
||||
@@ -161,7 +162,7 @@ namespace GeekDesk.Util
|
||||
// ext = System.IO.Path.GetExtension(path).ToLower();
|
||||
//}
|
||||
|
||||
string iconPath = null;
|
||||
string iconPath;
|
||||
//if (".lnk".Equals(ext))
|
||||
//{
|
||||
|
||||
@@ -180,17 +181,18 @@ namespace GeekDesk.Util
|
||||
BitmapImage bi = ImageUtil.GetBitmapIconByPath(iconPath);
|
||||
IconInfo iconInfo = new IconInfo
|
||||
{
|
||||
Path = path,
|
||||
LnkPath = tempPath,
|
||||
BitmapImage = bi,
|
||||
StartArg = FileUtil.GetArgByLnk(tempPath)
|
||||
Path_NoWrite = path,
|
||||
LnkPath_NoWrite = tempPath,
|
||||
BitmapImage_NoWrite = bi,
|
||||
StartArg_NoWrite = FileUtil.GetArgByLnk(tempPath)
|
||||
};
|
||||
iconInfo.DefaultImage = iconInfo.ImageByteArr;
|
||||
iconInfo.Name = System.IO.Path.GetFileNameWithoutExtension(tempPath);
|
||||
iconInfo.DefaultImage_NoWrite = iconInfo.ImageByteArr;
|
||||
iconInfo.Name_NoWrite = System.IO.Path.GetFileNameWithoutExtension(tempPath);
|
||||
if (StringUtil.IsEmpty(iconInfo.Name))
|
||||
{
|
||||
iconInfo.Name = path;
|
||||
iconInfo.Name_NoWrite = path;
|
||||
}
|
||||
iconInfo.RelativePath_NoWrite = FileUtil.MakeRelativePath(Constants.APP_DIR + "GeekDesk.exe", iconInfo.Path);
|
||||
return iconInfo;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using IWshRuntimeLibrary;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -156,5 +157,26 @@ namespace GeekDesk.Util
|
||||
}
|
||||
}
|
||||
|
||||
public static String MakeRelativePath(String fromPath, String toPath)
|
||||
{
|
||||
if (String.IsNullOrEmpty(fromPath)) throw new ArgumentNullException("fromPath");
|
||||
if (String.IsNullOrEmpty(toPath)) throw new ArgumentNullException("toPath");
|
||||
|
||||
Uri fromUri = new Uri(fromPath);
|
||||
Uri toUri = new Uri(toPath);
|
||||
|
||||
if (fromUri.Scheme != toUri.Scheme) { return toPath; } // path can't be made relative.
|
||||
|
||||
Uri relativeUri = fromUri.MakeRelativeUri(toUri);
|
||||
String relativePath = Uri.UnescapeDataString(relativeUri.ToString());
|
||||
|
||||
if (toUri.Scheme.Equals("file", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
relativePath = relativePath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
|
||||
}
|
||||
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,36 @@ namespace GeekDesk.ViewModel
|
||||
private string startArg; //启动参数
|
||||
private string lnkPath;
|
||||
|
||||
private string relativePath; //相对路径
|
||||
|
||||
private IconType iconType = IconType.OTHER;
|
||||
|
||||
|
||||
public string RelativePath_NoWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
return relativePath;
|
||||
}
|
||||
set
|
||||
{
|
||||
relativePath = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string RelativePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return relativePath;
|
||||
}
|
||||
set
|
||||
{
|
||||
relativePath = value;
|
||||
OnPropertyChanged("RelativePath");
|
||||
}
|
||||
}
|
||||
|
||||
public string LnkPath_NoWrite
|
||||
{
|
||||
get
|
||||
|
||||
Reference in New Issue
Block a user