Explorar el Código

:bug: 修复了某些路径无法建立相对路径导致程序启动崩溃的bug

liufei hace 3 años
padre
commit
001d807bb3
Se han modificado 7 ficheros con 82 adiciones y 26 borrados
  1. 1 1
      App.config
  2. 1 0
      GeekDesk.csproj
  3. 14 13
      MainWindow.xaml.cs
  4. 31 0
      Task/ShowSecondTask.cs
  5. 2 2
      Update.json
  6. 17 10
      Util/FileUtil.cs
  7. 16 0
      ViewModel/IconInfo.cs

+ 1 - 1
App.config

@@ -54,7 +54,7 @@
     </assemblyBinding>
   </runtime>
   <appSettings>
-      <add key="Version" value="2.5.10" />
+      <add key="Version" value="2.5.11" />
       <add key="GitHubUrl" value="https://github.com/BookerLiu/GeekDesk" />
       <add key="GiteeUrl" value="https://gitee.com/BookerLiu/GeekDesk/tree/master" />
       <add key="GitHubUpdateUrl" value="https://raw.githubusercontent.com/BookerLiu/GeekDesk/master/Update.json" />

+ 1 - 0
GeekDesk.csproj

@@ -265,6 +265,7 @@
     <Compile Include="Converts\HideTypeConvert.cs" />
     <Compile Include="Interface\IWindowCommon.cs" />
     <Compile Include="MyThread\RelativePathThread.cs" />
+    <Compile Include="Task\ShowSecondTask.cs" />
     <Compile Include="Task\ToDoTask.cs" />
     <Compile Include="MyThread\MouseHookThread.cs" />
     <Compile Include="MyThread\DispatcherBuild.cs" />

+ 14 - 13
MainWindow.xaml.cs

@@ -185,7 +185,7 @@ namespace GeekDesk
             {
                 ShowApp();
             }
-
+            //ShowSecondTask.SHowSecond();
             //给任务栏图标一个名字
             BarIcon.Text = Constants.MY_NAME;
 
@@ -426,17 +426,6 @@ namespace GeekDesk
             //    return;
             //}
 
-            MainWindow.mainWindow.Activate();
-            mainWindow.Show();
-            //mainWindow.Visibility = Visibility.Visible;
-            if (appData.AppConfig.AppAnimation)
-            {
-                appData.AppConfig.IsShow = true;
-            } else
-            {
-                appData.AppConfig.IsShow = null;
-            }
-
             if (MarginHide.ON_HIDE)
             {
                 //修改贴边隐藏状态为未隐藏
@@ -452,7 +441,19 @@ namespace GeekDesk
             {
                 ShowWindowFollowMouse.Show(mainWindow, MousePosition.CENTER, 0, 0);
             }
-            
+
+            MainWindow.mainWindow.Activate();
+            mainWindow.Show();
+            //mainWindow.Visibility = Visibility.Visible;
+            if (appData.AppConfig.AppAnimation)
+            {
+                appData.AppConfig.IsShow = true;
+            }
+            else
+            {
+                appData.AppConfig.IsShow = null;
+            }
+
 
             //FadeStoryBoard(1, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Visible);
 

+ 31 - 0
Task/ShowSecondTask.cs

@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace GeekDesk.Task
+{
+    internal class ShowSecondTask
+    {
+
+        public static void SHowSecond()
+        {
+            System.Timers.Timer timer = new System.Timers.Timer
+            {
+                Enabled = true,
+                Interval = 5000
+            };
+            timer.Start();
+            timer.Elapsed += Timer_Elapsed;
+        }
+
+        private static void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
+        {
+            Process[] pcArr = Process.GetProcessesByName("ShellExperienceHost.exe");
+            Thread.Sleep(1000);
+        }
+    }
+}

+ 2 - 2
Update.json

@@ -1,9 +1,9 @@
 {
 	"title": "GeekDesk版本更新",
-	"subTitle": "V2.5.10",
+	"subTitle": "V2.5.11",
 	"msgTitle": "本次更新内容如下",
 	"msg": "['依旧耗费了我大量精力开发,希望大家去给我点个免费的Star', '这个版本有一些优化点, 大家可以自行探索, 另外征集新Logo的设计, 要求美观并能体现\\'极客\\'风格','本次重新打包了程序文件(文件目录更清爽了,注意,这次不要使用覆盖升级), 可以将旧版本根目录下的Data文件复制到新版本根目录, 然后使用新版本启动','增加可拖动图标到其它菜单的功能,取消了拖动时的动画','增加了列表展开动画的开关','增加了数据备份功能','优化大部分动画','优化搜索功能(达到了可只用键盘或只用鼠标启动所需目标)','增加了相对路径(实验性,可能有bug)','增加列表加密功能(实验性,可能有bug)','其它已知问题修复']",
 	"githubUrl": "https://github.com/BookerLiu/GeekDesk/releases",
 	"giteeUrl": "https://gitee.com/BookerLiu/GeekDesk/releases",
-	"version": "2.5.10"
+	"version": "2.5.11"
 }

+ 17 - 10
Util/FileUtil.cs

@@ -159,16 +159,23 @@ namespace GeekDesk.Util
 
         public static string MakeRelativePath(string fromPath, string toPath)
         {
-            if (string.IsNullOrEmpty(toPath) || string.IsNullOrEmpty(fromPath)) return null;
-            Uri file = new Uri(@toPath);
-            // Must end in a slash to indicate folder
-            Uri folder = new Uri(@fromPath);
-            string relativePath =
-            Uri.UnescapeDataString(
-                folder.MakeRelativeUri(file)
-                    .ToString()
-                    .Replace('/', Path.DirectorySeparatorChar)
-                );
+            string relativePath = null;
+            try
+            {
+                if (string.IsNullOrEmpty(toPath) || string.IsNullOrEmpty(fromPath)) return null;
+                Uri file = new Uri(@toPath);
+                // Must end in a slash to indicate folder
+                Uri folder = new Uri(@fromPath);
+                relativePath =
+                Uri.UnescapeDataString(
+                    folder.MakeRelativeUri(file)
+                        .ToString()
+                        .Replace('/', Path.DirectorySeparatorChar)
+                    );
+            } catch (Exception ex)
+            {
+                LogUtil.WriteErrorLog(ex, "建立相对路径出错:fromPath:" + fromPath + ",toPath:" + toPath);
+            }
             return relativePath;
         }
 

+ 16 - 0
ViewModel/IconInfo.cs

@@ -205,6 +205,14 @@ namespace GeekDesk.ViewModel
             set
             {
                 name = value;
+                if (StringUtil.IsEmpty(Path))
+                {
+                    content = Name + "\n使用次数: " + Count;
+                }
+                else
+                {
+                    content = Path + "\n" + Name + "\n使用次数: " + Count;
+                }
             }
         }
 
@@ -238,6 +246,14 @@ namespace GeekDesk.ViewModel
             set
             {
                 path = value;
+                if (StringUtil.IsEmpty(Path))
+                {
+                    content = Name + "\n使用次数: " + Count;
+                }
+                else
+                {
+                    content = Path + "\n" + Name + "\n使用次数: " + Count;
+                }
             }
         }