From 2f54e9d7b3942b319247735eaf839b21eefb1baa Mon Sep 17 00:00:00 2001 From: PrefacedCorg <1876568293@qq.com> Date: Sun, 5 Apr 2026 17:01:20 +0800 Subject: [PATCH] =?UTF-8?q?add:=E5=A4=8D=E5=88=B6=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/Controls/CopyButton.xaml | 24 ++++ Ink Canvas/Controls/CopyButton.xaml.cs | 115 ++++++++++++++++++ .../SettingsViews2/Pages/IconographyPage.xaml | 28 ++++- .../Pages/IconographyPage.xaml.cs | 4 +- .../SettingsViews2/SettingsWindow2.xaml.cs | 2 +- 5 files changed, 166 insertions(+), 7 deletions(-) create mode 100644 Ink Canvas/Controls/CopyButton.xaml create mode 100644 Ink Canvas/Controls/CopyButton.xaml.cs diff --git a/Ink Canvas/Controls/CopyButton.xaml b/Ink Canvas/Controls/CopyButton.xaml new file mode 100644 index 00000000..fe3bff2e --- /dev/null +++ b/Ink Canvas/Controls/CopyButton.xaml @@ -0,0 +1,24 @@ + + + diff --git a/Ink Canvas/Controls/CopyButton.xaml.cs b/Ink Canvas/Controls/CopyButton.xaml.cs new file mode 100644 index 00000000..fc2c2f30 --- /dev/null +++ b/Ink Canvas/Controls/CopyButton.xaml.cs @@ -0,0 +1,115 @@ +using System; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Media.Animation; + +namespace Ink_Canvas.Controls +{ + public partial class CopyButton : UserControl + { + public static readonly DependencyProperty TextProperty = DependencyProperty.Register( + nameof(Text), typeof(string), typeof(CopyButton), new PropertyMetadata(string.Empty)); + + public string Text + { + get => (string)GetValue(TextProperty); + set => SetValue(TextProperty, value); + } + + public event EventHandler Click; + + public CopyButton() + { + InitializeComponent(); + } + + private void CopyButton_Click(object sender, RoutedEventArgs e) + { + try + { + if (!string.IsNullOrEmpty(Text)) + { + Clipboard.SetText(Text); + } + + ShowSuccessAnimation(); + Click?.Invoke(this, EventArgs.Empty); + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString(), "Unable to Perform Copy", MessageBoxButton.OK, MessageBoxImage.Error); + } + } + + private async void ShowSuccessAnimation() + { + var copyScaleAnim = new DoubleAnimation + { + To = 0, + Duration = TimeSpan.FromMilliseconds(150) + }; + ScaleTransform_Copy.BeginAnimation(ScaleTransform.ScaleXProperty, copyScaleAnim); + + var copyOpacityAnim = new DoubleAnimation + { + To = 0, + BeginTime = TimeSpan.FromMilliseconds(100), + Duration = TimeSpan.FromMilliseconds(10) + }; + FontIcon_Copy.BeginAnimation(UIElement.OpacityProperty, copyOpacityAnim); + + await Task.Delay(150); + var successScaleAnim = new DoubleAnimation + { + To = 1, + Duration = TimeSpan.FromMilliseconds(150), + EasingFunction = new BackEase { EasingMode = EasingMode.EaseOut, Amplitude = 0.2 } + }; + ScaleTransform_Success.BeginAnimation(ScaleTransform.ScaleXProperty, successScaleAnim); + + var successOpacityAnim = new DoubleAnimation + { + To = 1, + Duration = TimeSpan.FromMilliseconds(15) + }; + FontIcon_Success.BeginAnimation(UIElement.OpacityProperty, successOpacityAnim); + + await Task.Delay(1000); + ShowCopyAnimation(); + } + + private async void ShowCopyAnimation() + { + var successOpacityAnim = new DoubleAnimation + { + To = 0, + Duration = TimeSpan.FromMilliseconds(150) + }; + FontIcon_Success.BeginAnimation(UIElement.OpacityProperty, successOpacityAnim); + + await Task.Delay(150); + var copyScaleAnim = new DoubleAnimation + { + To = 1, + Duration = TimeSpan.Zero + }; + ScaleTransform_Copy.BeginAnimation(ScaleTransform.ScaleXProperty, copyScaleAnim); + + var copyOpacityAnim = new DoubleAnimation + { + To = 1, + Duration = TimeSpan.FromMilliseconds(150) + }; + FontIcon_Copy.BeginAnimation(UIElement.OpacityProperty, copyOpacityAnim); + + var successScaleAnim = new DoubleAnimation + { + To = 0, + Duration = TimeSpan.Zero + }; + ScaleTransform_Success.BeginAnimation(ScaleTransform.ScaleXProperty, successScaleAnim); + } + } +} diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/IconographyPage.xaml b/Ink Canvas/Windows/SettingsViews2/Pages/IconographyPage.xaml index 8c7eef53..b2499cce 100644 --- a/Ink Canvas/Windows/SettingsViews2/Pages/IconographyPage.xaml +++ b/Ink Canvas/Windows/SettingsViews2/Pages/IconographyPage.xaml @@ -6,12 +6,34 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern" xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf" + xmlns:sys="clr-namespace:System;assembly=mscorlib" + xmlns:controls="clr-namespace:Ink_Canvas.Controls" Title="图标设置" mc:Ignorable="d"> - + - - + + + + + + + + + + + + + + + 0 + + + + \ No newline at end of file diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/IconographyPage.xaml.cs b/Ink Canvas/Windows/SettingsViews2/Pages/IconographyPage.xaml.cs index dba2cb19..a86403fb 100644 --- a/Ink Canvas/Windows/SettingsViews2/Pages/IconographyPage.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews2/Pages/IconographyPage.xaml.cs @@ -1,8 +1,6 @@ -using iNKORE.UI.WPF.Modern.Controls; - namespace Ink_Canvas.Windows.SettingsViews2.Pages { - public partial class IconographyPage : Page + public partial class IconographyPage : iNKORE.UI.WPF.Modern.Controls.Page { public IconographyPage() { diff --git a/Ink Canvas/Windows/SettingsViews2/SettingsWindow2.xaml.cs b/Ink Canvas/Windows/SettingsViews2/SettingsWindow2.xaml.cs index 273c3583..09a5edfd 100644 --- a/Ink Canvas/Windows/SettingsViews2/SettingsWindow2.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews2/SettingsWindow2.xaml.cs @@ -58,7 +58,7 @@ namespace Ink_Canvas.Windows.SettingsViews2 { "ThemePage", typeof(ThemePage) }, { "ColorsPage", typeof(ColorsPage) }, { "FontsPage", typeof(FontsPage) }, - { "StartupPage", typeof(StartupPage) }, + { "StartupPage", typeof(NewSettingStartup) }, { "AboutPage", typeof(AboutPage) }, { "Settings", typeof(SettingsPage) } };