add:复制按钮
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<UserControl x:Class="Ink_Canvas.Controls.CopyButton"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern">
|
||||
<Button x:Name="CopyButtonControl" Padding="6" Click="CopyButton_Click"
|
||||
ToolTipService.ToolTip="Copy">
|
||||
<Grid>
|
||||
<ui:FontIcon x:Name="FontIcon_Copy" FontSize="16"
|
||||
Icon="{x:Static ui:SegoeFluentIcons.Copy}" RenderTransformOrigin="0.5 0.5">
|
||||
<FrameworkElement.RenderTransform>
|
||||
<ScaleTransform x:Name="ScaleTransform_Copy"
|
||||
ScaleX="1" ScaleY="{Binding ScaleX, RelativeSource={RelativeSource Self}}"/>
|
||||
</FrameworkElement.RenderTransform>
|
||||
</ui:FontIcon>
|
||||
<ui:FontIcon x:Name="FontIcon_Success" FontSize="16"
|
||||
Icon="{x:Static ui:SegoeFluentIcons.CheckMark}" RenderTransformOrigin="0.5 0.5">
|
||||
<FrameworkElement.RenderTransform>
|
||||
<ScaleTransform x:Name="ScaleTransform_Success"
|
||||
ScaleX="0" ScaleY="{Binding ScaleX, RelativeSource={RelativeSource Self}}"/>
|
||||
</FrameworkElement.RenderTransform>
|
||||
</ui:FontIcon>
|
||||
</Grid>
|
||||
</Button>
|
||||
</UserControl>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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">
|
||||
<Grid>
|
||||
<Grid x:Name="RootGrid">
|
||||
<StackPanel Margin="24">
|
||||
<TextBlock Text="图标设置" Style="{DynamicResource TitleTextBlockStyle}" Margin="0,0,0,16" />
|
||||
<TextBlock Text="这里是图标设置页面" Style="{DynamicResource BodyTextBlockStyle}" />
|
||||
<ui:SettingsExpander x:Name="settingsCard" VerticalAlignment="Top"
|
||||
Description="The SettingsExpander has the same properties as a Card, and you can set SettingsCard as part of the Items collection."
|
||||
Header="SettingsExpander" IsEnabled="True">
|
||||
|
||||
<ui:SettingsExpander.HeaderIcon>
|
||||
<ui:FontIcon Glyph=""/>
|
||||
</ui:SettingsExpander.HeaderIcon>
|
||||
|
||||
|
||||
<controls:CopyButton Text="You can override the Left indention of a SettingsCard by overriding the SettingsCardLeftIndention"/>
|
||||
|
||||
|
||||
|
||||
<ui:SettingsExpander.Items>
|
||||
<ui:SettingsCard Description="You can override the Left indention of a SettingsCard by overriding the SettingsCardLeftIndention"
|
||||
Header="Customization">
|
||||
<ui:SettingsCard.Resources>
|
||||
<sys:Double x:Key="SettingsCardLeftIndention">0</sys:Double>
|
||||
</ui:SettingsCard.Resources>
|
||||
</ui:SettingsCard>
|
||||
</ui:SettingsExpander.Items>
|
||||
</ui:SettingsExpander>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ui:Page>
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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) }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user