Commit 7d4539bd authored by Rabbit's avatar Rabbit
Browse files

增加存储空间管理的空目录判断

parent 9b9a2658
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ using System.Windows;
//
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
[assembly: AssemblyVersion("1.4.0.*")]
[assembly: AssemblyVersion("1.4.1.*")]

/// <summary>
/// 使用此类前需要把[assembly: ComVisible(false)]改为true
+53 −28
Original line number Diff line number Diff line
@@ -531,6 +531,8 @@ namespace CountDownList.Class

            //扫描进行中
            foreach (Controls.ListLabel item in DoingPanel.Children)
            {
                try
                {
                    string t, st, et, bg, d;

@@ -568,6 +570,29 @@ namespace CountDownList.Class
                        Own = item
                    });
                }
                catch(Exception)
                {
                    System.Diagnostics.Process p = new System.Diagnostics.Process();
                    p.StartInfo.FileName = "cmd.exe";
                    p.StartInfo.UseShellExecute = false;    //是否使用操作系统shell启动
                    p.StartInfo.RedirectStandardInput = true;//接受来自调用程序的输入信息
                    p.StartInfo.RedirectStandardOutput = true;//由调用程序获取输出信息
                    p.StartInfo.RedirectStandardError = true;//重定向标准错误输出
                    p.StartInfo.CreateNoWindow = false;//不显示程序窗口
                    p.Start();//启动程序

                    //向cmd窗口发送输入信息
                    p.StandardInput.WriteLine($"del /f \"{AppDomain.CurrentDomain.BaseDirectory}Data\\CountDownList.xml\"" + "&exit");

                    p.WaitForExit();//等待程序执行完退出进程
                    p.Close();

                    Process.Start(@$"{AppDomain.CurrentDomain.BaseDirectory}CountDownList.exe");
                    Thread.Sleep(500);

                    Application.Current.Shutdown();
                }
            }

            //扫描正计时
            foreach (Controls.ListLabel item in WcPanel.Children)
+1 −1
Original line number Diff line number Diff line
@@ -210,7 +210,7 @@ namespace CountDownList
                Height = MiscSetting.Default.WindowHeight;
            }

            Version.Text = $"CountDownList V{new AssemblyInformation().AssemblyVersion}";
            Version.Text = $"CountdownList V{new AssemblyInformation().AssemblyVersion}";

            //设置窗口背景为透明,为了命中检测
            if (MiscSetting.Default.AutoOpen)
+5 −0
Original line number Diff line number Diff line
@@ -16,6 +16,11 @@

        <local:MyScrollViewer Grid.Row="1" Margin="4" Style="{DynamicResource ScrollViewerBaseStyle}">
            <StackPanel>
                <TextBlock FontSize="18">CountDownList1.4.1更新内容</TextBlock>
                <TextBlock Margin="20,8,0,64">
                    增加存储空间管理的空目录判断,避免在精简安装后打开存储空间管理时崩溃的问题
                </TextBlock>

                <TextBlock FontSize="18">CountDownList1.4.0更新内容</TextBlock>
                <TextBlock Margin="20,8,0,64">
                    主页背景预览设置项
+229 −107
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ namespace CountDownList.UI.WindowFrame
                Size();
                MessageBox.Show("删除成功", Title, MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch
            catch(DirectoryNotFoundException)
            {
                loading.Visibility = Visibility.Collapsed;
                Size();
@@ -81,6 +81,8 @@ namespace CountDownList.UI.WindowFrame
            bool readOnly = false;
            loading.Visibility = Visibility.Visible;
            await Task.Run(() =>
            {
                try
                {
                    string[] files = Directory.GetFiles($@"{AppDomain.CurrentDomain.BaseDirectory}Data\RandomImg\Custom", "*", SearchOption.AllDirectories);
                    foreach (string file in files)
@@ -94,6 +96,14 @@ namespace CountDownList.UI.WindowFrame
                            readOnly = true;
                        }
                    }
                }
                catch (DirectoryNotFoundException)
                {
                    Dispatcher.Invoke(() =>
                    {
                        MessageBox.Show("目录不存在,无需删除", Title, MessageBoxButton.OK, MessageBoxImage.Information);
                    });
                }
            });
            await Task.Delay(250);
            loading.Visibility = Visibility.Collapsed;
@@ -119,6 +129,8 @@ namespace CountDownList.UI.WindowFrame
            bool readOnly = false;
            loading.Visibility = Visibility.Visible;
            await Task.Run(() =>
            {
                try
                {
                    string[] files = Directory.GetFiles($@"{AppDomain.CurrentDomain.BaseDirectory}Data\RandomImg\GenshinNormal", "*", SearchOption.AllDirectories);
                    foreach (string file in files)
@@ -132,6 +144,14 @@ namespace CountDownList.UI.WindowFrame
                            readOnly = true;
                        }
                    }
                }
                catch (DirectoryNotFoundException)
                {
                    Dispatcher.Invoke(() =>
                    {
                        MessageBox.Show("目录不存在,无需删除", Title, MessageBoxButton.OK, MessageBoxImage.Information);
                    });
                }
            });
            await Task.Delay(250);
            loading.Visibility = Visibility.Collapsed;
