Skip to content

Commit

Permalink
Finish task and publish 1.2.1002.0 version
Browse files Browse the repository at this point in the history
Finish task and publish 1.2.1002.0 version
  • Loading branch information
Gaoyifei1011 committed Oct 2, 2023
1 parent 57a6a1e commit 7507fc8
Show file tree
Hide file tree
Showing 12 changed files with 372 additions and 91 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<!--从兼容性考虑,继续向上搜索 Directory.Build.props-->
<PropertyGroup>
<NoWarn>CS0169;CS0649;IDE0017;IDE0044;IDE0060;IDE0090;NU1701;NU1702</NoWarn>
<NoWarn>C4100;CS0169;CS0649;IDE0017;IDE0044;IDE0060;IDE0090;NU1701;NU1702</NoWarn>
<DirectoryBuildPropsPath>$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))</DirectoryBuildPropsPath>
</PropertyGroup>
<Import Project="$(DirectoryBuildPropsPath)" Condition="'$(DirectoryBuildPropsPath)' != ''" />
Expand Down
14 changes: 14 additions & 0 deletions FileRenamer/Helpers/Root/IOHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System.Text;

namespace FileRenamer.Helpers.Root
{
Expand All @@ -19,5 +20,18 @@ public static bool IsDir(string filepath)
return false;
}
}

/// <summary>
/// 过滤不合法的文件路径字符
/// </summary>
public static string FilterInvalidPathChars(string path)
{
StringBuilder titleBuilder = new StringBuilder(path);
foreach (char rInvalidChar in Path.GetInvalidPathChars())
{
titleBuilder = titleBuilder.Replace(rInvalidChar.ToString(), string.Empty);
}
return titleBuilder.ToString();
}
}
}
9 changes: 8 additions & 1 deletion FileRenamer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ public static void Main(string[] args)
{
if (args[0] is "FileName" || args[0] is "ExtensionName" || args[0] is "UpperAndLowerCase" || args[0] is "FileProperties")
{
CheckProcessState(args[0]);
if (args.Length is 1)
{
CheckProcessState(args[0]);
}
else if (args.Length is 2)
{
CheckProcessState(string.Format("{0} {1}", args[0], args[1]));
}
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions FileRenamer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
// 程序集信息设置
[assembly: AssemblyCopyright("Copyright ©2023 高怡飞, All Rights Reserved.")]
[assembly: AssemblyDescription("文件重命名工具")]
[assembly: AssemblyFileVersion("1.1.1002.0")]
[assembly: AssemblyInformationalVersion("1.1.1002.0")]
[assembly: AssemblyFileVersion("1.2.1002.0")]
[assembly: AssemblyInformationalVersion("1.2.1002.0")]
[assembly: AssemblyProduct("文件重命名工具")]
[assembly: AssemblyTitle("文件重命名工具")]
[assembly: AssemblyVersion("1.1.1002.0")]
[assembly: AssemblyVersion("1.2.1002.0")]

// 设置程序集对COM组件的访问权限
[assembly: ComVisible(false)]

// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("29636fb7-743c-426a-8715-a91f32d2d04a")]
[assembly: Guid("29636FB7-743C-426A-8715-A91F32D2D04A")]
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using FileRenamer.Extensions.DataType.Constant;
using FileRenamer.Services.Root;
using System;
using System.Diagnostics;

namespace FileRenamer.Services.Controls.Settings
{
Expand Down
191 changes: 179 additions & 12 deletions FileRenamer/Views/Forms/MainForm.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using FileReanmer.WindowsAPI.PInvoke.User32;
using FileRenamer.Helpers.Controls;
using FileRenamer.Helpers.Root;
using FileRenamer.Models;
using FileRenamer.Services.Controls.Settings;
using FileRenamer.Services.Window;
using FileRenamer.Strings;
Expand All @@ -17,7 +18,10 @@
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms;
using Windows.UI;
using Windows.UI.Xaml;
Expand Down Expand Up @@ -200,11 +204,11 @@ private void OnActualThemeChanged(FrameworkElement sender, object args)
{
if (sender.ActualTheme is ElementTheme.Light)
{
MainPage.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 243, 243, 243));
MainPage.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 240, 243, 249));
}
else
{
MainPage.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 32, 32, 32));
MainPage.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 20, 20, 20));
}
}
}
Expand Down Expand Up @@ -256,21 +260,184 @@ protected override void WndProc(ref Message m)
await ContentDialogHelper.ShowAsync(new AppRunningDialog(), MainPage);
});
}
else if (copyDataStruct.lpData is "FileName")
else if (copyDataStruct.lpData.Contains("FileName"))
{
NavigationService.NavigateTo(typeof(FileNamePage));
if (NavigationService.GetCurrentPageType() != typeof(FileNamePage))
{
NavigationService.NavigateTo(typeof(FileNamePage));
}

if (copyDataStruct.lpData.Contains("ShellContextMenu"))
{
FileNamePage fileNamePage = NavigationService.NavigationFrame.Content as FileNamePage;

if (fileNamePage is not null)
{
Task.Run(() =>
{
try
{
if (File.Exists(Program.TempFilePath))
{
string tempFileText = File.ReadAllText(Program.TempFilePath);
File.Delete(Program.TempFilePath);

string[] fileNamePathList = tempFileText.Split('\n').Where(item => !string.IsNullOrWhiteSpace(item)).ToArray();

foreach (string fileNamePath in fileNamePathList)
{
string fileName = IOHelper.FilterInvalidPathChars(fileNamePath);

BeginInvoke(() =>
{
fileNamePage.FileNameDataList.Add(new OldAndNewNameModel()
{
OriginalFileName = Path.GetFileName(fileName),
OriginalFilePath = fileName
});
});
}
}
}
catch (Exception) { }
});
}
}
}
else if (copyDataStruct.lpData is "ExtensionName")
else if (copyDataStruct.lpData.Contains("ExtensionName"))
{
NavigationService.NavigateTo(typeof(ExtensionNamePage));
if (NavigationService.GetCurrentPageType() != typeof(ExtensionNamePage))
{
NavigationService.NavigateTo(typeof(ExtensionNamePage));
}

if (copyDataStruct.lpData.Contains("ShellContextMenu"))
{
ExtensionNamePage extensionNamePage = NavigationService.NavigationFrame.Content as ExtensionNamePage;

if (extensionNamePage is not null)
{
Task.Run(() =>
{
try
{
if (File.Exists(Program.TempFilePath))
{
string tempFileText = File.ReadAllText(Program.TempFilePath);
File.Delete(Program.TempFilePath);

string[] extensionNamePathList = tempFileText.Split('\n').Where(item => !string.IsNullOrEmpty(item)).ToArray();

foreach (string extensionNamePath in extensionNamePathList)
{
string extensionName = IOHelper.FilterInvalidPathChars(extensionNamePath);

if (!IOHelper.IsDir(extensionName))
{
BeginInvoke(() =>
{
extensionNamePage.ExtensionNameDataList.Add(new OldAndNewNameModel()
{
OriginalFileName = Path.GetFileName(extensionName),
OriginalFilePath = extensionName
});
});
}
}
}
}
catch (Exception) { }
});
}
}
}
else if (copyDataStruct.lpData is "UpperAndLowerCase")
else if (copyDataStruct.lpData.Contains("UpperAndLowerCase"))
{
NavigationService.NavigateTo(typeof(UpperAndLowerCasePage));
if (NavigationService.GetCurrentPageType() != typeof(UpperAndLowerCase))
{
NavigationService.NavigateTo(typeof(UpperAndLowerCasePage));
}

if (copyDataStruct.lpData.Contains("ShellContextMenu"))
{
UpperAndLowerCasePage upperAndLowerCasePage = NavigationService.NavigationFrame.Content as UpperAndLowerCasePage;

if (upperAndLowerCasePage is not null)
{
Task.Run(() =>
{
try
{
if (File.Exists(Program.TempFilePath))
{
string tempFileText = File.ReadAllText(Program.TempFilePath);
File.Delete(Program.TempFilePath);

string[] upperAndLowerCasePathList = tempFileText.Split('\n').Where(item => !string.IsNullOrEmpty(item)).ToArray();

foreach (string upperAndLowerCasePath in upperAndLowerCasePathList)
{
string upperAndLowerCase = IOHelper.FilterInvalidPathChars(upperAndLowerCasePath);

BeginInvoke(() =>
{
upperAndLowerCasePage.UpperAndLowerCaseDataList.Add(new OldAndNewNameModel()
{
OriginalFileName = Path.GetFileName(upperAndLowerCase),
OriginalFilePath = upperAndLowerCase
});
});
}
}
}
catch (Exception) { }
});
}
}
}
else if (copyDataStruct.lpData is "FileProperties")
else if (copyDataStruct.lpData.Contains("FileProperties"))
{
NavigationService.NavigateTo(typeof(FilePropertiesPage));
if (NavigationService.GetCurrentPageType() != typeof(FilePropertiesPage))
{
NavigationService.NavigateTo(typeof(FilePropertiesPage));
}

if (copyDataStruct.lpData.Contains("ShellContextMenu"))
{
FilePropertiesPage filePropertiesPage = NavigationService.NavigationFrame.Content as FilePropertiesPage;

if (filePropertiesPage is not null)
{
Task.Run(() =>
{
try
{
if (File.Exists(Program.TempFilePath))
{
string tempFileText = File.ReadAllText(Program.TempFilePath);
File.Delete(Program.TempFilePath);

string[] filePropertiesPathList = tempFileText.Split('\n').Where(item => !string.IsNullOrEmpty(item)).ToArray();

foreach (string filePropertiesPath in filePropertiesPathList)
{
string fileProperties = IOHelper.FilterInvalidPathChars(filePropertiesPath);

BeginInvoke(() =>
{
filePropertiesPage.FilePropertiesDataList.Add(new OldAndNewPropertiesModel()
{
FileName = Path.GetFileName(fileProperties),
FilePath = fileProperties
});
});
}
}
}
catch (Exception) { }
});
}
}
}
break;
};
Expand Down Expand Up @@ -352,11 +519,11 @@ public void SetWindowBackdrop()
DwmApiLibrary.DwmSetWindowAttribute(Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, ref noBackdrop, Marshal.SizeOf(typeof(int)));
if (MainPage.ActualTheme is ElementTheme.Light)
{
MainPage.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 243, 243, 243));
MainPage.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 240, 243, 249));
}
else
{
MainPage.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 32, 32, 32));
MainPage.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 20, 20, 20));
}
}
else if (BackdropService.AppBackdrop.SelectedValue == BackdropService.BackdropList[1].SelectedValue)
Expand Down
Loading

0 comments on commit 7507fc8

Please sign in to comment.