123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- 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.Navigation;
- using System.Windows.Shapes;
- using Hardcodet.Wpf.TaskbarNotification;
- namespace Aitex.Core.UI.Control
- {
-
-
-
- public partial class MessageControl : UserControl
- {
- public MessageControl()
- {
- InitializeComponent();
- this.Visibility = Visibility.Hidden;
- }
- private bool isClosing = false;
- #region BalloonText dependency property
-
-
-
- public static readonly DependencyProperty MessageToolBarText =
- DependencyProperty.Register("MessageText",
- typeof(string),
- typeof(MessageControl),
- new FrameworkPropertyMetadata("aaaaa"));
-
-
-
-
-
- public string MessageText
- {
- get { return (string)GetValue(MessageToolBarText); }
- set { SetValue(MessageToolBarText, value); }
- }
- #endregion
-
-
-
-
-
- private void OnBalloonClosing(object sender, RoutedEventArgs e)
- {
- e.Handled = true;
- isClosing = true;
- }
-
-
-
-
- private void imgClose_MouseDown(object sender, MouseButtonEventArgs e)
- {
-
- TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);
- taskbarIcon.CloseBalloon();
- }
-
-
-
- private void grid_MouseEnter(object sender, MouseEventArgs e)
- {
-
-
- if (isClosing) return;
-
- TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);
- taskbarIcon.ResetBalloonCloseTimer();
- }
-
-
-
-
-
- private void OnFadeOutCompleted(object sender, EventArgs e)
- {
-
-
-
-
-
- }
- public void SetMessage(MessageType type, string content)
- {
- switch (type)
- {
- case MessageType.Info:
- MessageLbl.Foreground = Brushes.DarkGreen;
- break;
- case MessageType.Success:
- MessageLbl.Foreground = Brushes.Green;
- break;
- case MessageType.Warning:
- MessageLbl.Foreground = Brushes.Yellow;
- break;
- case MessageType.Erro:
- MessageLbl.Foreground = Brushes.Red;
- break;
- default:
- break;
- }
- this.Visibility = Visibility.Visible;
-
- MessageLbl.Text = content;
- MessageLbl.ToolTip = content;
- }
-
-
-
- public static List<string> messageList = new List<string>();
- public void ClearMessage()
- {
- if (!string.IsNullOrEmpty(MessageLbl.Text + ""))
- {
- messageList.Add(MessageLbl.Text.ToString());
- MessageText = "";
- }
- }
- }
- }
|