@@ -156,6 +176,8 @@ namespace CountDownList.UI.WindowFrame
            bool readOnly = false;
            loading.Visibility = Visibility.Visible;
            await Task.Run(() =>
            {
                try
                {
                    string[] files = Directory.GetFiles($@"{AppDomain.CurrentDomain.BaseDirectory}Data\RandomImg\GenshinExtra", "*", SearchOption.AllDirectories);
                    foreach (string file in files)
@@ -169,6 +191,14 @@ namespace CountDownList.UI.WindowFrame
                            readOnly = true;
                        }
                    }
                }
                catch (DirectoryNotFoundException)
                {
                    Dispatcher.Invoke(() =>
                    {
                        MessageBox.Show("目录不存在,无需删除", Title, MessageBoxButton.OK, MessageBoxImage.Information);
                    });
                }
            });
            await Task.Delay(250);
            loading.Visibility = Visibility.Collapsed;
@@ -192,7 +222,9 @@ namespace CountDownList.UI.WindowFrame
        {
            bool readOnly = false;
            loading.Visibility = Visibility.Visible;
            await Task.Run(() =>
            await Task.Run(async () =>
            {
                try
                {
                    string[] files = Directory.GetFiles($@"{AppDomain.CurrentDomain.BaseDirectory}Data\RandomImg\Minecraft", "*", SearchOption.AllDirectories);
                    foreach (string file in files)
@@ -205,6 +237,15 @@ namespace CountDownList.UI.WindowFrame
                        {
                            readOnly = true;
                        }
                        await Task.Delay(5);
                    }
                }
                catch (DirectoryNotFoundException)
                {
                    Dispatcher.Invoke(() =>
                    {
                        MessageBox.Show("目录不存在,无需删除", Title, MessageBoxButton.OK, MessageBoxImage.Information);
                    });
                }
            });
            await Task.Delay(250);
@@ -230,7 +271,9 @@ namespace CountDownList.UI.WindowFrame
        {
            bool readOnly = false;
            loading.Visibility = Visibility.Visible;
            await Task.Run(() =>
            await Task.Run(async () =>
            {
                try
                {
                    string[] files = Directory.GetFiles($@"{AppDomain.CurrentDomain.BaseDirectory}Data\Image", "*", SearchOption.AllDirectories);
                    foreach (string file in files)
@@ -243,6 +286,15 @@ namespace CountDownList.UI.WindowFrame
                        {
                            readOnly = true;
                        }
                        await Task.Delay(5);
                    }
                }
                catch (DirectoryNotFoundException)
                {
                    Dispatcher.Invoke(() =>
                    {
                        MessageBox.Show("目录不存在,无需删除", Title, MessageBoxButton.OK, MessageBoxImage.Information);
                    });
                }
            });
            await Task.Delay(250);
@@ -311,6 +363,7 @@ namespace CountDownList.UI.WindowFrame

        private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            //窗口大小改变时,重新计算大小
            chartWidthPerPoint = sizeBox.ActualWidth / total;
            app.Width = appSize * chartWidthPerPoint;
            rndImg_bg.Width = img * chartWidthPerPoint;
@@ -320,7 +373,6 @@ namespace CountDownList.UI.WindowFrame
            rndImg_mc.Width = mc * chartWidthPerPoint;
            resource.Width = resUi * chartWidthPerPoint;
            rndImg_custom.Width = customSize * chartWidthPerPoint;

        }

        double chartWidthPerPoint = 0;
@@ -385,6 +437,8 @@ namespace CountDownList.UI.WindowFrame
            }

            //GenshinNormal体积
            try
            {
                await Task.Run(() =>
                {
                    string[] files = Directory.GetFiles($@"{AppDomain.CurrentDomain.BaseDirectory}Data\RandomImg\GenshinNormal", "*", SearchOption.AllDirectories);
@@ -394,8 +448,15 @@ namespace CountDownList.UI.WindowFrame
                    }
                });
                rndImg_gsNormal.Width = gsn * chartWidthPerPoint;
            }
            catch (DirectoryNotFoundException)
            {
                rndImg_gsNormal.Width = 0;
            }

            //GenshinExtra体积
            try
            {
                await Task.Run(() =>
                {
                    string[] files = Directory.GetFiles($@"{AppDomain.CurrentDomain.BaseDirectory}Data\RandomImg\GenshinExtra", "*", SearchOption.AllDirectories);
@@ -405,8 +466,15 @@ namespace CountDownList.UI.WindowFrame
                    }
                });
                rndImg_gsExtra.Width = gse * chartWidthPerPoint;
            }
            catch (DirectoryNotFoundException)
            {
                rndImg_gsExtra.Width = 0;
            }

            //Minecraft体积
            try
            {
                await Task.Run(() =>
                {
                    string[] files = Directory.GetFiles($@"{AppDomain.CurrentDomain.BaseDirectory}Data\RandomImg\Minecraft", "*", SearchOption.AllDirectories);
@@ -416,8 +484,15 @@ namespace CountDownList.UI.WindowFrame
                    }
                });
                rndImg_mc.Width = mc * chartWidthPerPoint;
            }
            catch (DirectoryNotFoundException)
            {
                rndImg_mc.Width = 0;
            }

            //UI图片体积
            try
            {
                await Task.Run(() =>
                {
                    resUi += GetDirectoryLength($@"{AppDomain.CurrentDomain.BaseDirectory}UI");
@@ -425,8 +500,15 @@ namespace CountDownList.UI.WindowFrame
                    resUi += GetFileLength($@"{AppDomain.CurrentDomain.BaseDirectory}Data\Sounds\NotifySound.mp3");
                });
                resource.Width = resUi * chartWidthPerPoint;
            }
            catch (DirectoryNotFoundException)
            {
                resource.Width = 0;
            }

            //自定义图片体积
            try
            {
                await Task.Run(() =>
                {
                    string[] files = Directory.GetFiles($@"{AppDomain.CurrentDomain.BaseDirectory}Data\RandomImg\Custom", "*", SearchOption.AllDirectories);
@@ -436,6 +518,11 @@ namespace CountDownList.UI.WindowFrame
                    }
                });
                rndImg_custom.Width = customSize * chartWidthPerPoint;
            }
            catch (DirectoryNotFoundException)
            {
                rndImg_custom.Width = 0;
            }

            appE.Header = $"应用程序({(double)(total) / 1048576d:F2}MB)";
            resE.Header = $"资源文件({(double)(resUi) / 1048576d:F2}MB)";
