using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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.ComponentModel;

namespace FLY.ControlLibrary
{
    /// <summary>
    /// Window_Tip.xaml 的交互逻辑
    /// </summary>
    public partial class Window_Tip : Window
    {
        public TimeSpan Duration;
        public string Message;

        public Window_Tip()
        {
            InitializeComponent();
            Duration = TimeSpan.FromSeconds(2);
            timer = new System.Windows.Threading.DispatcherTimer();
            timer.Tick += new EventHandler(timer_Tick);
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.Left = SystemParameters.PrimaryScreenWidth - this.Width;
            this.Top = SystemParameters.PrimaryScreenHeight - this.Height - 100;
            this.textblock_message.Text = Message;
            timer.Interval = Duration;
            timer.Start();
        }
        /// <summary>
        /// 右下角 提示
        /// </summary>
        /// <param name="title">标题</param>
        /// <param name="message">内容</param>
        /// <param name="duration">持续时间</param>
        public static void Show(string title, string message, TimeSpan duration)
        {
            new Window_Tip() { Title = title, Message = message, Duration = duration }.Show();
        }
        void timer_Tick(object sender, EventArgs e)
        {
            timer.Stop();
            this.Close();
        }
        void Button_Click(object sender, RoutedEventArgs e)
        {
            timer_Tick(null, null);
        }


        System.Windows.Threading.DispatcherTimer timer;
    }
}
