将自定义控件单开一个项目
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
<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>
|
||||
@@ -1,115 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<UserControl x:Class="Ink_Canvas.Controls.LabeledToggleSwitch"
|
||||
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"
|
||||
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf">
|
||||
<ikw:SimpleStackPanel Spacing="4">
|
||||
<ikw:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<TextBlock Text="{Binding Label, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="#fafafa"
|
||||
FontSize="14"
|
||||
Margin="0,0,16,0"/>
|
||||
<ui:ToggleSwitch x:Name="ToggleSwitch"
|
||||
OnContent="{Binding OnContent, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
||||
OffContent="{Binding OffContent, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
||||
IsOn="{Binding IsOn, RelativeSource={RelativeSource AncestorType=UserControl}, Mode=TwoWay}"
|
||||
FontWeight="Bold"
|
||||
Toggled="ToggleSwitch_Toggled"/>
|
||||
</ikw:SimpleStackPanel>
|
||||
<TextBlock x:Name="HintTextBlock"
|
||||
Text="{Binding Hint, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
||||
TextWrapping="Wrap"
|
||||
Foreground="#a1a1aa"
|
||||
Visibility="Collapsed"/>
|
||||
</ikw:SimpleStackPanel>
|
||||
</UserControl>
|
||||
@@ -1,96 +0,0 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using ui = iNKORE.UI.WPF.Modern.Controls;
|
||||
|
||||
namespace Ink_Canvas.Controls
|
||||
{
|
||||
public partial class LabeledToggleSwitch : UserControl
|
||||
{
|
||||
public ui.ToggleSwitch ToggleSwitchControl => ToggleSwitch;
|
||||
|
||||
public static readonly DependencyProperty LabelProperty = DependencyProperty.Register(
|
||||
nameof(Label), typeof(string), typeof(LabeledToggleSwitch), new PropertyMetadata(string.Empty));
|
||||
|
||||
public string Label
|
||||
{
|
||||
get => (string)GetValue(LabelProperty);
|
||||
set => SetValue(LabelProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty HintProperty = DependencyProperty.Register(
|
||||
nameof(Hint), typeof(string), typeof(LabeledToggleSwitch), new PropertyMetadata(string.Empty, OnHintChanged));
|
||||
|
||||
public string Hint
|
||||
{
|
||||
get => (string)GetValue(HintProperty);
|
||||
set => SetValue(HintProperty, value);
|
||||
}
|
||||
|
||||
private static void OnHintChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is LabeledToggleSwitch control)
|
||||
{
|
||||
var hint = e.NewValue as string;
|
||||
control.HintTextBlock.Visibility = string.IsNullOrEmpty(hint) ? Visibility.Collapsed : Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IsOnProperty = DependencyProperty.Register(
|
||||
nameof(IsOn), typeof(bool), typeof(LabeledToggleSwitch), new PropertyMetadata(false));
|
||||
|
||||
public bool IsOn
|
||||
{
|
||||
get => (bool)GetValue(IsOnProperty);
|
||||
set => SetValue(IsOnProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty OnContentProperty = DependencyProperty.Register(
|
||||
nameof(OnContent), typeof(string), typeof(LabeledToggleSwitch), new PropertyMetadata(string.Empty));
|
||||
|
||||
public string OnContent
|
||||
{
|
||||
get => (string)GetValue(OnContentProperty);
|
||||
set => SetValue(OnContentProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty OffContentProperty = DependencyProperty.Register(
|
||||
nameof(OffContent), typeof(string), typeof(LabeledToggleSwitch), new PropertyMetadata(string.Empty));
|
||||
|
||||
public string OffContent
|
||||
{
|
||||
get => (string)GetValue(OffContentProperty);
|
||||
set => SetValue(OffContentProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ShowWhenProperty = DependencyProperty.Register(
|
||||
nameof(ShowWhen), typeof(bool), typeof(LabeledToggleSwitch), new PropertyMetadata(true, OnShowWhenChanged));
|
||||
|
||||
public bool ShowWhen
|
||||
{
|
||||
get => (bool)GetValue(ShowWhenProperty);
|
||||
set => SetValue(ShowWhenProperty, value);
|
||||
}
|
||||
|
||||
private static void OnShowWhenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is LabeledToggleSwitch control)
|
||||
{
|
||||
control.Visibility = (bool)e.NewValue ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
public event RoutedEventHandler Toggled;
|
||||
|
||||
public LabeledToggleSwitch()
|
||||
{
|
||||
InitializeComponent();
|
||||
Visibility = ShowWhen ? Visibility.Visible : Visibility.Collapsed;
|
||||
HintTextBlock.Visibility = string.IsNullOrEmpty(Hint) ? Visibility.Collapsed : Visibility.Visible;
|
||||
}
|
||||
|
||||
private void ToggleSwitch_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Toggled?.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<UserControl x:Class="Ink_Canvas.Controls.ToolbarImageButton"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="45" d:DesignWidth="28">
|
||||
<ikw:SimpleStackPanel Name="ButtonPanel"
|
||||
MouseDown="ButtonPanel_MouseDown"
|
||||
MouseLeave="ButtonPanel_MouseLeave"
|
||||
MouseUp="ButtonPanel_MouseUp"
|
||||
Background="Transparent" Orientation="Vertical"
|
||||
HorizontalAlignment="Center" Width="28" Margin="0,-2">
|
||||
<Image x:Name="ButtonImage" RenderOptions.BitmapScalingMode="HighQuality" Height="17" Margin="0,3,0,0">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
|
||||
<GeometryDrawing x:Name="IconGeometryInternal" Brush="{DynamicResource IconForeground}" />
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
<TextBlock x:Name="LabelTextBlock"
|
||||
Foreground="{DynamicResource FloatBarForeground}"
|
||||
FontSize="8"
|
||||
Margin="0,1,0,0" TextAlignment="Center"
|
||||
Style="{DynamicResource AutoFitMainToolbarLabel8}" />
|
||||
</ikw:SimpleStackPanel>
|
||||
</UserControl>
|
||||
@@ -1,110 +0,0 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Ink_Canvas.Controls
|
||||
{
|
||||
public partial class ToolbarImageButton : UserControl
|
||||
{
|
||||
private static ToolbarImageButton _lastPressedButton;
|
||||
|
||||
public static readonly DependencyProperty LabelProperty = DependencyProperty.Register(
|
||||
nameof(Label), typeof(string), typeof(ToolbarImageButton),
|
||||
new PropertyMetadata(string.Empty, (d, e) => ((ToolbarImageButton)d).LabelTextBlock.Text = (string)e.NewValue));
|
||||
|
||||
public string Label
|
||||
{
|
||||
get => (string)GetValue(LabelProperty);
|
||||
set => SetValue(LabelProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IconGeometryDrawingProperty = DependencyProperty.Register(
|
||||
nameof(IconGeometryDrawing), typeof(GeometryDrawing), typeof(ToolbarImageButton),
|
||||
new PropertyMetadata(null, OnIconGeometryDrawingChanged));
|
||||
|
||||
private static void OnIconGeometryDrawingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var button = (ToolbarImageButton)d;
|
||||
if (e.NewValue is GeometryDrawing newDrawing)
|
||||
{
|
||||
button.IconGeometryInternal.Geometry = newDrawing.Geometry;
|
||||
button.IconGeometryInternal.Brush = newDrawing.Brush;
|
||||
}
|
||||
}
|
||||
|
||||
public GeometryDrawing IconGeometryDrawing
|
||||
{
|
||||
get => (GeometryDrawing)GetValue(IconGeometryDrawingProperty);
|
||||
set => SetValue(IconGeometryDrawingProperty, value);
|
||||
}
|
||||
|
||||
public GeometryDrawing Icon => IconGeometryInternal;
|
||||
|
||||
public GeometryDrawing GeometryDrawing => IconGeometryInternal;
|
||||
|
||||
public static readonly DependencyProperty IconBrushProperty = DependencyProperty.Register(
|
||||
nameof(IconBrush), typeof(Brush), typeof(ToolbarImageButton),
|
||||
new PropertyMetadata(null, (d, e) => ((ToolbarImageButton)d).IconGeometryInternal.Brush = (Brush)e.NewValue));
|
||||
|
||||
public Brush IconBrush
|
||||
{
|
||||
get => (Brush)GetValue(IconBrushProperty);
|
||||
set => SetValue(IconBrushProperty, value);
|
||||
}
|
||||
|
||||
public new Brush Background
|
||||
{
|
||||
get => ButtonPanel.Background;
|
||||
set => ButtonPanel.Background = value;
|
||||
}
|
||||
|
||||
public event MouseButtonEventHandler ButtonMouseDown;
|
||||
public event MouseEventHandler ButtonMouseLeave;
|
||||
public event RoutedEventHandler ButtonMouseUp;
|
||||
|
||||
public ToolbarImageButton()
|
||||
{
|
||||
InitializeComponent();
|
||||
ButtonPanel.Background = Brushes.Transparent;
|
||||
IsEnabledChanged += ToolbarImageButton_IsEnabledChanged;
|
||||
}
|
||||
|
||||
private void ToolbarImageButton_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var isEnabled = (bool)e.NewValue;
|
||||
ButtonImage.Opacity = isEnabled ? 1.0 : 0.5;
|
||||
LabelTextBlock.Opacity = isEnabled ? 1.0 : 0.5;
|
||||
ButtonPanel.IsEnabled = isEnabled;
|
||||
}
|
||||
|
||||
private void ButtonPanel_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (!IsEnabled) return;
|
||||
if (_lastPressedButton != null && _lastPressedButton != this)
|
||||
{
|
||||
_lastPressedButton.Background = Brushes.Transparent;
|
||||
}
|
||||
_lastPressedButton = this;
|
||||
ButtonPanel.Background = new SolidColorBrush(Color.FromArgb(28, 24, 24, 27));
|
||||
ButtonMouseDown?.Invoke(this, e);
|
||||
}
|
||||
|
||||
private void ButtonPanel_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (!IsEnabled) return;
|
||||
ButtonMouseLeave?.Invoke(this, e);
|
||||
}
|
||||
|
||||
private void ButtonPanel_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (!IsEnabled) return;
|
||||
if (_lastPressedButton == this)
|
||||
{
|
||||
ButtonPanel.Background = Brushes.Transparent;
|
||||
_lastPressedButton = null;
|
||||
}
|
||||
ButtonMouseUp?.Invoke(this, new RoutedEventArgs(e.RoutedEvent, this));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
@@ -148,6 +148,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\InkCanvas.PluginSdk\InkCanvas.PluginSdk.csproj" />
|
||||
<ProjectReference Include="..\InkCanvas.Controls\InkCanvas.Controls.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(MSBuildRuntimeType)' == 'Full'">
|
||||
<COMReference Include="IWshRuntimeLibrary">
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
|
||||
xmlns:c="clr-namespace:Ink_Canvas.Converter"
|
||||
xmlns:Controls="http://schemas.microsoft.com/netfx/2009/xaml/presentation"
|
||||
xmlns:controls="clr-namespace:Ink_Canvas.Controls"
|
||||
xmlns:controls="clr-namespace:Ink_Canvas.Controls;assembly=InkCanvas.Controls"
|
||||
xmlns:localControls="clr-namespace:Ink_Canvas.Controls"
|
||||
xmlns:Windows="clr-namespace:Ink_Canvas.Windows"
|
||||
xmlns:props="clr-namespace:Ink_Canvas.Properties"
|
||||
xmlns:i18n="clr-namespace:Ink_Canvas.MarkupExtensions"
|
||||
@@ -3982,7 +3983,7 @@
|
||||
</Canvas>
|
||||
|
||||
<!-- 快抽悬浮按钮 -->
|
||||
<controls:QuickDrawFloatingButtonControl x:Name="QuickDrawFloatingButton"
|
||||
<localControls:QuickDrawFloatingButtonControl x:Name="QuickDrawFloatingButton"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Margin="0,0,0,200"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
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"
|
||||
xmlns:controls="clr-namespace:Ink_Canvas.Controls;assembly=InkCanvas.Controls"
|
||||
Title="图标设置"
|
||||
mc:Ignorable="d">
|
||||
<Grid x:Name="RootGrid">
|
||||
|
||||
@@ -345,6 +345,13 @@
|
||||
"resolved": "4.5.0",
|
||||
"contentHash": "okurQJO6NRE/apDIP23ajJ0hpiNmJ+f0BwOlB/cSqTLQlw5upkf+5+96+iG2Jw40G1fCVCyPz/FhIABUjMR+RQ=="
|
||||
},
|
||||
"inkcanvas.controls": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"iNKORE.UI.WPF": "[1.2.8, )",
|
||||
"iNKORE.UI.WPF.Modern": "[0.10.2.1, )"
|
||||
}
|
||||
},
|
||||
"inkcanvas.pluginsdk": {
|
||||
"type": "Project"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user