You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.7 KiB
55 lines
1.7 KiB
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.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Shapes;
|
|
using System.Windows.Threading;
|
|
|
|
namespace AIK.Views.MenuPages.CommonPage
|
|
{
|
|
/// <summary>
|
|
/// LightTipWindow.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class LightTipWindow : Window
|
|
{
|
|
public static readonly DependencyProperty MessageProperty =
|
|
DependencyProperty.Register(nameof(Message), typeof(string), typeof(LightTipWindow));
|
|
|
|
|
|
public string Message
|
|
{
|
|
get => (string)GetValue(MessageProperty);
|
|
set => SetValue(MessageProperty, value);
|
|
}
|
|
|
|
|
|
private readonly DispatcherTimer _closeTimer;
|
|
|
|
public LightTipWindow(string message, int autoCloseMs = 2000)
|
|
{
|
|
InitializeComponent();
|
|
DataContext = this;
|
|
Message = message;
|
|
ShowInTaskbar = false;
|
|
// 自动关闭定时器
|
|
_closeTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(autoCloseMs) };
|
|
_closeTimer.Tick += (s, e) => { Close(); _closeTimer.Stop(); };
|
|
_closeTimer.Start();
|
|
}
|
|
|
|
// 静态调用方法(简化使用)
|
|
public static void ShowTip(Window owner, string message, int autoCloseMs = 2000)
|
|
{
|
|
var tipWindow = new LightTipWindow(message, autoCloseMs) { Owner = owner };
|
|
tipWindow.Show();
|
|
}
|
|
}
|
|
}
|
|
|