diff --git a/.gitignore b/.gitignore index d3f28b6..25e5aa4 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,6 @@ node_modules/ *.pfx AppPackages/ -BundleArtifacts/ \ No newline at end of file +BundleArtifacts/ + +*.assets.cache \ No newline at end of file diff --git a/PasteEx.Deploy/PasteEx.Deploy.csproj b/PasteEx.Deploy/PasteEx.Deploy.csproj index 8ad7cca..03e3b9c 100644 --- a/PasteEx.Deploy/PasteEx.Deploy.csproj +++ b/PasteEx.Deploy/PasteEx.Deploy.csproj @@ -1,88 +1,13 @@ - - - + - Debug - AnyCPU - {E351ACDD-645A-47F1-BD2A-51D3EE4E2124} + net8.0-windows Exe - PasteEx.Deploy - PasteEx.Deploy - v4.8 - 512 - true - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - + true + true - - - - - - - - - - - - - - - Form - - - FormMian.cs - - - - - FormMian.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - True - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - + + - \ No newline at end of file diff --git a/PasteEx.Deploy/Properties/AssemblyInfo.cs b/PasteEx.Deploy/Properties/AssemblyInfo.cs deleted file mode 100644 index 971446a..0000000 --- a/PasteEx.Deploy/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// 有关程序集的一般信息由以下 -// 控制。更改这些特性值可修改 -// 与程序集关联的信息。 -[assembly: AssemblyTitle("PasteEx.Deploy")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PasteEx.Deploy")] -[assembly: AssemblyCopyright("Copyright © 2021")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// 将 ComVisible 设置为 false 会使此程序集中的类型 -//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 -//请将此类型的 ComVisible 特性设置为 true。 -[assembly: ComVisible(false)] - -// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID -[assembly: Guid("e351acdd-645a-47f1-bd2a-51d3ee4e2124")] - -// 程序集的版本信息由下列四个值组成: -// -// 主版本 -// 次版本 -// 生成号 -// 修订号 -// -//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 -//通过使用 "*",如下所示: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PasteEx/Core/History/PasteResult.cs b/PasteEx/Core/History/PasteResult.cs index ddcecc4..e1aaaf2 100644 --- a/PasteEx/Core/History/PasteResult.cs +++ b/PasteEx/Core/History/PasteResult.cs @@ -2,7 +2,7 @@ using PasteEx.Util; using System; using System.Diagnostics; -using System.Web.Script.Serialization; +using System.Text.Json.Serialization; namespace PasteEx.Core.History { @@ -17,14 +17,13 @@ public class PasteResult public string[] UserHistoryExts { get; set; } - [ScriptIgnore] + [JsonIgnore] public string Key { get { string str = string.Format("[{0}]-[{1}]-[{2}]", CopySourceName, string.Join(",", ClipboardFormats), string.Join(",", AnalyzeResultExts)); - byte[] b = ObjectHelper.SerializeObject(str); - return ObjectHelper.ComputeMD5(b); + return ObjectHelper.ComputeMD5(str); } } diff --git a/PasteEx/Core/History/PasteResultHistory.cs b/PasteEx/Core/History/PasteResultHistory.cs index 9c519da..a048ee0 100644 --- a/PasteEx/Core/History/PasteResultHistory.cs +++ b/PasteEx/Core/History/PasteResultHistory.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; -using System.Web.Script.Serialization; +using System.Text.Json; +using System.Text.Json.Serialization; namespace PasteEx.Core.History { @@ -14,12 +15,12 @@ public PasteResultHistory() public string ToJSONString() { - return new JavaScriptSerializer().Serialize(this); + return JsonSerializer.Serialize(this); } public static PasteResultHistory Parse(string str) { - return new JavaScriptSerializer().Deserialize(str); + return JsonSerializer.Deserialize(str); } public PasteResult Find(PasteResult res) diff --git a/PasteEx/Forms/FormSetting.cs b/PasteEx/Forms/FormSetting.cs index 3ec1785..18b613c 100644 --- a/PasteEx/Forms/FormSetting.cs +++ b/PasteEx/Forms/FormSetting.cs @@ -5,7 +5,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; -using System.Web.Script.Serialization; +using System.Text.Json; using System.Windows.Forms; using PasteEx.Properties; @@ -311,8 +311,7 @@ private async void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { try { - JavaScriptSerializer serializer = new JavaScriptSerializer(); - AppInfo appInfo = serializer.Deserialize(json); + AppInfo appInfo = JsonSerializer.Deserialize(json); string latestVersion = appInfo.Version; string currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); diff --git a/PasteEx/Forms/Hotkey/HotkeyTextBox.cs b/PasteEx/Forms/Hotkey/HotkeyTextBox.cs index 689d9f5..a58c8d7 100644 --- a/PasteEx/Forms/Hotkey/HotkeyTextBox.cs +++ b/PasteEx/Forms/Hotkey/HotkeyTextBox.cs @@ -27,7 +27,7 @@ public HotkeyTextBox() { hotkey = new Hotkey(); - ContextMenu = new ContextMenu(); // Disable right-clicking + ContextMenuStrip = new ContextMenuStrip(); // Disable right-clicking GotFocus += delegate { User32.HideCaret(Handle); }; } diff --git a/PasteEx/PasteEx.csproj b/PasteEx/PasteEx.csproj index ba00e97..f22c7d8 100644 --- a/PasteEx/PasteEx.csproj +++ b/PasteEx/PasteEx.csproj @@ -1,17 +1,8 @@ - - - + - Debug - AnyCPU - {403DF4F1-6A38-4F91-9381-75CC15ED5C7E} + net8.0-windows WinExe - PasteEx - PasteEx - v4.7.2 - 512 false - publish\ true Disk @@ -28,199 +19,34 @@ false true true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 3 - - + true + true Resources\Image\ico.ico - - LocalIntranet - - true - - Properties\app.manifest - - 73497E3F38CAAA710D6CA8F58F3DF55FCDB8DB7A - - PasteEx_TemporaryKey.pfx - - false + xcopy /s /y zh-CN Language\zh-CN\ +xcopy /s /y zh-Hant Language\zh-Hant\ +rd /s /q zh-CN +rd /s /q zh-Hant + + + 3 - - - - - - - - - - - - - - + + + + - - - - - - - - - - Form - - - FormInfo.cs - - - + Component - - - - - - - - - - Form - - - FormMain.cs - - - Form - - - FormSetting.cs - - - - - True - True - Resources.resx - - - Strings.resx - True - True - - - Strings.zh-Hant.resx - True - True - - - - - - - - - - - - - - - - - - True - True - Strings.zh-CN.resx - - - - - - FormMain.cs - Designer - - - FormMain.cs - - - FormMain.cs - - - FormSetting.cs - Designer - - - FormSetting.cs - Designer - - - FormSetting.cs - Designer - - - FormInfo.cs - - - ResXFileCodeGenerator - Resources1.Designer.cs - - - ResXFileCodeGenerator - Strings.Designer.cs - - - ResXFileCodeGenerator - Strings.zh-Hant.Designer.cs - - - ResXFileCodeGenerator - Strings.zh-CN.Designer.cs - - - - PublicSettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - - Designer - @@ -248,11 +74,4 @@ True - - - xcopy /s /y zh-CN Language\zh-CN\ -xcopy /s /y zh-Hant Language\zh-Hant\ -rd /s /q zh-CN -rd /s /q zh-Hant - \ No newline at end of file diff --git a/PasteEx/Properties/AssemblyInfo.cs b/PasteEx/Properties/AssemblyInfo.cs deleted file mode 100644 index e2ea9e8..0000000 --- a/PasteEx/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// 有关程序集的一般信息由以下 -// 控制。更改这些特性值可修改 -// 与程序集关联的信息。 -[assembly: AssemblyTitle("PasteEx")] -[assembly: AssemblyDescription("Paste As File")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PasteEx")] -[assembly: AssemblyCopyright("Copyright © 2017 - 2022")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// 将 ComVisible 设置为 false 会使此程序集中的类型 -//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 -//请将此类型的 ComVisible 特性设置为 true。 -[assembly: ComVisible(false)] - -// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID -[assembly: Guid("403df4f1-6a38-4f91-9381-75cc15ed5c7e")] - -// 程序集的版本信息由下列四个值组成: -// -// 主版本 -// 次版本 -// 生成号 -// 修订号 -// -// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 -// 方法是按如下所示使用“*”: : -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1.9.1")] -[assembly: AssemblyFileVersion("1.1.9.1")] diff --git a/PasteEx/Util/Logger.cs b/PasteEx/Util/Logger.cs index 844731e..6c94545 100644 --- a/PasteEx/Util/Logger.cs +++ b/PasteEx/Util/Logger.cs @@ -19,7 +19,7 @@ static Logger() } string path = Path.Combine(folder, "PasteEx.log"); - Trace.Listeners.Add(new TextWriterTraceListener(path)); + System.Diagnostics.Trace.Listeners.Add(new TextWriterTraceListener(path)); Trace.AutoFlush = true; } diff --git a/PasteEx/Util/ObjectHelper.cs b/PasteEx/Util/ObjectHelper.cs index 653afd8..6544a35 100644 --- a/PasteEx/Util/ObjectHelper.cs +++ b/PasteEx/Util/ObjectHelper.cs @@ -8,36 +8,6 @@ namespace PasteEx.Util { public class ObjectHelper { - public static byte[] SerializeObject(object obj) - { - if (obj == null) - { - return null; - } - - MemoryStream ms = new MemoryStream(); - BinaryFormatter formatter = new BinaryFormatter(); - formatter.Serialize(ms, obj); - byte[] bytes = ms.GetBuffer(); - return bytes; - } - - public static object DeserializeObject(byte[] bytes) - { - if (bytes == null) - { - return null; - } - - object obj = null; - MemoryStream ms = new MemoryStream(bytes); - ms.Position = 0; - BinaryFormatter formatter = new BinaryFormatter(); - obj = formatter.Deserialize(ms); - ms.Close(); - return obj; - } - public static string ComputeMD5(byte[] bytes) { if (bytes == null) @@ -56,6 +26,10 @@ public static string ComputeMD5(byte[] bytes) return sb.ToString(); } + public static string ComputeMD5(string str) { + return ComputeMD5(Encoding.UTF8.GetBytes(str)); + } + /// /// Can't work. /// @@ -94,35 +68,5 @@ public static string ComputeMD5(object obj) md5 = md5.Replace("-", ""); return md5; } - - /// - /// Perform a deep Copy of the object. - /// - /// The type of object being copied. - /// The object instance to copy. - /// The copied object. - public static T Clone(T source) - { - if (!typeof(T).IsSerializable) - { - throw new ArgumentException("The type must be serializable.", "source"); - } - - // Don't serialize a null object, simply return the default for that object - if (Object.ReferenceEquals(source, null)) - { - return default(T); - } - - BinaryFormatter formatter = new BinaryFormatter(); - Stream stream = new MemoryStream(); - using (stream) - { - formatter.Serialize(stream, source); - stream.Seek(0, SeekOrigin.Begin); - return (T)formatter.Deserialize(stream); - } - } - } }