From 1373c3d70688035af4712d791ad6eff6d038a45c Mon Sep 17 00:00:00 2001 From: Tom <17379620@qq.com> Date: Thu, 14 Nov 2024 11:06:46 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=84=20Beautiful=20AntdUI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/SVGView/Localizer.cs | 64 +++++++++++++++++++ example/SVGView/Main.Designer.cs | 3 + example/SVGView/Main.cs | 4 +- example/SVGView/Program.cs | 6 ++ .../PublishProfiles/FolderProfile.pubxml | 16 +++++ example/SVGView/SVGView.csproj | 20 +++++- example/SVGView/rd.xml | 12 ++++ 7 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 example/SVGView/Localizer.cs create mode 100644 example/SVGView/Properties/PublishProfiles/FolderProfile.pubxml create mode 100644 example/SVGView/rd.xml diff --git a/example/SVGView/Localizer.cs b/example/SVGView/Localizer.cs new file mode 100644 index 0000000..f368f14 --- /dev/null +++ b/example/SVGView/Localizer.cs @@ -0,0 +1,64 @@ +// COPYRIGHT (C) Tom. ALL RIGHTS RESERVED. +// THE AntdUI PROJECT IS AN WINFORM LIBRARY LICENSED UNDER THE Apache-2.0 License. +// LICENSED UNDER THE Apache License, VERSION 2.0 (THE "License") +// YOU MAY NOT USE THIS FILE EXCEPT IN COMPLIANCE WITH THE License. +// YOU MAY OBTAIN A COPY OF THE LICENSE AT +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, SOFTWARE +// DISTRIBUTED UNDER THE LICENSE IS DISTRIBUTED ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +// SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING PERMISSIONS AND +// LIMITATIONS UNDER THE License. +// GITEE: https://gitee.com/antdui/AntdUI +// GITHUB: https://github.com/AntdUI/AntdUI +// CSDN: https://blog.csdn.net/v_132 +// QQ: 17379620 + +namespace SVGView +{ + public class Localizer : AntdUI.ILocalization + { + public string? GetLocalizedString(string key) + { + switch (key) + { + case "ID": + return "en-US"; + + case "Cancel": + return "Cancel"; + case "OK": + return "OK"; + case "Now": + return "Now"; + case "ToDay": + return "Today"; + case "NoData": + return "No data"; + + case "ItemsPerPage": + return "Per/Page"; + + #region SVGView + + case "Title": + return "SVG View"; + case "Auto": + return "Auto"; + case "Zip": + return "Zip"; + case "CopyOK": + return "copied"; + case "CopyFailed": + return "copy failed"; + + #endregion + + default: + return null; + } + } + } +} \ No newline at end of file diff --git a/example/SVGView/Main.Designer.cs b/example/SVGView/Main.Designer.cs index e42bf6b..346c918 100644 --- a/example/SVGView/Main.Designer.cs +++ b/example/SVGView/Main.Designer.cs @@ -65,6 +65,7 @@ namespace SVGView windowBar1.Name = "windowBar1"; windowBar1.Size = new Size(800, 36); windowBar1.TabIndex = 0; + windowBar1.LocalizationText = "Title"; windowBar1.Text = "SVG视图"; // // button2 @@ -76,6 +77,7 @@ namespace SVGView button2.Name = "button2"; button2.Size = new Size(77, 36); button2.TabIndex = 1; + button2.LocalizationText = "Auto"; button2.Text = "一键"; button2.Type = AntdUI.TTypeMini.Success; button2.MouseClick += button2_Click; @@ -88,6 +90,7 @@ namespace SVGView button1.Name = "button1"; button1.Size = new Size(57, 36); button1.TabIndex = 0; + button1.LocalizationText = "Zip"; button1.Text = "剔除"; button1.Type = AntdUI.TTypeMini.Primary; button1.MouseClick += button1_Click; diff --git a/example/SVGView/Main.cs b/example/SVGView/Main.cs index b039f9f..e7d779d 100644 --- a/example/SVGView/Main.cs +++ b/example/SVGView/Main.cs @@ -79,10 +79,10 @@ namespace SVGView { try { - var svg = Clipboard.GetText(); + var svg = AntdUI.Helper.ClipboardGetText(); if (string.IsNullOrEmpty(svg)) return; input1.Text = Hand(svg.Trim(), e.Button == MouseButtons.Right); - Clipboard.SetText(input1.Text); + AntdUI.Helper.ClipboardSetText(input1.Text); } catch { } } diff --git a/example/SVGView/Program.cs b/example/SVGView/Program.cs index 650a935..13da999 100644 --- a/example/SVGView/Program.cs +++ b/example/SVGView/Program.cs @@ -16,6 +16,8 @@ // CSDN: https://blog.csdn.net/v_132 // QQ: 17379620 +using System.Runtime.InteropServices; + namespace SVGView { internal static class Program @@ -26,9 +28,13 @@ namespace SVGView [STAThread] static void Main() { + ComWrappers.RegisterForMarshalling(WinFormsComInterop.WinFormsComWrappers.Instance); AntdUI.Config.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.SetCompatibleTextRenderingDefault(false); + AntdUI.Localization.DefaultLanguage = "zh-CN"; + var lang = AntdUI.Localization.CurrentLanguage; + if (lang.StartsWith("en")) AntdUI.Localization.Provider = new Localizer(); Application.Run(new Main()); } } diff --git a/example/SVGView/Properties/PublishProfiles/FolderProfile.pubxml b/example/SVGView/Properties/PublishProfiles/FolderProfile.pubxml new file mode 100644 index 0000000..f0756f3 --- /dev/null +++ b/example/SVGView/Properties/PublishProfiles/FolderProfile.pubxml @@ -0,0 +1,16 @@ + + + + + Release + Any CPU + bin\SVGView\ + FileSystem + <_TargetId>Folder + net9.0-windows + win-x86 + true + + \ No newline at end of file diff --git a/example/SVGView/SVGView.csproj b/example/SVGView/SVGView.csproj index 233d9fc..302eb1e 100644 --- a/example/SVGView/SVGView.csproj +++ b/example/SVGView/SVGView.csproj @@ -2,13 +2,31 @@ WinExe - net6.0-windows + net9.0-windows enable true enable true + + 5.1 + 5.1 + true + true + true + <_SuppressWinFormsTrimError>true + true + Size + + + + + + + + + diff --git a/example/SVGView/rd.xml b/example/SVGView/rd.xml new file mode 100644 index 0000000..d9118bc --- /dev/null +++ b/example/SVGView/rd.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + +