-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFloatingStatusWindow.xaml.cs
More file actions
57 lines (51 loc) · 1.44 KB
/
Copy pathFloatingStatusWindow.xaml.cs
File metadata and controls
57 lines (51 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System.Windows;
using System.Windows.Media.Animation;
namespace WechatBot;
public partial class FloatingStatusWindow : Window
{
public FloatingStatusWindow()
{
InitializeComponent();
PositionToBottomRight();
}
/// <summary>
/// 定位到屏幕右下角
/// </summary>
private void PositionToBottomRight()
{
var screenWidth = SystemParameters.PrimaryScreenWidth;
var screenHeight = SystemParameters.PrimaryScreenHeight;
Left = screenWidth - Width - 20;
Top = screenHeight - Height - 60;
}
/// <summary>
/// 更新状态
/// </summary>
public void UpdateStatus(string icon, string text, string stepInfo = "")
{
Dispatcher.Invoke(() =>
{
StatusIcon.Text = icon;
StatusText.Text = text;
StepInfo.Text = stepInfo;
});
}
/// <summary>
/// 显示窗口(带淡入动画)
/// </summary>
public void ShowWithAnimation()
{
Show();
var fadeIn = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(300));
BeginAnimation(OpacityProperty, fadeIn);
}
/// <summary>
/// 隐藏窗口(带淡出动画)
/// </summary>
public void HideWithAnimation()
{
var fadeOut = new DoubleAnimation(1, 0, TimeSpan.FromMilliseconds(300));
fadeOut.Completed += (_, _) => Hide();
BeginAnimation(OpacityProperty, fadeOut);
}
}