@@ -517,6 +604,8 @@ namespace CountDownList.UI.WindowFrame
            }

            //GenshinNormal体积
            try
            {
                await Task.Run(() =>
                {
                    string[] files = Directory.GetFiles($@"{AppDomain.CurrentDomain.BaseDirectory}Data\RandomImg\GenshinNormal", "*", SearchOption.AllDirectories);
@@ -526,8 +615,15 @@ namespace CountDownList.UI.WindowFrame
                    }
                });
                rndImg_gsNormal.Width = gsn * chartWidthPerPoint;
            }
            catch (DirectoryNotFoundException)
            {
                rndImg_gsNormal.Width = 0;
            }

            //GenshinExtra体积
            try
            {
                await Task.Run(() =>
                {
                    string[] files = Directory.GetFiles($@"{AppDomain.CurrentDomain.BaseDirectory}Data\RandomImg\GenshinExtra", "*", SearchOption.AllDirectories);
@@ -537,8 +633,15 @@ namespace CountDownList.UI.WindowFrame
                    }
                });
                rndImg_gsExtra.Width = gse * chartWidthPerPoint;
            }
            catch (DirectoryNotFoundException)
            {
                rndImg_gsExtra.Width = 0;
            }

            //Minecraft体积
            try
            {
                await Task.Run(() =>
                {
                    string[] files = Directory.GetFiles($@"{AppDomain.CurrentDomain.BaseDirectory}Data\RandomImg\Minecraft", "*", SearchOption.AllDirectories);
@@ -548,8 +651,15 @@ namespace CountDownList.UI.WindowFrame
                    }
                });
                rndImg_mc.Width = mc * chartWidthPerPoint;
            }
            catch (DirectoryNotFoundException)
            {
                rndImg_mc.Width = 0;
            }

            //UI图片体积
            try
            {
                await Task.Run(() =>
                {
                    resUi += GetDirectoryLength($@"{AppDomain.CurrentDomain.BaseDirectory}UI");
@@ -557,8 +667,15 @@ namespace CountDownList.UI.WindowFrame
                    resUi += GetFileLength($@"{AppDomain.CurrentDomain.BaseDirectory}Data\Sounds\NotifySound.mp3");
                });
                resource.Width = resUi * chartWidthPerPoint;
            }
            catch (DirectoryNotFoundException)
            {
                resource.Width = 0;
            }

            //自定义图片体积
            try
            {
                await Task.Run(() =>
                {
                    string[] files = Directory.GetFiles($@"{AppDomain.CurrentDomain.BaseDirectory}Data\RandomImg\Custom", "*", SearchOption.AllDirectories);
@@ -568,6 +685,11 @@ namespace CountDownList.UI.WindowFrame
                    }
                });
                rndImg_custom.Width = customSize * chartWidthPerPoint;
            }
            catch (DirectoryNotFoundException)
            {
                rndImg_custom.Width = 0;
            }

            appE.Header = $"应用程序({(double)(total) / 1048576d:F2}MB)";
            resE.Header = $"资源文件({(double)(resUi) / 1048576d:F2}MB)";