Skip to content

Commit

Permalink
“阳间化”小黑板颜色选择界面 等 2 项调整
Browse files Browse the repository at this point in the history
## 小黑板颜色选择界面
- 优化外观
- 加入画笔大小调节
- 在画笔为黑色或白色时,调整色相,提醒用户调整饱和度
## 上下课通知
- 修复倒计时显示 "-01" 的问题
  • Loading branch information
STBBRD committed Oct 19, 2024
1 parent e34e546 commit 398ebb8
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 39 deletions.
52 changes: 38 additions & 14 deletions ZongziTEK_Blackboard_Sticker/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,50 @@
HorizontalAlignment="Right" Visibility="{Binding Visibility, ElementName=eraserButton}">
<ui:FontIcon Icon="{x:Static ui:FluentSystemIcons.Edit_20_Regular}" FontSize="24"/>
</Button>
<Border Name="borderColorPicker" Margin="-100,-480,-124,36" CornerRadius="8" Width="246" Height="450" Visibility="Collapsed" BorderThickness="1"
<Border Name="borderColorPicker" Margin="-100,-490,-124,36" CornerRadius="8" Width="246" Height="464" Visibility="Collapsed" d:Visibility="Visible" BorderThickness="1"
Background="{DynamicResource {x:Static ui:ThemeKeys.CardBackgroundFillColorDefaultBrushKey}}" BorderBrush="{DynamicResource BorderBrush}">
<ikw:SimpleStackPanel Margin="16" Spacing="12">
<TextBlock Text="选择画笔颜色" FontSize="24" Foreground="{DynamicResource ForegroundColor}"/>
<Border Name="borderShowColor" Height="8" CornerRadius="2" Background="White" BorderThickness="1" BorderBrush="#33000000"/>
<ikw:SquarePicker Name="squarePicker" Height="222" ColorChanged="squarePicker_ColorChanged" SelectedColor="White"/>
<Grid Height="75">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<ikw:SimpleStackPanel Margin="16" Spacing="8">
<Grid >
<TextBlock Text="设置画笔" FontSize="24" Foreground="{DynamicResource ForegroundColor}"/>
<Border Name="borderShowColor" HorizontalAlignment="Right" Width="24" Height="24" CornerRadius="12" Background="White" BorderThickness="1" BorderBrush="#33000000"/>
</Grid>
<Label Content="颜色" FontSize="12" Opacity="0.75"/>
<ikw:SquarePicker Name="squarePicker" Height="222" ColorChanged="squarePicker_ColorChanged" SelectedColor="White"
PreviewMouseUp="squarePicker_PreviewMouseUp"/>
<ui:TeachingTip x:Name="TeachingTipColorPicker" Target="{Binding ElementName=squarePicker}" Visibility="Collapsed"
Title="提示"
Subtitle="当画笔处于黑色或白色时,仅调整色相环是不会改变画笔颜色的,需要调整中间的圆点到右上角的彩色位置"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Name="btnWhite" Click="btnWhite_Click" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Stretch" Margin="0,4,4,4" VerticalAlignment="Stretch" Background="{DynamicResource ForegroundColor}" BorderThickness="0"/>
<Button Name="btnBlue" Click="btnBlue_Click" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Stretch" Margin="0,4,4,4" VerticalAlignment="Stretch" Background="#FF00FFFF" BorderThickness="0"/>
<Button Name="btnYellow" Click="btnYellow_Click" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch" Margin="4,4,0,4" VerticalAlignment="Stretch" Background="#FFFFFF00" BorderThickness="0"/>
<Button Name="btnRed" Click="btnRed_Click" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" Margin="4,4,0,4" VerticalAlignment="Stretch" Background="#FFFF00FF" BorderThickness="0"/>
<Border Grid.Column="0" Width="36" Height="36" CornerRadius="18"
BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1"
Background="{DynamicResource ForegroundColor}"
HorizontalAlignment="Center" VerticalAlignment="Center"
MouseUp="BorderColorSelector_MouseUp"/>
<Border Grid.Column="1" Width="36" Height="36" CornerRadius="18"
BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1"
Background="#EE00AA"
HorizontalAlignment="Center" VerticalAlignment="Center"
MouseUp="BorderColorSelector_MouseUp"/>
<Border Grid.Column="2" Width="36" Height="36" CornerRadius="18"
BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1"
Background="#EEAA00"
HorizontalAlignment="Center" VerticalAlignment="Center"
MouseUp="BorderColorSelector_MouseUp"/>
<Border Grid.Column="3" Width="36" Height="36" CornerRadius="18"
BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1"
Background="#00CCCC"
HorizontalAlignment="Center" VerticalAlignment="Center"
MouseUp="BorderColorSelector_MouseUp"/>
</Grid>
<Label Content="大小" FontSize="12" Opacity="0.75"/>
<Slider x:Name="SliderPenThickness" Minimum="1.75" Maximum="4.75" TickFrequency="0.5" IsSnapToTickEnabled="True" TickPlacement="Both" AutoToolTipPlacement="None" Value="1.75"
ValueChanged="SliderPenThickness_ValueChanged"/>
<Button x:Name="btnCloseColorPicker" Content="关闭" HorizontalAlignment="Stretch" Click="btnCloseColorPicker_Click"/>
</ikw:SimpleStackPanel>
</Border>
Expand Down
44 changes: 27 additions & 17 deletions ZongziTEK_Blackboard_Sticker/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,33 +290,41 @@ private void btnClearOK_Click(object sender, RoutedEventArgs e)
//touchGrid.Visibility = Visibility.Visible;
}

private void squarePicker_ColorChanged(object sender, RoutedEventArgs e)
{
borderShowColor.Background = new SolidColorBrush(squarePicker.SelectedColor);
inkCanvas.DefaultDrawingAttributes.Color = squarePicker.SelectedColor;
}
private void btnWhite_Click(object sender, RoutedEventArgs e)
private void BorderColorSelector_MouseUp(object sender, MouseButtonEventArgs e)
{
squarePicker.SelectedColor = ((SolidColorBrush)btnWhite.Background).Color;
if (sender is Border)
{
Border border = (Border)sender;
squarePicker.SelectedColor = ((SolidColorBrush)border.Background).Color;
}
}

private void btnBlue_Click(object sender, RoutedEventArgs e)
private void squarePicker_PreviewMouseUp(object sender, MouseButtonEventArgs e)
{
squarePicker.SelectedColor = ((SolidColorBrush)btnBlue.Background).Color;
if (squarePicker.ColorState.HSL_S == 0 || squarePicker.ColorState.HSL_L == 0)
{
TeachingTipColorPicker.IsOpen = true;
}
}

private void btnYellow_Click(object sender, RoutedEventArgs e)
private void squarePicker_ColorChanged(object sender, RoutedEventArgs e)
{
squarePicker.SelectedColor = ((SolidColorBrush)btnYellow.Background).Color;
borderShowColor.Background = new SolidColorBrush(squarePicker.SelectedColor);
inkCanvas.DefaultDrawingAttributes.Color = squarePicker.SelectedColor;
}

private void btnRed_Click(object sender, RoutedEventArgs e)
private void btnCloseColorPicker_Click(object sender, RoutedEventArgs e)
{
squarePicker.SelectedColor = ((SolidColorBrush)btnRed.Background).Color;
HideColorPicker();
}
private void btnCloseColorPicker_Click(object sender, RoutedEventArgs e)

private void SliderPenThickness_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
borderColorPicker.Visibility = Visibility.Collapsed;
if (drawingAttributes != null)
{
drawingAttributes.Width = SliderPenThickness.Value;
drawingAttributes.Height = SliderPenThickness.Value;
}
}

private void ToggleButtonLock_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -433,6 +441,8 @@ private void ShowColorPicker()

private async void HideColorPicker()
{
TeachingTipColorPicker.IsOpen = false;

ThicknessAnimation marginAnimation = new()
{
From = originalColorPickerMargin,
Expand Down Expand Up @@ -1983,7 +1993,7 @@ public static void SetTheme()

if (window.inkCanvas.DefaultDrawingAttributes.Color == Colors.White)
{
window.btnWhite_Click(null, null);
window.inkCanvas.DefaultDrawingAttributes.Color = Colors.Black;
}

foreach (Stroke stroke in window.inkCanvas.Strokes)
Expand All @@ -2005,7 +2015,7 @@ public static void SetTheme()

if (window.inkCanvas.DefaultDrawingAttributes.Color == Colors.Black)
{
window.btnWhite_Click(null, null);
window.inkCanvas.DefaultDrawingAttributes.Color = Colors.White;
}
foreach (Stroke stroke in window.inkCanvas.Strokes)
{
Expand Down
36 changes: 28 additions & 8 deletions ZongziTEK_Blackboard_Sticker/TimetableNotificationWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ private void Timer_Tick(object sender, EventArgs e)
timeLeft = timeToHide - DateTime.Now.TimeOfDay;
TextTime.Text = timeLeft.TotalSeconds.ToString("00");

if (timeLeft.TotalSeconds == 1)
if (timeLeft.TotalSeconds <= 1)
{
if (!isTimeHidden) HideTime();
if (!isTimeHidden)
HideTime();
}
else if (timeLeft.TotalSeconds <= 0)
if (timeLeft <= TimeSpan.Zero)
{
if (!isNotificationHidden) HideNotification();
if (!isNotificationHidden)
HideNotification();
}
}

Expand All @@ -106,16 +108,25 @@ private void ShowNotification()
EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }
};

ThicknessAnimation marginAnimation = new()
/*ThicknessAnimation marginAnimation = new()
{
From = new Thickness(0, -160, 0, 0),
To = new Thickness(0),
Duration = TimeSpan.FromMilliseconds(750),
EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }
};*/

DoubleAnimation topAnimation = new()
{
From = -Height,
To = 0,
Duration = TimeSpan.FromMilliseconds(750),
EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }
};

GridNotification.BeginAnimation(OpacityProperty, opacityAnimation);
GridNotification.BeginAnimation(MarginProperty, marginAnimation);
//GridNotification.BeginAnimation(MarginProperty, marginAnimation);
BeginAnimation(TopProperty, topAnimation);
}

private async void HideNotification()
Expand All @@ -130,16 +141,25 @@ private async void HideNotification()
EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseIn }
};

ThicknessAnimation marginAnimation = new()
/*ThicknessAnimation marginAnimation = new()
{
From = new Thickness(0),
To = new Thickness(0, -160, 0, 0),
Duration = TimeSpan.FromMilliseconds(750),
EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseIn }
};*/

DoubleAnimation topAnimation = new()
{
From = 0,
To = -Height,
Duration = TimeSpan.FromMilliseconds(750),
EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseIn }
};

GridNotification.BeginAnimation(OpacityProperty, opacityAnimation);
GridNotification.BeginAnimation(MarginProperty, marginAnimation);
//GridNotification.BeginAnimation(MarginProperty, marginAnimation);
BeginAnimation(TopProperty, topAnimation);

await Task.Delay(750);
Close();
Expand Down

0 comments on commit 398ebb8

Please sign in to comment.