-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
186 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
ZongziTEK_Blackboard_Sticker/StrongNotificationWindow.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<Window x:Class="ZongziTEK_Blackboard_Sticker.StrongNotificationWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern" | ||
xmlns:local="clr-namespace:ZongziTEK_Blackboard_Sticker" | ||
mc:Ignorable="d" | ||
Title="ZongziTEK 黑板贴 - 强提醒" Height="450" Width="800" WindowStyle="None" WindowState="Maximized" AllowsTransparency="True" Topmost="True" | ||
Loaded="Window_Loaded"> | ||
<Grid> | ||
<Rectangle> | ||
<Rectangle.Fill> | ||
<LinearGradientBrush EndPoint="1,1" StartPoint="0,0"> | ||
<GradientStop Color="#FF41C4F8"/> | ||
<GradientStop Color="#FF037BD5" Offset="1"/> | ||
</LinearGradientBrush> | ||
</Rectangle.Fill> | ||
</Rectangle> | ||
<Viewbox Name="ViewboxContent" Margin="100"> | ||
<ui:SimpleStackPanel Spacing="24"> | ||
<TextBlock Name="TextBlockTitle" HorizontalAlignment="Center" Foreground="White" FontSize="144"/> | ||
<TextBlock Name="TextBlockSubtitle" HorizontalAlignment="Center" Opacity="0.8" Foreground="White" FontSize="64"/> | ||
</ui:SimpleStackPanel> | ||
</Viewbox> | ||
</Grid> | ||
</Window> |
91 changes: 91 additions & 0 deletions
91
ZongziTEK_Blackboard_Sticker/StrongNotificationWindow.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Interop; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Shapes; | ||
using System.Speech.Synthesis; | ||
using ZongziTEK_Blackboard_Sticker.Helpers; | ||
using System.Windows.Media.Animation; | ||
|
||
namespace ZongziTEK_Blackboard_Sticker | ||
{ | ||
/// <summary> | ||
/// StrongNotificationWindow.xaml 的交互逻辑 | ||
/// </summary> | ||
public partial class StrongNotificationWindow : Window | ||
{ | ||
public StrongNotificationWindow(string title, string subtitle) | ||
{ | ||
InitializeComponent(); | ||
|
||
TextBlockTitle.Text = title; | ||
TextBlockSubtitle.Text = subtitle; | ||
|
||
if (subtitle == "") TextBlockSubtitle.Visibility = Visibility.Collapsed; | ||
} | ||
|
||
private SpeechSynthesizer synthesizer = new(); | ||
|
||
private async void Window_Loaded(object sender, RoutedEventArgs e) | ||
{ | ||
// 设置为 ToolWindow | ||
var hwnd = new WindowInteropHelper(this).Handle; | ||
WindowsHelper.SetWindowStyleToolWindow(hwnd); | ||
|
||
// 进入动画 | ||
DoubleAnimation opacityAnimationIn = new() | ||
{ | ||
From = 0, | ||
To = 1, | ||
Duration = TimeSpan.FromMilliseconds(500), | ||
EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut } | ||
}; | ||
BeginAnimation(OpacityProperty, opacityAnimationIn); | ||
|
||
ThicknessAnimation viewboxMarginAnimationIn = new() | ||
{ | ||
From = new Thickness(24), | ||
To = new Thickness(100), | ||
Duration = TimeSpan.FromMilliseconds(500), | ||
EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut } | ||
}; | ||
ViewboxContent.BeginAnimation(MarginProperty, viewboxMarginAnimationIn); | ||
await Task.Delay(500); | ||
|
||
// 语音播报 | ||
synthesizer.Speak(TextBlockTitle.Text); | ||
await Task.Delay(200); | ||
synthesizer.Speak(TextBlockSubtitle.Text); | ||
|
||
// 退出动画 | ||
DoubleAnimation opacityAnimationOut = new() | ||
{ | ||
From = 1, | ||
To = 0, | ||
Duration = TimeSpan.FromMilliseconds(500), | ||
EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseIn } | ||
}; | ||
BeginAnimation(OpacityProperty, opacityAnimationOut); | ||
|
||
ThicknessAnimation viewboxMarginAnimationOut = new() | ||
{ | ||
From = new Thickness(100), | ||
To = new Thickness(24), | ||
Duration = TimeSpan.FromMilliseconds(500), | ||
EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseIn } | ||
}; | ||
ViewboxContent.BeginAnimation(MarginProperty, viewboxMarginAnimationOut); | ||
await Task.Delay(600); | ||
Close(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters