[feature] 修復熒光筆顏色切換問題,為調色板添加動畫

This commit is contained in:
Dubi906w 2024-05-14 01:24:47 +08:00
parent b8813d11ee
commit 5e3224451a
3 changed files with 49 additions and 14 deletions

View File

@ -49,6 +49,9 @@
<RoutedUICommand x:Key="HotKey_ChangeToPen5" Text=" "/>
<RoutedUICommand x:Key="HotKey_DrawLine" Text=" "/>
</Window.Resources>
<WindowChrome.WindowChrome>
<WindowChrome GlassFrameThickness="-1" />
</WindowChrome.WindowChrome>
<!--输入命令绑定-->
<Window.InputBindings>
<KeyBinding Gesture="Shift+Esc" Command="{StaticResource KeyExit}"/>

View File

@ -10,6 +10,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Media;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media.Animation;
namespace Ink_Canvas
{
@ -100,17 +101,16 @@ namespace Ink_Canvas
double alpha = inkCanvas.DefaultDrawingAttributes.Color.A;
if (inkColor == 0)
{ // Black
inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 0, 0, 0);
}
else if (inkColor == 5)
{ // White
inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 255, 255, 255);
}
else if (penType==0)
if (penType==0)
{
if (isUselightThemeColor)
if (inkColor == 0)
{ // Black
inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 0, 0, 0);
}
else if (inkColor == 5)
{ // White
inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 255, 255, 255);
} else if (isUselightThemeColor)
{
if (inkColor == 1)
{ // Red
@ -396,7 +396,7 @@ namespace Ink_Canvas
}
private void CheckPenTypeUIState()
private async void CheckPenTypeUIState()
{
if (penType==0)
{
@ -404,7 +404,6 @@ namespace Ink_Canvas
DefaultPenColorsPanel.Visibility = Visibility.Visible;
HighlighterPenColorsPanel.Visibility = Visibility.Collapsed;
HighlighterPenPropsPanel.Visibility = Visibility.Collapsed;
PenPalette.Margin = new Thickness(-160, -200, -33, 32);
DefaultPenTabButton.Opacity = 1;
DefaultPenTabButtonText.FontWeight = FontWeights.Bold;
DefaultPenTabButtonText.Margin = new Thickness(2, 0.5, 0, 0);
@ -417,13 +416,29 @@ namespace Ink_Canvas
HighlightPenTabButtonText.Margin = new Thickness(2, 1, 0, 0);
HighlightPenTabButton.Background = new SolidColorBrush(Colors.Transparent);
HighlightPenTabButtonIndicator.Visibility = Visibility.Collapsed;
// PenPalette.Margin = new Thickness(-160, -200, -33, 32);
await Dispatcher.InvokeAsync(() =>
{
ThicknessAnimation marginAnimation = new ThicknessAnimation
{
Duration = TimeSpan.FromSeconds(0.1),
From = PenPalette.Margin,
To = new Thickness(-160, -200, -33, 32)
};
PenPalette.BeginAnimation(FrameworkElement.MarginProperty, marginAnimation);
});
await Task.Delay(100);
await Dispatcher.InvokeAsync(() => {
PenPalette.Margin = new Thickness(-160, -200, -33, 32);
});
} else if (penType==1)
{
DefaultPenPropsPanel.Visibility = Visibility.Collapsed;
DefaultPenColorsPanel.Visibility = Visibility.Collapsed;
HighlighterPenColorsPanel.Visibility = Visibility.Visible;
HighlighterPenPropsPanel.Visibility = Visibility.Visible;
PenPalette.Margin = new Thickness(-160, -157, -33, 32);
DefaultPenTabButton.Opacity = 0.9;
DefaultPenTabButtonText.FontWeight = FontWeights.Normal;
DefaultPenTabButtonText.FontSize = 9;
@ -436,6 +451,23 @@ namespace Ink_Canvas
HighlightPenTabButtonText.Margin = new Thickness(2, 0.5, 0, 0);
HighlightPenTabButton.Background = new SolidColorBrush(Color.FromArgb(72, 219, 234, 254));
HighlightPenTabButtonIndicator.Visibility = Visibility.Visible;
// PenPalette.Margin = new Thickness(-160, -157, -33, 32);
await Dispatcher.InvokeAsync(() =>
{
ThicknessAnimation marginAnimation = new ThicknessAnimation
{
Duration = TimeSpan.FromSeconds(0.1),
From = PenPalette.Margin,
To = new Thickness(-160, -157, -33, 32)
};
PenPalette.BeginAnimation(FrameworkElement.MarginProperty, marginAnimation);
});
await Task.Delay(100);
await Dispatcher.InvokeAsync(() => {
PenPalette.Margin = new Thickness(-160, -157, -33, 32);
});
}
}

View File

@ -271,7 +271,7 @@ namespace Ink_Canvas {
private void updateBorderStrokeSelectionControlLocation() {
double borderLeft = (inkCanvas.GetSelectionBounds().Left + inkCanvas.GetSelectionBounds().Right - BorderStrokeSelectionControlWidth) / 2;
double borderTop = inkCanvas.GetSelectionBounds().Bottom + 15;
double borderTop = inkCanvas.GetSelectionBounds().Bottom + 1;
if (borderLeft < 0) borderLeft = 0;
if (borderTop < 0) borderTop = 0;
if (Width - borderLeft < BorderStrokeSelectionControlWidth || double.IsNaN(borderLeft)) borderLeft = Width - BorderStrokeSelectionControlWidth;